build.sh: pass OPTS also to linking stage, so -static can be passed
[rofl0r-memcpy-test.git] / memcpy_noalign.c
blob6ed32c6e38cc61d5dd03e080489fab3a9e722ab3
1 #include <string.h>
2 #include <stdlib.h>
3 #include <stdint.h>
5 #define SS (sizeof(size_t))
6 #define ALIGN (sizeof(size_t)-1)
7 #define ONES ((size_t)-1/UCHAR_MAX)
9 typedef struct block { unsigned char data[4*SS]; } block;
11 void *mymemcpy(void *restrict dest, const void *restrict src, size_t n)
13 unsigned char *d = dest;
14 const unsigned char *s = src;
16 for (; n>=4*SS; n-=4*SS, s+=4*SS, d+=4*SS)
17 *(block *)d = *(block *)s;
18 for (; n; n--) *d++ = *s++;
20 return dest;