summaryrefslogtreecommitdiff
path: root/src/ldso/dynlink.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-06-03 16:35:59 -0400
committerRich Felker <dalias@aerifal.cx>2013-06-03 16:35:59 -0400
commit44b4d09fc0626541ca12cf96f65adc21ab1fc413 (patch)
tree5ef32eaf4dc0e507a69fb9bb4cca14d8b2cab35a /src/ldso/dynlink.c
parentd9265653552a2b667bf3e84407a06edaa7e9f74f (diff)
downloadmusl-44b4d09fc0626541ca12cf96f65adc21ab1fc413.tar.gz
musl-44b4d09fc0626541ca12cf96f65adc21ab1fc413.tar.bz2
musl-44b4d09fc0626541ca12cf96f65adc21ab1fc413.tar.xz
musl-44b4d09fc0626541ca12cf96f65adc21ab1fc413.zip
ensure that thread dtv pointer is never null to optimize __tls_get_addr
Diffstat (limited to 'src/ldso/dynlink.c')
-rw-r--r--src/ldso/dynlink.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index dec95111..ee5ec302 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -740,13 +740,13 @@ void *__copy_tls(unsigned char *mem)
void *__tls_get_addr(size_t *v)
{
pthread_t self = __pthread_self();
- if (self->dtv && v[0]<=(size_t)self->dtv[0] && self->dtv[v[0]])
+ if (v[0]<=(size_t)self->dtv[0] && self->dtv[v[0]])
return (char *)self->dtv[v[0]]+v[1];
/* Block signals to make accessing new TLS async-signal-safe */
sigset_t set;
pthread_sigmask(SIG_BLOCK, SIGALL_SET, &set);
- if (self->dtv && v[0]<=(size_t)self->dtv[0] && self->dtv[v[0]]) {
+ if (v[0]<=(size_t)self->dtv[0] && self->dtv[v[0]]) {
pthread_sigmask(SIG_SETMASK, &set, 0);
return (char *)self->dtv[v[0]]+v[1];
}
@@ -759,10 +759,10 @@ void *__tls_get_addr(size_t *v)
for (p=head; p->tls_id != v[0]; p=p->next);
/* Get new DTV space from new DSO if needed */
- if (!self->dtv || v[0] > (size_t)self->dtv[0]) {
+ if (v[0] > (size_t)self->dtv[0]) {
void **newdtv = p->new_dtv +
(v[0]+1)*sizeof(void *)*a_fetch_add(&p->new_dtv_idx,1);
- if (self->dtv) memcpy(newdtv, self->dtv,
+ memcpy(newdtv, self->dtv,
((size_t)self->dtv[0]+1) * sizeof(void *));
newdtv[0] = (void *)v[0];
self->dtv = newdtv;