compiler-gcc5.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef __LINUX_COMPILER_H
  2. #error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
  3. #endif
  4. #define __used __attribute__((__used__))
  5. #define __must_check __attribute__((warn_unused_result))
  6. #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
  7. /* Mark functions as cold. gcc will assume any path leading to a call
  8. to them will be unlikely. This means a lot of manual unlikely()s
  9. are unnecessary now for any paths leading to the usual suspects
  10. like BUG(), printk(), panic() etc. [but let's keep them for now for
  11. older compilers]
  12. Early snapshots of gcc 4.3 don't support this and we can't detect this
  13. in the preprocessor, but we can live with this because they're unreleased.
  14. Maketime probing would be overkill here.
  15. gcc also has a __attribute__((__hot__)) to move hot functions into
  16. a special section, but I don't see any sense in this right now in
  17. the kernel context */
  18. #define __cold __attribute__((__cold__))
  19. #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
  20. #ifndef __CHECKER__
  21. # define __compiletime_warning(message) __attribute__((warning(message)))
  22. # define __compiletime_error(message) __attribute__((error(message)))
  23. #endif /* __CHECKER__ */
  24. /*
  25. * Mark a position in code as unreachable. This can be used to
  26. * suppress control flow warnings after asm blocks that transfer
  27. * control elsewhere.
  28. *
  29. * Early snapshots of gcc 4.5 don't support this and we can't detect
  30. * this in the preprocessor, but we can live with this because they're
  31. * unreleased. Really, we need to have autoconf for the kernel.
  32. */
  33. #define unreachable() __builtin_unreachable()
  34. /* Mark a function definition as prohibited from being cloned. */
  35. #define __noclone __attribute__((__noclone__))
  36. /*
  37. * Tell the optimizer that something else uses this function or variable.
  38. */
  39. #define __visible __attribute__((externally_visible))
  40. /*
  41. * GCC 'asm goto' miscompiles certain code sequences:
  42. *
  43. * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
  44. *
  45. * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
  46. * Fixed in GCC 4.8.2 and later versions.
  47. *
  48. * (asm goto is automatically volatile - the naming reflects this.)
  49. */
  50. #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
  51. #ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
  52. #define __HAVE_BUILTIN_BSWAP32__
  53. #define __HAVE_BUILTIN_BSWAP64__
  54. #define __HAVE_BUILTIN_BSWAP16__
  55. #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */