* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage): Allocate the

TCB with __libc_memalign instead of mmap.
	(_dl_deallocate_tls): Free it with free instad of munmap.
This commit is contained in:
Roland McGrath 2002-08-05 01:28:17 +00:00
parent a816b435dd
commit a4dda453b8
2 changed files with 10 additions and 15 deletions

View File

@ -1,5 +1,9 @@
2002-08-04 Roland McGrath <roland@redhat.com> 2002-08-04 Roland McGrath <roland@redhat.com>
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage): Allocate the
TCB with __libc_memalign instead of mmap.
(_dl_deallocate_tls): Free it with free instad of munmap.
* Makerules (cpp-srcs-left): When setting this to run * Makerules (cpp-srcs-left): When setting this to run
cppflags-iterator.mk, must append .c to $(tests) and $(xtests) cppflags-iterator.mk, must append .c to $(tests) and $(xtests)
words. Combine the two loops into one on the concatenated list, words. Combine the two loops into one on the concatenated list,

View File

@ -205,25 +205,16 @@ _dl_allocate_tls_storage (void)
size_t dtv_length; size_t dtv_length;
/* Allocate a correctly aligned chunk of memory. */ /* Allocate a correctly aligned chunk of memory. */
/* XXX For now */ result = __libc_memalign (GL(dl_tls_static_align), GL(dl_tls_static_size));
assert (GL(dl_tls_static_align) <= GL(dl_pagesize)); if (__builtin_expect (result == NULL, 0))
# ifdef MAP_ANON return result;
# define _dl_zerofd (-1)
# else
# define _dl_zerofd GL(dl_zerofd)
if ((dl_zerofd) == -1)
GL(dl_zerofd) = _dl_sysdep_open_zero_fill ();
# define MAP_ANON 0
# endif
result = __mmap (0, GL(dl_tls_static_size) ?: 1, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, _dl_zerofd, 0);
/* We allocate a few more elements in the dtv than are needed for the /* We allocate a few more elements in the dtv than are needed for the
initial set of modules. This should avoid in most cases expansions initial set of modules. This should avoid in most cases expansions
of the dtv. */ of the dtv. */
dtv_length = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS; dtv_length = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS;
dtv = (dtv_t *) malloc ((dtv_length + 2) * sizeof (dtv_t)); dtv = (dtv_t *) malloc ((dtv_length + 2) * sizeof (dtv_t));
if (result != MAP_FAILED && dtv != NULL) if (dtv != NULL)
{ {
# if TLS_TCB_AT_TP # if TLS_TCB_AT_TP
/* The TCB follows the TLS blocks. */ /* The TCB follows the TLS blocks. */
@ -241,7 +232,7 @@ _dl_allocate_tls_storage (void)
/* Add the dtv to the thread data structures. */ /* Add the dtv to the thread data structures. */
INSTALL_DTV (result, dtv); INSTALL_DTV (result, dtv);
} }
else if (result != NULL) else
{ {
free (result); free (result);
result = NULL; result = NULL;
@ -335,7 +326,7 @@ _dl_deallocate_tls (void *tcb)
/* The array starts with dtv[-1]. */ /* The array starts with dtv[-1]. */
free (dtv - 1); free (dtv - 1);
munmap (tcb, GL(dl_tls_static_size)); free (tcb);
} }