7 #define ALIGN (sizeof(size_t)-1)
8 #define ONES ((size_t)-1/UCHAR_MAX)
9 #define HIGHS (ONES * (UCHAR_MAX/2+1))
10 #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
12 char *__stpncpy(char *restrict d, const char *restrict s, size_t n)
17 if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
18 for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
19 if (!n || !*s) goto tail;
20 wd=(void *)d; ws=(const void *)s;
21 for (; n>=sizeof(size_t) && !HASZERO(*ws);
22 n-=sizeof(size_t), ws++, wd++) *wd = *ws;
23 d=(void *)wd; s=(const void *)ws;
25 for (; n && (*d=*s); n--, s++, d++);
31 weak_alias(__stpncpy, stpncpy);