blob: 5415a9d06f53b75c4a993b0bbe96508502691142 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/string.h>
2#include <linux/module.h>
3
4#undef memcpy
5#undef memset
6
7void *memcpy(void *to, const void *from, size_t n)
8{
9#ifdef CONFIG_X86_USE_3DNOW
10 return __memcpy3d(to, from, n);
11#else
12 return __memcpy(to, from, n);
13#endif
14}
15EXPORT_SYMBOL(memcpy);
16
17void *memset(void *s, int c, size_t count)
18{
19 return __memset(s, c, count);
20}
21EXPORT_SYMBOL(memset);
22
23void *memmove(void *dest, const void *src, size_t n)
24{
25 int d0, d1, d2;
26
27 if (dest < src) {
Paolo Ciarrocchi93d8bd32008-02-22 23:10:23 +010028 memcpy(dest, src, n);
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 } else {
30 __asm__ __volatile__(
31 "std\n\t"
32 "rep\n\t"
33 "movsb\n\t"
34 "cld"
35 : "=&c" (d0), "=&S" (d1), "=&D" (d2)
36 :"0" (n),
Jan Engelhardtade1af72008-01-30 13:33:23 +010037 "1" (n-1+src),
38 "2" (n-1+dest)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 :"memory");
40 }
41 return dest;
42}
43EXPORT_SYMBOL(memmove);