summaryrefslogtreecommitdiffstats
path: root/src/prelude.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/prelude.h')
-rw-r--r--src/prelude.h39
1 files changed, 7 insertions, 32 deletions
diff --git a/src/prelude.h b/src/prelude.h
index ddeacbd..0944df1 100644
--- a/src/prelude.h
+++ b/src/prelude.h
@@ -16,7 +16,8 @@
#define C17 201710L
#define C23 202311L
-#include <stddef.h>
+// Get the static_assert() definition as well as __GLIBC__
+#include <assert.h>
#if __STDC_VERSION__ < C23
# include <stdalign.h>
@@ -49,6 +50,9 @@ extern const char bfs_version[];
#if __has_include(<paths.h>)
# define BFS_HAS_PATHS_H true
#endif
+#if __has_include(<stdbit.h>)
+# define BFS_HAS_STDBIT_H true
+#endif
#if __has_include(<sys/extattr.h>)
# define BFS_HAS_SYS_EXTATTR_H true
#endif
@@ -75,6 +79,7 @@ extern const char bfs_version[];
#define BFS_HAS_MNTENT_H __GLIBC__
#define BFS_HAS_PATHS_H true
+#define BFS_HAS_STDBIT_H (__STDC_VERSION__ >= C23)
#define BFS_HAS_SYS_EXTATTR_H __FreeBSD__
#define BFS_HAS_SYS_MKDEV_H false
#define BFS_HAS_SYS_PARAM_H true
@@ -127,27 +132,12 @@ extern const char bfs_version[];
# define __has_attribute(attr) false
#endif
-// Platform detection
-
-// Get the definition of BSD if available
-#if BFS_USE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-
-#ifndef __GLIBC_PREREQ
-# define __GLIBC_PREREQ(maj, min) false
-#endif
-
-#ifndef __NetBSD_Prereq__
-# define __NetBSD_Prereq__(maj, min, patch) false
-#endif
-
// Fundamental utilities
/**
* Get the length of an array.
*/
-#define countof(array) (sizeof(array) / sizeof(0[array]))
+#define countof(...) (sizeof(__VA_ARGS__) / sizeof(0[__VA_ARGS__]))
/**
* False sharing/destructive interference/largest cache line size.
@@ -168,21 +158,6 @@ extern const char bfs_version[];
#endif
/**
- * Polyfill max_align_t if we don't already have it.
- */
-#if !BFS_HAS_MAX_ALIGN_T
-typedef union {
-# ifdef __BIGGEST_ALIGNMENT__
- alignas(__BIGGEST_ALIGNMENT__) char c;
-# else
- long double ld;
- long long ll;
- void *ptr;
-# endif
-} max_align_t;
-#endif
-
-/**
* Alignment specifier that avoids false sharing.
*/
#define cache_align alignas(FALSE_SHARING_SIZE)