]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 20 Aug 2002 07:22:11 +0000 (07:22 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 20 Aug 2002 07:22:11 +0000 (07:22 +0000)
2002-08-20  Ulrich Drepper  <drepper@redhat.com>

* elf/Versions [ld] (GLIBC_PRIVATE): Add _dl_get_tls_static_info.
* sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage): Move dtv
memory allocation to...
(allocate_dtv): ...here.  New function.
(_dl_allocate_tls): Change to take parameter.  If parameter is non-NULL
call allocate_dtv instead of _dl_allocate_tls_storage.
(_dl_deallocate_tls): New parameter.  Deallocate TCB only if true.
(_dl_get_tls_static_info): New function.
* sysdeps/generic/ldsodefs.h: Adjust prototypes of _dl_allocate_tls
and _dl_deallocate_tls.  Add prototype for _dl_get_tls_static_info.

ChangeLog
elf/Versions
sysdeps/generic/dl-tls.c
sysdeps/generic/ldsodefs.h

index 21164f2ff5d4273ff7b0808ffec48575e91f8faf..bfd9a2d28193a16d0d6438a383b9d1653d474429 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-08-20  Ulrich Drepper  <drepper@redhat.com>
+
+       * elf/Versions [ld] (GLIBC_PRIVATE): Add _dl_get_tls_static_info.
+       * sysdeps/generic/dl-tls.c (_dl_allocate_tls_storage): Move dtv
+       memory allocation to...
+       (allocate_dtv): ...here.  New function.
+       (_dl_allocate_tls): Change to take parameter.  If parameter is non-NULL
+       call allocate_dtv instead of _dl_allocate_tls_storage.
+       (_dl_deallocate_tls): New parameter.  Deallocate TCB only if true.
+       (_dl_get_tls_static_info): New function.
+       * sysdeps/generic/ldsodefs.h: Adjust prototypes of _dl_allocate_tls
+       and _dl_deallocate_tls.  Add prototype for _dl_get_tls_static_info.
+
 2002-08-19  Ulrich Drepper  <drepper@redhat.com>
 
        * sysdeps/generic/dl-tls.c (_dl_allocate_tls_init): Return
index 4f924e6df58f07d62d7b2d4133bad6fef7eeaaac..a49ecbf7de022c3ee53bcf6320223441cd4bef64 100644 (file)
@@ -50,6 +50,7 @@ ld {
     _dl_relocate_object; _dl_signal_error; _dl_start_profile; _dl_starting_up;
     _dl_unload_cache;
     _rtld_global; _dl_tls_symaddr; _dl_allocate_tls; _dl_deallocate_tls;
+    _dl_get_tls_static_info;
     _dl_get_origin;
   }
 }
index 2b47195c968a6f20813168a5601b098b4a64d532..38f40ac8aed997da27421166119ea7427fda4e84 100644 (file)
@@ -196,19 +196,13 @@ _dl_determine_tlsoffset (void)
 }
 
 
-void *
+static void *
 internal_function
-_dl_allocate_tls_storage (void)
+allocate_dtv (void *result)
 {
-  void *result;
   dtv_t *dtv;
   size_t dtv_length;
 
-  /* Allocate a correctly aligned chunk of memory.  */
-  result = __libc_memalign (GL(dl_tls_static_align), GL(dl_tls_static_size));
-  if (__builtin_expect (result == NULL, 0))
-    return result;
-
   /* 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
      of the dtv.  */
@@ -216,11 +210,6 @@ _dl_allocate_tls_storage (void)
   dtv = (dtv_t *) malloc ((dtv_length + 2) * sizeof (dtv_t));
   if (dtv != NULL)
     {
-# if TLS_TCB_AT_TP
-      /* The TCB follows the TLS blocks.  */
-      result = (char *) result + GL(dl_tls_static_size) - TLS_TCB_SIZE;
-# endif
-
       /* This is the initial length of the dtv.  */
       dtv[0].counter = dtv_length;
       /* Fill in the generation number.  */
@@ -233,9 +222,43 @@ _dl_allocate_tls_storage (void)
       INSTALL_DTV (result, dtv);
     }
   else
+    result = NULL;
+
+  return result;
+}
+
+
+/* Get size and alignment requirements of the static TLS block.  */
+void
+internal_function
+_dl_get_tls_static_info (size_t *sizep, size_t *alignp)
+{
+  *sizep = GL(dl_tls_static_size);
+  *alignp = GL(dl_tls_static_align);
+}
+
+
+void *
+internal_function
+_dl_allocate_tls_storage (void)
+{
+  void *result;
+
+  /* Allocate a correctly aligned chunk of memory.  */
+  result = __libc_memalign (GL(dl_tls_static_align), GL(dl_tls_static_size));
+  if (__builtin_expect (result != NULL, 0))
     {
-      free (result);
-      result = NULL;
+      /* Allocate the DTV.  */
+      void *allocated = result;
+
+# if TLS_TCB_AT_TP
+      /* The TCB follows the TLS blocks.  */
+      result = (char *) result + GL(dl_tls_static_size) - TLS_TCB_SIZE;
+# endif
+
+      result = allocate_dtv (result);
+      if (result == NULL)
+       free (allocated);
     }
 
   return result;
@@ -315,23 +338,26 @@ _dl_allocate_tls_init (void *result)
 
 void *
 internal_function
-_dl_allocate_tls (void)
+_dl_allocate_tls (void *mem)
 {
-  return _dl_allocate_tls_init (_dl_allocate_tls_storage ());
+  return _dl_allocate_tls_init (mem == NULL
+                               ? _dl_allocate_tls_storage ()
+                               : allocate_dtv (mem));
 }
 INTDEF(_dl_allocate_tls)
 
 
 void
 internal_function
-_dl_deallocate_tls (void *tcb)
+_dl_deallocate_tls (void *tcb, bool dealloc_tcb)
 {
   dtv_t *dtv = GET_DTV (tcb);
 
   /* The array starts with dtv[-1].  */
   free (dtv - 1);
 
-  free (tcb);
+  if (dealloc_tcb)
+    free (tcb);
 }
 
 
index cd499f61b70020a1a54bb8c8373b254048f1e52f..361cb0b72d7b4aadbb9adf1c39858ca0ef6517f6 100644 (file)
@@ -724,8 +724,12 @@ extern size_t _dl_next_tls_modid (void) internal_function;
 /* Calculate offset of the TLS blocks in the static TLS block.  */
 extern void _dl_determine_tlsoffset (void) internal_function;
 
-/* Allocate memory for static TLS block and dtv.  */
-extern void *_dl_allocate_tls (void) internal_function;
+/* Allocate memory for static TLS block (unless MEM is nonzero) and dtv.  */
+extern void *_dl_allocate_tls (void *mem) internal_function;
+
+/* Get size and alignment requirements of the static TLS block.  */
+extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp)
+     internal_function;
 
 /* These are internal entry points to the two halves of _dl_allocate_tls,
    only used within rtld.c itself at startup time.  */
@@ -735,7 +739,7 @@ extern void *_dl_allocate_tls_init (void *)
   internal_function attribute_hidden;
 
 /* Deallocate memory allocated with _dl_allocate_tls.  */
-extern void _dl_deallocate_tls (void *tcb) internal_function;
+extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb) internal_function;
 
 /* Return the symbol address given the map of the module it is in and
    the symbol record.  */