]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/compiler_types.h
ACPI: fix acpi_find_child_device() invocation in acpi_preset_companion()
[mirror_ubuntu-bionic-kernel.git] / include / linux / compiler_types.h
1 #ifndef __LINUX_COMPILER_TYPES_H
2 #define __LINUX_COMPILER_TYPES_H
3
4 #ifndef __ASSEMBLY__
5
6 #ifdef __CHECKER__
7 # define __user __attribute__((noderef, address_space(1)))
8 # define __kernel __attribute__((address_space(0)))
9 # define __safe __attribute__((safe))
10 # define __force __attribute__((force))
11 # define __nocast __attribute__((nocast))
12 # define __iomem __attribute__((noderef, address_space(2)))
13 # define __must_hold(x) __attribute__((context(x,1,1)))
14 # define __acquires(x) __attribute__((context(x,0,1)))
15 # define __releases(x) __attribute__((context(x,1,0)))
16 # define __acquire(x) __context__(x,1)
17 # define __release(x) __context__(x,-1)
18 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
19 # define __percpu __attribute__((noderef, address_space(3)))
20 # define __rcu __attribute__((noderef, address_space(4)))
21 # define __private __attribute__((noderef))
22 extern void __chk_user_ptr(const volatile void __user *);
23 extern void __chk_io_ptr(const volatile void __iomem *);
24 # define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member))
25 #else /* __CHECKER__ */
26 # ifdef STRUCTLEAK_PLUGIN
27 # define __user __attribute__((user))
28 # else
29 # define __user
30 # endif
31 # define __kernel
32 # define __safe
33 # define __force
34 # define __nocast
35 # define __iomem
36 # define __chk_user_ptr(x) (void)0
37 # define __chk_io_ptr(x) (void)0
38 # define __builtin_warning(x, y...) (1)
39 # define __must_hold(x)
40 # define __acquires(x)
41 # define __releases(x)
42 # define __acquire(x) (void)0
43 # define __release(x) (void)0
44 # define __cond_lock(x,c) (c)
45 # define __percpu
46 # define __rcu
47 # define __private
48 # define ACCESS_PRIVATE(p, member) ((p)->member)
49 #endif /* __CHECKER__ */
50
51 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
52 #define ___PASTE(a,b) a##b
53 #define __PASTE(a,b) ___PASTE(a,b)
54
55 #ifdef __KERNEL__
56
57 #ifdef __GNUC__
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__
78 #include <linux/compiler-clang.h>
79 #endif
80
81 /*
82 * Some architectures need to provide custom definitions of macros provided
83 * by linux/compiler-*.h, and can do so using asm/compiler.h. We include that
84 * conditionally rather than using an asm-generic wrapper in order to avoid
85 * build failures if any C compilation, which will include this file via an
86 * -include argument in c_flags, occurs prior to the asm-generic wrappers being
87 * generated.
88 */
89 #ifdef CONFIG_HAVE_ARCH_COMPILER_H
90 #include <asm/compiler.h>
91 #endif
92
93 /*
94 * Generic compiler-dependent macros required for kernel
95 * build go below this comment. Actual compiler/compiler version
96 * specific implementations come from the above header files
97 */
98
99 struct ftrace_branch_data {
100 const char *func;
101 const char *file;
102 unsigned line;
103 union {
104 struct {
105 unsigned long correct;
106 unsigned long incorrect;
107 };
108 struct {
109 unsigned long miss;
110 unsigned long hit;
111 };
112 unsigned long miss_hit[2];
113 };
114 };
115
116 struct ftrace_likely_data {
117 struct ftrace_branch_data data;
118 unsigned long constant;
119 };
120
121 #endif /* __KERNEL__ */
122
123 #endif /* __ASSEMBLY__ */
124
125 #ifdef __KERNEL__
126 /*
127 * Allow us to mark functions as 'deprecated' and have gcc emit a nice
128 * warning for each use, in hopes of speeding the functions removal.
129 * Usage is:
130 * int __deprecated foo(void)
131 */
132 #ifndef __deprecated
133 # define __deprecated /* unimplemented */
134 #endif
135
136 #ifdef MODULE
137 #define __deprecated_for_modules __deprecated
138 #else
139 #define __deprecated_for_modules
140 #endif
141
142 #ifndef __must_check
143 #define __must_check
144 #endif
145
146 #ifndef CONFIG_ENABLE_MUST_CHECK
147 #undef __must_check
148 #define __must_check
149 #endif
150 #ifndef CONFIG_ENABLE_WARN_DEPRECATED
151 #undef __deprecated
152 #undef __deprecated_for_modules
153 #define __deprecated
154 #define __deprecated_for_modules
155 #endif
156
157 #ifndef __malloc
158 #define __malloc
159 #endif
160
161 /*
162 * Allow us to avoid 'defined but not used' warnings on functions and data,
163 * as well as force them to be emitted to the assembly file.
164 *
165 * As of gcc 3.4, static functions that are not marked with attribute((used))
166 * may be elided from the assembly file. As of gcc 3.4, static data not so
167 * marked will not be elided, but this may change in a future gcc version.
168 *
169 * NOTE: Because distributions shipped with a backported unit-at-a-time
170 * compiler in gcc 3.3, we must define __used to be __attribute__((used))
171 * for gcc >=3.3 instead of 3.4.
172 *
173 * In prior versions of gcc, such functions and data would be emitted, but
174 * would be warned about except with attribute((unused)).
175 *
176 * Mark functions that are referenced only in inline assembly as __used so
177 * the code is emitted even though it appears to be unreferenced.
178 */
179 #ifndef __used
180 # define __used /* unimplemented */
181 #endif
182
183 #ifndef __maybe_unused
184 # define __maybe_unused /* unimplemented */
185 #endif
186
187 #ifndef __always_unused
188 # define __always_unused /* unimplemented */
189 #endif
190
191 #ifndef noinline
192 #define noinline
193 #endif
194
195 /*
196 * Rather then using noinline to prevent stack consumption, use
197 * noinline_for_stack instead. For documentation reasons.
198 */
199 #define noinline_for_stack noinline
200
201 #ifndef __always_inline
202 #define __always_inline inline
203 #endif
204
205 #endif /* __KERNEL__ */
206
207 /*
208 * From the GCC manual:
209 *
210 * Many functions do not examine any values except their arguments,
211 * and have no effects except the return value. Basically this is
212 * just slightly more strict class than the `pure' attribute above,
213 * since function is not allowed to read global memory.
214 *
215 * Note that a function that has pointer arguments and examines the
216 * data pointed to must _not_ be declared `const'. Likewise, a
217 * function that calls a non-`const' function usually must not be
218 * `const'. It does not make sense for a `const' function to return
219 * `void'.
220 */
221 #ifndef __attribute_const__
222 # define __attribute_const__ /* unimplemented */
223 #endif
224
225 #ifndef __designated_init
226 # define __designated_init
227 #endif
228
229 #ifndef __latent_entropy
230 # define __latent_entropy
231 #endif
232
233 #ifndef __copy
234 # define __copy(symbol)
235 #endif
236
237 #ifndef __randomize_layout
238 # define __randomize_layout __designated_init
239 #endif
240
241 #ifndef __no_randomize_layout
242 # define __no_randomize_layout
243 #endif
244
245 #ifndef randomized_struct_fields_start
246 # define randomized_struct_fields_start
247 # define randomized_struct_fields_end
248 #endif
249
250 /*
251 * Tell gcc if a function is cold. The compiler will assume any path
252 * directly leading to the call is unlikely.
253 */
254
255 #ifndef __cold
256 #define __cold
257 #endif
258
259 /* Simple shorthand for a section definition */
260 #ifndef __section
261 # define __section(S) __attribute__ ((__section__(#S)))
262 #endif
263
264 #ifndef __visible
265 #define __visible
266 #endif
267
268 #ifndef __nostackprotector
269 # define __nostackprotector
270 #endif
271
272 /*
273 * Assume alignment of return value.
274 */
275 #ifndef __assume_aligned
276 #define __assume_aligned(a, ...)
277 #endif
278
279
280 #ifndef asm_volatile_goto
281 #define asm_volatile_goto(x...) asm goto(x)
282 #endif
283
284 /* Are two types/vars the same type (ignoring qualifiers)? */
285 #ifndef __same_type
286 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
287 #endif
288
289 /* Is this type a native word size -- useful for atomic operations */
290 #ifndef __native_word
291 # define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
292 #endif
293
294 #endif /* __LINUX_COMPILER_TYPES_H */