[patch 09/20] x86 inline memcpy

Mathieu Desnoyers
2010-07-09T23:40:10Z

[-- Attachment #1: x86-inline-memcpy.patch --]
[-- Type: text/plain, Size: 1672 bytes --]

Export an inline_memcpy() API. Useful when the memcpy size is unknown but the
caller cannot afford the cost of a function call. Useful for very frequent
memcpy callers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
---
arch/x86/include/asm/string_32.h | 7 +++++++
arch/x86/include/asm/string_64.h | 7 +++++++
2 files changed, 14 insertions(+)

Index: linux.trees.git/arch/x86/include/asm/string_32.h
===================================================================
--- linux.trees.git.orig/arch/x86/include/asm/string_32.h 2010-06-21 17:50:21.000000000 -0400
+++ linux.trees.git/arch/x86/include/asm/string_32.h 2010-06-21 17:56:49.000000000 -0400
@@ -44,6 +44,13 @@ static __always_inline void *__memcpy(vo
return to;
}

+#define __HAVE_ARCH_INLINE_MEMCPY
+static __always_inline void *inline_memcpy(void *to, const void *from,
+ size_t n)
+{
+ return __memcpy(to, from, n);
+}
+
/*
* This looks ugly, but the compiler can optimize it totally,
* as the count is constant.
Index: linux.trees.git/arch/x86/include/asm/string_64.h
===================================================================
--- linux.trees.git.orig/arch/x86/include/asm/string_64.h 2010-06-21 17:50:21.000000000 -0400
+++ linux.trees.git/arch/x86/include/asm/string_64.h 2010-06-21 17:57:13.000000000 -0400
@@ -23,6 +23,13 @@ static __always_inline void *__inline_me
return to;
}

+#define __HAVE_ARCH_INLINE_MEMCPY
+static __always_inline void *inline_memcpy(void *to, const void *from,
+ size_t n)
+{
+ return __inline_memcpy(to, from, n);
+}
+
/* Even with __builtin_ the compiler may decide to use the out of line
function. */