compiler-gcc4.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __LINUX_COMPILER_H
  2. #error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
  3. #endif
  4. /* GCC 4.1.[01] miscompiles __weak */
  5. #ifdef __KERNEL__
  6. # if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
  7. # error Your version of gcc miscompiles the __weak directive
  8. # endif
  9. #endif
  10. #define __used __attribute__((__used__))
  11. #define __must_check __attribute__((warn_unused_result))
  12. #define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
  13. #if GCC_VERSION >= 40100
  14. # define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
  15. #endif
  16. #if GCC_VERSION >= 40300
  17. /* Mark functions as cold. gcc will assume any path leading to a call
  18. to them will be unlikely. This means a lot of manual unlikely()s
  19. are unnecessary now for any paths leading to the usual suspects
  20. like BUG(), printk(), panic() etc. [but let's keep them for now for
  21. older compilers]
  22. Early snapshots of gcc 4.3 don't support this and we can't detect this
  23. in the preprocessor, but we can live with this because they're unreleased.
  24. Maketime probing would be overkill here.
  25. gcc also has a __attribute__((__hot__)) to move hot functions into
  26. a special section, but I don't see any sense in this right now in
  27. the kernel context */
  28. #define __cold __attribute__((__cold__))
  29. #define __linktime_error(message) __attribute__((__error__(message)))
  30. #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
  31. #ifndef __CHECKER__
  32. # define __compiletime_warning(message) __attribute__((warning(message)))
  33. # define __compiletime_error(message) __attribute__((error(message)))
  34. #endif /* __CHECKER__ */
  35. #endif /* GCC_VERSION >= 40300 */
  36. #if GCC_VERSION >= 40500
  37. /*
  38. * Mark a position in code as unreachable. This can be used to
  39. * suppress control flow warnings after asm blocks that transfer
  40. * control elsewhere.
  41. *
  42. * Early snapshots of gcc 4.5 don't support this and we can't detect
  43. * this in the preprocessor, but we can live with this because they're
  44. * unreleased. Really, we need to have autoconf for the kernel.
  45. */
  46. #define unreachable() __builtin_unreachable()
  47. /* Mark a function definition as prohibited from being cloned. */
  48. #define __noclone __attribute__((__noclone__))
  49. #endif /* GCC_VERSION >= 40500 */
  50. #if GCC_VERSION >= 40600
  51. /*
  52. * Tell the optimizer that something else uses this function or variable.
  53. */
  54. #define __visible __attribute__((externally_visible))
  55. #endif
  56. #ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
  57. #if GCC_VERSION >= 40400
  58. #define __HAVE_BUILTIN_BSWAP32__
  59. #define __HAVE_BUILTIN_BSWAP64__
  60. #endif
  61. #if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
  62. #define __HAVE_BUILTIN_BSWAP16__
  63. #endif
  64. #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */