195857638SErik Schmauss /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 21da177e4SLinus Torvalds /****************************************************************************** 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Name: acgcc.h - GCC specific defines, etc. 51da177e4SLinus Torvalds * 6612c2932SBob Moore * Copyright (C) 2000 - 2023, Intel Corp. 71da177e4SLinus Torvalds * 895857638SErik Schmauss *****************************************************************************/ 91da177e4SLinus Torvalds 101da177e4SLinus Torvalds #ifndef __ACGCC_H__ 111da177e4SLinus Torvalds #define __ACGCC_H__ 121da177e4SLinus Torvalds 1384676b87SLv Zheng #ifndef va_arg 14136f2820SMiguel Bernal Marin #ifdef __KERNEL__ 15c0891ac1SAlexey Dobriyan #include <linux/stdarg.h> 16136f2820SMiguel Bernal Marin #else 17136f2820SMiguel Bernal Marin #include <stdarg.h> 18136f2820SMiguel Bernal Marin #endif /* __KERNEL__ */ 19136f2820SMiguel Bernal Marin #endif /* ! va_arg */ 205fb3ab84SLv Zheng 218f40f171SLin Ming #define ACPI_INLINE __inline__ 228f40f171SLin Ming 23f9f4601fSRobert Moore /* Function name is used for debug output. Non-ANSI, compiler-dependent */ 24f9f4601fSRobert Moore 25d5c003b4SHarvey Harrison #define ACPI_GET_FUNCTION_NAME __func__ 26f9f4601fSRobert Moore 27b8e4d893SBob Moore /* 28b8e4d893SBob Moore * This macro is used to tag functions as "printf-like" because 291da177e4SLinus Torvalds * some compilers (like GCC) can catch printf format string problems. 301da177e4SLinus Torvalds */ 31b8e4d893SBob Moore #define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1))) 321da177e4SLinus Torvalds 33b8e4d893SBob Moore /* 34b8e4d893SBob Moore * Some compilers complain about unused variables. Sometimes we don't want to 35f9f4601fSRobert Moore * use all the variables (for example, _acpi_module_name). This allows us 36fd589a8fSAnand Gadiyar * to tell the compiler warning in a per-variable manner that a variable 371da177e4SLinus Torvalds * is unused. 381da177e4SLinus Torvalds */ 391da177e4SLinus Torvalds #define ACPI_UNUSED_VAR __attribute__ ((unused)) 401da177e4SLinus Torvalds 417b09d8fdSLv Zheng /* GCC supports __VA_ARGS__ in macros */ 427b09d8fdSLv Zheng 437b09d8fdSLv Zheng #define COMPILER_VA_MACRO 1 447b09d8fdSLv Zheng 4565082bfcSLv Zheng /* GCC supports native multiply/shift on 32-bit platforms */ 4665082bfcSLv Zheng 4765082bfcSLv Zheng #define ACPI_USE_NATIVE_MATH64 4865082bfcSLv Zheng 49c1a7c2ceSNick Desaulniers /* GCC did not support __has_attribute until 5.1. */ 50c1a7c2ceSNick Desaulniers 51c1a7c2ceSNick Desaulniers #ifndef __has_attribute 52c1a7c2ceSNick Desaulniers #define __has_attribute(x) 0 53c1a7c2ceSNick Desaulniers #endif 54c1a7c2ceSNick Desaulniers 55c1a7c2ceSNick Desaulniers /* 56e527db8fSColin Ian King * Explicitly mark intentional explicit fallthrough to silence 57c1a7c2ceSNick Desaulniers * -Wimplicit-fallthrough in GCC 7.1+. 58c1a7c2ceSNick Desaulniers */ 59c1a7c2ceSNick Desaulniers 60c1a7c2ceSNick Desaulniers #if __has_attribute(__fallthrough__) 61c1a7c2ceSNick Desaulniers #define ACPI_FALLTHROUGH __attribute__((__fallthrough__)) 62c1a7c2ceSNick Desaulniers #endif 63c1a7c2ceSNick Desaulniers 64*11132ad0SKees Cook /* 65*11132ad0SKees Cook * Flexible array members are not allowed to be part of a union under 66*11132ad0SKees Cook * C99, but this is not for any technical reason. Work around the 67*11132ad0SKees Cook * limitation. 68*11132ad0SKees Cook */ 69*11132ad0SKees Cook #define ACPI_FLEX_ARRAY(TYPE, NAME) \ 70*11132ad0SKees Cook struct { \ 71*11132ad0SKees Cook struct { } __Empty_ ## NAME; \ 72*11132ad0SKees Cook TYPE NAME[]; \ 73*11132ad0SKees Cook } 74*11132ad0SKees Cook 751da177e4SLinus Torvalds #endif /* __ACGCC_H__ */ 76