Chameleon

Chameleon Svn Source Tree

Root/branches/xZen/src/modules/klibc/memmove.c

Source at commit 1247 created 7 years 11 months ago.
By meklort, Update makefiles... initial work for fat modules
1/*
2 * memmove.c
3 */
4#include <sys/types.h>
5
6void *memmove(void *dst, const void *src, size_t n)
7{
8const char *p = src;
9char *q = dst;
10#if defined(__i386__) || defined(__x86_64__)
11if (q < p) {
12asm volatile("cld; rep; movsb"
13 : "+c" (n), "+S"(p), "+D"(q));
14} else {
15p += (n - 1);
16q += (n - 1);
17asm volatile("std; rep; movsb; cld"
18 : "+c" (n), "+S"(p), "+D"(q));
19}
20#else
21if (q < p) {
22while (n--) {
23*q++ = *p++;
24}
25} else {
26p += n;
27q += n;
28while (n--) {
29*--q = *--p;
30}
31}
32#endif
33
34return dst;
35}
36

Archive Download this file

Revision: 1247