| int memcmp(const void *vl, const void *vr, size_t n) | |
| { | |
| const unsigned char *l=vl, *r=vr; | |
| // XXX EMSCRIPTEN: add an optimized version. | |
| // If we have enough bytes, and everything is aligned, loop on words instead | |
| // of single bytes. | |
| if (n >= 4 && !((((uintptr_t)l) & 3) | (((uintptr_t)r) & 3))) { | |
| while (n >= 4) { | |
| if (*((uint32_t *)l) != *((uint32_t *)r)) { | |
| // Go to the single-byte loop to find the specific byte. | |
| break; | |
| } | |
| l += 4; | |
| r += 4; | |
| n -= 4; | |
| } | |
| } | |
| for (; n && *l == *r; n--, l++, r++); | |
| return n ? *l-*r : 0; | |
| } | |