From: Ivan Maidanski Date: Tue, 17 Nov 2015 08:39:29 +0000 (+0300) Subject: Allow specific TLS attributes for GC_thread_key X-Git-Tag: gc7_6_0~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02528757f439dfc5750e28fb3e5794303ccd21f9;p=gc 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. --- diff --git a/doc/README.macros b/doc/README.macros index 09dedcf8..c3d27437 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 d5c5d580..9205bd83 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 29a337b2..9db324eb 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;