1 /*
2 * Copyright (c) 1994 William F. Jolitz.
3 * 386BSD Copyright Restrictions Apply. All Other Rights Reserved.
4 *
5 * $Id: memcpy.h,v 1.1 94/06/09 18:19:59 bill Exp Locker: bill $
6 * POSIX (non-overlapping) block memory copy.
7 */
8
9 __INLINE void *
memcpy(void * to,const void * from,size_t len)10 memcpy(void *to, const void *from, size_t len) {
11 void *rv = to;
12 extern const int zero; /* compiler bug workaround */
13 const void *f = from + zero; /* compiler bug workaround */
14
15 asm volatile ("cld ; repe ; movsl" :
16 "=D" (to), "=S" (f) :
17 "0" (to), "1" (f), "c" (len / 4));
18
19 asm volatile ("repe ; movsb" :
20 "=D" (to), "=S" (f) :
21 "0" (to), "1" (f), "c" (len & 3));
22
23 return (rv);
24 }
25