diff options
author | Steve MacLean <Steve.MacLean@Microsoft.com> | 2020-05-21 13:34:26 -0400 |
---|---|---|
committer | Steve MacLean <Steve.MacLean@Microsoft.com> | 2020-05-21 17:59:52 -0400 |
commit | d627f4aea024f7d1bfaa7ce7293379316c7713ea (patch) | |
tree | 071e0b29d8ab3198d09c0b6b7d664a7d1786c05a | |
parent | 8321b7820096c44750cf5360654dcaae99827439 (diff) | |
download | libunwind-d627f4aea024f7d1bfaa7ce7293379316c7713ea.tar.gz |
Use C11 _Thread_local
-rw-r--r-- | acinclude.m4 | 21 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | include/compiler.h | 9 | ||||
-rw-r--r-- | include/libunwind_i.h | 2 | ||||
-rw-r--r-- | src/aarch64/Gtrace.c | 4 | ||||
-rw-r--r-- | src/arm/Gtrace.c | 4 | ||||
-rw-r--r-- | src/dwarf/Gparser.c | 4 | ||||
-rw-r--r-- | src/ia64/Gscript.c | 6 | ||||
-rw-r--r-- | src/x86_64/Ginit.c | 6 | ||||
-rw-r--r-- | src/x86_64/Gtrace.c | 4 |
10 files changed, 17 insertions, 49 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 497f7c2f..3fff6c96 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,24 +1,3 @@ -AC_DEFUN([LIBUNWIND___THREAD], -[dnl Check whether the compiler supports the __thread keyword. -if test "x$enable___thread" != xno; then - AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread, - [cat > conftest.c <<\EOF - __thread int a = 42; -EOF - if AC_TRY_COMMAND([${CC-cc} $CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then - libc_cv_gcc___thread=yes - else - libc_cv_gcc___thread=no - fi - rm -f conftest*]) - if test "$libc_cv_gcc___thread" = yes; then - AC_DEFINE(HAVE___THREAD, 1, - [Define to 1 if __thread keyword is supported by the C compiler.]) - fi -else - libc_cv_gcc___thread=no -fi]) - AC_DEFUN([CHECK_ATOMIC_OPS], [dnl Check whether the system has the atomic_ops package installed. AC_CHECK_HEADERS(atomic_ops.h) diff --git a/configure.ac b/configure.ac index 226a10fb..5348481c 100644 --- a/configure.ac +++ b/configure.ac @@ -328,10 +328,8 @@ AC_ARG_ENABLE([per-thread-cache], AS_HELP_STRING([--enable-per-thread-cache], [build with support for UNW_CACHE_PER_THREAD (which imposes a hight TLS memory usage) (default: disabled)])) AC_MSG_RESULT([$enable_per_thread_cache]) AS_IF([test x$enable_per_thread_cache = xyes], [ - LIBUNWIND___THREAD - AS_IF([test x$libc_cv_gcc___thread = xno], [ - AC_MSG_FAILURE([UNW_CACHE_PER_THREAD requires __thread]) - ]) + AC_DEFINE(HAVE___CACHE_PER_THREAD, 1, + [Define to 1 if --enable-per-thread-cache]) ]) AC_MSG_CHECKING([for Intel compiler]) diff --git a/include/compiler.h b/include/compiler.h index 3100be09..726936c0 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -30,15 +30,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef COMPILER_H #define COMPILER_H -#if defined(__STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L // C11 -# include <thread.h> -# define THREAD_LOCAL thread_local -#elseif defined(__GNUC__) -# define THREAD_LOCAL __thread -#else -# define THREAD_LOCAL -#endif - #ifdef __GNUC__ # define ALIGNED(x) __attribute__((aligned(x))) # define CONST_ATTR __attribute__((__const__)) diff --git a/include/libunwind_i.h b/include/libunwind_i.h index 3eecab72..083f60e5 100644 --- a/include/libunwind_i.h +++ b/include/libunwind_i.h @@ -37,7 +37,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "compiler.h" -#if defined(HAVE___THREAD) && HAVE___THREAD +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD #define UNWI_DEFAULT_CACHING_POLICY UNW_CACHE_PER_THREAD #else #define UNWI_DEFAULT_CACHING_POLICY UNW_CACHE_GLOBAL diff --git a/src/aarch64/Gtrace.c b/src/aarch64/Gtrace.c index 2f8c3f8d..bcdf1929 100644 --- a/src/aarch64/Gtrace.c +++ b/src/aarch64/Gtrace.c @@ -52,8 +52,8 @@ static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; static sig_atomic_t trace_cache_once_happen; static pthread_key_t trace_cache_key; static struct mempool trace_cache_pool; -static THREAD_LOCAL unw_trace_cache_t *tls_cache; -static THREAD_LOCAL int tls_cache_destroyed; +static _Thread_local unw_trace_cache_t *tls_cache; +static _Thread_local int tls_cache_destroyed; /* Free memory for a thread's trace cache. */ static void diff --git a/src/arm/Gtrace.c b/src/arm/Gtrace.c index 7ed320cc..51fc281d 100644 --- a/src/arm/Gtrace.c +++ b/src/arm/Gtrace.c @@ -52,8 +52,8 @@ static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; static sig_atomic_t trace_cache_once_happen; static pthread_key_t trace_cache_key; static struct mempool trace_cache_pool; -static THREAD_LOCAL unw_trace_cache_t *tls_cache; -static THREAD_LOCAL int tls_cache_destroyed; +static _Thread_local unw_trace_cache_t *tls_cache; +static _Thread_local int tls_cache_destroyed; /* Free memory for a thread's trace cache. */ static void diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c index 28fd73c6..b3636abf 100644 --- a/src/dwarf/Gparser.c +++ b/src/dwarf/Gparser.c @@ -601,10 +601,10 @@ get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp) if (caching == UNW_CACHE_NONE) return NULL; -#if defined(HAVE___THREAD) && HAVE___THREAD +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD if (likely (caching == UNW_CACHE_PER_THREAD)) { - static __thread struct dwarf_rs_cache tls_cache __attribute__((tls_model("initial-exec"))); + static _Thread_local struct dwarf_rs_cache tls_cache __attribute__((tls_model("initial-exec"))); Debug (16, "using TLS cache\n"); cache = &tls_cache; } diff --git a/src/ia64/Gscript.c b/src/ia64/Gscript.c index 526aeaf2..0e2d2b86 100644 --- a/src/ia64/Gscript.c +++ b/src/ia64/Gscript.c @@ -45,8 +45,8 @@ enum ia64_script_insn_opcode IA64_INSN_MOVE_SCRATCH_NO_NAT /* like above, but clear NaT info */ }; -#if defined(HAVE___THREAD) && HAVE___THREAD -static __thread struct ia64_script_cache ia64_per_thread_cache = +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD +static _Thread_local struct ia64_script_cache ia64_per_thread_cache = { #ifdef HAVE_ATOMIC_OPS_H .busy = AO_TS_INITIALIZER @@ -105,7 +105,7 @@ get_script_cache (unw_addr_space_t as, intrmask_t *saved_maskp) if (!spin_trylock_irqsave (&cache->busy, *saved_maskp)) return NULL; #else -# if defined(HAVE___THREAD) && HAVE___THREAD +# if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD if (as->caching_policy == UNW_CACHE_PER_THREAD) cache = &ia64_per_thread_cache; # endif diff --git a/src/x86_64/Ginit.c b/src/x86_64/Ginit.c index 81c663c1..250ead4a 100644 --- a/src/x86_64/Ginit.c +++ b/src/x86_64/Ginit.c @@ -203,10 +203,10 @@ tdep_init_mem_validate (void) /* Cache of already validated addresses */ #define NLGA 4 -#if defined(HAVE___THREAD) && HAVE___THREAD +#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD // thread-local variant -static THREAD_LOCAL unw_word_t last_good_addr[NLGA]; -static THREAD_LOCAL int lga_victim; +static _Thread_local unw_word_t last_good_addr[NLGA]; +static _Thread_local int lga_victim; static int is_cached_valid_mem(unw_word_t addr) diff --git a/src/x86_64/Gtrace.c b/src/x86_64/Gtrace.c index 7be10a00..40be17eb 100644 --- a/src/x86_64/Gtrace.c +++ b/src/x86_64/Gtrace.c @@ -50,8 +50,8 @@ static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; static sig_atomic_t trace_cache_once_happen; static pthread_key_t trace_cache_key; static struct mempool trace_cache_pool; -static THREAD_LOCAL unw_trace_cache_t *tls_cache; -static THREAD_LOCAL int tls_cache_destroyed; +static _Thread_local unw_trace_cache_t *tls_cache; +static _Thread_local int tls_cache_destroyed; /* Free memory for a thread's trace cache. */ static void |