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