aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/compiler-gcc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/compiler-gcc.h')
-rw-r--r--include/linux/compiler-gcc.h75
1 files changed, 7 insertions, 68 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 90ddfefb6c2b..c0f5db3a9621 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -68,31 +68,20 @@
68 */ 68 */
69#define uninitialized_var(x) x = x 69#define uninitialized_var(x) x = x
70 70
71#ifdef __CHECKER__
72#define __must_be_array(a) 0
73#else
74/* &a[0] degrades to a pointer: a different type from an array */
75#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
76#endif
77
78#ifdef RETPOLINE 71#ifdef RETPOLINE
79#define __noretpoline __attribute__((indirect_branch("keep"))) 72#define __noretpoline __attribute__((__indirect_branch__("keep")))
80#endif 73#endif
81 74
82#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 75#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
83 76
84#define __optimize(level) __attribute__((__optimize__(level)))
85
86#define __compiletime_object_size(obj) __builtin_object_size(obj, 0) 77#define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
87 78
88#ifndef __CHECKER__ 79#define __compiletime_warning(message) __attribute__((__warning__(message)))
89#define __compiletime_warning(message) __attribute__((warning(message))) 80#define __compiletime_error(message) __attribute__((__error__(message)))
90#define __compiletime_error(message) __attribute__((error(message)))
91 81
92#ifdef LATENT_ENTROPY_PLUGIN 82#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__)
93#define __latent_entropy __attribute__((latent_entropy)) 83#define __latent_entropy __attribute__((latent_entropy))
94#endif 84#endif
95#endif /* __CHECKER__ */
96 85
97/* 86/*
98 * calling noreturn functions, __builtin_unreachable() and __builtin_trap() 87 * calling noreturn functions, __builtin_unreachable() and __builtin_trap()
@@ -107,10 +96,6 @@
107 * Mark a position in code as unreachable. This can be used to 96 * Mark a position in code as unreachable. This can be used to
108 * suppress control flow warnings after asm blocks that transfer 97 * suppress control flow warnings after asm blocks that transfer
109 * control elsewhere. 98 * control elsewhere.
110 *
111 * Early snapshots of gcc 4.5 don't support this and we can't detect
112 * this in the preprocessor, but we can live with this because they're
113 * unreleased. Really, we need to have autoconf for the kernel.
114 */ 99 */
115#define unreachable() \ 100#define unreachable() \
116 do { \ 101 do { \
@@ -119,9 +104,6 @@
119 __builtin_unreachable(); \ 104 __builtin_unreachable(); \
120 } while (0) 105 } while (0)
121 106
122/* Mark a function definition as prohibited from being cloned. */
123#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
124
125#if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__) 107#if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__)
126#define __randomize_layout __attribute__((randomize_layout)) 108#define __randomize_layout __attribute__((randomize_layout))
127#define __no_randomize_layout __attribute__((no_randomize_layout)) 109#define __no_randomize_layout __attribute__((no_randomize_layout))
@@ -131,32 +113,6 @@
131#endif 113#endif
132 114
133/* 115/*
134 * When used with Link Time Optimization, gcc can optimize away C functions or
135 * variables which are referenced only from assembly code. __visible tells the
136 * optimizer that something else uses this function or variable, thus preventing
137 * this.
138 */
139#define __visible __attribute__((externally_visible))
140
141/* gcc version specific checks */
142
143#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
144/*
145 * __assume_aligned(n, k): Tell the optimizer that the returned
146 * pointer can be assumed to be k modulo n. The second argument is
147 * optional (default 0), so we use a variadic macro to make the
148 * shorthand.
149 *
150 * Beware: Do not apply this to functions which may return
151 * ERR_PTRs. Also, it is probably unwise to apply it to functions
152 * returning extra information in the low bits (but in that case the
153 * compiler should see some alignment anyway, when the return value is
154 * massaged by 'flags = ptr & 3; ptr &= ~3;').
155 */
156#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
157#endif
158
159/*
160 * GCC 'asm goto' miscompiles certain code sequences: 116 * GCC 'asm goto' miscompiles certain code sequences:
161 * 117 *
162 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 118 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
@@ -187,39 +143,22 @@
187#define KASAN_ABI_VERSION 3 143#define KASAN_ABI_VERSION 3
188#endif 144#endif
189 145
190#if GCC_VERSION >= 40902
191/* 146/*
192 * Tell the compiler that address safety instrumentation (KASAN) 147 * Because __no_sanitize_address conflicts with inlining:
193 * should not be applied to that function. 148 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
194 * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 149 * we do one or the other.
195 */ 150 */
196#define __no_sanitize_address __attribute__((no_sanitize_address))
197#ifdef CONFIG_KASAN 151#ifdef CONFIG_KASAN
198#define __no_sanitize_address_or_inline \ 152#define __no_sanitize_address_or_inline \
199 __no_sanitize_address __maybe_unused notrace 153 __no_sanitize_address __maybe_unused notrace
200#else 154#else
201#define __no_sanitize_address_or_inline inline 155#define __no_sanitize_address_or_inline inline
202#endif 156#endif
203#endif
204 157
205#if GCC_VERSION >= 50100 158#if GCC_VERSION >= 50100
206/*
207 * Mark structures as requiring designated initializers.
208 * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
209 */
210#define __designated_init __attribute__((designated_init))
211#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 159#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
212#endif 160#endif
213 161
214#if !defined(__noclone)
215#define __noclone /* not needed */
216#endif
217
218#if !defined(__no_sanitize_address)
219#define __no_sanitize_address
220#define __no_sanitize_address_or_inline inline
221#endif
222
223/* 162/*
224 * Turn individual warnings and errors on and off locally, depending 163 * Turn individual warnings and errors on and off locally, depending
225 * on version. 164 * on version.