diff --git a/float.h b/float.h index 58b53b9..e74fb7b 100644 --- a/float.h +++ b/float.h @@ -12,10 +12,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(__FSTD_HDRS_FLOAT_H) || defined(__FSTD_HDRS_CXX_WRAP) -#if !defined(__FSTD_HDRS_CXX_WRAP) +#ifndef __FSTD_HDRS_FLOAT_H #define __FSTD_HDRS_FLOAT_H 1 -#endif #undef FLT_ROUNDS #define FLT_ROUNDS 1 @@ -30,19 +28,17 @@ #undef LDBL_MANT_DIG #define LDBL_MANT_DIG __LDBL_MANT_DIG__ +#if (defined(__cplusplus) && __cplusplus >= 201103L) \ + || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) + #undef DECIMAL_DIG #define DECIMAL_DIG __DECIMAL_DIG__ -#undef FLT_DECIMAL_DIG -#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ -#undef DBL_DECIMAL_DIG -#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ -#undef LDBL_DECIMAL_DIG -#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ - #undef FLT_EVAL_METHOD #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#endif + #undef FLT_DIG #define FLT_DIG __FLT_DIG__ #undef DBL_DIG @@ -99,6 +95,16 @@ #undef LDBL_MIN #define LDBL_MIN __LDBL_MIN__ +#if (defined(__cplusplus) && __cplusplus >= 201703L) \ + || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) + +#undef FLT_DECIMAL_DIG +#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ +#undef DBL_DECIMAL_DIG +#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ +#undef LDBL_DECIMAL_DIG +#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ + #undef FLT_TRUE_MIN #define FLT_TRUE_MIN __FLT_DENORM_MIN__ #undef DBL_TRUE_MIN @@ -114,3 +120,5 @@ #define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ #endif + +#endif diff --git a/limits.h b/limits.h index 0b503a7..5d14b49 100644 --- a/limits.h +++ b/limits.h @@ -12,10 +12,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(__FSTD_HDRS_LIMITS_H) || defined(__FSTD_HDRS_CXX_WRAP) -#if !defined(__FSTD_HDRS_CXX_WRAP) +#ifndef __FSTD_HDRS_LIMITS_H #define __FSTD_HDRS_LIMITS_H 1 -#endif #undef CHAR_BIT #define CHAR_BIT __CHAR_BIT__ @@ -80,6 +78,8 @@ #undef ULONG_MAX #define ULONG_MAX (LONG_MAX * 2UL + 1UL) +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #undef LLONG_MAX #define LLONG_MAX __LONG_LONG_MAX__ #undef LLONG_MIN @@ -89,3 +89,5 @@ #define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) #endif + +#endif diff --git a/stdalign.h b/stdalign.h index 28f5f88..7aab6a3 100644 --- a/stdalign.h +++ b/stdalign.h @@ -16,6 +16,10 @@ #define __FSTD_HDRS_STDALIGN_H 1 #ifndef __cplusplus + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L + /* These do not need to be defined for C23+ */ +#else # undef alignas # define alignas _Alignas # undef alignof @@ -28,3 +32,5 @@ #endif #endif + +#endif diff --git a/stdarg.h b/stdarg.h index fbeeb3f..b158794 100644 --- a/stdarg.h +++ b/stdarg.h @@ -12,15 +12,17 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(__FSTD_HDRS_STDARG_H) || defined(__FSTD_HDRS_CXX_WRAP) -#if !defined(__FSTD_HDRS_CXX_WRAP) +#ifndef __FSTD_HDRS_STDARG_H #define __FSTD_HDRS_STDARG_H 1 -#endif typedef __builtin_va_list va_list; #undef va_start -#define va_start(v, l) __builtin_va_start(v, l) +#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L +# define va_start(v, ...) __builtin_va_start(v, 0) +#else +# define va_start(v, l) __builtin_va_start(v, l) +#endif #undef va_end #define va_end(v) __builtin_va_end(v) #undef va_arg diff --git a/stdbool.h b/stdbool.h index d109057..b0e7320 100644 --- a/stdbool.h +++ b/stdbool.h @@ -12,12 +12,14 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(__FSTD_HDRS_STDBOOL_H) || defined(__FSTD_HDRS_CXX_WRAP) -#if !defined(__FSTD_HDRS_CXX_WRAP) +#ifndef __FSTD_HDRS_STDBOOL_H #define __FSTD_HDRS_STDBOOL_H 1 -#endif #ifndef __cplusplus + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L + /* These do not need to be defined for C23+ */ +#else # undef bool # define bool _Bool @@ -27,6 +29,8 @@ # define false 0 #endif +#endif + #undef __bool_true_false_are_defined #define __bool_true_false_are_defined 1 diff --git a/stddef.h b/stddef.h index 376eb75..adf4a32 100644 --- a/stddef.h +++ b/stddef.h @@ -12,10 +12,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(__FSTD_HDRS_STDDEF_H) || defined(__FSTD_HDRS_CXX_WRAP) -#if !defined(__FSTD_HDRS_CXX_WRAP) +#ifndef __FSTD_HDRS_STDDEF_H #define __FSTD_HDRS_STDDEF_H 1 -#endif typedef __SIZE_TYPE__ size_t; typedef __PTRDIFF_TYPE__ ptrdiff_t; @@ -23,8 +21,7 @@ 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) +#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L typedef typeof(nullptr) nullptr_t; #endif @@ -44,10 +41,11 @@ typedef decltype(nullptr) nullptr_t; #undef offsetof #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) +#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L # undef unreachable # define unreachable() __builtin_unreachable() + +# define __STDC_VERSION_STDDEF_H__ 202311L #endif #endif diff --git a/stdint.h b/stdint.h index 55991b6..7ff828a 100644 --- a/stdint.h +++ b/stdint.h @@ -12,10 +12,8 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(__FSTD_HDRS_STDINT_H) || defined(__FSTD_HDRS_CXX_WRAP) -#if !defined(__FSTD_HDRS_CXX_WRAP) +#ifndef __FSTD_HDRS_STDINT_H #define __FSTD_HDRS_STDINT_H 1 -#endif #ifdef __UINT8_TYPE__ typedef __UINT8_TYPE__ uint8_t;