acgcc.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /******************************************************************************
  3. *
  4. * Name: acgcc.h - GCC specific defines, etc.
  5. *
  6. * Copyright (C) 2000 - 2025, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #ifndef __ACGCC_H__
  10. #define __ACGCC_H__
  11. #ifndef va_arg
  12. #ifdef __KERNEL__
  13. #include <linux/stdarg.h>
  14. #else
  15. #include <stdarg.h>
  16. #endif /* __KERNEL__ */
  17. #endif /* ! va_arg */
  18. #define ACPI_INLINE __inline__
  19. /* Function name is used for debug output. Non-ANSI, compiler-dependent */
  20. #define ACPI_GET_FUNCTION_NAME __func__
  21. /*
  22. * This macro is used to tag functions as "printf-like" because
  23. * some compilers (like GCC) can catch printf format string problems.
  24. */
  25. #define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1)))
  26. /*
  27. * Some compilers complain about unused variables. Sometimes we don't want to
  28. * use all the variables (for example, _acpi_module_name). This allows us
  29. * to tell the compiler warning in a per-variable manner that a variable
  30. * is unused.
  31. */
  32. #define ACPI_UNUSED_VAR __attribute__ ((unused))
  33. /* GCC supports __VA_ARGS__ in macros */
  34. #define COMPILER_VA_MACRO 1
  35. /* GCC supports native multiply/shift on 32-bit platforms */
  36. #define ACPI_USE_NATIVE_MATH64
  37. /* GCC did not support __has_attribute until 5.1. */
  38. #ifndef __has_attribute
  39. #define __has_attribute(x) 0
  40. #endif
  41. /*
  42. * Explicitly mark intentional explicit fallthrough to silence
  43. * -Wimplicit-fallthrough in GCC 7.1+.
  44. */
  45. #if __has_attribute(__fallthrough__)
  46. #define ACPI_FALLTHROUGH __attribute__((__fallthrough__))
  47. #endif
  48. /*
  49. * Flexible array members are not allowed to be part of a union under
  50. * C99, but this is not for any technical reason. Work around the
  51. * limitation.
  52. */
  53. #define ACPI_FLEX_ARRAY(TYPE, NAME) \
  54. struct { \
  55. struct { } __Empty_ ## NAME; \
  56. TYPE NAME[]; \
  57. }
  58. /*
  59. * Explicitly mark strings that lack a terminating NUL character so
  60. * that ACPICA can be built with -Wunterminated-string-initialization.
  61. */
  62. #if __has_attribute(__nonstring__)
  63. #define ACPI_NONSTRING __attribute__((__nonstring__))
  64. #endif
  65. #endif /* __ACGCC_H__ */