2 ** Copyright 2001, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
9 /* do not build for for arches that have overridden this with an assembly version */
10 #if !defined(ARCH_x86)
14 #define lsize sizeof(word)
15 #define lmask (lsize - 1)
17 void *memcpy(void *dest
, const void *src
, size_t count
)
19 char *d
= (char *)dest
;
20 const char *s
= (const char *)src
;
23 if(count
== 0 || dest
== src
)
26 if(((long)d
| (long)s
) & lmask
) {
27 // src and/or dest do not align on word boundary
28 if((((long)d
^ (long)s
) & lmask
) || (count
< lsize
))
29 len
= count
; // copy the rest of the buffer with the byte mover
31 len
= lsize
- ((long)d
& lmask
); // move the ptrs up to a word boundary
37 for(len
= count
/ lsize
; len
> 0; len
--) {
38 *(word
*)d
= *(word
*)s
;
42 for(len
= count
& lmask
; len
> 0; len
--)