Closed jart closed 1 year ago
memcmp doesn't have to worry about page boundaries, so the current behaviour is expected and correct. Why are you trying to write memcmp in C? That's never going to be as fast as assembler implementations like in GLIBC.
EXPECT_LT(memcmp(map + pagesz - 9, map2 + pagesz - 9, 79), 0);
only 9 bytes of the objects can be accessed, not 79. so this call is invalid: memcmp may access all bytes within the specified bounds (although iso c wording is not very clear about such details).
i think writing this in c is fine, but technically *(xmm_t *)p
is aliasing violation, it needs a may_alias attribute or memcpy to an xmm_t object first and hoping the compiler will be smart.
closing this now.
Optimized Routines' memcmp() function appears to have a bug where it'll overlap a page boundary inappropriately when performing lookahead. The test I'm using which triggers this is:
To give an example of how an implementation can work around this issue, here's what I came up with for x86: