blob: 61ec2fbe571695dd5eb64238cf82700d8a355253 [file] [log] [blame]
Patrick Williams8b8bc412016-08-17 15:02:23 -05001Fix compile with GCC6
2
3Upstream-status: Denied [https://github.com/raspberrypi/linux/pull/1528]
4
5Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
6
7Index: source/include/linux/compiler-gcc6.h
8===================================================================
9--- /dev/null
10+++ source/include/linux/compiler-gcc6.h
11@@ -0,0 +1,67 @@
12+#ifndef __LINUX_COMPILER_H
13+#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
14+#endif
15+
16+#define __used __attribute__((__used__))
17+#define __must_check __attribute__((warn_unused_result))
18+#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
19+
20+/* Mark functions as cold. gcc will assume any path leading to a call
21+ to them will be unlikely. This means a lot of manual unlikely()s
22+ are unnecessary now for any paths leading to the usual suspects
23+ like BUG(), printk(), panic() etc. [but let's keep them for now for
24+ older compilers]
25+
26+ Early snapshots of gcc 4.3 don't support this and we can't detect this
27+ in the preprocessor, but we can live with this because they're unreleased.
28+ Maketime probing would be overkill here.
29+
30+ gcc also has a __attribute__((__hot__)) to move hot functions into
31+ a special section, but I don't see any sense in this right now in
32+ the kernel context */
33+#define __cold __attribute__((__cold__))
34+
35+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
36+
37+#ifndef __CHECKER__
38+# define __compiletime_warning(message) __attribute__((warning(message)))
39+# define __compiletime_error(message) __attribute__((error(message)))
40+#endif /* __CHECKER__ */
41+
42+/*
43+ * Mark a position in code as unreachable. This can be used to
44+ * suppress control flow warnings after asm blocks that transfer
45+ * control elsewhere.
46+ *
47+ * Early snapshots of gcc 4.5 don't support this and we can't detect
48+ * this in the preprocessor, but we can live with this because they're
49+ * unreleased. Really, we need to have autoconf for the kernel.
50+ */
51+#define unreachable() __builtin_unreachable()
52+
53+/* Mark a function definition as prohibited from being cloned. */
54+#define __noclone __attribute__((__noclone__))
55+
56+/*
57+ * Tell the optimizer that something else uses this function or variable.
58+ */
59+#define __visible __attribute__((externally_visible))
60+
61+/*
62+ * GCC 'asm goto' miscompiles certain code sequences:
63+ *
64+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
65+ *
66+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
67+ *
68+ * (asm goto is automatically volatile - the naming reflects this.)
69+ */
70+#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
71+
72+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
73+#define __HAVE_BUILTIN_BSWAP32__
74+#define __HAVE_BUILTIN_BSWAP64__
75+#define __HAVE_BUILTIN_BSWAP16__
76+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
77+
78+#define KASAN_ABI_VERSION 4