[tip:x86/urgent] x86/boot: #undef memcpy() et al in string.c

From: tip-bot for Michael Davidson
Date: Tue Jul 25 2017 - 09:52:48 EST


Commit-ID: 18d5e6c34a8eda438d5ad8b3b15f42dab01bf05d
Gitweb: http://git.kernel.org/tip/18d5e6c34a8eda438d5ad8b3b15f42dab01bf05d
Author: Michael Davidson <md@xxxxxxxxxx>
AuthorDate: Mon, 24 Jul 2017 16:51:55 -0700
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitDate: Tue, 25 Jul 2017 11:13:55 +0200

x86/boot: #undef memcpy() et al in string.c

undef memcpy() and friends in boot/string.c so that the functions
defined here will have the correct names, otherwise we end up
up trying to redefine __builtin_memcpy() etc.

Surprisingly, GCC allows this (and, helpfully, discards the
__builtin_ prefix from the function name when compiling it),
but clang does not.

Adding these #undef's appears to preserve what I assume was
the original intent of the code.

Signed-off-by: Michael Davidson <md@xxxxxxxxxx>
Signed-off-by: Matthias Kaehlcke <mka@xxxxxxxxxxxx>
Acked-by: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Bernhard.Rosenkranzer@xxxxxxxxxx
Cc: Greg Hackmann <ghackmann@xxxxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Link: http://lkml.kernel.org/r/20170724235155.79255-1-mka@xxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
arch/x86/boot/string.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 630e366..16f4912 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -16,6 +16,15 @@
#include "ctype.h"
#include "string.h"

+/*
+ * Undef these macros so that the functions that we provide
+ * here will have the correct names regardless of how string.h
+ * may have chosen to #define them.
+ */
+#undef memcpy
+#undef memset
+#undef memcmp
+
int memcmp(const void *s1, const void *s2, size_t len)
{
bool diff;