~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/compiler_types.h

Version: ~ [ linux-4.20-rc2 ] ~ [ linux-4.19.1 ] ~ [ linux-4.18.18 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.80 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.136 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.163 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.125 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.60 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.31.14 ] ~ [ linux-2.6.30.10 ] ~ [ linux-2.6.29.6 ] ~ [ linux-2.6.28.10 ] ~ [ linux-2.6.27.62 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __LINUX_COMPILER_TYPES_H
  3 #define __LINUX_COMPILER_TYPES_H
  4 
  5 #ifndef __ASSEMBLY__
  6 
  7 #ifdef __CHECKER__
  8 # define __user         __attribute__((noderef, address_space(1)))
  9 # define __kernel       __attribute__((address_space(0)))
 10 # define __safe         __attribute__((safe))
 11 # define __force        __attribute__((force))
 12 # define __nocast       __attribute__((nocast))
 13 # define __iomem        __attribute__((noderef, address_space(2)))
 14 # define __must_hold(x) __attribute__((context(x,1,1)))
 15 # define __acquires(x)  __attribute__((context(x,0,1)))
 16 # define __releases(x)  __attribute__((context(x,1,0)))
 17 # define __acquire(x)   __context__(x,1)
 18 # define __release(x)   __context__(x,-1)
 19 # define __cond_lock(x,c)       ((c) ? ({ __acquire(x); 1; }) : 0)
 20 # define __percpu       __attribute__((noderef, address_space(3)))
 21 # define __rcu          __attribute__((noderef, address_space(4)))
 22 # define __private      __attribute__((noderef))
 23 extern void __chk_user_ptr(const volatile void __user *);
 24 extern void __chk_io_ptr(const volatile void __iomem *);
 25 # define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member))
 26 #else /* __CHECKER__ */
 27 # ifdef STRUCTLEAK_PLUGIN
 28 #  define __user __attribute__((user))
 29 # else
 30 #  define __user
 31 # endif
 32 # define __kernel
 33 # define __safe
 34 # define __force
 35 # define __nocast
 36 # define __iomem
 37 # define __chk_user_ptr(x) (void)0
 38 # define __chk_io_ptr(x) (void)0
 39 # define __builtin_warning(x, y...) (1)
 40 # define __must_hold(x)
 41 # define __acquires(x)
 42 # define __releases(x)
 43 # define __acquire(x) (void)0
 44 # define __release(x) (void)0
 45 # define __cond_lock(x,c) (c)
 46 # define __percpu
 47 # define __rcu
 48 # define __private
 49 # define ACCESS_PRIVATE(p, member) ((p)->member)
 50 #endif /* __CHECKER__ */
 51 
 52 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
 53 #define ___PASTE(a,b) a##b
 54 #define __PASTE(a,b) ___PASTE(a,b)
 55 
 56 #ifdef __KERNEL__
 57 
 58 /* Attributes */
 59 #include <linux/compiler_attributes.h>
 60 
 61 /* Compiler specific macros. */
 62 #ifdef __clang__
 63 #include <linux/compiler-clang.h>
 64 #elif defined(__INTEL_COMPILER)
 65 #include <linux/compiler-intel.h>
 66 #elif defined(__GNUC__)
 67 /* The above compilers also define __GNUC__, so order is important here. */
 68 #include <linux/compiler-gcc.h>
 69 #else
 70 #error "Unknown compiler"
 71 #endif
 72 
 73 /*
 74  * Some architectures need to provide custom definitions of macros provided
 75  * by linux/compiler-*.h, and can do so using asm/compiler.h. We include that
 76  * conditionally rather than using an asm-generic wrapper in order to avoid
 77  * build failures if any C compilation, which will include this file via an
 78  * -include argument in c_flags, occurs prior to the asm-generic wrappers being
 79  * generated.
 80  */
 81 #ifdef CONFIG_HAVE_ARCH_COMPILER_H
 82 #include <asm/compiler.h>
 83 #endif
 84 
 85 struct ftrace_branch_data {
 86         const char *func;
 87         const char *file;
 88         unsigned line;
 89         union {
 90                 struct {
 91                         unsigned long correct;
 92                         unsigned long incorrect;
 93                 };
 94                 struct {
 95                         unsigned long miss;
 96                         unsigned long hit;
 97                 };
 98                 unsigned long miss_hit[2];
 99         };
100 };
101 
102 struct ftrace_likely_data {
103         struct ftrace_branch_data       data;
104         unsigned long                   constant;
105 };
106 
107 #endif /* __KERNEL__ */
108 
109 #endif /* __ASSEMBLY__ */
110 
111 /*
112  * The below symbols may be defined for one or more, but not ALL, of the above
113  * compilers. We don't consider that to be an error, so set them to nothing.
114  * For example, some of them are for compiler specific plugins.
115  */
116 #ifndef __latent_entropy
117 # define __latent_entropy
118 #endif
119 
120 #ifndef __randomize_layout
121 # define __randomize_layout __designated_init
122 #endif
123 
124 #ifndef __no_randomize_layout
125 # define __no_randomize_layout
126 #endif
127 
128 #ifndef randomized_struct_fields_start
129 # define randomized_struct_fields_start
130 # define randomized_struct_fields_end
131 #endif
132 
133 #ifndef asm_volatile_goto
134 #define asm_volatile_goto(x...) asm goto(x)
135 #endif
136 
137 /* Are two types/vars the same type (ignoring qualifiers)? */
138 #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
139 
140 /* Is this type a native word size -- useful for atomic operations */
141 #define __native_word(t) \
142         (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
143          sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
144 
145 /* Helpers for emitting diagnostics in pragmas. */
146 #ifndef __diag
147 #define __diag(string)
148 #endif
149 
150 #ifndef __diag_GCC
151 #define __diag_GCC(version, severity, string)
152 #endif
153 
154 #define __diag_push()   __diag(push)
155 #define __diag_pop()    __diag(pop)
156 
157 #define __diag_ignore(compiler, version, option, comment) \
158         __diag_ ## compiler(version, ignore, option)
159 #define __diag_warn(compiler, version, option, comment) \
160         __diag_ ## compiler(version, warn, option)
161 #define __diag_error(compiler, version, option, comment) \
162         __diag_ ## compiler(version, error, option)
163 
164 #ifdef CONFIG_ENABLE_MUST_CHECK
165 #define __must_check            __attribute__((__warn_unused_result__))
166 #else
167 #define __must_check
168 #endif
169 
170 #if defined(CC_USING_HOTPATCH)
171 #define notrace                 __attribute__((hotpatch(0, 0)))
172 #else
173 #define notrace                 __attribute__((__no_instrument_function__))
174 #endif
175 
176 /*
177  * it doesn't make sense on ARM (currently the only user of __naked)
178  * to trace naked functions because then mcount is called without
179  * stack and frame pointer being set up and there is no chance to
180  * restore the lr register to the value before mcount was called.
181  */
182 #define __naked                 __attribute__((__naked__)) notrace
183 
184 #define __compiler_offsetof(a, b)       __builtin_offsetof(a, b)
185 
186 /*
187  * Force always-inline if the user requests it so via the .config.
188  * GCC does not warn about unused static inline functions for
189  * -Wunused-function.  This turns out to avoid the need for complex #ifdef
190  * directives.  Suppress the warning in clang as well by using "unused"
191  * function attribute, which is redundant but not harmful for gcc.
192  * Prefer gnu_inline, so that extern inline functions do not emit an
193  * externally visible function. This makes extern inline behave as per gnu89
194  * semantics rather than c99. This prevents multiple symbol definition errors
195  * of extern inline functions at link time.
196  * A lot of inline functions can cause havoc with function tracing.
197  * Do not use __always_inline here, since currently it expands to inline again
198  * (which would break users of __always_inline).
199  */
200 #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
201         !defined(CONFIG_OPTIMIZE_INLINING)
202 #define inline inline __attribute__((__always_inline__)) __gnu_inline \
203         __maybe_unused notrace
204 #else
205 #define inline inline                                    __gnu_inline \
206         __maybe_unused notrace
207 #endif
208 
209 #define __inline__ inline
210 #define __inline   inline
211 
212 /*
213  * Rather then using noinline to prevent stack consumption, use
214  * noinline_for_stack instead.  For documentation reasons.
215  */
216 #define noinline_for_stack noinline
217 
218 #endif /* __LINUX_COMPILER_TYPES_H */
219 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp