/** * memmove - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * Unlike memcpy(), memmove() copes with overlapping areas. */ void *memmove(void *dest, const void *src, size_t count) { /*char *tmp; const char *s; if (dest <= src) { tmp = dest; s = src; while (count--) *tmp++ = *s++;*/ unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; if (dest - src >= count) { /* Copy from the beginning to the end */ mem_copy_fwd(dstp, srcp, count); } else { /*tmp = dest; tmp += count; s = src; s += count; while (count--) *--tmp = *--s;*/ mem_copy_bwd(dstp, srcp, count); } return dest; }
/** * memcpy - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ void *memcpy(void *dest, const void *src, size_t count) { unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; mem_copy_fwd(dstp, srcp, count); return dest; }
/** * memcpy - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ void *memcpy(void *dest, const void *src, size_t count) { unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; /* Copy from the beginning to the end */ mem_copy_fwd(dstp, srcp, count); return dest; }
/** * memmove - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * Unlike memcpy(), memmove() copes with overlapping areas. */ void *memmove(void *dest, const void *src, size_t count) { unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; if (dest - src >= count) { mem_copy_fwd(dstp, srcp, count); } else { mem_copy_bwd(dstp, srcp, count); } return dest; }
/** * memcpy - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ void *memcpy(void *dest, const void *src, size_t count) { /*char *tmp = dest; const char *s = src;*/ unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; /* Copy from the beginning to the end */ mem_copy_fwd(dstp, srcp, count); /*while (count--) *tmp++ = *s++;*/ return dest; }
/** * memmove - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * Unlike memcpy(), memmove() copes with overlapping areas. */ void *memmove(void *dest, const void *src, size_t count) { unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; if (dest - src >= count) { /* Copy from the beginning to the end */ mem_copy_fwd(dstp, srcp, count); } else { /* Copy from the end to the beginning */ mem_copy_bwd(dstp, srcp, count); } return dest; }
/** * memcpy - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ void *memcpy(void *dest, const void *src, size_t count) { #ifdef CONFIG_GLIBC_MEMCPY unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; mem_copy_fwd(dstp, srcp, count); #else char *tmp = dest; const char *s = src; while (count--) *tmp++ = *s++; #endif return dest; }
/** * memmove - Copy one area of memory to another * @dest: Where to copy to * @src: Where to copy from * @count: The size of the area. * * Unlike memcpy(), memmove() copes with overlapping areas. */ void *memmove(void *dest, const void *src, size_t count) { #ifdef CONFIG_GLIBC_MEMCPY unsigned long dstp = (unsigned long)dest; unsigned long srcp = (unsigned long)src; if (dest - src >= count) { mem_copy_fwd(dstp, srcp, count); #else char *tmp; const char *s; if (dest <= src) { tmp = dest; s = src; while (count--) *tmp++ = *s++; #endif } else { #ifdef CONFIG_GLIBC_MEMCPY mem_copy_bwd(dstp, srcp, count); #else tmp = dest; tmp += count; s = src; s += count; while (count--) *--tmp = *--s; #endif } return dest; } EXPORT_SYMBOL(memmove); #endif #ifndef __HAVE_ARCH_MEMCMP /** * memcmp - Compare two areas of memory * @cs: One area of memory * @ct: Another area of memory * @count: The size of the area. */ #undef memcmp int memcmp(const void *cs, const void *ct, size_t count) { const unsigned char *su1, *su2; int res = 0; for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--) if ((res = *su1 - *su2) != 0) break; return res; } EXPORT_SYMBOL(memcmp); #endif #ifndef __HAVE_ARCH_MEMSCAN /** * memscan - Find a character in an area of memory. * @addr: The memory area * @c: The byte to search for * @size: The size of the area. * * returns the address of the first occurrence of @c, or 1 byte past * the area if @c is not found */ void *memscan(void *addr, int c, size_t size) { unsigned char *p = addr; while (size) { if (*p == c) return (void *)p; p++; size--; } return (void *)p; }