compiler-gcc4.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ <= 1
  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 __GNUC_MINOR__ >= 3
  14. /* Mark functions as cold. gcc will assume any path leading to a call
  15. to them will be unlikely. This means a lot of manual unlikely()s
  16. are unnecessary now for any paths leading to the usual suspects
  17. like BUG(), printk(), panic() etc. [but let's keep them for now for
  18. older compilers]
  19. Early snapshots of gcc 4.3 don't support this and we can't detect this
  20. in the preprocessor, but we can live with this because they're unreleased.
  21. Maketime probing would be overkill here.
  22. gcc also has a __attribute__((__hot__)) to move hot functions into
  23. a special section, but I don't see any sense in this right now in
  24. the kernel context */
  25. #define __cold __attribute__((__cold__))
  26. #if __GNUC_MINOR__ >= 5
  27. /*
  28. * Mark a position in code as unreachable. This can be used to
  29. * suppress control flow warnings after asm blocks that transfer
  30. * control elsewhere.
  31. *
  32. * Early snapshots of gcc 4.5 don't support this and we can't detect
  33. * this in the preprocessor, but we can live with this because they're
  34. * unreleased. Really, we need to have autoconf for the kernel.
  35. */
  36. #define unreachable() __builtin_unreachable()
  37. /* Mark a function definition as prohibited from being cloned. */
  38. #define __noclone __attribute__((__noclone__))
  39. #endif
  40. #endif
  41. #if __GNUC_MINOR__ > 0
  42. #define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
  43. #endif
  44. #if __GNUC_MINOR__ >= 4
  45. #define __compiletime_warning(message) __attribute__((warning(message)))
  46. #define __compiletime_error(message) __attribute__((error(message)))
  47. #endif