2003-03-14 Roland McGrath <roland@redhat.com>

* descr.h (struct pthread): Move the union out of [!TLS_DTV_AT_TP], so
	we always define the padding space.
	[!TLS_DTV_AT_TP]: Give tcbhead_t field a name, `header', since GCC
	stopped supporting its own extensions fully.
	[TLS_MULTIPLE_THREADS_IN_TCB]: Put `multiple_threads' inside a wrapper
	struct also called `header', so `header.multiple_threads' is the field
	name to use on all machines.
	* allocatestack.c (allocate_stack): Use `header.' prefix.
	* sysdeps/pthread/createthread.c (create_thread): Likewise.
	* pthread_create.c (__pthread_create_2_1): Likewise.
	* sysdeps/i386/tls.h (INSTALL_NEW_DTV, THREAD_DTV): Likewise.
	(THREAD_SELF): Likewise.
	* sysdeps/x86_64/tls.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
	(SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
	(SINGLE_THREAD_P): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
	(SINGLE_THREAD_P): Likewise.
This commit is contained in:
Roland McGrath 2003-03-14 22:34:02 +00:00
parent 0eb1828169
commit 55c11fbdb0
9 changed files with 35 additions and 25 deletions

View File

@ -321,14 +321,14 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* This is at least the second thread. */
pd->multiple_threads = 1;
pd->header.multiple_threads = 1;
#else
__pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
#endif
#ifdef NEED_DL_SYSINFO
/* Copy the sysinfo value from the parent. */
pd->sysinfo = THREAD_GETMEM (THREAD_SELF, sysinfo);
pd->header.sysinfo = THREAD_GETMEM (THREAD_SELF, header.sysinfo);
#endif
/* Allocate the DTV for this thread. */
@ -446,14 +446,14 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* This is at least the second thread. */
pd->multiple_threads = 1;
pd->header.multiple_threads = 1;
#else
__pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
#endif
#ifdef NEED_DL_SYSINFO
/* Copy the sysinfo value from the parent. */
pd->sysinfo = THREAD_GETMEM (THREAD_SELF, sysinfo);
pd->header.sysinfo = THREAD_GETMEM (THREAD_SELF, header.sysinfo);
#endif
/* Allocate the DTV for this thread. */

View File

@ -57,16 +57,24 @@
/* Thread descriptor data structure. */
struct pthread
{
#if !TLS_DTV_AT_TP
/* This overlaps tcbhead_t (see tls.h), as used for TLS without threads. */
union
{
tcbhead_t;
#if !TLS_DTV_AT_TP
/* This overlaps the TCB as used for TLS without threads (see tls.h). */
tcbhead_t header;
#elif TLS_MULTIPLE_THREADS_IN_TCB
struct
{
int multiple_threads;
} header;
#endif
/* This extra padding has no special purpose, and this structure layout
is private and subject to change without affecting the official ABI.
We just have it here in case it might be convenient for some
implementation-specific instrumentation hack or suchlike. */
void *__padding[16];
};
#elif TLS_MULTIPLE_THREADS_IN_TCB
int multiple_threads;
#endif
/* This descriptor's link on the `stack_used' or `__stack_user' list. */
list_t list;

View File

@ -347,10 +347,10 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
#ifdef TLS_TCB_AT_TP
/* Reference to the TCB itself. */
pd->self = pd;
pd->header.self = pd;
/* Self-reference for TLS. */
pd->tcb = pd;
pd->header.tcb = pd;
#endif
/* Store the address of the start routine and the parameter. Since

View File

@ -122,7 +122,7 @@ union user_desc_init
/* Install new dtv for current thread. */
# define INSTALL_NEW_DTV(dtvp) \
({ struct pthread *__pd; \
THREAD_SETMEM (__pd, dtv, (dtvp)); })
THREAD_SETMEM (__pd, header.dtv, (dtvp)); })
/* Return dtv of given thread descriptor. */
# define GET_DTV(descr) \
@ -228,7 +228,7 @@ union user_desc_init
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
({ struct pthread *__pd; \
THREAD_GETMEM (__pd, dtv); })
THREAD_GETMEM (__pd, header.dtv); })
/* Return the thread descriptor for the current thread.
@ -240,7 +240,7 @@ union user_desc_init
# define THREAD_SELF \
({ struct pthread *__self; \
asm ("movl %%gs:%c1,%0" : "=r" (__self) \
: "i" (offsetof (struct pthread, self))); \
: "i" (offsetof (struct pthread, header.self))); \
__self;})

View File

@ -55,7 +55,7 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
#endif
#ifdef TLS_TCB_AT_TP
assert (pd->tcb != NULL);
assert (pd->header.tcb != NULL);
#endif
if (__builtin_expect (THREAD_GETMEM (THREAD_SELF, report_events), 0))
@ -85,7 +85,7 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* We now have for sure more than one thread. */
pd->multiple_threads = 1;
pd->header.multiple_threads = 1;
#else
__pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
#endif
@ -114,7 +114,7 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
}
#ifdef NEED_DL_SYSINFO
assert (THREAD_GETMEM (THREAD_SELF, sysinfo) == pd->sysinfo);
assert (THREAD_GETMEM (THREAD_SELF, header.sysinfo) == pd->header.sysinfo);
#endif
/* We rely heavily on various flags the CLONE function understands:
@ -157,7 +157,7 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* We now have for sure more than one thread. */
THREAD_SETMEM (THREAD_SELF, multiple_threads, 1);
THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
#endif
return 0;

View File

@ -78,7 +78,8 @@
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, multiple_threads) == 0, 1)
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
# else
# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
# endif

View File

@ -81,7 +81,7 @@ L(pseudo_end):
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.data.multiple_threads) == 0, 1)
header.multiple_threads) == 0, 1)
# else
# define SINGLE_THREAD_P \
ear %r1,%a0; \

View File

@ -117,7 +117,8 @@
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, multiple_threads) == 0, 1)
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
# else
# define SINGLE_THREAD_P \
stc gbr,r0; \

View File

@ -92,7 +92,7 @@ typedef struct
/* Install new dtv for current thread. */
# define INSTALL_NEW_DTV(dtvp) \
({ struct pthread *__pd; \
THREAD_SETMEM (__pd, dtv, (dtvp)); })
THREAD_SETMEM (__pd, header.dtv, (dtvp)); })
/* Return dtv of given thread descriptor. */
# define GET_DTV(descr) \
@ -136,7 +136,7 @@ typedef struct
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
({ struct pthread *__pd; \
THREAD_GETMEM (__pd, dtv); })
THREAD_GETMEM (__pd, header.dtv); })
/* Return the thread descriptor for the current thread.
@ -148,7 +148,7 @@ typedef struct
# define THREAD_SELF \
({ struct pthread *__self; \
asm ("movq %%fs:%c1,%q0" : "=r" (__self) \
: "i" (offsetof (struct pthread, self))); \
: "i" (offsetof (struct pthread, header.self))); \
__self;})