|
68 | 68 | */ |
69 | 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 | 71 | #ifdef RETPOLINE |
79 | | -#define __noretpoline __attribute__((indirect_branch("keep"))) |
| 72 | +#define __noretpoline __attribute__((__indirect_branch__("keep"))) |
80 | 73 | #endif |
81 | 74 |
|
82 | 75 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) |
83 | 76 |
|
84 | | -#define __optimize(level) __attribute__((__optimize__(level))) |
85 | | - |
86 | 77 | #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) |
87 | 78 |
|
88 | | -#ifndef __CHECKER__ |
89 | | -#define __compiletime_warning(message) __attribute__((warning(message))) |
90 | | -#define __compiletime_error(message) __attribute__((error(message))) |
| 79 | +#define __compiletime_warning(message) __attribute__((__warning__(message))) |
| 80 | +#define __compiletime_error(message) __attribute__((__error__(message))) |
91 | 81 |
|
92 | | -#ifdef LATENT_ENTROPY_PLUGIN |
| 82 | +#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) |
93 | 83 | #define __latent_entropy __attribute__((latent_entropy)) |
94 | 84 | #endif |
95 | | -#endif /* __CHECKER__ */ |
96 | 85 |
|
97 | 86 | /* |
98 | 87 | * calling noreturn functions, __builtin_unreachable() and __builtin_trap() |
|
107 | 96 | * Mark a position in code as unreachable. This can be used to |
108 | 97 | * suppress control flow warnings after asm blocks that transfer |
109 | 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 | 100 | #define unreachable() \ |
116 | 101 | do { \ |
|
119 | 104 | __builtin_unreachable(); \ |
120 | 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 | 107 | #if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__) |
126 | 108 | #define __randomize_layout __attribute__((randomize_layout)) |
127 | 109 | #define __no_randomize_layout __attribute__((no_randomize_layout)) |
|
130 | 112 | #define randomized_struct_fields_end } __randomize_layout; |
131 | 113 | #endif |
132 | 114 |
|
133 | | -/* |
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 | 115 | /* |
160 | 116 | * GCC 'asm goto' miscompiles certain code sequences: |
161 | 117 | * |
|
187 | 143 | #define KASAN_ABI_VERSION 3 |
188 | 144 | #endif |
189 | 145 |
|
190 | | -#if GCC_VERSION >= 40902 |
191 | 146 | /* |
192 | | - * Tell the compiler that address safety instrumentation (KASAN) |
193 | | - * should not be applied to that function. |
194 | | - * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 |
| 147 | + * Because __no_sanitize_address conflicts with inlining: |
| 148 | + * 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 | 151 | #ifdef CONFIG_KASAN |
198 | 152 | #define __no_sanitize_address_or_inline \ |
199 | 153 | __no_sanitize_address __maybe_unused notrace |
200 | 154 | #else |
201 | 155 | #define __no_sanitize_address_or_inline inline |
202 | 156 | #endif |
203 | | -#endif |
204 | 157 |
|
205 | 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 | 159 | #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 |
212 | 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 | 163 | * Turn individual warnings and errors on and off locally, depending |
225 | 164 | * on version. |
|
0 commit comments