memcpy(): faster version using ASM rep; movsl
This commit is contained in:
23
arch/x86/kernel/include/arch-string.h
Normal file
23
arch/x86/kernel/include/arch-string.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef _ASM_X86_STRING_H
|
||||
#define _ASM_X86_STRING_H
|
||||
|
||||
#define ARCH_FAST_MEMCPY
|
||||
|
||||
static inline void *__inline_memcpy(void *to, const void *from, size_t n)
|
||||
{
|
||||
unsigned long d0, d1, d2;
|
||||
asm volatile("rep ; movsl\n\t"
|
||||
"testb $2,%b4\n\t"
|
||||
"je 1f\n\t"
|
||||
"movsw\n"
|
||||
"1:\ttestb $1,%b4\n\t"
|
||||
"je 2f\n\t"
|
||||
"movsb\n"
|
||||
"2:"
|
||||
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
||||
: "0" (n / 4), "q" (n), "1" ((long)to), "2" ((long)from)
|
||||
: "memory");
|
||||
return to;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -7910,7 +7910,8 @@ retry_lookup:
|
||||
|
||||
rva = phys_to_virt(rphys);
|
||||
|
||||
memcpy((op == PROCESS_VM_READ) ? local_iov[li].iov_base + loff : rva,
|
||||
fast_memcpy(
|
||||
(op == PROCESS_VM_READ) ? local_iov[li].iov_base + loff : rva,
|
||||
(op == PROCESS_VM_READ) ? rva : local_iov[li].iov_base + loff,
|
||||
to_copy);
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#define __STRING_H
|
||||
|
||||
#include <types.h>
|
||||
#include <arch-string.h>
|
||||
|
||||
size_t strlen(const char *p);
|
||||
size_t strnlen(const char *p, size_t maxlen);
|
||||
@ -29,6 +30,12 @@ void *memcpy_long(void *dest, const void *src, size_t n);
|
||||
int memcmp(const void *s1, const void *s2, size_t n);
|
||||
void *memset(void *s, int n, size_t l);
|
||||
|
||||
#ifdef ARCH_FAST_MEMCPY
|
||||
#define fast_memcpy __inline_memcpy
|
||||
#else
|
||||
#define fast_memcpy memcpy
|
||||
#endif
|
||||
|
||||
extern int snprintf(char * buf, size_t size, const char *fmt, ...);
|
||||
extern int sprintf(char * buf, const char *fmt, ...);
|
||||
extern int sscanf(const char * buf, const char * fmt, ...);
|
||||
|
||||
Reference in New Issue
Block a user