From 373684fdc09c508982eff8c7d3fee88ffa1f9627 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 13 Oct 2017 10:45:15 +0200 Subject: [PATCH] shared: add _nm_thread_local macro Copied and adjusted from systemd. --- shared/nm-utils/nm-macros-internal.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index f511c142b8..435cef6568 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -32,6 +32,22 @@ #define _nm_const __attribute__ ((const)) #define _nm_printf(a,b) __attribute__ ((__format__ (__printf__, a, b))) +/*****************************************************************************/ + +#ifdef thread_local +#define _nm_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 _nm_thread_local _Thread_local +#else +#define _nm_thread_local __thread +#endif + +/*****************************************************************************/ + #include "nm-glib.h" /*****************************************************************************/