summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-08-27 15:50:42 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-08-28 17:33:20 -0400
commita37a564b66b363cc509cc5cdd16fd65b7950b0be (patch)
tree17960f7a657cd45d7421ad92c38501730f4c56bc
parent8ca167ee93d4a79f1f24bd959de8b85183577064 (diff)
downloadbfs-a37a564b66b363cc509cc5cdd16fd65b7950b0be.tar.xz
prelude: Define thread_local
-rw-r--r--src/prelude.h20
-rw-r--r--src/thread.h8
-rw-r--r--tests/main.c1
3 files changed, 17 insertions, 12 deletions
diff --git a/src/prelude.h b/src/prelude.h
index 9aaec04..59fa645 100644
--- a/src/prelude.h
+++ b/src/prelude.h
@@ -19,10 +19,24 @@
// Get the static_assert() definition as well as __GLIBC__
#include <assert.h>
+// Get the convenience macros that became standard spellings in C23
#if __STDC_VERSION__ < C23
-# include <stdalign.h>
-# include <stdbool.h>
-#endif
+
+/** _Alignas(), _Alignof() => alignas(), alignof() */
+#include <stdalign.h>
+/** _Bool => bool, true, false */
+#include <stdbool.h>
+
+/**
+ * C23 deprecates `noreturn void` in favour of `[[noreturn]] void`, so we expose
+ * _noreturn instead with the other attributes.
+ */
+// #include <stdnoreturn.h>
+
+/** Part of <threads.h>, but we don't use anything else from it. */
+#define thread_local _Thread_local
+
+#endif // !C23
// bfs packaging configuration
diff --git a/src/thread.h b/src/thread.h
index db11bd8..dbf11ce 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -11,14 +11,6 @@
#include "prelude.h"
#include <pthread.h>
-#if __STDC_VERSION__ < C23 && !defined(thread_local)
-# if BFS_USE_THREADS_H
-# include <threads.h>
-# else
-# define thread_local _Thread_local
-# endif
-#endif
-
/** Thread entry point type. */
typedef void *thread_fn(void *arg);
diff --git a/tests/main.c b/tests/main.c
index 7386469..e4d9e61 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -9,7 +9,6 @@
#include "tests.h"
#include "bfstd.h"
#include "color.h"
-#include "thread.h"
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>