[Glibc-bsd-commits] r4503 - trunk/glibc-ports/linuxthreads
Petr Salinger
ps-guest at alioth.debian.org
Thu May 30 16:21:27 UTC 2013
Author: ps-guest
Date: 2013-05-30 16:21:27 +0000 (Thu, 30 May 2013)
New Revision: 4503
Modified:
trunk/glibc-ports/linuxthreads/attr.c
trunk/glibc-ports/linuxthreads/descr.h
trunk/glibc-ports/linuxthreads/errno.c
trunk/glibc-ports/linuxthreads/internals.h
trunk/glibc-ports/linuxthreads/libc-tls-loc.c
trunk/glibc-ports/linuxthreads/libc-tsd.c
trunk/glibc-ports/linuxthreads/libc_pthread_init.c
trunk/glibc-ports/linuxthreads/pthread.c
trunk/glibc-ports/linuxthreads/restart.h
trunk/glibc-ports/linuxthreads/specific.c
trunk/glibc-ports/linuxthreads/tst-context.c
trunk/glibc-ports/linuxthreads/tst-tls1.h
Log:
part 1 of "these are now mandatory":
USE___THREAD
HAVE_TLS_SUPPORT
FLOATING_STACKS
USE_TLS
HAVE___THREAD
HAVE_Z_NODELETE
__ASSUME_REALTIME_SIGNALS
Modified: trunk/glibc-ports/linuxthreads/attr.c
===================================================================
--- trunk/glibc-ports/linuxthreads/attr.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/attr.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -208,7 +208,6 @@
int __pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
{
-#ifdef FLOATING_STACKS
/* We have to check against the maximum allowed stack size. This is no
problem if the manager is already started and we determined it. If
this hasn't happened, we have to find the limit outself. */
@@ -217,11 +216,6 @@
if (stacksize > __pthread_max_stacksize)
return EINVAL;
-#else
- /* We have a fixed size limit. */
- if (stacksize > STACK_SIZE)
- return EINVAL;
-#endif
/* We don't accept value smaller than PTHREAD_STACK_MIN. */
if (stacksize < PTHREAD_STACK_MIN)
@@ -241,7 +235,6 @@
int __old_pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
{
-# ifdef FLOATING_STACKS
/* We have to check against the maximum allowed stack size. This is no
problem if the manager is already started and we determined it. If
this hasn't happened, we have to find the limit outself. */
@@ -250,11 +243,6 @@
if (stacksize > __pthread_max_stacksize)
return EINVAL;
-# else
- /* We have a fixed size limit. */
- if (stacksize > STACK_SIZE)
- return EINVAL;
-# endif
/* We don't accept value smaller than old PTHREAD_STACK_MIN. */
if (stacksize < 16384)
@@ -377,19 +365,10 @@
attr->__scope = PTHREAD_SCOPE_SYSTEM;
#ifdef _STACK_GROWS_DOWN
-# ifdef USE_TLS
attr->__stacksize = descr->p_stackaddr - (char *)descr->p_guardaddr
- descr->p_guardsize;
-# else
- attr->__stacksize = (char *)(descr + 1) - (char *)descr->p_guardaddr
- - descr->p_guardsize;
-# endif
#else
-# ifdef USE_TLS
attr->__stacksize = (char *)descr->p_guardaddr - descr->p_stackaddr;
-# else
- attr->__stacksize = (char *)descr->p_guardaddr - (char *)descr;
-# endif
#endif
attr->__guardsize = descr->p_guardsize;
attr->__stackaddr_set = descr->p_userstack;
@@ -401,21 +380,8 @@
otherwise the range of the stack area cannot be computed. */
attr->__stacksize += attr->__guardsize;
#endif
-#ifdef USE_TLS
attr->__stackaddr = descr->p_stackaddr;
-#else
-# ifndef _STACK_GROWS_UP
- attr->__stackaddr = (char *)(descr + 1);
-# else
- attr->__stackaddr = (char *)descr;
-# endif
-#endif
-
-#ifdef USE_TLS
if (attr->__stackaddr == NULL)
-#else
- if (descr == &__pthread_initial_thread)
-#endif
{
/* Stack size limit. */
struct rlimit rl;
Modified: trunk/glibc-ports/linuxthreads/descr.h
===================================================================
--- trunk/glibc-ports/linuxthreads/descr.h 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/descr.h 2013-05-30 16:21:27 UTC (rev 4503)
@@ -109,7 +109,7 @@
struct _pthread_descr_struct
{
-#if !defined USE_TLS || !TLS_DTV_AT_TP || INCLUDE_TLS_PADDING
+#if !TLS_DTV_AT_TP || INCLUDE_TLS_PADDING
/* This overlaps tcbhead_t (see tls.h), as used for TLS without threads. */
union
{
@@ -156,14 +156,6 @@
char p_sigwaiting; /* true if a sigwait() is in progress */
struct pthread_start_args p_start_args; /* arguments for thread creation */
void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE]; /* thread-specific data */
-#if !(USE_TLS && HAVE___THREAD)
- void * p_libc_specific[_LIBC_TSD_KEY_N]; /* thread-specific data for libc */
- int * p_errnop; /* pointer to used errno variable */
- int p_errno; /* error returned by last system call */
- int * p_h_errnop; /* pointer to used h_errno variable */
- int p_h_errno; /* error returned by last netdb function */
- struct __res_state *p_resp; /* Pointer to resolver state */
-#endif
struct __res_state p_res; /* per-thread resolver state */
int p_userstack; /* nonzero if the user provided the stack */
void *p_guardaddr; /* address of guard area or NULL */
@@ -184,9 +176,7 @@
#if HP_TIMING_AVAIL
hp_timing_t p_cpuclock_offset; /* Initial CPU clock for thread. */
#endif
-#ifdef USE_TLS
char *p_stackaddr; /* Stack address. */
-#endif
size_t p_alloca_cutoff; /* Maximum size which should be allocated
using alloca() instead of malloc(). */
/* New elements must be added at the end. */
Modified: trunk/glibc-ports/linuxthreads/errno.c
===================================================================
--- trunk/glibc-ports/linuxthreads/errno.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/errno.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -21,27 +21,4 @@
#include "pthread.h"
#include "internals.h"
-#if !USE_TLS || !HAVE___THREAD
/* The definition in libc is sufficient if we use TLS. */
-int *
-__errno_location (void)
-{
- pthread_descr self = thread_self();
- return THREAD_GETMEM (self, p_errnop);
-}
-
-int *
-__h_errno_location (void)
-{
- pthread_descr self = thread_self();
- return THREAD_GETMEM (self, p_h_errnop);
-}
-
-/* Return thread specific resolver state. */
-struct __res_state *
-__res_state (void)
-{
- pthread_descr self = thread_self();
- return THREAD_GETMEM (self, p_resp);
-}
-#endif
Modified: trunk/glibc-ports/linuxthreads/internals.h
===================================================================
--- trunk/glibc-ports/linuxthreads/internals.h 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/internals.h 2013-05-30 16:21:27 UTC (rev 4503)
@@ -45,7 +45,7 @@
# define THREAD_SETMEM_NC(descr, member, value) descr->member = (value)
#endif
-#if !defined NOT_IN_libc && defined FLOATING_STACKS
+#if !defined NOT_IN_libc
# define LIBC_THREAD_GETMEM(descr, member) THREAD_GETMEM (descr, member)
# define LIBC_THREAD_SETMEM(descr, member, value) \
THREAD_SETMEM (descr, member, value)
@@ -144,10 +144,8 @@
extern int __pthread_manager_reader;
-#ifdef FLOATING_STACKS
/* Maximum stack size. */
extern size_t __pthread_max_stacksize;
-#endif
/* Pending request for a process-wide exit */
@@ -511,21 +509,7 @@
extern int * __libc_pthread_init (const struct pthread_functions *functions);
-#if !defined NOT_IN_libc && !defined FLOATING_STACKS
-# ifdef SHARED
-# define thread_self() \
- (*__libc_pthread_functions.ptr_pthread_thread_self) ()
-# else
-weak_extern (__pthread_thread_self)
-# define thread_self() __pthread_thread_self ()
-# endif
-#endif
-
-#ifndef USE_TLS
-# define __manager_thread (&__pthread_manager_thread)
-#else
# define __manager_thread __pthread_manager_threadp
-#endif
extern inline __attribute__((always_inline)) pthread_descr
check_thread_self (void)
Modified: trunk/glibc-ports/linuxthreads/libc-tls-loc.c
===================================================================
--- trunk/glibc-ports/linuxthreads/libc-tls-loc.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/libc-tls-loc.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -19,7 +19,6 @@
#include <tls.h>
-#if USE___THREAD
# include <errno.h>
# include <netdb.h>
# include <resolv.h>
@@ -45,5 +44,3 @@
{
return __resp;
}
-
-#endif
Modified: trunk/glibc-ports/linuxthreads/libc-tsd.c
===================================================================
--- trunk/glibc-ports/linuxthreads/libc-tsd.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/libc-tsd.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -20,19 +20,6 @@
#include <tls.h>
#include <resolv.h>
-#if ! USE___THREAD
-
-/* Special hack used to build link-time libc.so object for linking libpthread.
- See Makefile comments near libc_pic_lite.os rule for what this is for. */
-
-# undef _res
-
-int _errno;
-int _h_errno;
-struct __res_state _res;
-
-#endif
-
int
__res_maybe_init (res_state resp, int preinit)
{
Modified: trunk/glibc-ports/linuxthreads/libc_pthread_init.c
===================================================================
--- trunk/glibc-ports/linuxthreads/libc_pthread_init.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/libc_pthread_init.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -36,11 +36,5 @@
sizeof (__libc_pthread_functions));
#endif
-#if !(USE_TLS && HAVE___THREAD)
- /* Initialize thread-locale current locale to point to the global one.
- With __thread support, the variable's initializer takes care of this. */
- __uselocale (LC_GLOBAL_LOCALE);
-#endif
-
return &__libc_multiple_threads;
}
Modified: trunk/glibc-ports/linuxthreads/pthread.c
===================================================================
--- trunk/glibc-ports/linuxthreads/pthread.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/pthread.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -41,72 +41,14 @@
# error "This must not happen"
#endif
-#if !(USE_TLS && HAVE___THREAD)
-/* These variables are used by the setup code. */
-extern int _errno;
-extern int _h_errno;
-
-/* We need the global/static resolver state here. */
-# include <resolv.h>
-# undef _res
-
-extern struct __res_state _res;
-#endif
-
-#ifdef USE_TLS
-
/* We need only a few variables. */
#define manager_thread __pthread_manager_threadp
pthread_descr __pthread_manager_threadp attribute_hidden;
-#else
-
-/* Descriptor of the initial thread */
-
-struct _pthread_descr_struct __pthread_initial_thread = {
- .p_header.data.self = &__pthread_initial_thread,
- .p_nextlive = &__pthread_initial_thread,
- .p_prevlive = &__pthread_initial_thread,
- .p_tid = PTHREAD_THREADS_MAX,
- .p_lock = &__pthread_handles[0].h_lock,
- .p_start_args = PTHREAD_START_ARGS_INITIALIZER(NULL),
-#if !(USE_TLS && HAVE___THREAD)
- .p_errnop = &_errno,
- .p_h_errnop = &_h_errno,
- .p_resp = &_res,
-#endif
- .p_userstack = 1,
- .p_resume_count = __ATOMIC_INITIALIZER,
- .p_alloca_cutoff = __MAX_ALLOCA_CUTOFF
-};
-
-/* Descriptor of the manager thread; none of this is used but the error
- variables, the p_pid and p_priority fields,
- and the address for identification. */
-
-#define manager_thread (&__pthread_manager_thread)
-struct _pthread_descr_struct __pthread_manager_thread = {
- .p_header.data.self = &__pthread_manager_thread,
- .p_header.data.multiple_threads = 1,
- .p_lock = &__pthread_handles[1].h_lock,
- .p_start_args = PTHREAD_START_ARGS_INITIALIZER(__pthread_manager),
-#if !(USE_TLS && HAVE___THREAD)
- .p_errnop = &__pthread_manager_thread.p_errno,
-#endif
- .p_nr = 1,
- .p_resume_count = __ATOMIC_INITIALIZER,
- .p_alloca_cutoff = PTHREAD_STACK_MIN / 4
-};
-#endif
-
/* Pointer to the main thread (the father of the thread manager thread) */
/* Originally, this is the initial thread, but this changes after fork() */
-#ifdef USE_TLS
pthread_descr __pthread_main_thread;
-#else
-pthread_descr __pthread_main_thread = &__pthread_initial_thread;
-#endif
/* Limit between the stack of the initial thread (above) and the
stacks of other threads (below). Aligned on a STACK_SIZE boundary. */
@@ -140,16 +82,6 @@
/* Nozero if the machine has more than one processor. */
int __pthread_smp_kernel;
-
-#if !__ASSUME_REALTIME_SIGNALS
-/* Pointers that select new or old suspend/resume functions
- based on availability of rt signals. */
-
-void (*__pthread_restart)(pthread_descr) = __pthread_restart_old;
-void (*__pthread_suspend)(pthread_descr) = __pthread_suspend_old;
-int (*__pthread_timedsuspend)(pthread_descr, const struct timespec *) = __pthread_timedsuspend_old;
-#endif /* __ASSUME_REALTIME_SIGNALS */
-
/* Communicate relevant LinuxThreads constants to gdb */
const int __pthread_threads_max = PTHREAD_THREADS_MAX;
@@ -168,10 +100,6 @@
/* Forward declarations */
static void pthread_onexit_process(int retcode, void *arg);
-#ifndef HAVE_Z_NODELETE
-static void pthread_atexit_process(void *arg, int retcode);
-static void pthread_atexit_retcode(void *arg, int retcode);
-#endif
static void pthread_handle_sigcancel(int sig);
static void pthread_handle_sigrestart(int sig);
static void pthread_handle_sigdebug(int sig);
@@ -193,35 +121,6 @@
extern int __libc_current_sigrtmin_private (void);
-#if !__ASSUME_REALTIME_SIGNALS
-static int rtsigs_initialized;
-
-static void
-init_rtsigs (void)
-{
- if (rtsigs_initialized)
- return;
-
- if (__libc_current_sigrtmin_private () == -1)
- {
-#ifndef PTHREAD_SIGBASE
- __pthread_sig_restart = SIGUSR1;
- __pthread_sig_cancel = SIGUSR2;
- __pthread_sig_debug = 0;
-#endif
- }
- else
- {
- __pthread_restart = __pthread_restart_new;
- __pthread_suspend = __pthread_wait_for_restart_signal;
- __pthread_timedsuspend = __pthread_timedsuspend_new;
- }
-
- rtsigs_initialized = 1;
-}
-#endif
-
-
/* Initialize the pthread library.
Initialization is split in two functions:
- a constructor function that blocks the __pthread_sig_restart signal
@@ -231,22 +130,12 @@
static void pthread_initialize(void) __attribute__((constructor));
-#ifndef HAVE_Z_NODELETE
-extern void *__dso_handle __attribute__ ((weak));
-#endif
-
-
-#if defined USE_TLS && !defined SHARED
+#if !defined SHARED
extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
#endif
struct pthread_functions __pthread_functions =
{
-#if !(USE_TLS && HAVE___THREAD)
- .ptr_pthread_internal_tsd_set = __pthread_internal_tsd_set,
- .ptr_pthread_internal_tsd_get = __pthread_internal_tsd_get,
- .ptr_pthread_internal_tsd_address = __pthread_internal_tsd_address,
-#endif
.ptr_pthread_fork = __pthread_fork,
.ptr_pthread_attr_destroy = __pthread_attr_destroy,
#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)
@@ -305,7 +194,6 @@
void
__pthread_initialize_minimal(void)
{
-#ifdef USE_TLS
pthread_descr self;
/* First of all init __pthread_handles[0] and [1] if needed. */
@@ -317,51 +205,6 @@
/* Unlike in the dynamically linked case the dynamic linker has not
taken care of initializing the TLS data structures. */
__libc_setup_tls (TLS_TCB_SIZE, TLS_TCB_ALIGN);
-# elif !USE___THREAD
- if (__builtin_expect (GL(dl_tls_dtv_slotinfo_list) == NULL, 0))
- {
- tcbhead_t *tcbp;
-
- /* There is no actual TLS being used, so the thread register
- was not initialized in the dynamic linker. */
-
- /* We need to install special hooks so that the malloc and memalign
- calls in _dl_tls_setup and _dl_allocate_tls won't cause full
- malloc initialization that will try to set up its thread state. */
-
- extern void __libc_malloc_pthread_startup (bool first_time);
- __libc_malloc_pthread_startup (true);
-
- if (__builtin_expect (_dl_tls_setup (), 0)
- || __builtin_expect ((tcbp = _dl_allocate_tls (NULL)) == NULL, 0))
- {
- static const char msg[] = "\
-cannot allocate TLS data structures for initial thread\n";
- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
- msg, sizeof msg - 1));
- abort ();
- }
- const char *lossage = TLS_INIT_TP (tcbp, 0);
- if (__builtin_expect (lossage != NULL, 0))
- {
- static const char msg[] = "cannot set up thread-local storage: ";
- const char nl = '\n';
- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
- msg, sizeof msg - 1));
- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO,
- lossage, strlen (lossage)));
- TEMP_FAILURE_RETRY (write_not_cancel (STDERR_FILENO, &nl, 1));
- }
-
- /* Though it was allocated with libc's malloc, that was done without
- the user's __malloc_hook installed. A later realloc that uses
- the hooks might not work with that block from the plain malloc.
- So we record this block as unfreeable just as the dynamic linker
- does when it allocates the DTV before the libc malloc exists. */
- GL(dl_initial_dtv) = GET_DTV (tcbp);
-
- __libc_malloc_pthread_startup (false);
- }
# endif
self = THREAD_SELF;
@@ -373,10 +216,6 @@
self->p_nextlive = self->p_prevlive = self;
self->p_tid = PTHREAD_THREADS_MAX;
self->p_lock = &__pthread_handles[0].h_lock;
-# ifndef HAVE___THREAD
- self->p_errnop = &_errno;
- self->p_h_errnop = &_h_errno;
-# endif
/* self->p_start_args need not be initialized, it's all zero. */
self->p_userstack = 1;
# if __LT_SPINLOCK_INIT != 0
@@ -390,29 +229,8 @@
/* And fill in the pointer the the thread __pthread_handles array. */
__pthread_handles[0].h_descr = self;
-#else /* USE_TLS */
-
- /* First of all init __pthread_handles[0] and [1]. */
-# if __LT_SPINLOCK_INIT != 0
- __pthread_handles[0].h_lock = __LOCK_INITIALIZER;
- __pthread_handles[1].h_lock = __LOCK_INITIALIZER;
-# endif
- __pthread_handles[0].h_descr = &__pthread_initial_thread;
- __pthread_handles[1].h_descr = &__pthread_manager_thread;
-
- /* If we have special thread_self processing, initialize that for the
- main thread now. */
-# ifdef INIT_THREAD_SELF
- INIT_THREAD_SELF(&__pthread_initial_thread, 0);
-# endif
-#endif
-
#if HP_TIMING_AVAIL
-# ifdef USE_TLS
self->p_cpuclock_offset = GL(dl_cpuclock_offset);
-# else
- __pthread_initial_thread.p_cpuclock_offset = GL(dl_cpuclock_offset);
-# endif
#endif
__libc_multiple_threads_ptr = __libc_pthread_init (ptr_pthread_functions);
@@ -426,7 +244,6 @@
size_t max_stack;
getrlimit(RLIMIT_STACK, &limit);
-#ifdef FLOATING_STACKS
if (limit.rlim_cur == RLIM_INFINITY)
limit.rlim_cur = ARCH_STACK_MAX_SIZE;
# ifdef NEED_SEPARATE_REGISTER_STACK
@@ -434,48 +251,20 @@
# else
max_stack = limit.rlim_cur;
# endif
-#else
- /* Play with the stack size limit to make sure that no stack ever grows
- beyond STACK_SIZE minus one page (to act as a guard page). */
-# ifdef NEED_SEPARATE_REGISTER_STACK
- /* STACK_SIZE bytes hold both the main stack and register backing
- store. The rlimit value applies to each individually. */
- max_stack = STACK_SIZE/2 - __getpagesize ();
-# else
- max_stack = STACK_SIZE - __getpagesize();
-# endif
- if (limit.rlim_cur > max_stack) {
- limit.rlim_cur = max_stack;
- setrlimit(RLIMIT_STACK, &limit);
- }
-#endif
__pthread_max_stacksize = max_stack;
if (max_stack / 4 < __MAX_ALLOCA_CUTOFF)
{
-#ifdef USE_TLS
pthread_descr self = THREAD_SELF;
self->p_alloca_cutoff = max_stack / 4;
-#else
- __pthread_initial_thread.p_alloca_cutoff = max_stack / 4;
-#endif
}
}
#ifdef SHARED
-# if USE___THREAD
/* When using __thread for this, we do it in libc so as not
to give libpthread its own TLS segment just for this. */
extern void **__libc_dl_error_tsd (void) __attribute__ ((const));
-# else
-static void ** __attribute__ ((const))
-__libc_dl_error_tsd (void)
-{
- return &thread_self ()->p_libc_specific[_LIBC_TSD_KEY_DL_ERROR];
-}
-# endif
#endif
-#ifdef USE_TLS
static inline void __attribute__((always_inline))
init_one_static_tls (pthread_descr descr, struct link_map *map)
{
@@ -512,7 +301,6 @@
__pthread_unlock (&__pthread_handles[i].h_lock);
}
}
-#endif
static void pthread_initialize(void)
{
@@ -525,42 +313,11 @@
/* Test if compare-and-swap is available */
__pthread_has_cas = compare_and_swap_is_available();
#endif
-#ifdef FLOATING_STACKS
/* We don't need to know the bottom of the stack. Give the pointer some
value to signal that initialization happened. */
__pthread_initial_thread_bos = (void *) -1l;
-#else
- /* Determine stack size limits . */
- __pthread_init_max_stacksize ();
-# ifdef _STACK_GROWS_UP
- /* The initial thread already has all the stack it needs */
- __pthread_initial_thread_bos = (char *)
- ((long)CURRENT_STACK_FRAME &~ (STACK_SIZE - 1));
-# else
- /* For the initial stack, reserve at least STACK_SIZE bytes of stack
- below the current stack address, and align that on a
- STACK_SIZE boundary. */
- __pthread_initial_thread_bos =
- (char *)(((long)CURRENT_STACK_FRAME - 2 * STACK_SIZE) & ~(STACK_SIZE - 1));
-# endif
-#endif
-#ifdef USE_TLS
/* Update the descriptor for the initial thread. */
THREAD_SETMEM (((pthread_descr) NULL), p_pid, __getpid());
-# ifndef HAVE___THREAD
- /* Likewise for the resolver state _res. */
- THREAD_SETMEM (((pthread_descr) NULL), p_resp, &_res);
-# endif
-#else
- /* Update the descriptor for the initial thread. */
- __pthread_initial_thread.p_pid = __getpid();
- /* Likewise for the resolver state _res. */
- __pthread_initial_thread.p_resp = &_res;
-#endif
-#if !__ASSUME_REALTIME_SIGNALS
- /* Initialize real-time signals. */
- init_rtsigs ();
-#endif
/* Setup signal handlers for the initial thread.
Since signal handlers are shared between threads, these settings
will be inherited by all other threads. */
@@ -589,12 +346,6 @@
/* Register an exit function to kill all other threads. */
/* Do it early so that user-registered atexit functions are called
before pthread_*exit_process. */
-#ifndef HAVE_Z_NODELETE
- if (__builtin_expect (&__dso_handle != NULL, 1))
- __cxa_atexit ((void (*) (void *)) pthread_atexit_process, NULL,
- __dso_handle);
- else
-#endif
__on_exit (pthread_onexit_process, NULL);
/* How many processors. */
__pthread_smp_kernel = is_smp_system ();
@@ -614,9 +365,7 @@
__pthread_mutex_lock (&GL(dl_load_lock).mutex);
#endif
-#ifdef USE_TLS
GL(dl_init_static_tls) = &__pthread_init_static_tls;
-#endif
}
void __pthread_initialize(void)
@@ -631,22 +380,14 @@
struct pthread_request request;
int report_events;
pthread_descr mgr;
-#ifdef USE_TLS
tcbhead_t *tcbp;
-#endif
__pthread_multiple_threads = 1;
-#if TLS_MULTIPLE_THREADS_IN_TCB || !defined USE_TLS || !TLS_DTV_AT_TP
+#if TLS_MULTIPLE_THREADS_IN_TCB || !TLS_DTV_AT_TP
__pthread_main_thread->p_multiple_threads = 1;
#endif
*__libc_multiple_threads_ptr = 1;
-#ifndef HAVE_Z_NODELETE
- if (__builtin_expect (&__dso_handle != NULL, 1))
- __cxa_atexit ((void (*) (void *)) pthread_atexit_retcode, NULL,
- __dso_handle);
-#endif
-
if (__pthread_max_stacksize == 0)
__pthread_init_max_stacksize ();
/* If basic initialization not done yet (e.g. we're called from a
@@ -686,7 +427,6 @@
manager_pipe[1] = new_fd;
}
-#ifdef USE_TLS
/* Allocate memory for the thread descriptor and the dtv. */
tcbp = _dl_allocate_tls (NULL);
if (tcbp == NULL) {
@@ -706,7 +446,7 @@
__pthread_handles[1].h_descr = manager_thread = mgr;
/* Initialize the descriptor. */
-#if !defined USE_TLS || !TLS_DTV_AT_TP
+#if TLS_DTV_AT_TP
mgr->p_header.data.tcb = tcbp;
mgr->p_header.data.self = mgr;
mgr->p_header.data.multiple_threads = 1;
@@ -714,18 +454,12 @@
mgr->p_multiple_threads = 1;
#endif
mgr->p_lock = &__pthread_handles[1].h_lock;
-# ifndef HAVE___THREAD
- mgr->p_errnop = &mgr->p_errno;
-# endif
mgr->p_start_args = (struct pthread_start_args) PTHREAD_START_ARGS_INITIALIZER(__pthread_manager);
mgr->p_nr = 1;
# if __LT_SPINLOCK_INIT != 0
self->p_resume_count = (struct pthread_atomic) __ATOMIC_INITIALIZER;
# endif
mgr->p_alloca_cutoff = PTHREAD_STACK_MIN / 4;
-#else
- mgr = &__pthread_manager_thread;
-#endif
/* Copy the stack guard canary. */
#ifdef THREAD_COPY_STACK_GUARD
@@ -742,17 +476,10 @@
/* Start the thread manager */
pid = 0;
-#ifdef USE_TLS
if (__linuxthreads_initial_report_events != 0)
THREAD_SETMEM (((pthread_descr) NULL), p_report_events,
__linuxthreads_initial_report_events);
report_events = THREAD_GETMEM (((pthread_descr) NULL), p_report_events);
-#else
- if (__linuxthreads_initial_report_events != 0)
- __pthread_initial_thread.p_report_events
- = __linuxthreads_initial_report_events;
- report_events = __pthread_initial_thread.p_report_events;
-#endif
if (__builtin_expect (report_events, 0))
{
/* It's a bit more complicated. We have to report the creation of
@@ -761,12 +488,8 @@
uint32_t mask = __td_eventmask (TD_CREATE);
uint32_t event_bits;
-#ifdef USE_TLS
event_bits = THREAD_GETMEM_NC (((pthread_descr) NULL),
p_eventbuf.eventmask.event_bits[idx]);
-#else
- event_bits = __pthread_initial_thread.p_eventbuf.eventmask.event_bits[idx];
-#endif
if ((mask & (__pthread_threads_events.event_bits[idx] | event_bits))
!= 0)
@@ -827,9 +550,7 @@
#endif
}
if (__builtin_expect (pid, 0) == -1) {
-#ifdef USE_TLS
_dl_deallocate_tls (tcbp, true);
-#endif
free(__pthread_manager_thread_bos);
close_not_cancel(manager_pipe[0]);
close_not_cancel(manager_pipe[1]);
@@ -958,7 +679,6 @@
if (sp >= __pthread_manager_thread_bos && sp < __pthread_manager_thread_tos)
return manager_thread;
h = __pthread_handles + 2;
-# ifdef USE_TLS
# ifdef _STACK_GROWS_UP
while (h->h_descr == NULL
|| ! (sp >= h->h_descr->p_stackaddr && sp < h->h_descr->p_guardaddr))
@@ -968,15 +688,6 @@
|| ! (sp <= (char *) h->h_descr->p_stackaddr && sp >= h->h_bottom))
h++;
# endif
-# else
-# ifdef _STACK_GROWS_UP
- while (! (sp >= (char *) h->h_descr && sp < h->h_descr->p_guardaddr))
- h++;
-# else
- while (! (sp <= (char *) h->h_descr && sp >= h->h_bottom))
- h++;
-# endif
-# endif
return h->h_descr;
}
@@ -1059,15 +770,11 @@
children, so that timings for main thread account for all threads. */
if (self == __pthread_main_thread)
{
-#ifdef USE_TLS
waitpid(manager_thread->p_pid, NULL, __WCLONE);
-#else
- waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
-#endif
/* Since all threads have been asynchronously terminated
(possibly holding locks), free cannot be used any more.
For mtrace, we'd like to print something though. */
- /* #ifdef USE_TLS
+ /* #if 1
tcbhead_t *tcbp = (tcbhead_t *) manager_thread;
# if TLS_DTV_AT_TP
tcbp = (tcbhead_t) ((char *) tcbp + TLS_PRE_TCB_SIZE);
@@ -1080,20 +787,6 @@
}
}
-#ifndef HAVE_Z_NODELETE
-static int __pthread_atexit_retcode;
-
-static void pthread_atexit_process(void *arg, int retcode)
-{
- pthread_onexit_process (retcode ?: __pthread_atexit_retcode, arg);
-}
-
-static void pthread_atexit_retcode(void *arg, int retcode)
-{
- __pthread_atexit_retcode = retcode;
-}
-#endif
-
/* The handler for the RESTART signal just records the signal received
in the thread descriptor, and optionally performs a siglongjmp
(for pthread_cond_timedwait). */
@@ -1125,11 +818,7 @@
/* Main thread should accumulate times for thread manager and its
children, so that timings for main thread account for all threads. */
if (self == __pthread_main_thread) {
-#ifdef USE_TLS
waitpid(manager_thread->p_pid, NULL, __WCLONE);
-#else
- waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
-#endif
}
_exit(__pthread_exit_code);
}
@@ -1186,26 +875,6 @@
__pthread_main_thread = self;
THREAD_SETMEM(self, p_nextlive, self);
THREAD_SETMEM(self, p_prevlive, self);
-#if !(USE_TLS && HAVE___THREAD)
- /* Now this thread modifies the global variables. */
- THREAD_SETMEM(self, p_errnop, &_errno);
- THREAD_SETMEM(self, p_h_errnop, &_h_errno);
- THREAD_SETMEM(self, p_resp, &_res);
-#endif
-
-#ifndef FLOATING_STACKS
- /* This is to undo the setrlimit call in __pthread_init_max_stacksize.
- XXX This can be wrong if the user set the limit during the run. */
- {
- struct rlimit limit;
- if (getrlimit (RLIMIT_STACK, &limit) == 0
- && limit.rlim_cur != limit.rlim_max)
- {
- limit.rlim_cur = limit.rlim_max;
- setrlimit(RLIMIT_STACK, &limit);
- }
- }
-#endif
}
/* Process-wide exec() request */
@@ -1276,104 +945,6 @@
READ_MEMORY_BARRIER(); /* See comment in __pthread_restart_new */
}
-#if !__ASSUME_REALTIME_SIGNALS
-/* The _old variants are for 2.0 and early 2.1 kernels which don't have RT
- signals.
- On these kernels, we use SIGUSR1 and SIGUSR2 for restart and cancellation.
- Since the restart signal does not queue, we use an atomic counter to create
- queuing semantics. This is needed to resolve a rare race condition in
- pthread_cond_timedwait_relative. */
-
-void __pthread_restart_old(pthread_descr th)
-{
- if (pthread_atomic_increment(&th->p_resume_count) == -1)
- kill(th->p_pid, __pthread_sig_restart);
-}
-
-void __pthread_suspend_old(pthread_descr self)
-{
- if (pthread_atomic_decrement(&self->p_resume_count) <= 0)
- __pthread_wait_for_restart_signal(self);
-}
-
-int
-__pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
-{
- sigset_t unblock, initial_mask;
- int was_signalled = 0;
- sigjmp_buf jmpbuf;
-
- if (pthread_atomic_decrement(&self->p_resume_count) == 0) {
- /* Set up a longjmp handler for the restart signal, unblock
- the signal and sleep. */
-
- if (sigsetjmp(jmpbuf, 1) == 0) {
- THREAD_SETMEM(self, p_signal_jmp, &jmpbuf);
- THREAD_SETMEM(self, p_signal, 0);
- /* Unblock the restart signal */
- sigemptyset(&unblock);
- sigaddset(&unblock, __pthread_sig_restart);
- sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
-
- while (1) {
- struct timeval now;
- struct timespec reltime;
-
- /* Compute a time offset relative to now. */
- __gettimeofday (&now, NULL);
- reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000;
- reltime.tv_sec = abstime->tv_sec - now.tv_sec;
- if (reltime.tv_nsec < 0) {
- reltime.tv_nsec += 1000000000;
- reltime.tv_sec -= 1;
- }
-
- /* Sleep for the required duration. If woken by a signal,
- resume waiting as required by Single Unix Specification. */
- if (reltime.tv_sec < 0 || __libc_nanosleep(&reltime, NULL) == 0)
- break;
- }
-
- /* Block the restart signal again */
- sigprocmask(SIG_SETMASK, &initial_mask, NULL);
- was_signalled = 0;
- } else {
- was_signalled = 1;
- }
- THREAD_SETMEM(self, p_signal_jmp, NULL);
- }
-
- /* Now was_signalled is true if we exited the above code
- due to the delivery of a restart signal. In that case,
- we know we have been dequeued and resumed and that the
- resume count is balanced. Otherwise, there are some
- cases to consider. First, try to bump up the resume count
- back to zero. If it goes to 1, it means restart() was
- invoked on this thread. The signal must be consumed
- and the count bumped down and everything is cool. We
- can return a 1 to the caller.
- Otherwise, no restart was delivered yet, so a potential
- race exists; we return a 0 to the caller which must deal
- with this race in an appropriate way; for example by
- atomically removing the thread from consideration for a
- wakeup---if such a thing fails, it means a restart is
- being delivered. */
-
- if (!was_signalled) {
- if (pthread_atomic_increment(&self->p_resume_count) != -1) {
- __pthread_wait_for_restart_signal(self);
- pthread_atomic_decrement(&self->p_resume_count); /* should be zero now! */
- /* woke spontaneously and consumed restart signal */
- return 1;
- }
- /* woke spontaneously but did not consume restart---caller must resolve */
- return 0;
- }
- /* woken due to restart signal */
- return 1;
-}
-#endif /* __ASSUME_REALTIME_SIGNALS */
-
void __pthread_restart_new(pthread_descr th)
{
/* The barrier is proabably not needed, in which case it still documents
Modified: trunk/glibc-ports/linuxthreads/restart.h
===================================================================
--- trunk/glibc-ports/linuxthreads/restart.h 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/restart.h 2013-05-30 16:21:27 UTC (rev 4503)
@@ -19,31 +19,16 @@
static inline void restart(pthread_descr th)
{
- /* See pthread.c */
-#if __ASSUME_REALTIME_SIGNALS
__pthread_restart_new(th);
-#else
- __pthread_restart(th);
-#endif
}
static inline void suspend(pthread_descr self)
{
- /* See pthread.c */
-#if __ASSUME_REALTIME_SIGNALS
__pthread_wait_for_restart_signal(self);
-#else
- __pthread_suspend(self);
-#endif
}
static inline int timedsuspend(pthread_descr self,
const struct timespec *abstime)
{
- /* See pthread.c */
-#if __ASSUME_REALTIME_SIGNALS
return __pthread_timedsuspend_new(self, abstime);
-#else
- return __pthread_timedsuspend(self, abstime);
-#endif
}
Modified: trunk/glibc-ports/linuxthreads/specific.c
===================================================================
--- trunk/glibc-ports/linuxthreads/specific.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/specific.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -211,33 +211,3 @@
}
__pthread_unlock(THREAD_GETMEM(self, p_lock));
}
-
-#if !(USE_TLS && HAVE___THREAD)
-
-/* Thread-specific data for libc. */
-
-int
-__pthread_internal_tsd_set (int key, const void * pointer)
-{
- pthread_descr self = thread_self();
-
- THREAD_SETMEM_NC(self, p_libc_specific[key], (void *) pointer);
- return 0;
-}
-
-void *
-__pthread_internal_tsd_get (int key)
-{
- pthread_descr self = thread_self();
-
- return THREAD_GETMEM_NC(self, p_libc_specific[key]);
-}
-
-void ** __attribute__ ((__const__))
-__pthread_internal_tsd_address (int key)
-{
- pthread_descr self = thread_self();
- return &self->p_libc_specific[key];
-}
-
-#endif
Modified: trunk/glibc-ports/linuxthreads/tst-context.c
===================================================================
--- trunk/glibc-ports/linuxthreads/tst-context.c 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/tst-context.c 2013-05-30 16:21:27 UTC (rev 4503)
@@ -1,12 +1,3 @@
-/* Ack, a hack! We need to get the proper definition, or lack thereof,
- for FLOATING_STACKS. But when !IS_IN_libpthread, this can get defined
- incidentally by <tls.h>. So kludge around it. */
-
-#define IS_IN_libpthread
-#include <tls.h>
-#undef IS_IN_libpthread
-#undef USE___THREAD
-
#include <errno.h>
#include <error.h>
#include <pthread.h>
@@ -17,7 +8,6 @@
#define N 4
-#ifdef FLOATING_STACKS
static char stacks[N][8192];
static ucontext_t ctx[N][2];
static volatile int failures;
@@ -60,20 +50,13 @@
return NULL;
}
-#endif
-#ifdef FLOATING_STACKS
static volatile int global;
-#endif
int
main (void)
{
-#ifndef FLOATING_STACKS
- puts ("not supported");
- return 0;
-#else
int n;
pthread_t th[N];
ucontext_t mctx;
@@ -112,5 +95,4 @@
pthread_join (th[n], NULL);
return failures;
-#endif
}
Modified: trunk/glibc-ports/linuxthreads/tst-tls1.h
===================================================================
--- trunk/glibc-ports/linuxthreads/tst-tls1.h 2013-05-30 15:00:11 UTC (rev 4502)
+++ trunk/glibc-ports/linuxthreads/tst-tls1.h 2013-05-30 16:21:27 UTC (rev 4503)
@@ -2,8 +2,6 @@
#include <stdlib.h>
#include <tls.h>
-#if USE_TLS && HAVE___THREAD
-
struct tls_obj
{
const char *name;
@@ -24,5 +22,3 @@
tls_registry[i].size = sizeof (x); \
tls_registry[i].align = __alignof__ (x); \
}
-
-#endif
More information about the Glibc-bsd-commits
mailing list