Loading...
Searching...
No Matches
23#include "pw_polyfill/static_assert.h"
57#define PW_PACKED(declaration) declaration __attribute__((packed))
60#define PW_USED __attribute__((used))
64#define PW_NO_PROLOGUE __attribute__((naked))
86#define PW_PRINTF_FORMAT(format_index, parameter_index) \
87 __attribute__((format(_PW_PRINTF_FORMAT_TYPE, format_index, parameter_index)))
92#ifdef __USE_MINGW_ANSI_STDIO
93#define _PW_PRINTF_FORMAT_TYPE gnu_printf
95#define _PW_PRINTF_FORMAT_TYPE printf
100#define PW_PLACE_IN_SECTION(name) __attribute__((section("__DATA," name)))
102#define PW_PLACE_IN_SECTION(name) __attribute__((section(name)))
110#define PW_KEEP_IN_SECTION(name) __attribute__((section("__DATA," name), used))
112#define PW_KEEP_IN_SECTION(name) __attribute__((section(name), used))
120#define PW_NO_RETURN __attribute__((noreturn))
123#define PW_NO_INLINE __attribute__((noinline))
135#define PW_UNREACHABLE __builtin_unreachable()
153#define PW_NO_SANITIZE(check) __attribute__((no_sanitize(check)))
155#define PW_NO_SANITIZE(check)
161#ifdef __has_attribute
162#define PW_HAVE_ATTRIBUTE(x) __has_attribute(x)
164#define PW_HAVE_ATTRIBUTE(x) 0
174#if defined(__cplusplus) && defined(__has_cpp_attribute)
175#define PW_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
177#define PW_HAVE_CPP_ATTRIBUTE(x) 0
181#define _PW_REQUIRE_SEMICOLON \
182 static_assert(1, "This macro must be terminated with a semicolon")
186#define PW_MODIFY_DIAGNOSTICS_PUSH() \
187 _Pragma("GCC diagnostic push") _PW_REQUIRE_SEMICOLON
191#define PW_MODIFY_DIAGNOSTICS_POP() \
192 _Pragma("GCC diagnostic pop") _PW_REQUIRE_SEMICOLON
200#define PW_MODIFY_DIAGNOSTIC(kind, option) \
201 PW_PRAGMA(GCC diagnostic kind option) _PW_REQUIRE_SEMICOLON
206#define PW_MODIFY_DIAGNOSTIC_GCC(kind, option) _PW_REQUIRE_SEMICOLON
208#define PW_MODIFY_DIAGNOSTIC_GCC(kind, option) \
209 PW_MODIFY_DIAGNOSTIC(kind, option)
215#define PW_MODIFY_DIAGNOSTIC_CLANG(kind, option) \
216 PW_MODIFY_DIAGNOSTIC(kind, option)
218#define PW_MODIFY_DIAGNOSTIC_CLANG(kind, option) _PW_REQUIRE_SEMICOLON
223#define PW_PRAGMA(contents) _Pragma(#contents)
235#define PW_WEAK __attribute__((weak))
247#define PW_ALIAS(aliased_to) __attribute__((weak, alias(#aliased_to)))
265#if PW_HAVE_CPP_ATTRIBUTE(clang::lifetimebound)
266#define PW_ATTRIBUTE_LIFETIME_BOUND [[clang::lifetimebound]]
267#elif PW_HAVE_ATTRIBUTE(lifetimebound)
268#define PW_ATTRIBUTE_LIFETIME_BOUND __attribute__((lifetimebound))
270#define PW_ATTRIBUTE_LIFETIME_BOUND
282#define PW_ADD_OVERFLOW(a, b, out) __builtin_add_overflow(a, b, out)
294#define PW_SUB_OVERFLOW(a, b, out) __builtin_sub_overflow(a, b, out)
304#define PW_MUL_OVERFLOW(a, b, out) __builtin_mul_overflow(a, b, out)
308#if (defined(__clang_major__) && __clang_major__ < 9) || \
309 (defined(__GNUC__) && __GNUC__ < 12)
310#define PW_VA_OPT_SUPPORTED() 0
312#define PW_VA_OPT_SUPPORTED() _PW_VA_OPT_SUPPORTED()
315#define _PW_VA_OPT_SUPPORTED(...) _PW_VA_OPT_SUPPORTED_##__VA_OPT__()
316#define _PW_VA_OPT_SUPPORTED_ 1
317#define _PW_VA_OPT_SUPPORTED___VA_OPT__() 0
324#if PW_HAVE_CPP_ATTRIBUTE(no_unique_address)
325#define PW_NO_UNIQUE_ADDRESS [[no_unique_address]]
327#define PW_NO_UNIQUE_ADDRESS