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