]> git.ipfire.org Git - people/ms/linux.git/blob - include/linux/compiler-gcc5.h
Importing "grsecurity-3.1-3.19.2-201503201903.patch"
[people/ms/linux.git] / include / linux / compiler-gcc5.h
1 #ifndef __LINUX_COMPILER_H
2 #error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
3 #endif
4
5 #define __used __attribute__((__used__))
6 #define __must_check __attribute__((warn_unused_result))
7 #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
8
9 /* Mark functions as cold. gcc will assume any path leading to a call
10 to them will be unlikely. This means a lot of manual unlikely()s
11 are unnecessary now for any paths leading to the usual suspects
12 like BUG(), printk(), panic() etc. [but let's keep them for now for
13 older compilers]
14
15 Early snapshots of gcc 4.3 don't support this and we can't detect this
16 in the preprocessor, but we can live with this because they're unreleased.
17 Maketime probing would be overkill here.
18
19 gcc also has a __attribute__((__hot__)) to move hot functions into
20 a special section, but I don't see any sense in this right now in
21 the kernel context */
22 #define __cold __attribute__((__cold__))
23
24 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
25
26 #ifndef __CHECKER__
27 # define __compiletime_warning(message) __attribute__((warning(message)))
28 # define __compiletime_error(message) __attribute__((error(message)))
29 #endif /* __CHECKER__ */
30
31 #define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
32 #define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
33 #define __bos0(ptr) __bos((ptr), 0)
34 #define __bos1(ptr) __bos((ptr), 1)
35
36 #ifdef CONSTIFY_PLUGIN
37 #error not yet
38 #define __no_const __attribute__((no_const))
39 #define __do_const __attribute__((do_const))
40 #endif
41
42 #ifdef SIZE_OVERFLOW_PLUGIN
43 #error not yet
44 #define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
45 #define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
46 #endif
47
48 #ifdef LATENT_ENTROPY_PLUGIN
49 #error not yet
50 #define __latent_entropy __attribute__((latent_entropy))
51 #endif
52
53 /*
54 * Mark a position in code as unreachable. This can be used to
55 * suppress control flow warnings after asm blocks that transfer
56 * control elsewhere.
57 *
58 * Early snapshots of gcc 4.5 don't support this and we can't detect
59 * this in the preprocessor, but we can live with this because they're
60 * unreleased. Really, we need to have autoconf for the kernel.
61 */
62 #define unreachable() __builtin_unreachable()
63
64 /* Mark a function definition as prohibited from being cloned. */
65 #define __noclone __attribute__((__noclone__))
66
67 /*
68 * Tell the optimizer that something else uses this function or variable.
69 */
70 #define __visible __attribute__((externally_visible))
71
72 /*
73 * GCC 'asm goto' miscompiles certain code sequences:
74 *
75 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
76 *
77 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
78 *
79 * (asm goto is automatically volatile - the naming reflects this.)
80 */
81 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
82
83 #ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
84 #define __HAVE_BUILTIN_BSWAP32__
85 #define __HAVE_BUILTIN_BSWAP64__
86 #define __HAVE_BUILTIN_BSWAP16__
87 #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */