diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-11-10 09:58:57 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-11-10 09:58:57 -0500 |
commit | 4efbe8eca395c90fc0053c7ba1038ccb7bf69e61 (patch) | |
tree | 28cb2bc0052df4b3926d72a9da9df8c4ce59258f /src | |
parent | e25261a90222de75781726a93ab809c660208afd (diff) | |
download | bfs-4efbe8eca395c90fc0053c7ba1038ccb7bf69e61.tar.xz |
config: Add constants for C standard versions
Diffstat (limited to 'src')
-rw-r--r-- | src/bit.h | 8 | ||||
-rw-r--r-- | src/config.h | 10 | ||||
-rw-r--r-- | src/diag.h | 4 | ||||
-rw-r--r-- | src/thread.h | 2 |
4 files changed, 16 insertions, 8 deletions
@@ -12,7 +12,7 @@ #include <limits.h> #include <stdint.h> -#if __STDC_VERSION__ >= 202311L +#if __STDC_VERSION__ >= C23 # include <stdbit.h> #endif @@ -173,7 +173,7 @@ # define ENDIAN_NATIVE 0 #endif -#if __STDC_VERSION__ >= 202311L +#if __STDC_VERSION__ >= C23 # define bswap16 stdc_memreverse8u16 # define bswap32 stdc_memreverse8u32 # define bswap64 stdc_memreverse8u64 @@ -236,7 +236,7 @@ static inline uint8_t bswap8(uint8_t n) { // C23 polyfill: bit utilities -#if __STDC_VERSION__ >= 202311L +#if __STDC_VERSION__ >= C23 # define count_ones stdc_count_ones # define count_zeros stdc_count_zeros # define rotate_left stdc_rotate_left @@ -395,6 +395,6 @@ UINT_OVERLOADS(BIT_CEIL) #define bit_floor(n) UINT_SELECT(n, bit_floor)(n) #define bit_ceil(n) UINT_SELECT(n, bit_ceil)(n) -#endif // __STDC_VERSION__ < 202311L +#endif // __STDC_VERSION__ < C23 #endif // BFS_BIT_H diff --git a/src/config.h b/src/config.h index db62ef8..821e4a9 100644 --- a/src/config.h +++ b/src/config.h @@ -8,9 +8,17 @@ #ifndef BFS_CONFIG_H #define BFS_CONFIG_H +// Possible __STDC_VERSION__ values + +#define C95 199409L +#define C99 199901L +#define C11 201112L +#define C17 201710L +#define C23 202311L + #include <stddef.h> -#if __STDC_VERSION__ < 202311L +#if __STDC_VERSION__ < C23 # include <stdalign.h> # include <stdbool.h> # include <stdnoreturn.h> @@ -14,7 +14,7 @@ /** * static_assert() with an optional second argument. */ -#if __STDC_VERSION__ >= 202311L +#if __STDC_VERSION__ >= C23 # define bfs_static_assert static_assert #else # define bfs_static_assert(...) bfs_static_assert_(__VA_ARGS__, #__VA_ARGS__, ) @@ -35,7 +35,7 @@ struct bfs_loc { /** * Get the current source code location. */ -#if __STDC_VERSION__ >= 202311L +#if __STDC_VERSION__ >= C23 # define bfs_location() (&(static const struct bfs_loc)BFS_LOC_INIT) #else # define bfs_location() (&(const struct bfs_loc)BFS_LOC_INIT) diff --git a/src/thread.h b/src/thread.h index b37d45f..8174fe4 100644 --- a/src/thread.h +++ b/src/thread.h @@ -11,7 +11,7 @@ #include "config.h" #include <pthread.h> -#if __STDC_VERSION__ < 202311L && !defined(thread_local) +#if __STDC_VERSION__ < C23 && !defined(thread_local) # if BFS_USE_THREADS_H # include <threads.h> # else |