ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / compiler.h
1 #ifndef __LINUX_COMPILER_H
2 #define __LINUX_COMPILER_H
3
4 #ifdef __CHECKER__
5 # define __user         __attribute__((noderef, address_space(1)))
6 # define __kernel       /* default address space */
7 # define __safe         __attribute__((safe))
8 #else
9 # define __user
10 # define __kernel
11 # define __safe
12 #endif
13
14 #ifdef __KERNEL__
15
16 #ifndef __ASSEMBLY__
17 #if __GNUC__ > 3
18 # include <linux/compiler-gcc+.h>       /* catch-all for GCC 4, 5, etc. */
19 #elif __GNUC__ == 3
20 # include <linux/compiler-gcc3.h>
21 #elif __GNUC__ == 2
22 # include <linux/compiler-gcc2.h>
23 #else
24 # error Sorry, your compiler is too old/not recognized.
25 #endif
26 #endif
27
28 /* Intel compiler defines __GNUC__. So we will overwrite implementations
29  * coming from above header files here
30  */
31 #ifdef __INTEL_COMPILER
32 # include <linux/compiler-intel.h>
33 #endif
34
35 /*
36  * Generic compiler-dependent macros required for kernel
37  * build go below this comment. Actual compiler/compiler version
38  * specific implementations come from the above header files
39  */
40
41 #define likely(x)       __builtin_expect(!!(x), 1)
42 #define unlikely(x)     __builtin_expect(!!(x), 0)
43
44 /* Optimization barrier */
45 #ifndef barrier
46 # define barrier() __memory_barrier()
47 #endif
48
49 #ifndef RELOC_HIDE
50 # define RELOC_HIDE(ptr, off)                                   \
51   ({ unsigned long __ptr;                                       \
52      __ptr = (unsigned long) (ptr);                             \
53     (typeof(ptr)) (__ptr + (off)); })
54 #endif
55
56 #endif /* __KERNEL__ */
57
58 /*
59  * Allow us to mark functions as 'deprecated' and have gcc emit a nice
60  * warning for each use, in hopes of speeding the functions removal.
61  * Usage is:
62  *              int __deprecated foo(void)
63  */
64 #ifndef __deprecated
65 # define __deprecated           /* unimplemented */
66 #endif
67
68 /*
69  * Allow us to avoid 'defined but not used' warnings on functions and data,
70  * as well as force them to be emitted to the assembly file.
71  *
72  * As of gcc 3.3, static functions that are not marked with attribute((used))
73  * may be elided from the assembly file.  As of gcc 3.3, static data not so
74  * marked will not be elided, but this may change in a future gcc version.
75  *
76  * In prior versions of gcc, such functions and data would be emitted, but
77  * would be warned about except with attribute((unused)).
78  */
79 #ifndef __attribute_used__
80 # define __attribute_used__     /* unimplemented */
81 #endif
82
83 /*
84  * From the GCC manual:
85  *
86  * Many functions have no effects except the return value and their
87  * return value depends only on the parameters and/or global
88  * variables.  Such a function can be subject to common subexpression
89  * elimination and loop optimization just as an arithmetic operator
90  * would be.
91  * [...]
92  */
93 #ifndef __attribute_pure__
94 # define __attribute_pure__     /* unimplemented */
95 #endif
96
97 /*
98  * From the GCC manual:
99  *
100  * Many functions do not examine any values except their arguments,
101  * and have no effects except the return value.  Basically this is
102  * just slightly more strict class than the `pure' attribute above,
103  * since function is not allowed to read global memory.
104  *
105  * Note that a function that has pointer arguments and examines the
106  * data pointed to must _not_ be declared `const'.  Likewise, a
107  * function that calls a non-`const' function usually must not be
108  * `const'.  It does not make sense for a `const' function to return
109  * `void'.
110  */
111 #ifndef __attribute_const__
112 # define __attribute_const__    /* unimplemented */
113 #endif
114
115 #ifndef noinline
116 #define noinline
117 #endif
118
119 #endif /* __LINUX_COMPILER_H */