From cd30b01ee9cdefd2e6f81b1c25ee6897243706fc Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 7 Feb 2002 08:44:37 +0000 Subject: Update. 2002-02-07 Ulrich Drepper * sysdeps/generic/dl-tls.c (_dl_determine_tlsoffset): Account for alignment of the TCB and store total size and alignment of static TLS block in _dl_tls_static_size and _dl_tls_static_align. tls_index is a typedef. * sysdeps/generic/ldsodefs.h: Declare _dl_tls_static_size and _dl_tls_static_align. * sysdeps/i386/dl-tls.h: tls_index is a typedef. * elf/dl-support.c: Define _dl_tls_static_size and _dl_tls_static_align. --- linuxthreads/descr.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'linuxthreads/descr.h') diff --git a/linuxthreads/descr.h b/linuxthreads/descr.h index 4cfad89dcb..a2cddb1212 100644 --- a/linuxthreads/descr.h +++ b/linuxthreads/descr.h @@ -165,4 +165,71 @@ struct _pthread_descr_struct { 32 bytes might give better cache utilization. */ + + +/* Limit between the stack of the initial thread (above) and the + stacks of other threads (below). Aligned on a STACK_SIZE boundary. + Initially 0, meaning that the current thread is (by definition) + the initial thread. */ + +extern char *__pthread_initial_thread_bos; + +/* Descriptor of the initial thread */ + +extern struct _pthread_descr_struct __pthread_initial_thread; + +/* Limits of the thread manager stack. */ + +extern char *__pthread_manager_thread_bos; +extern char *__pthread_manager_thread_tos; + +/* Descriptor of the manager thread */ + +extern struct _pthread_descr_struct __pthread_manager_thread; + +/* Indicate whether at least one thread has a user-defined stack (if 1), + or all threads have stacks supplied by LinuxThreads (if 0). */ + +extern int __pthread_nonstandard_stacks; + +/* The max size of the thread stack segments. If the default + THREAD_SELF implementation is used, this must be a power of two and + a multiple of PAGE_SIZE. */ +#ifndef STACK_SIZE +#define STACK_SIZE (2 * 1024 * 1024) +#endif + +/* Get some notion of the current stack. Need not be exactly the top + of the stack, just something somewhere in the current frame. */ +#ifndef CURRENT_STACK_FRAME +#define CURRENT_STACK_FRAME ({ char __csf; &__csf; }) +#endif + +/* Recover thread descriptor for the current thread */ + +extern pthread_descr __pthread_find_self (void) __attribute__ ((const)); + +static inline pthread_descr thread_self (void) __attribute__ ((const)); +static inline pthread_descr thread_self (void) +{ +#ifdef THREAD_SELF + return THREAD_SELF; +#else + char *sp = CURRENT_STACK_FRAME; + if (sp >= __pthread_initial_thread_bos) + return &__pthread_initial_thread; + else if (sp >= __pthread_manager_thread_bos + && sp < __pthread_manager_thread_tos) + return &__pthread_manager_thread; + else if (__pthread_nonstandard_stacks) + return __pthread_find_self(); + else +#ifdef _STACK_GROWS_DOWN + return (pthread_descr)(((unsigned long)sp | (STACK_SIZE-1))+1) - 1; +#else + return (pthread_descr)((unsigned long)sp &~ (STACK_SIZE-1)); +#endif +#endif +} + #endif /* descr.h */ -- cgit v1.2.3