compiler-gcc.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _TOOLS_LINUX_COMPILER_H_
  3. #error "Please do not include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
  4. #endif
  5. /*
  6. * Common definitions for all gcc versions go here.
  7. */
  8. #ifndef GCC_VERSION
  9. #define GCC_VERSION (__GNUC__ * 10000 \
  10. + __GNUC_MINOR__ * 100 \
  11. + __GNUC_PATCHLEVEL__)
  12. #endif
  13. #if __has_attribute(__fallthrough__)
  14. # define fallthrough __attribute__((__fallthrough__))
  15. #else
  16. # define fallthrough do {} while (0) /* fallthrough */
  17. #endif
  18. #if __has_attribute(__error__)
  19. # define __compiletime_error(message) __attribute__((error(message)))
  20. #endif
  21. /* &a[0] degrades to a pointer: a different type from an array */
  22. #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
  23. #ifndef __pure
  24. #define __pure __attribute__((pure))
  25. #endif
  26. #define noinline __attribute__((noinline))
  27. #ifndef __packed
  28. #define __packed __attribute__((packed))
  29. #endif
  30. #ifndef __noreturn
  31. #define __noreturn __attribute__((noreturn))
  32. #endif
  33. #ifndef __aligned
  34. #define __aligned(x) __attribute__((aligned(x)))
  35. #endif
  36. #define __printf(a, b) __attribute__((format(printf, a, b)))
  37. #define __scanf(a, b) __attribute__((format(scanf, a, b)))