summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/capability-util.c1
-rw-r--r--src/basic/cgroup-util.c1
-rw-r--r--src/basic/log.c1
-rw-r--r--src/basic/macro.h14
-rw-r--r--src/basic/memory-util.c1
-rw-r--r--src/basic/missing_threads.h15
-rw-r--r--src/basic/process-util.c1
-rw-r--r--src/basic/psi-util.c1
-rw-r--r--src/basic/random-util.c1
-rw-r--r--src/basic/signal-util.c1
-rw-r--r--src/basic/time-util.c1
-rw-r--r--src/basic/virt.c1
12 files changed, 25 insertions, 14 deletions
diff --git a/src/basic/capability-util.c b/src/basic/capability-util.c
index 87fb2203f0..1698ea02cc 100644
--- a/src/basic/capability-util.c
+++ b/src/basic/capability-util.c
@@ -14,6 +14,7 @@
#include "logarithm.h"
#include "macro.h"
#include "missing_prctl.h"
+#include "missing_threads.h"
#include "parse-util.h"
#include "user-util.h"
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index feda596939..90877c9fa1 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -23,6 +23,7 @@
#include "login-util.h"
#include "macro.h"
#include "missing_magic.h"
+#include "missing_threads.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
diff --git a/src/basic/log.c b/src/basic/log.c
index 6a43731012..40602d5dda 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -25,6 +25,7 @@
#include "log.h"
#include "macro.h"
#include "missing_syscall.h"
+#include "missing_threads.h"
#include "parse-util.h"
#include "proc-cmdline.h"
#include "process-util.h"
diff --git a/src/basic/macro.h b/src/basic/macro.h
index ddf3032fbc..2425d27819 100644
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -297,20 +297,6 @@ static inline int __coverity_check_and_return__(int condition) {
p != (typeof(p)) POINTER_MAX; \
p = *(++_l))
-/* Define C11 thread_local attribute even on older gcc compiler
- * version */
-#ifndef thread_local
-/*
- * Don't break on glibc < 2.16 that doesn't define __STDC_NO_THREADS__
- * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769
- */
-#if __STDC_VERSION__ >= 201112L && !(defined(__STDC_NO_THREADS__) || (defined(__GNU_LIBRARY__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 16))
-#define thread_local _Thread_local
-#else
-#define thread_local __thread
-#endif
-#endif
-
#define DEFINE_TRIVIAL_DESTRUCTOR(name, type, func) \
static inline void name(type *p) { \
func(p); \
diff --git a/src/basic/memory-util.c b/src/basic/memory-util.c
index c4f54c7b4e..fcedae2d41 100644
--- a/src/basic/memory-util.c
+++ b/src/basic/memory-util.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include "memory-util.h"
+#include "missing_threads.h"
size_t page_size(void) {
static thread_local size_t pgsz = 0;
diff --git a/src/basic/missing_threads.h b/src/basic/missing_threads.h
new file mode 100644
index 0000000000..fb3b72249b
--- /dev/null
+++ b/src/basic/missing_threads.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+/* If threads.h doesn't exist, then define our own thread_local to match C11's thread_local. */
+#if HAVE_THREADS_H
+# include <threads.h>
+#elif !(defined(thread_local))
+/* Don't break on glibc < 2.16 that doesn't define __STDC_NO_THREADS__
+ * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769 */
+# if __STDC_VERSION__ >= 201112L && !(defined(__STDC_NO_THREADS__) || (defined(__GNU_LIBRARY__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 16))
+# define thread_local _Thread_local
+# else
+# define thread_local __thread
+# endif
+#endif
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 919387f958..5d499a57b4 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -36,6 +36,7 @@
#include "memory-util.h"
#include "missing_sched.h"
#include "missing_syscall.h"
+#include "missing_threads.h"
#include "mountpoint-util.h"
#include "namespace-util.h"
#include "nulstr-util.h"
diff --git a/src/basic/psi-util.c b/src/basic/psi-util.c
index a3b553cb44..af8e278bd0 100644
--- a/src/basic/psi-util.c
+++ b/src/basic/psi-util.c
@@ -8,6 +8,7 @@
#include "extract-word.h"
#include "fd-util.h"
#include "fileio.h"
+#include "missing_threads.h"
#include "parse-util.h"
#include "psi-util.h"
#include "string-util.h"
diff --git a/src/basic/random-util.c b/src/basic/random-util.c
index 28ace92f19..98bcc7444c 100644
--- a/src/basic/random-util.c
+++ b/src/basic/random-util.c
@@ -24,6 +24,7 @@
#include "io-util.h"
#include "missing_random.h"
#include "missing_syscall.h"
+#include "missing_threads.h"
#include "parse-util.h"
#include "random-util.h"
#include "sha256.h"
diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c
index 7875ca69bb..5d9484626d 100644
--- a/src/basic/signal-util.c
+++ b/src/basic/signal-util.c
@@ -6,6 +6,7 @@
#include "errno-util.h"
#include "macro.h"
#include "missing_syscall.h"
+#include "missing_threads.h"
#include "parse-util.h"
#include "signal-util.h"
#include "stdio-util.h"
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index 26fd1bae65..e2c0d7ea9e 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -17,6 +17,7 @@
#include "io-util.h"
#include "log.h"
#include "macro.h"
+#include "missing_threads.h"
#include "missing_timerfd.h"
#include "parse-util.h"
#include "path-util.h"
diff --git a/src/basic/virt.c b/src/basic/virt.c
index ca3edaf3b5..f264cc6eb3 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -16,6 +16,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "macro.h"
+#include "missing_threads.h"
#include "process-util.h"
#include "stat-util.h"
#include "string-table.h"