Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7c18400 authored by Miao Xie's avatar Miao Xie Committed by Razziell
Browse files

lib/string: use glibc version

the performance of memcpy and memmove of the general version is very
inefficient, this patch improved them.

Signed-off-by: Miao Xie <miaox*******>
parent f6293ac9
Loading
Loading
Loading
Loading
+12 −17
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/export.h>
#include <linux/bug.h>
#include <linux/errno.h>
#include <linux/memcopy.h>

#include <asm/byteorder.h>
#include <asm/word-at-a-time.h>
@@ -715,11 +716,11 @@ EXPORT_SYMBOL(memzero_explicit);
 */
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; 

	while (count--)
		*tmp++ = *s++;
	/* Copy from the beginning to the end */ 
	mem_copy_fwd(dstp, srcp, count); 
	return dest;
}
EXPORT_SYMBOL(memcpy);
@@ -736,21 +737,15 @@ EXPORT_SYMBOL(memcpy);
 */
void *memmove(void *dest, const void *src, size_t count)
{
	char *tmp;
	const char *s;
	unsigned long dstp = (unsigned long)dest; 
	unsigned long srcp = (unsigned long)src; 

	if (dest <= src) {
		tmp = dest;
		s = src;
		while (count--)
			*tmp++ = *s++;
	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;
		/* Copy from the end to the beginning */ 
		mem_copy_bwd(dstp, srcp, count); 
	}
	return dest;
}