diff options
author | Thomas Schwinge <thomas@schwinge.name> | 2011-10-20 17:04:43 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@schwinge.name> | 2011-10-20 17:07:46 +0200 |
commit | 081c7aeb4d4de82ab615db565c60dd776a385c34 (patch) | |
tree | 2730963b4c865851b0a17d65d03ba7131245785f /pthread | |
parent | 75f6fe21205a87d1942492cb34e8aab482008a78 (diff) | |
parent | 577976c386d89696ec392fdfbb77ea153ddd6588 (diff) |
Merge branch 'tls'
Conflicts:
ChangeLog
Makefile
pthread/pt-exit.c
pthread/pt-internal.h
sysdeps/mach/hurd/ia32/pt-setup.c
sysdeps/mach/hurd/pt-docancel.c
sysdeps/mach/hurd/pt-sysdep.h
Diffstat (limited to 'pthread')
-rw-r--r-- | pthread/pt-create.c | 11 | ||||
-rw-r--r-- | pthread/pt-exit.c | 7 | ||||
-rw-r--r-- | pthread/pt-internal.h | 29 |
3 files changed, 45 insertions, 2 deletions
diff --git a/pthread/pt-create.c b/pthread/pt-create.c index 8f62b78..346c697 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -129,6 +129,13 @@ __pthread_create_internal (struct __pthread **thread, if (err) goto failed_thread_alloc; +#ifdef ENABLE_TLS + pthread->tcb = _dl_allocate_tls (NULL); + if (!pthread->tcb) + goto failed_thread_tls_alloc; + pthread->tcb->tcb = pthread->tcb; +#endif /* ENABLE_TLS */ + /* And initialize the rest of the machine context. This may include additional machine- and system-specific initializations that prove convenient. */ @@ -194,6 +201,10 @@ __pthread_create_internal (struct __pthread **thread, failed_sigstate: __pthread_sigstate_destroy (pthread); failed_setup: +#ifdef ENABLE_TLS + _dl_deallocate_tls (pthread->tcb, 1); + failed_thread_tls_alloc: +#endif /* ENABLE_TLS */ __pthread_thread_dealloc (pthread); __pthread_thread_halt (pthread); failed_thread_alloc: diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index 3b3853e..c01efda 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -1,5 +1,5 @@ /* Thread termination. - Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2005, 2007, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -69,6 +69,11 @@ pthread_exit (void *status) if (self->cancel_state == PTHREAD_CANCEL_ENABLE && self->cancel_pending) status = PTHREAD_CANCELED; +#ifdef ENABLE_TLS + if (self->tcb) + _dl_deallocate_tls (self->tcb, 1); +#endif /* ENABLE_TLS */ + switch (self->state) { default: diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index cb441d0..3f69d2d 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -1,5 +1,5 @@ /* Internal defenitions for pthreads library. - Copyright (C) 2000, 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2000, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -54,6 +54,16 @@ enum pthread_state # define PTHREAD_SYSDEP_MEMBERS #endif +#ifdef ENABLE_TLS +/* Type of the TCB. */ +typedef struct +{ + void *tcb; /* Points to this structure. */ + void *dtv; /* Vector of pointers to TLS data. */ + thread_t self; /* This thread's control port. */ +} tcbhead_t; +#endif /* ENABLE_TLS */ + /* This structure describes a POSIX thread. */ struct __pthread { @@ -89,6 +99,10 @@ struct __pthread PTHREAD_SYSDEP_MEMBERS +#ifdef ENABLE_TLS + tcbhead_t *tcb; +#endif /* ENABLE_TLS */ + struct __pthread *next, **prevp; }; @@ -287,4 +301,17 @@ const struct __pthread_rwlockattr __pthread_default_rwlockattr; /* Default condition attributes. */ const struct __pthread_condattr __pthread_default_condattr; + +#ifdef ENABLE_TLS + +/* From glibc. */ + +/* Dynamic linker TLS allocation. */ +extern void *_dl_allocate_tls(void *); + +/* Dynamic linker TLS deallocation. */ +extern void _dl_deallocate_tls(void *, int); + +#endif /* ENABLE_TLS */ + #endif /* pt-internal.h */ |