#include #include #define aliases __attribute__((__may_alias__)) #define byte_repeat(x) ((size_t)~0 / 0xff * (x)) #define word_has_zero(x) (((x) - byte_repeat(0x01)) & ~(x) & byte_repeat(0x80)) size_t strlen(const char *s) { const char *const s0 = s; const size_t aliases *ws; for (; (uintptr_t)s & sizeof(size_t) - 1 && *s; s++); if (!*s) return s - s0; ws = (const void *)s; for (; !word_has_zero(*ws); ws++); s = (const void *)ws; for (; *s; s++); return s - s0; }