compiler.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* public domain */
  2. #ifndef COMPILER_H
  3. #define COMPILER_H
  4. #include "config-host.h"
  5. #define QEMU_NORETURN __attribute__ ((__noreturn__))
  6. #ifdef CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT
  7. #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  8. #else
  9. #define QEMU_WARN_UNUSED_RESULT
  10. #endif
  11. #define QEMU_BUILD_BUG_ON(x) \
  12. typedef char qemu_build_bug_on__##__LINE__[(x)?-1:1];
  13. #if defined __GNUC__
  14. # if (__GNUC__ < 4) || \
  15. defined(__GNUC_MINOR__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4)
  16. /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
  17. # define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
  18. # define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
  19. # else
  20. /* Use gnu_printf when supported (qemu uses standard format strings). */
  21. # define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
  22. # define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
  23. # endif
  24. #else
  25. #define GCC_ATTR /**/
  26. #define GCC_FMT_ATTR(n, m)
  27. #endif
  28. #endif /* COMPILER_H */