2004-03-30  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/generic/libc-start.c (LIBC_START_MAIN)
	[HAVE_CLEANUP_JMP_BUF]: Call __nptl_deallocate_tsd.
This commit is contained in:
Ulrich Drepper 2004-03-31 01:47:34 +00:00
parent a70e964ee0
commit 3fa21fd813
9 changed files with 116 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2004-03-30 Ulrich Drepper <drepper@redhat.com>
* sysdeps/generic/libc-start.c (LIBC_START_MAIN)
[HAVE_CLEANUP_JMP_BUF]: Call __nptl_deallocate_tsd.
2004-03-30 Jakub Jelinek <jakub@redhat.com>
* nis/nss_nis/nis-service.c (_nss_nis_getservbyname_r): If protocol

View File

@ -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

View File

@ -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 \

View File

@ -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

View File

@ -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 */

View File

@ -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 ();

View File

@ -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. */

81
nptl/tst-tsd5.c Normal file
View File

@ -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"

View File

@ -210,6 +210,14 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
}
else
{
/* Remove the thread-local data. */
# ifdef SHARED
__libc_pthread_functions.ptr__nptl_deallocate_tsd ();
# else
extern void __nptl_deallocate_tsd (void) __attribute ((weak));
__nptl_deallocate_tsd ();
# endif
/* One less thread. Decrement the counter. If it is zero we
terminate the entire process. */
result = 0;