compiler.h 4.2 KB

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