source: bootcd/isolinux/syslinux-6.03/com32/lib/memmove.c

Last change on this file was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 535 bytes
Line 
1/*
2 * memmove.c
3 */
4
5#include <string.h>
6
7void *memmove(void *dst, const void *src, size_t n)
8{
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"
14                             : "+c" (n), "+S"(p), "+D"(q));
15        } else {
16                p += (n - 1);
17                q += (n - 1);
18                asm volatile("std; rep; movsb; cld"
19                             : "+c" (n), "+S"(p), "+D"(q));
20        }
21#else
22        if (q < p) {
23                while (n--) {
24                        *q++ = *p++;
25                }
26        } else {
27                p += n;
28                q += n;
29                while (n--) {
30                        *--q = *--p;
31                }
32        }
33#endif
34
35        return dst;
36}
Note: See TracBrowser for help on using the repository browser.