about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog11
-rw-r--r--nptl/Makefile2
-rw-r--r--nptl/init.c3
-rw-r--r--nptl/pthreadP.h2
-rw-r--r--nptl/pthread_create.c8
-rw-r--r--nptl/sysdeps/pthread/pthread-functions.h3
-rw-r--r--nptl/tst-tsd5.c81
7 files changed, 103 insertions, 7 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 4e400f67f9..ccbaef276d 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,14 @@
+2004-03-30  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/pthread/pthread-functions.h: Add ptr__nptl_deallocate_tsd.
+	* init.c (pthread_functions): Add ptr__nptl_deallocate_tsd.
+	* pthreadP.h: Declare __nptl_deallocate_tsd.
+	* pthread_create.c (deallocate_tsd): Remove to __nptl_deallocate_tsd.
+	Adjust caller.
+
+	* Makefile (tests): Add tst-tsd5.
+	* tst-tsd5.c: New file.
+
 2004-03-29  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
diff --git a/nptl/Makefile b/nptl/Makefile
index c3bc89cb43..484824fea6 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -210,7 +210,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
 	tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \
 	tst-detach1 \
 	tst-eintr1 tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
-	tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 \
+	tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 \
 	tst-tls1 tst-tls2 \
 	tst-fork1 tst-fork2 tst-fork3 tst-fork4 \
 	tst-atfork1 \
diff --git a/nptl/init.c b/nptl/init.c
index 47bb0a6f72..e58dae0ba6 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -130,7 +130,8 @@ static const struct pthread_functions pthread_functions =
     .ptr__pthread_cleanup_push_defer = __pthread_cleanup_push_defer,
     .ptr__pthread_cleanup_pop_restore = __pthread_cleanup_pop_restore,
     .ptr_nthreads = &__nptl_nthreads,
-    .ptr___pthread_unwind = &__pthread_unwind
+    .ptr___pthread_unwind = &__pthread_unwind,
+    .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd
   };
 # define ptr_pthread_functions &pthread_functions
 #else
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index ba9529f01b..c0941f0cf5 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -439,4 +439,6 @@ extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
 extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
                                           int execute);
 
+extern void __nptl_deallocate_tsd (void) attribute_hidden;
+
 #endif	/* pthreadP.h */
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 014c41b7a4..34edee498f 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -102,9 +102,9 @@ __find_in_stack_list (pd)
 
 
 /* Deallocate POSIX thread-local-storage.  */
-static void
-internal_function
-deallocate_tsd (void)
+void
+attribute_hidden
+__nptl_deallocate_tsd (void)
 {
   struct pthread *self = THREAD_SELF;
 
@@ -268,7 +268,7 @@ start_thread (void *arg)
     }
 
   /* Run the destructor for the thread-local data.  */
-  deallocate_tsd ();
+  __nptl_deallocate_tsd ();
 
   /* Clean up any state libc stored in thread-local variables.  */
   __libc_thread_freeres ();
diff --git a/nptl/sysdeps/pthread/pthread-functions.h b/nptl/sysdeps/pthread/pthread-functions.h
index 38155e240f..23af214518 100644
--- a/nptl/sysdeps/pthread/pthread-functions.h
+++ b/nptl/sysdeps/pthread/pthread-functions.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -92,6 +92,7 @@ struct pthread_functions
   int *ptr_nthreads;
   void (*ptr___pthread_unwind) (__pthread_unwind_buf_t *)
        __attribute ((noreturn)) __cleanup_fct_attribute;
+  void (*ptr__nptl_deallocate_tsd) (void);
 };
 
 /* Variable in libc.so.  */
diff --git a/nptl/tst-tsd5.c b/nptl/tst-tsd5.c
new file mode 100644
index 0000000000..8793e339a4
--- /dev/null
+++ b/nptl/tst-tsd5.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void
+cl (void *p)
+{
+  pthread_mutex_unlock (&m);
+}
+
+
+static void *
+tf (void *arg)
+{
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("2nd mutex_lock failed");
+      exit (1);
+    }
+
+  exit (0);
+}
+
+
+static int
+do_test (void)
+{
+  pthread_key_t k;
+  if (pthread_key_create (&k, cl) != 0)
+    {
+      puts ("key_create failed");
+      return 1;
+    }
+  if (pthread_setspecific (k, (void *) 1) != 0)
+    {
+      puts ("setspecific failed");
+      return 1;
+    }
+
+  if (pthread_mutex_lock (&m) != 0)
+    {
+      puts ("1st mutex_lock failed");
+      return 1;
+    }
+
+  pthread_t th;
+  if (pthread_create (&th, NULL, tf, NULL) != 0)
+    {
+      puts ("create failed");
+      return 1;
+    }
+
+  pthread_exit (NULL);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"