about summary refs log tree commit diff
path: root/sysdeps/generic/dl-tls.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-02-14 07:57:19 +0000
committerUlrich Drepper <drepper@redhat.com>2002-02-14 07:57:19 +0000
commitfc093be16082b406ee160762d773a791a5b3b965 (patch)
tree6649027f3fc3c8e9ca1950ded8278175a2ff5fe7 /sysdeps/generic/dl-tls.c
parentbb4cb25213ce21326236d72e8633844e4a777a8b (diff)
downloadglibc-fc093be16082b406ee160762d773a791a5b3b965.tar.gz
glibc-fc093be16082b406ee160762d773a791a5b3b965.tar.xz
glibc-fc093be16082b406ee160762d773a791a5b3b965.zip
Update.
	* elf/dl-close.c (remove_slotinfo): New function.  Handles everything
	for removing reference of module in slotinfo list.
	(_dl_close): Use remove_slotinfo.
	* sysdeps/generic/dl-tls.c: General pretty printing.
	(oom): Define only if SHARED.
	(_dl_next_tls_modid): Correct starting point for the case we assume
	there is a gap.  Add missing instruction grouping (doh!).  Correct
	tests for reaching maximum index.
	* elf/Makefile: Add rules to build and run tst-tls7.
	* elf/tst-tls7.c: New file.
	* elf/tst-tlsmod3.c: New file.

	* elf/tst-tlsmod1.c: Move #include "tls-macros.h" instead #ifdef
	USE_TLS.
	* elf/tst-tlsmod2.c: Likewise.
Diffstat (limited to 'sysdeps/generic/dl-tls.c')
-rw-r--r--sysdeps/generic/dl-tls.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/sysdeps/generic/dl-tls.c b/sysdeps/generic/dl-tls.c
index d13b0f93fa..7e45850198 100644
--- a/sysdeps/generic/dl-tls.c
+++ b/sysdeps/generic/dl-tls.c
@@ -29,14 +29,15 @@
 /* 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>
 
 /* Value used for dtv entries for which the allocation is delayed.  */
 # define TLS_DTV_UNALLOCATED	((void *) -1l)
 
 
 /* Out-of-memory handler.  */
+# ifdef SHARED
 static void
 __attribute__ ((__noreturn__))
 oom (void)
@@ -52,11 +53,12 @@ cannot allocate memory for thread-local data: ABORT\n";
   /* Just in case something goes wrong with the kill.  */
   while (1)
     {
-# ifdef ABORT_INSTRUCTION
+#  ifdef ABORT_INSTRUCTION
       ABORT_INSTRUCTION;
-# endif
+#  endif
     }
 }
+# endif
 
 
 
@@ -75,16 +77,20 @@ _dl_next_tls_modid (void)
 	 start since there are no gaps at that time.  Therefore it
 	 does not matter that the dl_tls_dtv_slotinfo is not allocated
 	 yet when the function is called for the first times.  */
-      result = GL(dl_tls_static_nelem);
-      assert (result < GL(dl_tls_max_dtv_idx));
+      result = GL(dl_tls_static_nelem) + 1;
+      /* If the following would not be true we mustn't have assumed
+	 there is a gap.  */
+      assert (result <= GL(dl_tls_max_dtv_idx));
       do
 	{
 	  while (result - disp < runp->len)
-	    if (runp->slotinfo[result - disp].map == NULL)
-	      break;
+	    {
+	      if (runp->slotinfo[result - disp].map == NULL)
+		break;
 
-	  ++result;
-	  assert (result <= GL(dl_tls_max_dtv_idx) + 1);
+	      ++result;
+	      assert (result <= GL(dl_tls_max_dtv_idx) + 1);
+	    }
 
 	  if (result - disp < runp->len)
 	    break;
@@ -93,11 +99,11 @@ _dl_next_tls_modid (void)
 	}
       while ((runp = runp->next) != NULL);
 
-      if (result >= GL(dl_tls_max_dtv_idx) + 1)
+      if (result >= GL(dl_tls_max_dtv_idx))
 	{
 	  /* The new index must indeed be exactly one higher than the
 	     previous high.  */
-	  assert (result == GL(dl_tls_max_dtv_idx) + 1);
+	  assert (result == GL(dl_tls_max_dtv_idx));
 
 	  /* There is no gap anymore.  */
 	  GL(dl_tls_dtv_gaps) = false;