diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-10-30 20:10:37 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2011-10-30 20:10:37 +0100 |
commit | 916e61485d5434e0b4052832ca331cf0eb315538 (patch) | |
tree | c747e26d7149265ecf07489d7a740a76e6a0138a /libpthread/pthread | |
parent | 532f60cb8ebdb47af86a4dbe7b551c5b5835f763 (diff) | |
parent | 221b60d8f0cf39511d26e275b3a0e26a4bdc4f15 (diff) |
Merge branch 'libpthread' into libpthread-moved
Diffstat (limited to 'libpthread/pthread')
-rw-r--r-- | libpthread/pthread/pt-create.c | 11 | ||||
-rw-r--r-- | libpthread/pthread/pt-exit.c | 8 | ||||
-rw-r--r-- | libpthread/pthread/pt-internal.h | 29 |
3 files changed, 45 insertions, 3 deletions
diff --git a/libpthread/pthread/pt-create.c b/libpthread/pthread/pt-create.c index 8f62b78e..346c6979 100644 --- a/libpthread/pthread/pt-create.c +++ b/libpthread/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/libpthread/pthread/pt-exit.c b/libpthread/pthread/pt-exit.c index 5fe0ba86..c01efda0 100644 --- a/libpthread/pthread/pt-exit.c +++ b/libpthread/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 @@ -35,7 +35,6 @@ pthread_exit (void *status) struct __pthread *self = _pthread_self (); struct __pthread_cancelation_handler **handlers; int oldstate; - int need_dealloc; /* Run any cancelation handlers. According to POSIX, the cancellation cleanup handlers should be called with cancellation @@ -70,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/libpthread/pthread/pt-internal.h b/libpthread/pthread/pt-internal.h index cb441d09..3f69d2dd 100644 --- a/libpthread/pthread/pt-internal.h +++ b/libpthread/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 */ |