diff options
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r-- | include/linux/compiler.h | 73 |
1 files changed, 44 insertions, 29 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 2e0b6322588b..18c80cfa4fc4 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -99,22 +99,13 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, | |||
99 | * unique, to convince GCC not to merge duplicate inline asm statements. | 99 | * unique, to convince GCC not to merge duplicate inline asm statements. |
100 | */ | 100 | */ |
101 | #define annotate_reachable() ({ \ | 101 | #define annotate_reachable() ({ \ |
102 | asm volatile("%c0:\n\t" \ | 102 | asm volatile("ANNOTATE_REACHABLE counter=%c0" \ |
103 | ".pushsection .discard.reachable\n\t" \ | 103 | : : "i" (__COUNTER__)); \ |
104 | ".long %c0b - .\n\t" \ | ||
105 | ".popsection\n\t" : : "i" (__COUNTER__)); \ | ||
106 | }) | 104 | }) |
107 | #define annotate_unreachable() ({ \ | 105 | #define annotate_unreachable() ({ \ |
108 | asm volatile("%c0:\n\t" \ | 106 | asm volatile("ANNOTATE_UNREACHABLE counter=%c0" \ |
109 | ".pushsection .discard.unreachable\n\t" \ | 107 | : : "i" (__COUNTER__)); \ |
110 | ".long %c0b - .\n\t" \ | ||
111 | ".popsection\n\t" : : "i" (__COUNTER__)); \ | ||
112 | }) | 108 | }) |
113 | #define ASM_UNREACHABLE \ | ||
114 | "999:\n\t" \ | ||
115 | ".pushsection .discard.unreachable\n\t" \ | ||
116 | ".long 999b - .\n\t" \ | ||
117 | ".popsection\n\t" | ||
118 | #else | 109 | #else |
119 | #define annotate_reachable() | 110 | #define annotate_reachable() |
120 | #define annotate_unreachable() | 111 | #define annotate_unreachable() |
@@ -302,6 +293,45 @@ static inline void *offset_to_ptr(const int *off) | |||
302 | return (void *)((unsigned long)off + *off); | 293 | return (void *)((unsigned long)off + *off); |
303 | } | 294 | } |
304 | 295 | ||
296 | #else /* __ASSEMBLY__ */ | ||
297 | |||
298 | #ifdef __KERNEL__ | ||
299 | #ifndef LINKER_SCRIPT | ||
300 | |||
301 | #ifdef CONFIG_STACK_VALIDATION | ||
302 | .macro ANNOTATE_UNREACHABLE counter:req | ||
303 | \counter: | ||
304 | .pushsection .discard.unreachable | ||
305 | .long \counter\()b -. | ||
306 | .popsection | ||
307 | .endm | ||
308 | |||
309 | .macro ANNOTATE_REACHABLE counter:req | ||
310 | \counter: | ||
311 | .pushsection .discard.reachable | ||
312 | .long \counter\()b -. | ||
313 | .popsection | ||
314 | .endm | ||
315 | |||
316 | .macro ASM_UNREACHABLE | ||
317 | 999: | ||
318 | .pushsection .discard.unreachable | ||
319 | .long 999b - . | ||
320 | .popsection | ||
321 | .endm | ||
322 | #else /* CONFIG_STACK_VALIDATION */ | ||
323 | .macro ANNOTATE_UNREACHABLE counter:req | ||
324 | .endm | ||
325 | |||
326 | .macro ANNOTATE_REACHABLE counter:req | ||
327 | .endm | ||
328 | |||
329 | .macro ASM_UNREACHABLE | ||
330 | .endm | ||
331 | #endif /* CONFIG_STACK_VALIDATION */ | ||
332 | |||
333 | #endif /* LINKER_SCRIPT */ | ||
334 | #endif /* __KERNEL__ */ | ||
305 | #endif /* __ASSEMBLY__ */ | 335 | #endif /* __ASSEMBLY__ */ |
306 | 336 | ||
307 | /* Compile time object size, -1 for unknown */ | 337 | /* Compile time object size, -1 for unknown */ |
@@ -313,29 +343,14 @@ static inline void *offset_to_ptr(const int *off) | |||
313 | #endif | 343 | #endif |
314 | #ifndef __compiletime_error | 344 | #ifndef __compiletime_error |
315 | # define __compiletime_error(message) | 345 | # define __compiletime_error(message) |
316 | /* | ||
317 | * Sparse complains of variable sized arrays due to the temporary variable in | ||
318 | * __compiletime_assert. Unfortunately we can't just expand it out to make | ||
319 | * sparse see a constant array size without breaking compiletime_assert on old | ||
320 | * versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether. | ||
321 | */ | ||
322 | # ifndef __CHECKER__ | ||
323 | # define __compiletime_error_fallback(condition) \ | ||
324 | do { ((void)sizeof(char[1 - 2 * condition])); } while (0) | ||
325 | # endif | ||
326 | #endif | ||
327 | #ifndef __compiletime_error_fallback | ||
328 | # define __compiletime_error_fallback(condition) do { } while (0) | ||
329 | #endif | 346 | #endif |
330 | 347 | ||
331 | #ifdef __OPTIMIZE__ | 348 | #ifdef __OPTIMIZE__ |
332 | # define __compiletime_assert(condition, msg, prefix, suffix) \ | 349 | # define __compiletime_assert(condition, msg, prefix, suffix) \ |
333 | do { \ | 350 | do { \ |
334 | int __cond = !(condition); \ | ||
335 | extern void prefix ## suffix(void) __compiletime_error(msg); \ | 351 | extern void prefix ## suffix(void) __compiletime_error(msg); \ |
336 | if (__cond) \ | 352 | if (!(condition)) \ |
337 | prefix ## suffix(); \ | 353 | prefix ## suffix(); \ |
338 | __compiletime_error_fallback(__cond); \ | ||
339 | } while (0) | 354 | } while (0) |
340 | #else | 355 | #else |
341 | # define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0) | 356 | # define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0) |