162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 262306a36Sopenharmony_ci/****************************************************************************** 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Name: acgcc.h - GCC specific defines, etc. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 2000 - 2023, Intel Corp. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci *****************************************************************************/ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef __ACGCC_H__ 1162306a36Sopenharmony_ci#define __ACGCC_H__ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#ifndef va_arg 1462306a36Sopenharmony_ci#ifdef __KERNEL__ 1562306a36Sopenharmony_ci#include <linux/stdarg.h> 1662306a36Sopenharmony_ci#else 1762306a36Sopenharmony_ci#include <stdarg.h> 1862306a36Sopenharmony_ci#endif /* __KERNEL__ */ 1962306a36Sopenharmony_ci#endif /* ! va_arg */ 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define ACPI_INLINE __inline__ 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/* Function name is used for debug output. Non-ANSI, compiler-dependent */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define ACPI_GET_FUNCTION_NAME __func__ 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci/* 2862306a36Sopenharmony_ci * This macro is used to tag functions as "printf-like" because 2962306a36Sopenharmony_ci * some compilers (like GCC) can catch printf format string problems. 3062306a36Sopenharmony_ci */ 3162306a36Sopenharmony_ci#define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1))) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* 3462306a36Sopenharmony_ci * Some compilers complain about unused variables. Sometimes we don't want to 3562306a36Sopenharmony_ci * use all the variables (for example, _acpi_module_name). This allows us 3662306a36Sopenharmony_ci * to tell the compiler warning in a per-variable manner that a variable 3762306a36Sopenharmony_ci * is unused. 3862306a36Sopenharmony_ci */ 3962306a36Sopenharmony_ci#define ACPI_UNUSED_VAR __attribute__ ((unused)) 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci/* GCC supports __VA_ARGS__ in macros */ 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define COMPILER_VA_MACRO 1 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* GCC supports native multiply/shift on 32-bit platforms */ 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define ACPI_USE_NATIVE_MATH64 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* GCC did not support __has_attribute until 5.1. */ 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#ifndef __has_attribute 5262306a36Sopenharmony_ci#define __has_attribute(x) 0 5362306a36Sopenharmony_ci#endif 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci/* 5662306a36Sopenharmony_ci * Explicitly mark intentional explicit fallthrough to silence 5762306a36Sopenharmony_ci * -Wimplicit-fallthrough in GCC 7.1+. 5862306a36Sopenharmony_ci */ 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#if __has_attribute(__fallthrough__) 6162306a36Sopenharmony_ci#define ACPI_FALLTHROUGH __attribute__((__fallthrough__)) 6262306a36Sopenharmony_ci#endif 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* 6562306a36Sopenharmony_ci * Flexible array members are not allowed to be part of a union under 6662306a36Sopenharmony_ci * C99, but this is not for any technical reason. Work around the 6762306a36Sopenharmony_ci * limitation. 6862306a36Sopenharmony_ci */ 6962306a36Sopenharmony_ci#define ACPI_FLEX_ARRAY(TYPE, NAME) \ 7062306a36Sopenharmony_ci struct { \ 7162306a36Sopenharmony_ci struct { } __Empty_ ## NAME; \ 7262306a36Sopenharmony_ci TYPE NAME[]; \ 7362306a36Sopenharmony_ci } 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#endif /* __ACGCC_H__ */ 76