1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-29 02:07:39 +01:00

Use __thread instead of pthread_getspecific()

This commit is contained in:
Arun Sharma 2011-04-05 21:03:30 -07:00
parent 171e3e51f4
commit 15f182828d

View file

@ -161,6 +161,8 @@ trace_cache_expand (unw_trace_cache_t *cache)
return 0; return 0;
} }
static __thread unw_trace_cache_t *tls_cache;
/* Get the frame cache for the current thread. Create it if there is none. */ /* Get the frame cache for the current thread. Create it if there is none. */
static unw_trace_cache_t * static unw_trace_cache_t *
trace_cache_get (void) trace_cache_get (void)
@ -169,10 +171,11 @@ trace_cache_get (void)
if (pthread_once) if (pthread_once)
{ {
pthread_once(&trace_cache_once, &trace_cache_init_once); pthread_once(&trace_cache_once, &trace_cache_init_once);
if (! (cache = pthread_getspecific(trace_cache_key))) if (! (cache = tls_cache))
{ {
cache = trace_cache_create(); cache = trace_cache_create();
pthread_setspecific(trace_cache_key, cache); pthread_setspecific(trace_cache_key, cache);
tls_cache = cache;
} }
Debug(5, "using cache %p\n", cache); Debug(5, "using cache %p\n", cache);
return cache; return cache;