blob: 0a33909bf12213dbb0945d057e5c7c537296074e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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>
Andi Kleen2ee60e172006-06-26 13:59:44 +02006#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8#undef memmove
Paolo Ciarrocchie9406592008-02-19 20:53:38 +01009void *memmove(void *dest, const void *src, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070010{
Paolo Ciarrocchie9406592008-02-19 20:53:38 +010011 if (dest < src) {
12 return memcpy(dest, src, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 } else {
Jan Engelhardtade1af72008-01-30 13:33:23 +010014 char *p = dest + count;
15 const char *s = src + count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 while (count--)
17 *--p = *--s;
18 }
19 return dest;
Paolo Ciarrocchie9406592008-02-19 20:53:38 +010020}
Andi Kleen2ee60e172006-06-26 13:59:44 +020021EXPORT_SYMBOL(memmove);