]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/compiler_types.h
1 #ifndef __LINUX_COMPILER_TYPES_H
2 #define __LINUX_COMPILER_TYPES_H
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))
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)
48 # define ACCESS_PRIVATE(p, member) ((p)->member)
49 #endif /* __CHECKER__ */
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)
58 #include <linux/compiler-gcc.h>
61 #if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__)
62 #define notrace __attribute__((hotpatch(0,0)))
64 #define notrace __attribute__((no_instrument_function))
67 /* Intel compiler defines __GNUC__. So we will overwrite implementations
68 * coming from above header files here
70 #ifdef __INTEL_COMPILER
71 # include <linux/compiler-intel.h>
74 /* Clang compiler defines __GNUC__. So we will overwrite implementations
75 * coming from above header files here
78 #include <linux/compiler-clang.h>
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
89 #ifdef CONFIG_HAVE_ARCH_COMPILER_H
90 #include <asm/compiler.h>
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
99 struct ftrace_branch_data
{
105 unsigned long correct
;
106 unsigned long incorrect
;
112 unsigned long miss_hit
[2];
116 struct ftrace_likely_data
{
117 struct ftrace_branch_data data
;
118 unsigned long constant
;
121 #endif /* __KERNEL__ */
123 #endif /* __ASSEMBLY__ */
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.
130 * int __deprecated foo(void)
133 # define __deprecated /* unimplemented */
137 #define __deprecated_for_modules __deprecated
139 #define __deprecated_for_modules
146 #ifndef CONFIG_ENABLE_MUST_CHECK
150 #ifndef CONFIG_ENABLE_WARN_DEPRECATED
152 #undef __deprecated_for_modules
154 #define __deprecated_for_modules
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.
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.
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.
173 * In prior versions of gcc, such functions and data would be emitted, but
174 * would be warned about except with attribute((unused)).
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.
180 # define __used /* unimplemented */
183 #ifndef __maybe_unused
184 # define __maybe_unused /* unimplemented */
187 #ifndef __always_unused
188 # define __always_unused /* unimplemented */
196 * Rather then using noinline to prevent stack consumption, use
197 * noinline_for_stack instead. For documentation reasons.
199 #define noinline_for_stack noinline
201 #ifndef __always_inline
202 #define __always_inline inline
205 #endif /* __KERNEL__ */
208 * From the GCC manual:
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.
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
221 #ifndef __attribute_const__
222 # define __attribute_const__ /* unimplemented */
225 #ifndef __designated_init
226 # define __designated_init
229 #ifndef __latent_entropy
230 # define __latent_entropy
234 # define __copy(symbol)
237 #ifndef __randomize_layout
238 # define __randomize_layout __designated_init
241 #ifndef __no_randomize_layout
242 # define __no_randomize_layout
245 #ifndef randomized_struct_fields_start
246 # define randomized_struct_fields_start
247 # define randomized_struct_fields_end
251 * Tell gcc if a function is cold. The compiler will assume any path
252 * directly leading to the call is unlikely.
259 /* Simple shorthand for a section definition */
261 # define __section(S) __attribute__ ((__section__(#S)))
268 #ifndef __nostackprotector
269 # define __nostackprotector
273 * Assume alignment of return value.
275 #ifndef __assume_aligned
276 #define __assume_aligned(a, ...)
280 #ifndef asm_volatile_goto
281 #define asm_volatile_goto(x...) asm goto(x)
284 /* Are two types/vars the same type (ignoring qualifiers)? */
286 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
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))
294 #endif /* __LINUX_COMPILER_TYPES_H */