Avoid self assignment in tsd_set().

This commit is contained in:
Jason Evans 2016-09-23 12:18:57 -07:00
parent 0222fb41d1
commit 61f467e16a

View File

@ -226,7 +226,8 @@ a_name##tsd_set(a_type *val) \
{ \
\
assert(a_name##tsd_booted); \
a_name##tsd_tls = (*val); \
if (likely(&a_name##tsd_tls != val)) \
a_name##tsd_tls = (*val); \
if (a_cleanup != malloc_tsd_no_cleanup) \
a_name##tsd_initialized = true; \
}
@ -277,7 +278,8 @@ a_name##tsd_set(a_type *val) \
{ \
\
assert(a_name##tsd_booted); \
a_name##tsd_tls = (*val); \
if (likely(&a_name##tsd_tls != val)) \
a_name##tsd_tls = (*val); \
if (a_cleanup != malloc_tsd_no_cleanup) { \
if (pthread_setspecific(a_name##tsd_tsd, \
(void *)(&a_name##tsd_tls))) { \
@ -409,7 +411,8 @@ a_name##tsd_set(a_type *val) \
\
assert(a_name##tsd_booted); \
wrapper = a_name##tsd_wrapper_get(); \
wrapper->val = *(val); \
if (likely(&wrapper->val != val)) \
wrapper->val = *(val); \
if (a_cleanup != malloc_tsd_no_cleanup) \
wrapper->initialized = true; \
}
@ -537,7 +540,8 @@ a_name##tsd_set(a_type *val) \
\
assert(a_name##tsd_booted); \
wrapper = a_name##tsd_wrapper_get(); \
wrapper->val = *(val); \
if (likely(&wrapper->val != val)) \
wrapper->val = *(val); \
if (a_cleanup != malloc_tsd_no_cleanup) \
wrapper->initialized = true; \
}