From 02528757f439dfc5750e28fb3e5794303ccd21f9 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 17 Nov 2015 11:39:29 +0300 Subject: [PATCH] Allow specific TLS attributes for GC_thread_key * doc/README.macros (GC_ATTR_TLS_FAST): Document. * include/private/thread_local_alloc.h (GC_ATTR_TLS_FAST): New macro (empty by default). * include/private/thread_local_alloc.h (GC_thread_key): Use GC_ATTR_TLS_FAST. * thread_local_alloc.c (GC_thread_key): Likewise. --- doc/README.macros | 3 +++ include/private/thread_local_alloc.h | 10 +++++++--- thread_local_alloc.c | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/README.macros b/doc/README.macros index 09dedcf..c3d2743 100644 --- a/doc/README.macros +++ b/doc/README.macros @@ -394,6 +394,9 @@ USE_COMPILER_TLS Causes thread local allocation to use default in HP/UX. It may help performance on recent Linux installations. (It failed for me on RedHat 8, but appears to work on RedHat 9.) +GC_ATTR_TLS_FAST Use specific attributes for GC_thread_key like + __attribute__((tls_model("local-exec"))). + PARALLEL_MARK Allows the marker to run in multiple threads. Recommended for multiprocessors. diff --git a/include/private/thread_local_alloc.h b/include/private/thread_local_alloc.h index d5c5d58..9205bd8 100644 --- a/include/private/thread_local_alloc.h +++ b/include/private/thread_local_alloc.h @@ -162,13 +162,17 @@ GC_INNER void GC_mark_thread_local_fls_for(GC_tlfs p); GC_EXTERN ptr_t * GC_finalized_objfreelist; #endif +#ifndef GC_ATTR_TLS_FAST +# define GC_ATTR_TLS_FAST /* empty */ +#endif + extern #if defined(USE_COMPILER_TLS) - __thread + __thread GC_ATTR_TLS_FAST #elif defined(USE_WIN32_COMPILER_TLS) - __declspec(thread) + __declspec(thread) GC_ATTR_TLS_FAST #endif -GC_key_t GC_thread_key; + GC_key_t GC_thread_key; /* This is set up by the thread_local_alloc implementation. No need */ /* for cleanup on thread exit. But the thread support layer makes sure */ /* that GC_thread_key is traced, if necessary. */ diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 29a337b..9db324e 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -24,9 +24,9 @@ #include #if defined(USE_COMPILER_TLS) - __thread + __thread GC_ATTR_TLS_FAST #elif defined(USE_WIN32_COMPILER_TLS) - __declspec(thread) + __declspec(thread) GC_ATTR_TLS_FAST #endif GC_key_t GC_thread_key; -- 2.7.4