From 85f4cc52a11508e42daa5625283410e0d6f3a993 Mon Sep 17 00:00:00 2001 From: joseph Date: Fri, 7 Feb 2014 21:04:10 +0000 Subject: Merge changes between r25087 and r25236 from /fsf/trunk. git-svn-id: svn://svn.eglibc.org/trunk@25237 7b3dc134-2b1b-0410-93df-9e9f96275f8d --- libc/nptl/allocatestack.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'libc/nptl/allocatestack.c') diff --git a/libc/nptl/allocatestack.c b/libc/nptl/allocatestack.c index 2a5ac2211..13eca47cf 100644 --- a/libc/nptl/allocatestack.c +++ b/libc/nptl/allocatestack.c @@ -242,7 +242,11 @@ get_cached_stack (size_t *sizep, void **memp) /* Clear the DTV. */ dtv_t *dtv = GET_DTV (TLS_TPADJ (result)); - _dl_clear_dtv (dtv); + for (size_t cnt = 0; cnt < dtv[-1].counter; ++cnt) + if (! dtv[1 + cnt].pointer.is_static + && dtv[1 + cnt].pointer.val != TLS_DTV_UNALLOCATED) + free (dtv[1 + cnt].pointer.val); + memset (dtv, '\0', (dtv[-1].counter + 1) * sizeof (dtv_t)); /* Re-initialize the TLS. */ _dl_allocate_tls_init (TLS_TPADJ (result)); @@ -1173,18 +1177,13 @@ init_one_static_tls (struct pthread *curp, struct link_map *map) # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" # endif - /* Initialize the memory. */ - memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size), - '\0', map->l_tls_blocksize - map->l_tls_initimage_size); - /* Fill in the DTV slot so that a later LD/GD access will find it. */ - dtv[map->l_tls_modid].pointer.is_static = true; - /* Pairs against the read barrier in tls_get_attr_tail, guaranteeing - any thread waiting for an update to pointer.val sees the - initimage write. */ - atomic_write_barrier (); dtv[map->l_tls_modid].pointer.val = dest; + dtv[map->l_tls_modid].pointer.is_static = true; + /* Initialize the memory. */ + memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size), + '\0', map->l_tls_blocksize - map->l_tls_initimage_size); } void -- cgit v1.2.1