compiler-gcc.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef _TOOLS_LINUX_COMPILER_H_
  2. #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
  3. #endif
  4. /*
  5. * Common definitions for all gcc versions go here.
  6. */
  7. #define GCC_VERSION (__GNUC__ * 10000 \
  8. + __GNUC_MINOR__ * 100 \
  9. + __GNUC_PATCHLEVEL__)
  10. #if GCC_VERSION >= 70000 && !defined(__CHECKER__)
  11. # define __fallthrough __attribute__ ((fallthrough))
  12. #endif
  13. #if GCC_VERSION >= 40300
  14. # define __compiletime_error(message) __attribute__((error(message)))
  15. #endif /* GCC_VERSION >= 40300 */
  16. /* &a[0] degrades to a pointer: a different type from an array */
  17. #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
  18. #define noinline __attribute__((noinline))
  19. #ifndef __packed
  20. #define __packed __attribute__((packed))
  21. #endif
  22. #ifndef __noreturn
  23. #define __noreturn __attribute__((noreturn))
  24. #endif
  25. #ifndef __aligned
  26. #define __aligned(x) __attribute__((aligned(x)))
  27. #endif
  28. #define __printf(a, b) __attribute__((format(printf, a, b)))
  29. #define __scanf(a, b) __attribute__((format(scanf, a, b)))