1/* Normally compiler builtins are used, but sometimes the compiler calls out
2   of line code. Based on asm-i386/string.h.
3 */
4#define _STRING_C
5#include <linux/string.h>
6
7#undef memmove
8void *memmove(void * dest,const void *src,size_t count)
9{
10	if (dest < src) {
11		__inline_memcpy(dest,src,count);
12	} else {
13		/* Could be more clever and move longs */
14		unsigned long d0, d1, d2;
15		__asm__ __volatile__(
16			"std\n\t"
17			"rep\n\t"
18			"movsb\n\t"
19			"cld"
20			: "=&c" (d0), "=&S" (d1), "=&D" (d2)
21			:"0" (count),
22			"1" (count-1+(const char *)src),
23			"2" (count-1+(char *)dest)
24			:"memory");
25	}
26	return dest;
27}
28