{
struct pthread *curr;
- curr = list_entry (entry, struct pthread, header.data.list);
+ curr = list_entry (entry, struct pthread, list);
if (FREE_P (curr) && curr->stackblock_size >= size)
{
if (curr->stackblock_size == size)
}
/* Dequeue the entry. */
- list_del (&result->header.data.list);
+ list_del (&result->list);
/* And add to the list of stacks in use. */
- list_add (&result->header.data.list, &stack_used);
+ list_add (&result->list, &stack_used);
/* And decrease the cache size. */
stack_cache_actsize -= result->stackblock_size;
/* We unconditionally add the stack to the list. The memory may
still be in use but it will not be reused until the kernel marks
the stack as not used anymore. */
- list_add (&stack->header.data.list, &stack_cache);
+ list_add (&stack->list, &stack_cache);
stack_cache_actsize += stack->stackblock_size;
if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0))
{
struct pthread *curr;
- curr = list_entry (entry, struct pthread, header.data.list);
+ curr = list_entry (entry, struct pthread, list);
if (FREE_P (curr))
{
/* Unlink the block. */
stack cache nor will the memory (except the TLS memory) be freed. */
pd->user_stack = true;
+#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* This is at least the second thread. */
- pd->header.data.multiple_threads = 1;
+ pd->multiple_threads = 1;
+#else
+ __pthread_multiple_threads = __libc_multiple_threads = 1;
+#endif
#ifdef NEED_DL_SYSINFO
/* Copy the sysinfo value from the parent. */
- pd->header.data.sysinfo
- = THREAD_GETMEM (THREAD_SELF, header.data.sysinfo);
+ pd->sysinfo = THREAD_GETMEM (THREAD_SELF, sysinfo);
#endif
/* Allocate the DTV for this thread. */
lll_lock (stack_cache_lock);
/* And add to the list of stacks in use. */
- list_add (&pd->header.data.list, &__stack_user);
+ list_add (&pd->list, &__stack_user);
lll_unlock (stack_cache_lock);
}
pd->lock = LLL_LOCK_INITIALIZER;
#endif
+#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* This is at least the second thread. */
- pd->header.data.multiple_threads = 1;
+ pd->multiple_threads = 1;
+#else
+ __pthread_multiple_threads = __libc_multiple_threads = 1;
+#endif
#ifdef NEED_DL_SYSINFO
/* Copy the sysinfo value from the parent. */
- pd->header.data.sysinfo
- = THREAD_GETMEM (THREAD_SELF, header.data.sysinfo);
+ pd->sysinfo = THREAD_GETMEM (THREAD_SELF, sysinfo);
#endif
/* Allocate the DTV for this thread. */
lll_lock (stack_cache_lock);
/* And add to the list of stacks in use. */
- list_add (&pd->header.data.list, &stack_used);
+ list_add (&pd->list, &stack_used);
lll_unlock (stack_cache_lock);
lll_lock (stack_cache_lock);
/* Remove the thread from the list. */
- list_del (&pd->header.data.list);
+ list_del (&pd->list);
lll_unlock (stack_cache_lock);
/* Remove the thread from the list of threads with user defined
stacks. */
- list_del (&pd->header.data.list);
+ list_del (&pd->list);
/* Not much to do. Just free the mmap()ed memory. Note that we do
not reset the 'used' flag in the 'tid' field. This is done by
{
struct pthread *curp;
- curp = list_entry (runp, struct pthread, header.data.list);
+ curp = list_entry (runp, struct pthread, list);
if (curp != self)
{
/* This marks the stack as free. */
/* Remove the entry for the current thread to from the cache list
and add it to the list of running threads. Which of the two
lists is decided by the user_stack flag. */
- list_del (&self->header.data.list);
+ list_del (&self->list);
/* Re-initialize the lists for all the threads. */
INIT_LIST_HEAD (&stack_used);
INIT_LIST_HEAD (&__stack_user);
if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0))
- list_add (&self->header.data.list, &__stack_user);
+ list_add (&self->list, &__stack_user);
else
- list_add (&self->header.data.list, &stack_used);
+ list_add (&self->list, &stack_used);
/* There is one thread running. */
__nptl_nthreads = 1;
#include <pthreaddef.h>
#include <dl-sysdep.h>
#include "../nptl_db/thread_db.h"
+#include <tls.h>
#ifndef TCB_ALIGNMENT
/* Thread descriptor data structure. */
struct pthread
{
- /* XXX Remove this union for IA-64 style TLS module */
+#if !TLS_DTV_AT_TP
+ /* This overlaps tcbhead_t (see tls.h), as used for TLS without threads. */
union
{
- /* It is very important to always append new elements. The offsets
- of some of the elements of the struct are used in assembler code. */
- struct
- {
- void *tcb; /* Pointer to the TCB. This is not always
- the address of this thread descriptor. */
- union dtv *dtvp;
- struct pthread *self; /* Pointer to this structure */
- int multiple_threads;
-#ifdef NEED_DL_SYSINFO
- uintptr_t sysinfo;
-#endif
- list_t list;
- } data;
+ tcbhead_t;
void *__padding[16];
- } header;
+ };
+#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;
/* Thread ID - which is also a 'is this thread descriptor (and
therefore stack) used' flag. */
/* Initialize the list of all running threads with the main thread. */
INIT_LIST_HEAD (&__stack_user);
- list_add (&pd->header.data.list, &__stack_user);
+ list_add (&pd->list, &__stack_user);
/* Install the cancellation signal handler. If for some reason we
{
struct pthread *curp;
- curp = list_entry (entry, struct pthread, header.data.list);
+ curp = list_entry (entry, struct pthread, list);
if (curp == pd)
{
result = curp;
{
struct pthread *curp;
- curp = list_entry (entry, struct pthread, header.data.list);
+ curp = list_entry (entry, struct pthread, list);
if (curp == pd)
{
result = curp;
the stack freshly allocated with 'mmap'. */
/* Reference to the TCB itself. */
- pd->header.data.self = pd;
+ pd->self = pd;
#ifdef TLS_TCB_AT_TP
- /* Self-reference. */
- pd->header.data.tcb = pd;
+ /* Self-reference for TLS. */
+ pd->tcb = pd;
#endif
/* Store the address of the start routine and the parameter. Since
void *self; /* Pointer to the thread descriptor. */
int multiple_threads;
uintptr_t sysinfo;
- list_t list;
} tcbhead_t;
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
#else /* __ASSEMBLER__ */
# include <tcb-offsets.h>
#endif
/* Install the dtv pointer. The pointer passed is to the element with
index -1 which contain the length. */
# define INSTALL_DTV(descr, dtvp) \
- ((tcbhead_t *) (descr))->dtv = dtvp + 1
+ ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
/* Install new dtv for current thread. */
-# define INSTALL_NEW_DTV(dtv) \
+# define INSTALL_NEW_DTV(dtvp) \
({ struct pthread *__pd; \
- THREAD_SETMEM (__pd, header.data.dtvp, dtv); })
+ THREAD_SETMEM (__pd, dtv, (dtvp)); })
/* Return dtv of given thread descriptor. */
# define GET_DTV(descr) \
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
({ struct pthread *__pd; \
- THREAD_GETMEM (__pd, header.data.dtvp); })
+ THREAD_GETMEM (__pd, dtv); })
/* Return the thread descriptor for the current thread.
# define THREAD_SELF \
({ struct pthread *__self; \
asm ("movl %%gs:%c1,%0" : "=r" (__self) \
- : "i" (offsetof (struct pthread, header.data.self))); \
+ : "i" (offsetof (struct pthread, self))); \
__self;})
PREPARE_CREATE;
#endif
- assert (pd->header.data.tcb != NULL);
+ assert (pd->tcb != NULL);
if (__builtin_expect (THREAD_GETMEM (THREAD_SELF, report_events), 0))
/* Failed. */
return errno;
+#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* We now have for sure more than one thread. */
- pd->header.data.multiple_threads = 1;
+ pd->multiple_threads = 1;
+#else
+ __pthread_multiple_threads = __libc_multiple_threads = 1;
+#endif
/* Now fill in the information about the new thread in
the newly created thread's data structure. We cannot let
}
#ifdef NEED_DL_SYSINFO
- assert (THREAD_GETMEM (THREAD_SELF, header.data.sysinfo)
- == pd->header.data.sysinfo);
+ assert (THREAD_GETMEM (THREAD_SELF, sysinfo) == pd->sysinfo);
#endif
/* We rely heavily on various flags the CLONE function understands:
/* Failed. */
return errno;
+#ifdef TLS_MULTIPLE_THREADS_IN_TCB
/* We now have for sure more than one thread. */
- THREAD_SETMEM (THREAD_SELF, header.data.multiple_threads, 1);
+ THREAD_SETMEM (THREAD_SELF, multiple_threads, 1);
+#endif
return 0;
}
#ifdef NEED_DL_SYSINFO
uintptr_t sysinfo;
#endif
- list_t list;
} tcbhead_t;
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
#else /* __ASSEMBLER__ */
# include <tcb-offsets.h>
#endif
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.data.multiple_threads) == 0, 1)
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, multiple_threads) == 0, 1)
# else
# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
# endif
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.data.multiple_threads) == 0, 1)
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, multiple_threads) == 0, 1)
# else
# define SINGLE_THREAD_P \
stc gbr,r0; \
/* Install the dtv pointer. The pointer passed is to the element with
index -1 which contain the length. */
# define INSTALL_DTV(descr, dtvp) \
- ((tcbhead_t *) (descr))->dtv = dtvp + 1
+ ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
/* Install new dtv for current thread. */
-# define INSTALL_NEW_DTV(dtv) \
+# define INSTALL_NEW_DTV(dtvp) \
({ struct pthread *__pd; \
- THREAD_SETMEM (__pd, header.data.dtvp, dtv); })
+ THREAD_SETMEM (__pd, dtv, (dtvp)); })
/* Return dtv of given thread descriptor. */
# define GET_DTV(descr) \
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
({ struct pthread *__pd; \
- THREAD_GETMEM (__pd, header.data.dtvp); })
+ THREAD_GETMEM (__pd, dtv); })
/* Return the thread descriptor for the current thread.
# define THREAD_SELF \
({ struct pthread *__self; \
asm ("movq %%fs:%c1,%0" : "=r" (__self) \
- : "i" (offsetof (struct pthread, header.data.self))); \
+ : "i" (offsetof (struct pthread, self))); \
__self;})