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