summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-05-06 12:05:49 +0200
committerThomas Haller <thaller@redhat.com>2022-05-06 12:20:16 +0200
commit0ea11bee7b974e193ffc34b5b1d7f0d5825b263a (patch)
tree8e435fddfffa5e5a08707427b220e3a853d9fddb
parent9b0493646c20f3eecdf664e7e00c6c9162e04fba (diff)
downloadlibnl-0ea11bee7b974e193ffc34b5b1d7f0d5825b263a.tar.gz
utils: add _nl_thread_local macro
-rw-r--r--include/netlink-private/utils.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h
index dca05b93..93a04c94 100644
--- a/include/netlink-private/utils.h
+++ b/include/netlink-private/utils.h
@@ -72,6 +72,23 @@
/*****************************************************************************/
+#ifdef thread_local
+#define _nl_thread_local thread_local
+/*
+ * Don't break on glibc < 2.16 that doesn't define __STDC_NO_THREADS__
+ * see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769
+ */
+#elif __STDC_VERSION__ >= 201112L && \
+ !(defined(__STDC_NO_THREADS__) || \
+ (defined(__GNU_LIBRARY__) && __GLIBC__ == 2 && \
+ __GLIBC_MINOR__ < 16))
+#define _nl_thread_local _Thread_local
+#else
+#define _nl_thread_local __thread
+#endif
+
+/*****************************************************************************/
+
#define _NL_STATIC_ASSERT(cond) ((void) sizeof (char[(cond) ? 1 : -1]))
/*****************************************************************************/