aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2018-08-22 19:37:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-22 20:31:34 -0400
commit815f0ddb346c196018d4d8f8f55c12b83da1de3f (patch)
tree4805bf7e3cb7ec4e727aba8e62f9211e9001a760
parent899fbc33fd775b9dfa363db28f322272920a2196 (diff)
include/linux/compiler*.h: make compiler-*.h mutually exclusive
Commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6") recently exposed a brittle part of the build for supporting non-gcc compilers. Both Clang and ICC define __GNUC__, __GNUC_MINOR__, and __GNUC_PATCHLEVEL__ for quick compatibility with code bases that haven't added compiler specific checks for __clang__ or __INTEL_COMPILER. This is brittle, as they happened to get compatibility by posing as a certain version of GCC. This broke when upgrading the minimal version of GCC required to build the kernel, to a version above what ICC and Clang claim to be. Rather than always including compiler-gcc.h then undefining or redefining macros in compiler-intel.h or compiler-clang.h, let's separate out the compiler specific macro definitions into mutually exclusive headers, do more proper compiler detection, and keep shared definitions in compiler_types.h. Fixes: cafa0010cd51 ("Raise the minimum required gcc version to 4.6") Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com> Suggested-by: Eli Friedman <efriedma@codeaurora.org> Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/arm/kernel/asm-offsets.c13
-rw-r--r--drivers/gpu/drm/i915/i915_utils.h2
-rw-r--r--drivers/watchdog/kempld_wdt.c5
-rw-r--r--include/linux/compiler-clang.h20
-rw-r--r--include/linux/compiler-gcc.h88
-rw-r--r--include/linux/compiler-intel.h13
-rw-r--r--include/linux/compiler_types.h238
-rw-r--r--mm/ksm.c4
-rw-r--r--mm/migrate.c3
9 files changed, 133 insertions, 253 deletions
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 974d8d7d1bcd..3968d6c22455 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -38,25 +38,14 @@
38#error Sorry, your compiler targets APCS-26 but this kernel requires APCS-32 38#error Sorry, your compiler targets APCS-26 but this kernel requires APCS-32
39#endif 39#endif
40/* 40/*
41 * GCC 3.0, 3.1: general bad code generation.
42 * GCC 3.2.0: incorrect function argument offset calculation.
43 * GCC 3.2.x: miscompiles NEW_AUX_ENT in fs/binfmt_elf.c
44 * (http://gcc.gnu.org/PR8896) and incorrect structure
45 * initialisation in fs/jffs2/erase.c
46 * GCC 4.8.0-4.8.2: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854 41 * GCC 4.8.0-4.8.2: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854
47 * miscompiles find_get_entry(), and can result in EXT3 and EXT4 42 * miscompiles find_get_entry(), and can result in EXT3 and EXT4
48 * filesystem corruption (possibly other FS too). 43 * filesystem corruption (possibly other FS too).
49 */ 44 */
50#ifdef __GNUC__ 45#if defined(GCC_VERSION) && GCC_VERSION >= 40800 && GCC_VERSION < 40803
51#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
52#error Your compiler is too buggy; it is known to miscompile kernels.
53#error Known good compilers: 3.3, 4.x
54#endif
55#if GCC_VERSION >= 40800 && GCC_VERSION < 40803
56#error Your compiler is too buggy; it is known to miscompile kernels 46#error Your compiler is too buggy; it is known to miscompile kernels
57#error and result in filesystem corruption and oopses. 47#error and result in filesystem corruption and oopses.
58#endif 48#endif
59#endif
60 49
61int main(void) 50int main(void)
62{ 51{
diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
index 00165ad55fb3..395dd2511568 100644
--- a/drivers/gpu/drm/i915/i915_utils.h
+++ b/drivers/gpu/drm/i915/i915_utils.h
@@ -43,7 +43,7 @@
43#define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \ 43#define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
44 __stringify(x), (long)(x)) 44 __stringify(x), (long)(x))
45 45
46#if GCC_VERSION >= 70000 46#if defined(GCC_VERSION) && GCC_VERSION >= 70000
47#define add_overflows(A, B) \ 47#define add_overflows(A, B) \
48 __builtin_add_overflow_p((A), (B), (typeof((A) + (B)))0) 48 __builtin_add_overflow_p((A), (B), (typeof((A) + (B)))0)
49#else 49#else
diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c
index 2f3b049ea301..e268add43010 100644
--- a/drivers/watchdog/kempld_wdt.c
+++ b/drivers/watchdog/kempld_wdt.c
@@ -146,12 +146,7 @@ static int kempld_wdt_set_stage_timeout(struct kempld_wdt_data *wdt_data,
146 u32 remainder; 146 u32 remainder;
147 u8 stage_cfg; 147 u8 stage_cfg;
148 148
149#if GCC_VERSION < 40400
150 /* work around a bug compiling do_div() */
151 prescaler = READ_ONCE(kempld_prescaler[PRESCALER_21]);
152#else
153 prescaler = kempld_prescaler[PRESCALER_21]; 149 prescaler = kempld_prescaler[PRESCALER_21];
154#endif
155 150
156 if (!stage) 151 if (!stage)
157 return -EINVAL; 152 return -EINVAL;
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index 7087446c24c8..b1ce500fe8b3 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -6,11 +6,7 @@
6/* Some compiler specific definitions are overwritten here 6/* Some compiler specific definitions are overwritten here
7 * for Clang compiler 7 * for Clang compiler
8 */ 8 */
9
10#ifdef uninitialized_var
11#undef uninitialized_var
12#define uninitialized_var(x) x = *(&(x)) 9#define uninitialized_var(x) x = *(&(x))
13#endif
14 10
15/* same as gcc, this was present in clang-2.6 so we can assume it works 11/* same as gcc, this was present in clang-2.6 so we can assume it works
16 * with any version that can compile the kernel 12 * with any version that can compile the kernel
@@ -25,14 +21,8 @@
25#define __SANITIZE_ADDRESS__ 21#define __SANITIZE_ADDRESS__
26#endif 22#endif
27 23
28#undef __no_sanitize_address
29#define __no_sanitize_address __attribute__((no_sanitize("address"))) 24#define __no_sanitize_address __attribute__((no_sanitize("address")))
30 25
31/* Clang doesn't have a way to turn it off per-function, yet. */
32#ifdef __noretpoline
33#undef __noretpoline
34#endif
35
36/* 26/*
37 * Not all versions of clang implement the the type-generic versions 27 * Not all versions of clang implement the the type-generic versions
38 * of the builtin overflow checkers. Fortunately, clang implements 28 * of the builtin overflow checkers. Fortunately, clang implements
@@ -40,9 +30,17 @@
40 * checks. Unfortunately, we don't know which version of gcc clang 30 * checks. Unfortunately, we don't know which version of gcc clang
41 * pretends to be, so the macro may or may not be defined. 31 * pretends to be, so the macro may or may not be defined.
42 */ 32 */
43#undef COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
44#if __has_builtin(__builtin_mul_overflow) && \ 33#if __has_builtin(__builtin_mul_overflow) && \
45 __has_builtin(__builtin_add_overflow) && \ 34 __has_builtin(__builtin_add_overflow) && \
46 __has_builtin(__builtin_sub_overflow) 35 __has_builtin(__builtin_sub_overflow)
47#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 36#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
48#endif 37#endif
38
39/* The following are for compatibility with GCC, from compiler-gcc.h,
40 * and may be redefined here because they should not be shared with other
41 * compilers, like ICC.
42 */
43#define barrier() __asm__ __volatile__("" : : : "memory")
44#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
45#define __assume_aligned(a, ...) \
46 __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 250b9b7cfd60..763bbad1e258 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -75,48 +75,6 @@
75#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) 75#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
76#endif 76#endif
77 77
78/*
79 * Feature detection for gnu_inline (gnu89 extern inline semantics). Either
80 * __GNUC_STDC_INLINE__ is defined (not using gnu89 extern inline semantics,
81 * and we opt in to the gnu89 semantics), or __GNUC_STDC_INLINE__ is not
82 * defined so the gnu89 semantics are the default.
83 */
84#ifdef __GNUC_STDC_INLINE__
85# define __gnu_inline __attribute__((gnu_inline))
86#else
87# define __gnu_inline
88#endif
89
90/*
91 * Force always-inline if the user requests it so via the .config,
92 * or if gcc is too old.
93 * GCC does not warn about unused static inline functions for
94 * -Wunused-function. This turns out to avoid the need for complex #ifdef
95 * directives. Suppress the warning in clang as well by using "unused"
96 * function attribute, which is redundant but not harmful for gcc.
97 * Prefer gnu_inline, so that extern inline functions do not emit an
98 * externally visible function. This makes extern inline behave as per gnu89
99 * semantics rather than c99. This prevents multiple symbol definition errors
100 * of extern inline functions at link time.
101 * A lot of inline functions can cause havoc with function tracing.
102 */
103#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
104 !defined(CONFIG_OPTIMIZE_INLINING)
105#define inline \
106 inline __attribute__((always_inline, unused)) notrace __gnu_inline
107#else
108#define inline inline __attribute__((unused)) notrace __gnu_inline
109#endif
110
111#define __inline__ inline
112#define __inline inline
113#define __always_inline inline __attribute__((always_inline))
114#define noinline __attribute__((noinline))
115
116#define __packed __attribute__((packed))
117#define __weak __attribute__((weak))
118#define __alias(symbol) __attribute__((alias(#symbol)))
119
120#ifdef RETPOLINE 78#ifdef RETPOLINE
121#define __noretpoline __attribute__((indirect_branch("keep"))) 79#define __noretpoline __attribute__((indirect_branch("keep")))
122#endif 80#endif
@@ -135,55 +93,9 @@
135 */ 93 */
136#define __naked __attribute__((naked)) noinline __noclone notrace 94#define __naked __attribute__((naked)) noinline __noclone notrace
137 95
138#define __noreturn __attribute__((noreturn))
139
140/*
141 * From the GCC manual:
142 *
143 * Many functions have no effects except the return value and their
144 * return value depends only on the parameters and/or global
145 * variables. Such a function can be subject to common subexpression
146 * elimination and loop optimization just as an arithmetic operator
147 * would be.
148 * [...]
149 */
150#define __pure __attribute__((pure))
151#define __aligned(x) __attribute__((aligned(x)))
152#define __aligned_largest __attribute__((aligned))
153#define __printf(a, b) __attribute__((format(printf, a, b)))
154#define __scanf(a, b) __attribute__((format(scanf, a, b)))
155#define __attribute_const__ __attribute__((__const__))
156#define __maybe_unused __attribute__((unused))
157#define __always_unused __attribute__((unused))
158#define __mode(x) __attribute__((mode(x)))
159
160#define __must_check __attribute__((warn_unused_result))
161#define __malloc __attribute__((__malloc__))
162
163#define __used __attribute__((__used__))
164#define __compiler_offsetof(a, b) \
165 __builtin_offsetof(a, b)
166
167/* Mark functions as cold. gcc will assume any path leading to a call
168 * to them will be unlikely. This means a lot of manual unlikely()s
169 * are unnecessary now for any paths leading to the usual suspects
170 * like BUG(), printk(), panic() etc. [but let's keep them for now for
171 * older compilers]
172 *
173 * Early snapshots of gcc 4.3 don't support this and we can't detect this
174 * in the preprocessor, but we can live with this because they're unreleased.
175 * Maketime probing would be overkill here.
176 *
177 * gcc also has a __attribute__((__hot__)) to move hot functions into
178 * a special section, but I don't see any sense in this right now in
179 * the kernel context
180 */
181#define __cold __attribute__((__cold__))
182
183#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 96#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
184 97
185#define __optimize(level) __attribute__((__optimize__(level))) 98#define __optimize(level) __attribute__((__optimize__(level)))
186#define __nostackprotector __optimize("no-stack-protector")
187 99
188#define __compiletime_object_size(obj) __builtin_object_size(obj, 0) 100#define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
189 101
diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h
index 547cdc920a3c..4c7f9befa9f6 100644
--- a/include/linux/compiler-intel.h
+++ b/include/linux/compiler-intel.h
@@ -14,10 +14,6 @@
14/* Intel ECC compiler doesn't support gcc specific asm stmts. 14/* Intel ECC compiler doesn't support gcc specific asm stmts.
15 * It uses intrinsics to do the equivalent things. 15 * It uses intrinsics to do the equivalent things.
16 */ 16 */
17#undef barrier
18#undef barrier_data
19#undef RELOC_HIDE
20#undef OPTIMIZER_HIDE_VAR
21 17
22#define barrier() __memory_barrier() 18#define barrier() __memory_barrier()
23#define barrier_data(ptr) barrier() 19#define barrier_data(ptr) barrier()
@@ -38,13 +34,12 @@
38 34
39#endif 35#endif
40 36
41#ifndef __HAVE_BUILTIN_BSWAP16__
42/* icc has this, but it's called _bswap16 */ 37/* icc has this, but it's called _bswap16 */
43#define __HAVE_BUILTIN_BSWAP16__ 38#define __HAVE_BUILTIN_BSWAP16__
44#define __builtin_bswap16 _bswap16 39#define __builtin_bswap16 _bswap16
45#endif
46 40
47/* 41/* The following are for compatibility with GCC, from compiler-gcc.h,
48 * icc defines __GNUC__, but does not implement the builtin overflow checkers. 42 * and may be redefined here because they should not be shared with other
43 * compilers, like clang.
49 */ 44 */
50#undef COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 45#define __visible __attribute__((externally_visible))
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index fbf337933fd8..90479a0f3986 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -54,32 +54,20 @@ extern void __chk_io_ptr(const volatile void __iomem *);
54 54
55#ifdef __KERNEL__ 55#ifdef __KERNEL__
56 56
57#ifdef __GNUC__ 57/* Compiler specific macros. */
58#include <linux/compiler-gcc.h>
59#endif
60
61#if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__)
62#define notrace __attribute__((hotpatch(0,0)))
63#else
64#define notrace __attribute__((no_instrument_function))
65#endif
66
67/* Intel compiler defines __GNUC__. So we will overwrite implementations
68 * coming from above header files here
69 */
70#ifdef __INTEL_COMPILER
71# include <linux/compiler-intel.h>
72#endif
73
74/* Clang compiler defines __GNUC__. So we will overwrite implementations
75 * coming from above header files here
76 */
77#ifdef __clang__ 58#ifdef __clang__
78#include <linux/compiler-clang.h> 59#include <linux/compiler-clang.h>
60#elif defined(__INTEL_COMPILER)
61#include <linux/compiler-intel.h>
62#elif defined(__GNUC__)
63/* The above compilers also define __GNUC__, so order is important here. */
64#include <linux/compiler-gcc.h>
65#else
66#error "Unknown compiler"
79#endif 67#endif
80 68
81/* 69/*
82 * Generic compiler-dependent macros required for kernel 70 * Generic compiler-independent macros required for kernel
83 * build go below this comment. Actual compiler/compiler version 71 * build go below this comment. Actual compiler/compiler version
84 * specific implementations come from the above header files 72 * specific implementations come from the above header files
85 */ 73 */
@@ -106,93 +94,19 @@ struct ftrace_likely_data {
106 unsigned long constant; 94 unsigned long constant;
107}; 95};
108 96
109#endif /* __KERNEL__ */
110
111#endif /* __ASSEMBLY__ */
112
113#ifdef __KERNEL__
114
115/* Don't. Just don't. */ 97/* Don't. Just don't. */
116#define __deprecated 98#define __deprecated
117#define __deprecated_for_modules 99#define __deprecated_for_modules
118 100
119#ifndef __must_check
120#define __must_check
121#endif
122
123#ifndef CONFIG_ENABLE_MUST_CHECK
124#undef __must_check
125#define __must_check
126#endif
127
128#ifndef __malloc
129#define __malloc
130#endif
131
132/*
133 * Allow us to avoid 'defined but not used' warnings on functions and data,
134 * as well as force them to be emitted to the assembly file.
135 *
136 * As of gcc 3.4, static functions that are not marked with attribute((used))
137 * may be elided from the assembly file. As of gcc 3.4, static data not so
138 * marked will not be elided, but this may change in a future gcc version.
139 *
140 * NOTE: Because distributions shipped with a backported unit-at-a-time
141 * compiler in gcc 3.3, we must define __used to be __attribute__((used))
142 * for gcc >=3.3 instead of 3.4.
143 *
144 * In prior versions of gcc, such functions and data would be emitted, but
145 * would be warned about except with attribute((unused)).
146 *
147 * Mark functions that are referenced only in inline assembly as __used so
148 * the code is emitted even though it appears to be unreferenced.
149 */
150#ifndef __used
151# define __used /* unimplemented */
152#endif
153
154#ifndef __maybe_unused
155# define __maybe_unused /* unimplemented */
156#endif
157
158#ifndef __always_unused
159# define __always_unused /* unimplemented */
160#endif
161
162#ifndef noinline
163#define noinline
164#endif
165
166/*
167 * Rather then using noinline to prevent stack consumption, use
168 * noinline_for_stack instead. For documentation reasons.
169 */
170#define noinline_for_stack noinline
171
172#ifndef __always_inline
173#define __always_inline inline
174#endif
175
176#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
177 102
103#endif /* __ASSEMBLY__ */
104
178/* 105/*
179 * From the GCC manual: 106 * The below symbols may be defined for one or more, but not ALL, of the above
180 * 107 * compilers. We don't consider that to be an error, so set them to nothing.
181 * Many functions do not examine any values except their arguments, 108 * For example, some of them are for compiler specific plugins.
182 * and have no effects except the return value. Basically this is
183 * just slightly more strict class than the `pure' attribute above,
184 * since function is not allowed to read global memory.
185 *
186 * Note that a function that has pointer arguments and examines the
187 * data pointed to must _not_ be declared `const'. Likewise, a
188 * function that calls a non-`const' function usually must not be
189 * `const'. It does not make sense for a `const' function to return
190 * `void'.
191 */ 109 */
192#ifndef __attribute_const__
193# define __attribute_const__ /* unimplemented */
194#endif
195
196#ifndef __designated_init 110#ifndef __designated_init
197# define __designated_init 111# define __designated_init
198#endif 112#endif
@@ -214,28 +128,10 @@ struct ftrace_likely_data {
214# define randomized_struct_fields_end 128# define randomized_struct_fields_end
215#endif 129#endif
216 130
217/*
218 * Tell gcc if a function is cold. The compiler will assume any path
219 * directly leading to the call is unlikely.
220 */
221
222#ifndef __cold
223#define __cold
224#endif
225
226/* Simple shorthand for a section definition */
227#ifndef __section
228# define __section(S) __attribute__ ((__section__(#S)))
229#endif
230
231#ifndef __visible 131#ifndef __visible
232#define __visible 132#define __visible
233#endif 133#endif
234 134
235#ifndef __nostackprotector
236# define __nostackprotector
237#endif
238
239/* 135/*
240 * Assume alignment of return value. 136 * Assume alignment of return value.
241 */ 137 */
@@ -243,17 +139,23 @@ struct ftrace_likely_data {
243#define __assume_aligned(a, ...) 139#define __assume_aligned(a, ...)
244#endif 140#endif
245 141
246
247/* Are two types/vars the same type (ignoring qualifiers)? */ 142/* Are two types/vars the same type (ignoring qualifiers)? */
248#ifndef __same_type 143#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
249# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
250#endif
251 144
252/* Is this type a native word size -- useful for atomic operations */ 145/* Is this type a native word size -- useful for atomic operations */
253#ifndef __native_word 146#define __native_word(t) \
254# define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) 147 (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
148 sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
149
150#ifndef __attribute_const__
151#define __attribute_const__ __attribute__((__const__))
255#endif 152#endif
256 153
154#ifndef __noclone
155#define __noclone
156#endif
157
158/* Helpers for emitting diagnostics in pragmas. */
257#ifndef __diag 159#ifndef __diag
258#define __diag(string) 160#define __diag(string)
259#endif 161#endif
@@ -272,4 +174,92 @@ struct ftrace_likely_data {
272#define __diag_error(compiler, version, option, comment) \ 174#define __diag_error(compiler, version, option, comment) \
273 __diag_ ## compiler(version, error, option) 175 __diag_ ## compiler(version, error, option)
274 176
177/*
178 * From the GCC manual:
179 *
180 * Many functions have no effects except the return value and their
181 * return value depends only on the parameters and/or global
182 * variables. Such a function can be subject to common subexpression
183 * elimination and loop optimization just as an arithmetic operator
184 * would be.
185 * [...]
186 */
187#define __pure __attribute__((pure))
188#define __aligned(x) __attribute__((aligned(x)))
189#define __aligned_largest __attribute__((aligned))
190#define __printf(a, b) __attribute__((format(printf, a, b)))
191#define __scanf(a, b) __attribute__((format(scanf, a, b)))
192#define __maybe_unused __attribute__((unused))
193#define __always_unused __attribute__((unused))
194#define __mode(x) __attribute__((mode(x)))
195#define __malloc __attribute__((__malloc__))
196#define __used __attribute__((__used__))
197#define __noreturn __attribute__((noreturn))
198#define __packed __attribute__((packed))
199#define __weak __attribute__((weak))
200#define __alias(symbol) __attribute__((alias(#symbol)))
201#define __cold __attribute__((cold))
202#define __section(S) __attribute__((__section__(#S)))
203
204
205#ifdef CONFIG_ENABLE_MUST_CHECK
206#define __must_check __attribute__((warn_unused_result))
207#else
208#define __must_check
209#endif
210
211#if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__)
212#define notrace __attribute__((hotpatch(0, 0)))
213#else
214#define notrace __attribute__((no_instrument_function))
215#endif
216
217#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
218
219/*
220 * Feature detection for gnu_inline (gnu89 extern inline semantics). Either
221 * __GNUC_STDC_INLINE__ is defined (not using gnu89 extern inline semantics,
222 * and we opt in to the gnu89 semantics), or __GNUC_STDC_INLINE__ is not
223 * defined so the gnu89 semantics are the default.
224 */
225#ifdef __GNUC_STDC_INLINE__
226# define __gnu_inline __attribute__((gnu_inline))
227#else
228# define __gnu_inline
229#endif
230
231/*
232 * Force always-inline if the user requests it so via the .config.
233 * GCC does not warn about unused static inline functions for
234 * -Wunused-function. This turns out to avoid the need for complex #ifdef
235 * directives. Suppress the warning in clang as well by using "unused"
236 * function attribute, which is redundant but not harmful for gcc.
237 * Prefer gnu_inline, so that extern inline functions do not emit an
238 * externally visible function. This makes extern inline behave as per gnu89
239 * semantics rather than c99. This prevents multiple symbol definition errors
240 * of extern inline functions at link time.
241 * A lot of inline functions can cause havoc with function tracing.
242 */
243#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
244 !defined(CONFIG_OPTIMIZE_INLINING)
245#define inline \
246 inline __attribute__((always_inline, unused)) notrace __gnu_inline
247#else
248#define inline inline __attribute__((unused)) notrace __gnu_inline
249#endif
250
251#define __inline__ inline
252#define __inline inline
253#define noinline __attribute__((noinline))
254
255#ifndef __always_inline
256#define __always_inline inline __attribute__((always_inline))
257#endif
258
259/*
260 * Rather then using noinline to prevent stack consumption, use
261 * noinline_for_stack instead. For documentation reasons.
262 */
263#define noinline_for_stack noinline
264
275#endif /* __LINUX_COMPILER_TYPES_H */ 265#endif /* __LINUX_COMPILER_TYPES_H */
diff --git a/mm/ksm.c b/mm/ksm.c
index 1bd514c9e5d0..5b0894b45ee5 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -652,9 +652,9 @@ static void remove_node_from_stable_tree(struct stable_node *stable_node)
652 * list_head to stay clear from the rb_parent_color union 652 * list_head to stay clear from the rb_parent_color union
653 * (aligned and different than any node) and also different 653 * (aligned and different than any node) and also different
654 * from &migrate_nodes. This will verify that future list.h changes 654 * from &migrate_nodes. This will verify that future list.h changes
655 * don't break STABLE_NODE_DUP_HEAD. 655 * don't break STABLE_NODE_DUP_HEAD. Only recent gcc can handle it.
656 */ 656 */
657#if GCC_VERSION >= 40903 /* only recent gcc can handle it */ 657#if defined(GCC_VERSION) && GCC_VERSION >= 40903
658 BUILD_BUG_ON(STABLE_NODE_DUP_HEAD <= &migrate_nodes); 658 BUILD_BUG_ON(STABLE_NODE_DUP_HEAD <= &migrate_nodes);
659 BUILD_BUG_ON(STABLE_NODE_DUP_HEAD >= &migrate_nodes + 1); 659 BUILD_BUG_ON(STABLE_NODE_DUP_HEAD >= &migrate_nodes + 1);
660#endif 660#endif
diff --git a/mm/migrate.c b/mm/migrate.c
index 4a83268e23c2..c27e97b5b69d 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1131,7 +1131,8 @@ out:
1131 * gcc 4.7 and 4.8 on arm get an ICEs when inlining unmap_and_move(). Work 1131 * gcc 4.7 and 4.8 on arm get an ICEs when inlining unmap_and_move(). Work
1132 * around it. 1132 * around it.
1133 */ 1133 */
1134#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900) && defined(CONFIG_ARM) 1134#if defined(CONFIG_ARM) && \
1135 defined(GCC_VERSION) && GCC_VERSION < 40900 && GCC_VERSION >= 40700
1135#define ICE_noinline noinline 1136#define ICE_noinline noinline
1136#else 1137#else
1137#define ICE_noinline 1138#define ICE_noinline