5 #define SS (sizeof(size_t))
6 #define ALIGN (sizeof(size_t)-1)
7 #define ONES ((size_t)-1/UCHAR_MAX)
9 void *mymemcpy(void *dest
, const void *src
, size_t n
)
11 unsigned char *d
= dest
;
12 const unsigned char *s
= src
;
14 if (((uintptr_t)d
& ALIGN
) != ((uintptr_t)s
& ALIGN
))
17 for (; ((uintptr_t)d
& ALIGN
) && n
; n
--) *d
++ = *s
++;
19 size_t *wd
= (void *)d
;
20 const size_t *ws
= (const void *)s
;
22 for (; n
>=SS
; n
-=SS
) *wd
++ = *ws
++;
26 for (; n
; n
--) *d
++ = *s
++;