summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2010-04-07 01:44:12 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-04-13 22:41:48 -0400
commit714559dccda3165a72f0a9935c1edc3aef535f30 (patch)
treef06d5fca23024412708975c190b8fe8a499b593d
parent634ba33b5b1fcfd5a0e7910f9991b4ed4f674549 (diff)
Fixes for pthread thread local storage.
The tls_name_key variable is passed to tls_name_get(), and the first time this happens it isn't initialized. tls_name_get() then passes it on to tls_name_alloc() which passes it on to pthread_setspecific() leading to undefined behavior. None of this is actually necessary at all because there is only one such variable per thread local variable, so it doesn't need to passed as a parameter at all. All of this was pointed out by Tor Lillqvist on the cairo mailing list.
-rw-r--r--pixman/pixman-compiler.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/pixman/pixman-compiler.h b/pixman/pixman-compiler.h
index cdac0d82..531c8c93 100644
--- a/pixman/pixman-compiler.h
+++ b/pixman/pixman-compiler.h
@@ -99,16 +99,16 @@
} \
\
static type * \
- tls_ ## name ## _alloc (key) \
+ tls_ ## name ## _alloc (void) \
{ \
type *value = calloc (1, sizeof (type)); \
if (value) \
- pthread_setspecific (key, value); \
+ pthread_setspecific (tls_ ## name ## _key, value); \
return value; \
} \
\
static force_inline type * \
- tls_ ## name ## _get (key) \
+ tls_ ## name ## _get (void) \
{ \
type *value = NULL; \
if (pthread_once (&tls_ ## name ## _once_control, \
@@ -116,13 +116,13 @@
{ \
value = pthread_getspecific (tls_ ## name ## _key); \
if (!value) \
- value = tls_ ## name ## _alloc (key); \
+ value = tls_ ## name ## _alloc (); \
} \
return value; \
}
# define PIXMAN_GET_THREAD_LOCAL(name) \
- tls_ ## name ## _get (tls_ ## name ## _key)
+ tls_ ## name ## _get ()
#else