Adding upstream version 3.50~pre5.
[syslinux-debian/hramrach.git] / com32 / lib / memmove.c
blobc1f042af39fd02a698a87f5d4c4ae46618f99ebd
1 /*
2 * memmove.c
3 */
5 #include <string.h>
7 void *memmove(void *dst, const void *src, size_t n)
9 const char *p = src;
10 char *q = dst;
11 #if defined(__i386__) || defined(__x86_64__)
12 if ( q < p ) {
13 asm volatile("cld ; rep ; movsb" : "+c" (n), "+S" (p), "+D" (q));
14 } else {
15 p += (n-1);
16 q += (n-1);
17 asm volatile("std ; rep ; movsb" : "+c" (n), "+S" (p), "+D" (q));
19 #else
20 if ( q < p ) {
21 while ( n-- ) {
22 *q++ = *p++;
24 } else {
25 p += n;
26 q += n;
27 while ( n-- ) {
28 *--q = *--p;
31 #endif
33 return dst;