]> Git Repo - linux.git/blob - include/linux/compiler_types.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide
[linux.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  * Generic compiler-dependent macros required for kernel
83  * build go below this comment. Actual compiler/compiler version
84  * specific implementations come from the above header files
85  */
86
87 struct ftrace_branch_data {
88         const char *func;
89         const char *file;
90         unsigned line;
91         union {
92                 struct {
93                         unsigned long correct;
94                         unsigned long incorrect;
95                 };
96                 struct {
97                         unsigned long miss;
98                         unsigned long hit;
99                 };
100                 unsigned long miss_hit[2];
101         };
102 };
103
104 struct ftrace_likely_data {
105         struct ftrace_branch_data       data;
106         unsigned long                   constant;
107 };
108
109 #endif /* __KERNEL__ */
110
111 #endif /* __ASSEMBLY__ */
112
113 #ifdef __KERNEL__
114
115 /* Don't. Just don't. */
116 #define __deprecated
117 #define __deprecated_for_modules
118
119 #ifndef __must_check
120 #define __must_check
121 #endif
122
123 #ifndef CONFIG_ENABLE_MUST_CHECK
124 #undef __must_check
125 #define __must_check
126 #endif
127
128 #ifndef __malloc
129 #define __malloc
130 #endif
131
132 /*
133  * Allow us to avoid 'defined but not used' warnings on functions and data,
134  * as well as force them to be emitted to the assembly file.
135  *
136  * As of gcc 3.4, static functions that are not marked with attribute((used))
137  * may be elided from the assembly file.  As of gcc 3.4, static data not so
138  * marked will not be elided, but this may change in a future gcc version.
139  *
140  * NOTE: Because distributions shipped with a backported unit-at-a-time
141  * compiler in gcc 3.3, we must define __used to be __attribute__((used))
142  * for gcc >=3.3 instead of 3.4.
143  *
144  * In prior versions of gcc, such functions and data would be emitted, but
145  * would be warned about except with attribute((unused)).
146  *
147  * Mark functions that are referenced only in inline assembly as __used so
148  * the code is emitted even though it appears to be unreferenced.
149  */
150 #ifndef __used
151 # define __used                 /* unimplemented */
152 #endif
153
154 #ifndef __maybe_unused
155 # define __maybe_unused         /* unimplemented */
156 #endif
157
158 #ifndef __always_unused
159 # define __always_unused        /* unimplemented */
160 #endif
161
162 #ifndef noinline
163 #define noinline
164 #endif
165
166 /*
167  * Rather then using noinline to prevent stack consumption, use
168  * noinline_for_stack instead.  For documentation reasons.
169  */
170 #define noinline_for_stack noinline
171
172 #ifndef __always_inline
173 #define __always_inline inline
174 #endif
175
176 #endif /* __KERNEL__ */
177
178 /*
179  * From the GCC manual:
180  *
181  * Many functions do not examine any values except their arguments,
182  * and have no effects except the return value.  Basically this is
183  * just slightly more strict class than the `pure' attribute above,
184  * since function is not allowed to read global memory.
185  *
186  * Note that a function that has pointer arguments and examines the
187  * data pointed to must _not_ be declared `const'.  Likewise, a
188  * function that calls a non-`const' function usually must not be
189  * `const'.  It does not make sense for a `const' function to return
190  * `void'.
191  */
192 #ifndef __attribute_const__
193 # define __attribute_const__    /* unimplemented */
194 #endif
195
196 #ifndef __designated_init
197 # define __designated_init
198 #endif
199
200 #ifndef __latent_entropy
201 # define __latent_entropy
202 #endif
203
204 #ifndef __randomize_layout
205 # define __randomize_layout __designated_init
206 #endif
207
208 #ifndef __no_randomize_layout
209 # define __no_randomize_layout
210 #endif
211
212 #ifndef randomized_struct_fields_start
213 # define randomized_struct_fields_start
214 # define randomized_struct_fields_end
215 #endif
216
217 /*
218  * Tell gcc if a function is cold. The compiler will assume any path
219  * directly leading to the call is unlikely.
220  */
221
222 #ifndef __cold
223 #define __cold
224 #endif
225
226 /* Simple shorthand for a section definition */
227 #ifndef __section
228 # define __section(S) __attribute__ ((__section__(#S)))
229 #endif
230
231 #ifndef __visible
232 #define __visible
233 #endif
234
235 #ifndef __nostackprotector
236 # define __nostackprotector
237 #endif
238
239 /*
240  * Assume alignment of return value.
241  */
242 #ifndef __assume_aligned
243 #define __assume_aligned(a, ...)
244 #endif
245
246
247 /* Are two types/vars the same type (ignoring qualifiers)? */
248 #ifndef __same_type
249 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
250 #endif
251
252 /* Is this type a native word size -- useful for atomic operations */
253 #ifndef __native_word
254 # define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
255 #endif
256
257 #ifndef __diag
258 #define __diag(string)
259 #endif
260
261 #ifndef __diag_GCC
262 #define __diag_GCC(version, severity, string)
263 #endif
264
265 #define __diag_push()   __diag(push)
266 #define __diag_pop()    __diag(pop)
267
268 #define __diag_ignore(compiler, version, option, comment) \
269         __diag_ ## compiler(version, ignore, option)
270 #define __diag_warn(compiler, version, option, comment) \
271         __diag_ ## compiler(version, warn, option)
272 #define __diag_error(compiler, version, option, comment) \
273         __diag_ ## compiler(version, error, option)
274
275 #endif /* __LINUX_COMPILER_TYPES_H */
This page took 0.047521 seconds and 4 git commands to generate.