#include #include #include #include "word.h" /** * strcmp - Word sized c standard strcmp. * @c: Comparative * @s: Source */ #undef strcmp int strcmp(const char *c, const char *s) { const size_t *wc, *ws; if ((uintptr_t)c % sizeof(size_t) != (uintptr_t)s % sizeof(size_t)) goto misaligned; for (; (uintptr_t)c % sizeof(size_t); c++, s++) { if (*c != *s || !*c || !*s) return *(const unsigned char *)c - *(const unsigned char *)s; } for (wc = (const size_t *)c, ws = (const size_t *)s ; (!word_has_zero(*wc) || !word_has_zero(*ws)) && *wc == *ws ; wc++, ws++); c = (const char *)wc; s = (const char *)ws; misaligned: for(; *c == *s && *c && *s; c++, s++); return *(const unsigned char *)c - *(const unsigned char *)s; }