aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-tls.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-10-27 23:11:47 +0000
committerUlrich Drepper <drepper@redhat.com>2006-10-27 23:11:47 +0000
commitb52bbc1bdf3886da8dd3265fd955cafe5368d34a (patch)
tree117b2e9abb35c86cb2259bf7cdf639fd0df9d39f /elf/dl-tls.c
parentffd0e1b7e9b540716e5a98b49157eb1aed231b57 (diff)
downloadglibc-b52bbc1bdf3886da8dd3265fd955cafe5368d34a.zip
glibc-b52bbc1bdf3886da8dd3265fd955cafe5368d34a.tar.gz
glibc-b52bbc1bdf3886da8dd3265fd955cafe5368d34a.tar.bz2
USE_TLS support is now default.
* tls.make.c: USE_TLS support is now default. * csu/Versions: Likewise. * csu/libc-start.c: Likewise. * csu/libc-tls.c: Likewise. * csu/version.c: Likewise. * dlfcn/dlinfo.c: Likewise. * elf/dl-addr.c: Likewise. * elf/dl-cache.c: Likewise. * elf/dl-close.c: Likewise. * elf/dl-iteratephdr.c: Likewise. * elf/dl-load.c: Likewise. * elf/dl-lookup.c: Likewise. * elf/dl-object.c: Likewise. * elf/dl-open.c: Likewise. * elf/dl-reloc.c: Likewise. * elf/dl-support.c: Likewise. * elf/dl-sym.c: Likewise. * elf/dl-sysdep.c: Likewise. * elf/dl-tls.c: Likewise. * elf/ldconfig.c: Likewise. * elf/rtld.c: Likewise. * elf/tst-tls-dlinfo.c: Likewise. * elf/tst-tls1.c: Likewise. * elf/tst-tls10.h: Likewise. * elf/tst-tls14.c: Likewise. * elf/tst-tls2.c: Likewise. * elf/tst-tls3.c: Likewise. * elf/tst-tls4.c: Likewise. * elf/tst-tls5.c: Likewise. * elf/tst-tls6.c: Likewise. * elf/tst-tls7.c: Likewise. * elf/tst-tls8.c: Likewise. * elf/tst-tls9.c: Likewise. * elf/tst-tlsmod1.c: Likewise. * elf/tst-tlsmod13.c: Likewise. * elf/tst-tlsmod13a.c: Likewise. * elf/tst-tlsmod14a.c: Likewise. * elf/tst-tlsmod2.c: Likewise. * elf/tst-tlsmod3.c: Likewise. * elf/tst-tlsmod4.c: Likewise. * elf/tst-tlsmod5.c: Likewise. * elf/tst-tlsmod6.c: Likewise. * include/errno.h: Likewise. * include/link.h: Likewise. * include/tls.h: Likewise. * locale/global-locale.c: Likewise. * locale/localeinfo.h: Likewise. * malloc/arena.c: Likewise. * malloc/hooks.c: Likewise. * malloc/malloc.c: Likewise. * resolv/Versions: Likewise. * sysdeps/alpha/dl-machine.h: Likewise. * sysdeps/alpha/libc-tls.c: Likewise. * sysdeps/generic/ldsodefs.h: Likewise. * sysdeps/generic/tls.h: Likewise. * sysdeps/i386/dl-machine.h: Likewise. * sysdeps/ia64/dl-machine.h: Likewise. * sysdeps/ia64/libc-tls.c: Likewise. * sysdeps/mach/hurd/fork.c: Likewise. * sysdeps/mach/hurd/i386/tls.h: Likewise. * sysdeps/powerpc/powerpc32/dl-machine.c: Likwise. * sysdeps/powerpc/powerpc32/dl-machine.h: Likewise. * sysdeps/powerpc/powerpc64/dl-machine.h: Likewise. * sysdeps/s390/libc-tls.c: Likewise. * sysdeps/s390/s390-32/dl-machine.h: Likewise. * sysdeps/s390/s390-64/dl-machine.h: Likewise. * sysdeps/sh/dl-machine.h: Likewise. * sysdeps/sparc/sparc32/dl-machine.h: Likewise. * sysdeps/sparc/sparc64/dl-machine.h: Likewise. * sysdeps/x86_64/dl-machine.h: Likewise.
Diffstat (limited to 'elf/dl-tls.c')
-rw-r--r--elf/dl-tls.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index a0f4f77..d5865ab 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -26,30 +26,26 @@
#include <sys/param.h>
#include <tls.h>
-
-/* We don't need any of this if TLS is not supported. */
-#ifdef USE_TLS
-
-# include <dl-tls.h>
-# include <ldsodefs.h>
+#include <dl-tls.h>
+#include <ldsodefs.h>
/* Amount of excess space to allocate in the static TLS area
to allow dynamic loading of modules defining IE-model TLS data. */
-# define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
+#define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
/* Value used for dtv entries for which the allocation is delayed. */
-# define TLS_DTV_UNALLOCATED ((void *) -1l)
+#define TLS_DTV_UNALLOCATED ((void *) -1l)
/* Out-of-memory handler. */
-# ifdef SHARED
+#ifdef SHARED
static void
__attribute__ ((__noreturn__))
oom (void)
{
_dl_fatal_printf ("cannot allocate memory for thread-local data: ABORT\n");
}
-# endif
+#endif
size_t
@@ -113,7 +109,7 @@ _dl_next_tls_modid (void)
}
-# ifdef SHARED
+#ifdef SHARED
void
internal_function
_dl_determine_tlsoffset (void)
@@ -158,7 +154,7 @@ _dl_determine_tlsoffset (void)
memory requirement for the next TLS block is smaller than the
gap. */
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
/* We simply start with zero. */
size_t offset = 0;
@@ -205,7 +201,7 @@ _dl_determine_tlsoffset (void)
GL(dl_tls_static_used) = offset;
GL(dl_tls_static_size) = (roundup (offset + TLS_STATIC_SURPLUS, max_align)
+ TLS_TCB_SIZE);
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
/* The TLS blocks start right after the TCB. */
size_t offset = TLS_TCB_SIZE;
@@ -249,9 +245,9 @@ _dl_determine_tlsoffset (void)
GL(dl_tls_static_used) = offset;
GL(dl_tls_static_size) = roundup (offset + TLS_STATIC_SURPLUS,
TLS_TCB_ALIGN);
-# else
-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
-# endif
+#else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+#endif
/* The alignment requirement for the static TLS block. */
GL(dl_tls_static_align) = max_align;
@@ -288,7 +284,7 @@ _dl_tls_setup (void)
return 0;
}
rtld_hidden_def (_dl_tls_setup)
-# endif
+#endif
static void *
internal_function
@@ -337,13 +333,13 @@ _dl_allocate_tls_storage (void)
void *result;
size_t size = GL(dl_tls_static_size);
-# if TLS_DTV_AT_TP
+#if TLS_DTV_AT_TP
/* Memory layout is:
[ TLS_PRE_TCB_SIZE ] [ TLS_TCB_SIZE ] [ TLS blocks ]
^ This should be returned. */
size += (TLS_PRE_TCB_SIZE + GL(dl_tls_static_align) - 1)
& ~(GL(dl_tls_static_align) - 1);
-# endif
+#endif
/* Allocate a correctly aligned chunk of memory. */
result = __libc_memalign (GL(dl_tls_static_align), size);
@@ -352,14 +348,14 @@ _dl_allocate_tls_storage (void)
/* Allocate the DTV. */
void *allocated = result;
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
/* The TCB follows the TLS blocks. */
result = (char *) result + size - TLS_TCB_SIZE;
/* Clear the TCB data structure. We can't ask the caller (i.e.
libpthread) to do it, because we will initialize the DTV et al. */
memset (result, '\0', TLS_TCB_SIZE);
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
result = (char *) result + size - GL(dl_tls_static_size);
/* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it.
@@ -367,7 +363,7 @@ _dl_allocate_tls_storage (void)
initialize the DTV et al. */
memset ((char *) result - TLS_PRE_TCB_SIZE, '\0',
TLS_PRE_TCB_SIZE + TLS_TCB_SIZE);
-# endif
+#endif
result = allocate_dtv (result);
if (result == NULL)
@@ -428,14 +424,14 @@ _dl_allocate_tls_init (void *result)
assert (map->l_tls_modid == cnt);
assert (map->l_tls_blocksize >= map->l_tls_initimage_size);
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
assert ((size_t) map->l_tls_offset >= map->l_tls_blocksize);
dest = (char *) result - map->l_tls_offset;
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
dest = (char *) result + map->l_tls_offset;
-# else
-# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
-# endif
+#else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+#endif
/* Copy the initialization image and clear the BSS part. */
dtv[map->l_tls_modid].pointer.val = dest;
@@ -491,21 +487,21 @@ _dl_deallocate_tls (void *tcb, bool dealloc_tcb)
if (dealloc_tcb)
{
-# if TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
/* The TCB follows the TLS blocks. Back up to free the whole block. */
tcb -= GL(dl_tls_static_size) - TLS_TCB_SIZE;
-# elif TLS_DTV_AT_TP
+#elif TLS_DTV_AT_TP
/* Back up the TLS_PRE_TCB_SIZE bytes. */
tcb -= (TLS_PRE_TCB_SIZE + GL(dl_tls_static_align) - 1)
& ~(GL(dl_tls_static_align) - 1);
-# endif
+#endif
free (tcb);
}
}
rtld_hidden_def (_dl_deallocate_tls)
-# ifdef SHARED
+#ifdef SHARED
/* The __tls_get_addr function has two basic forms which differ in the
arguments. The IA-64 form takes two parameters, the module ID and
offset. The form used, among others, on IA-32 takes a reference to
@@ -513,15 +509,15 @@ rtld_hidden_def (_dl_deallocate_tls)
form seems to be more often used (in the moment) so we default to
it. Users of the IA-64 form have to provide adequate definitions
of the following macros. */
-# ifndef GET_ADDR_ARGS
-# define GET_ADDR_ARGS tls_index *ti
-# endif
-# ifndef GET_ADDR_MODULE
-# define GET_ADDR_MODULE ti->ti_module
-# endif
-# ifndef GET_ADDR_OFFSET
-# define GET_ADDR_OFFSET ti->ti_offset
-# endif
+# ifndef GET_ADDR_ARGS
+# define GET_ADDR_ARGS tls_index *ti
+# endif
+# ifndef GET_ADDR_MODULE
+# define GET_ADDR_MODULE ti->ti_module
+# endif
+# ifndef GET_ADDR_OFFSET
+# define GET_ADDR_OFFSET ti->ti_offset
+# endif
static void *
@@ -732,7 +728,7 @@ __tls_get_addr (GET_ADDR_ARGS)
return (char *) p + GET_ADDR_OFFSET;
}
-# endif
+#endif
/* Look up the module's TLS block as for __tls_get_addr,
@@ -840,4 +836,3 @@ cannot create TLS data structures"));
listp->slotinfo[idx].map = l;
listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1;
}
-#endif /* use TLS */