From b28fd30353967e47354dcb39895336503ff978e7 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Thu, 23 Mar 2023 03:57:33 +0100 Subject: [PATCH] Misc std related updates --- stdarg.h | 4 +++- stddef.h | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/stdarg.h b/stdarg.h index e26da00..d756a59 100644 --- a/stdarg.h +++ b/stdarg.h @@ -11,7 +11,9 @@ typedef __builtin_va_list va_list; #define va_start(v, l) __builtin_va_start(v, l) #define va_end(v) __builtin_va_end(v) #define va_arg(v, l) __builtin_va_arg(v, l) -#define va_copy(d, s) __builtin_va_copy(d, s) +#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) +# define va_copy(d, s) __builtin_va_copy(d, s) +#endif #endif diff --git a/stddef.h b/stddef.h index e087eaa..b40d82d 100644 --- a/stddef.h +++ b/stddef.h @@ -8,12 +8,16 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; #ifndef __cplusplus typedef __WCHAR_TYPE__ wchar_t; + +/* XXX fix to use proper __STDC_VERSION__ number later on */ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202000L) +typedef typeof(nullptr) nullptr_t; +#endif + #endif #ifdef __cplusplus typedef decltype(nullptr) nullptr_t; - -enum class byte : unsigned char {}; #endif #ifndef __STDDEF_H_MACROS @@ -31,6 +35,11 @@ enum class byte : unsigned char {}; #define offsetof(s, m) __builtin_offsetof(s, m) +/* XXX fix to use proper __STDC_VERSION__ number later on */ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202000L) +# define unreachable() __builtin_unreachable() +#endif + #endif #endif