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