[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 for-next 1/2] x86/string: Clean up the declarations of __builtin_mem*()

None of the GCC docs mention memmove() in its list of builtins even today, but
4.1 does have the builtin, meaning that all currently supported compilers have

Rather than #undef'ing macros to avoid altering the function names, use the
method recommended by the C specification by enclosing the function name in
brackets to avoid the macro being expanded.  This means that optimisation
opportunities continue to work in the rest of the translation unit.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21602 confirms that the builtin
was present in 4.1.0
 xen/arch/x86/string.c        | 9 +++------
 xen/include/asm-x86/string.h | 7 +++----
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/string.c b/xen/arch/x86/string.c
index 1387dfb..f4d7f2a 100644
--- a/xen/arch/x86/string.c
+++ b/xen/arch/x86/string.c
@@ -7,8 +7,7 @@
 #include <xen/lib.h>
-#undef memcpy
-void *memcpy(void *dest, const void *src, size_t n)
+void *(memcpy)(void *dest, const void *src, size_t n)
     long d0, d1, d2;
@@ -23,8 +22,7 @@ void *memcpy(void *dest, const void *src, size_t n)
     return dest;
-#undef memset
-void *memset(void *s, int c, size_t n)
+void *(memset)(void *s, int c, size_t n)
     long d0, d1;
@@ -37,8 +35,7 @@ void *memset(void *s, int c, size_t n)
     return s;
-#undef memmove
-void *memmove(void *dest, const void *src, size_t n)
+void *(memmove)(void *dest, const void *src, size_t n)
     long d0, d1, d2;
diff --git a/xen/include/asm-x86/string.h b/xen/include/asm-x86/string.h
index c48d9c3..d636e82 100644
--- a/xen/include/asm-x86/string.h
+++ b/xen/include/asm-x86/string.h
@@ -2,13 +2,12 @@
 #define __X86_STRING_H__
-#define memcpy(t,f,n) (__builtin_memcpy((t),(f),(n)))
+#define memcpy(d, s, n)       __builtin_memcpy(d, s, n)
-/* Some versions of gcc don't have this builtin. It's non-critical anyway. */
-extern void *memmove(void *dest, const void *src, size_t n);
+#define memmove(d, s, n)      __builtin_memmove(d, s, n)
-#define memset(s,c,n) (__builtin_memset((s),(c),(n)))
+#define memset(s, c, n)       __builtin_memset(s, c, n)
 #endif /* __X86_STRING_H__ */

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.