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,6 +226,7 @@ a_name##tsd_set(a_type *val) \
{ \
\
assert(a_name##tsd_booted); \
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,6 +278,7 @@ a_name##tsd_set(a_type *val) \
{ \
\
assert(a_name##tsd_booted); \
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, \
@ -409,6 +411,7 @@ a_name##tsd_set(a_type *val) \
\
assert(a_name##tsd_booted); \
wrapper = a_name##tsd_wrapper_get(); \
if (likely(&wrapper->val != val)) \
wrapper->val = *(val); \
if (a_cleanup != malloc_tsd_no_cleanup) \
wrapper->initialized = true; \
@ -537,6 +540,7 @@ a_name##tsd_set(a_type *val) \
\
assert(a_name##tsd_booted); \
wrapper = a_name##tsd_wrapper_get(); \
if (likely(&wrapper->val != val)) \
wrapper->val = *(val); \
if (a_cleanup != malloc_tsd_no_cleanup) \
wrapper->initialized = true; \