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