aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/vdso/vdso2c.c
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@amacapital.net>2014-05-30 08:48:49 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2014-05-30 16:58:43 -0700
commitadd4eed0a2abea3951206f504330ee5daf8c178a (patch)
tree887492cf9d0f28135e9c353a5ceafe6d3e633247 /arch/x86/vdso/vdso2c.c
parentx86/vdso, build: When vdso2c fails, unlink the output (diff)
downloadlinux-dev-add4eed0a2abea3951206f504330ee5daf8c178a.tar.xz
linux-dev-add4eed0a2abea3951206f504330ee5daf8c178a.zip
x86/vdso, build: Fix cross-compilation from big-endian architectures
This adds a macro GET(x) to convert x from big-endian to little-endian. Hopefully I put it everywhere it needs to go and got all the cases needed for everyone's linux/elf.h. Signed-off-by: Andy Lutomirski <luto@amacapital.net> Link: http://lkml.kernel.org/r/2cf258df123cb24bad63c274c8563c050547d99d.1401464755.git.luto@amacapital.net Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/vdso/vdso2c.c')
-rw-r--r--arch/x86/vdso/vdso2c.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/vdso/vdso2c.c b/arch/x86/vdso/vdso2c.c
index fe8bfbf62612..de19ced6c87d 100644
--- a/arch/x86/vdso/vdso2c.c
+++ b/arch/x86/vdso/vdso2c.c
@@ -51,6 +51,21 @@ static void fail(const char *format, ...)
va_end(ap);
}
+/*
+ * Evil macros to do a little-endian read.
+ */
+#define __GET_TYPE(x, type, bits, ifnot) \
+ __builtin_choose_expr( \
+ __builtin_types_compatible_p(typeof(x), type), \
+ le##bits##toh((x)), ifnot)
+
+extern void bad_get(uint64_t);
+
+#define GET(x) \
+ __GET_TYPE((x), __u32, 32, __GET_TYPE((x), __u64, 64, \
+ __GET_TYPE((x), __s32, 32, __GET_TYPE((x), __s64, 64, \
+ __GET_TYPE((x), __u16, 16, bad_get(x))))))
+
#define NSYMS (sizeof(required_syms) / sizeof(required_syms[0]))
#define BITS 64