compiler.h 4.3 KB

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