diff options
Diffstat (limited to 'libpthread/linuxthreads')
20 files changed, 88 insertions, 93 deletions
diff --git a/libpthread/linuxthreads/attr.c b/libpthread/linuxthreads/attr.c index 52e115c8e..a621c2dcc 100644 --- a/libpthread/linuxthreads/attr.c +++ b/libpthread/linuxthreads/attr.c @@ -361,7 +361,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)    attr->__scope = PTHREAD_SCOPE_SYSTEM;  #ifdef _STACK_GROWS_DOWN -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__    attr->__stacksize = descr->p_stackaddr - (char *)descr->p_guardaddr  		      - descr->p_guardsize;  # else @@ -369,7 +369,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)  		      - descr->p_guardsize;  # endif  #else -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__    attr->__stacksize = (char *)descr->p_guardaddr - descr->p_stackaddr;  # else    attr->__stacksize = (char *)descr->p_guardaddr - (char *)descr; @@ -385,7 +385,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)       otherwise the range of the stack area cannot be computed.  */    attr->__stacksize += attr->__guardsize;  #endif -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    attr->__stackaddr = descr->p_stackaddr;  #else  # ifndef _STACK_GROWS_UP @@ -395,7 +395,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)  # endif  #endif -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    if (attr->__stackaddr == NULL)  #else    if (descr == &__pthread_initial_thread) diff --git a/libpthread/linuxthreads/descr.h b/libpthread/linuxthreads/descr.h index 47a9acd9b..1c816b225 100644 --- a/libpthread/linuxthreads/descr.h +++ b/libpthread/linuxthreads/descr.h @@ -23,7 +23,7 @@  #include <stdint.h>  #include <sys/types.h>  #include <hp-timing.h> -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  #include <tls.h>  #endif  #include "uClibc-glue.h" @@ -112,7 +112,7 @@ union dtv;  struct _pthread_descr_struct  { -#if !defined USE_TLS || !TLS_DTV_AT_TP || INCLUDE_TLS_PADDING +#if !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP || INCLUDE_TLS_PADDING    /* This overlaps tcbhead_t (see tls.h), as used for TLS without threads.  */    union    { @@ -157,7 +157,7 @@ struct _pthread_descr_struct    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) +#ifndef __UCLIBC_HAS_TLS__    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 */ @@ -185,7 +185,7 @@ struct _pthread_descr_struct  #if HP_TIMING_AVAIL    hp_timing_t p_cpuclock_offset; /* Initial CPU clock for thread.  */  #endif -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    char *p_stackaddr;		/* Stack address.  */  #endif    size_t p_alloca_cutoff;	/* Maximum size which should be allocated diff --git a/libpthread/linuxthreads/errno.c b/libpthread/linuxthreads/errno.c index 03c23f867..b8d9eb343 100644 --- a/libpthread/linuxthreads/errno.c +++ b/libpthread/linuxthreads/errno.c @@ -20,7 +20,7 @@  #include "pthread.h"  #include "internals.h" -#if !USE_TLS || !HAVE___THREAD +#ifndef __UCLIBC_HAS_TLS__  /* The definition in libc is sufficient if we use TLS.  */  int *  __errno_location (void) diff --git a/libpthread/linuxthreads/libc_pthread_init.c b/libpthread/linuxthreads/libc_pthread_init.c index afe995ae8..c59f40b85 100644 --- a/libpthread/linuxthreads/libc_pthread_init.c +++ b/libpthread/linuxthreads/libc_pthread_init.c @@ -20,7 +20,7 @@  #include <locale.h>  #include <stdlib.h>  #include <string.h> -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  #include <tls.h>  #endif  #include "internals.h" @@ -42,7 +42,7 @@ __libc_pthread_init (functions)  	  sizeof (__libc_pthread_functions));  #endif -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__    /* 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); diff --git a/libpthread/linuxthreads/manager.c b/libpthread/linuxthreads/manager.c index b1482f162..3c5bee876 100644 --- a/libpthread/linuxthreads/manager.c +++ b/libpthread/linuxthreads/manager.c @@ -126,7 +126,7 @@ __pthread_manager(void *arg)  #ifdef INIT_THREAD_SELF    INIT_THREAD_SELF(self, 1);  #endif -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__    /* Set the error variable.  */    self->p_errnop = &self->p_errno;    self->p_h_errnop = &self->p_h_errno; @@ -289,7 +289,7 @@ pthread_start_thread(void *arg)        __sched_setscheduler(THREAD_GETMEM(self, p_pid),                             SCHED_OTHER, &default_params);      } -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__    /* 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); @@ -333,7 +333,7 @@ pthread_start_thread_event(void *arg)    pthread_start_thread (arg);  } -#if defined USE_TLS && !FLOATING_STACKS +#if defined __UCLIBC_HAS_TLS__ && !FLOATING_STACKS  # error "TLS can only work with floating stacks"  #endif @@ -351,7 +351,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,    char * guardaddr;    size_t stacksize, guardsize; -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    /* TLS cannot work with fixed thread descriptor addresses.  */    assert (default_new_thread == NULL);  #endif @@ -360,7 +360,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,      {  #ifdef _STACK_GROWS_UP        /* The user provided a stack. */ -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__        /* This value is not needed.  */        new_thread = (pthread_descr) attr->__stackaddr;        new_thread_bottom = (char *) new_thread; @@ -381,7 +381,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,  	 addresses, stackaddr would be the lowest address in the stack  	 segment, so that it is consistently close to the initial sp  	 value. */ -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__        new_thread = (pthread_descr) attr->__stackaddr;  # else        new_thread = @@ -394,7 +394,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,  #ifndef THREAD_SELF        __pthread_nonstandard_stacks = 1;  #endif -#ifndef USE_TLS +#ifndef __UCLIBC_HAS_TLS__        /* Clear the thread data structure.  */        memset (new_thread, '\0', sizeof (*new_thread));  #endif @@ -438,7 +438,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,  	mprotect (guardaddr, guardsize, PROT_NONE);        new_thread_bottom = (char *) map_addr; -#  ifdef USE_TLS +#  ifdef __UCLIBC_HAS_TLS__        new_thread = ((pthread_descr) (new_thread_bottom + stacksize  				     + guardsize));  #  else @@ -451,7 +451,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,  	mprotect (guardaddr, guardsize, PROT_NONE);        new_thread_bottom = (char *) map_addr + guardsize; -#  ifdef USE_TLS +#  ifdef __UCLIBC_HAS_TLS__        new_thread = ((pthread_descr) (new_thread_bottom + stacksize));  #  else        new_thread = ((pthread_descr) (new_thread_bottom + stacksize)) - 1; @@ -462,7 +462,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,  	mprotect (guardaddr, guardsize, PROT_NONE);        new_thread = (pthread_descr) map_addr; -#  ifdef USE_TLS +#  ifdef __UCLIBC_HAS_TLS__        new_thread_bottom = (char *) new_thread;  #  else        new_thread_bottom = (char *) (new_thread + 1); @@ -597,7 +597,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,    int pagesize = __getpagesize();    int saved_errno = 0; -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    new_thread = _dl_allocate_tls (NULL);    if (new_thread == NULL)      return EAGAIN; @@ -621,7 +621,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,      {        if (sseg >= PTHREAD_THREADS_MAX)  	{ -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  # if defined(TLS_DTV_AT_TP)  	  new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);  # endif @@ -635,7 +635,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,  				 pagesize, &stack_addr, &new_thread_bottom,                                   &guardaddr, &guardsize, &stksize) == 0)  	{ -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  	  new_thread->p_stackaddr = stack_addr;  #else  	  new_thread = (pthread_descr) stack_addr; @@ -657,18 +657,18 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,    new_thread_id = sseg + pthread_threads_counter;    /* Initialize the thread descriptor.  Elements which have to be       initialized to zero already have this value.  */ -#if !defined USE_TLS || !TLS_DTV_AT_TP +#if !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP    new_thread->p_header.data.tcb = new_thread;    new_thread->p_header.data.self = new_thread;  #endif -#if TLS_MULTIPLE_THREADS_IN_TCB || !defined USE_TLS || !TLS_DTV_AT_TP +#if TLS_MULTIPLE_THREADS_IN_TCB || !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP    new_thread->p_multiple_threads = 1;  #endif    new_thread->p_tid = new_thread_id;    new_thread->p_lock = &(__pthread_handles[sseg].h_lock);    new_thread->p_cancelstate = PTHREAD_CANCEL_ENABLE;    new_thread->p_canceltype = PTHREAD_CANCEL_DEFERRED; -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__    new_thread->p_errnop = &new_thread->p_errno;    new_thread->p_h_errnop = &new_thread->p_h_errno;    new_thread->p_resp = &new_thread->p_res; @@ -807,7 +807,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,  	munmap((caddr_t)new_thread_bottom,  	       2 * stacksize + new_thread->p_guardsize);  #elif defined _STACK_GROWS_UP -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__  	size_t stacksize = guardaddr - stack_addr;  	munmap(stack_addr, stacksize + guardsize);  # else @@ -815,7 +815,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,  	munmap(new_thread, stacksize + guardsize);  # endif  #else -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__  	size_t stacksize = stack_addr - new_thread_bottom;  # else  	size_t stacksize = (char *)(new_thread+1) - new_thread_bottom; @@ -823,7 +823,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,  	munmap(new_thread_bottom - guardsize, guardsize + stacksize);  #endif        } -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  # if defined(TLS_DTV_AT_TP)      new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);  # endif @@ -890,7 +890,7 @@ static void pthread_free(pthread_descr th)        /* Free the stack and thread descriptor area */        char *guardaddr = th->p_guardaddr;  #ifdef _STACK_GROWS_UP -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__        size_t stacksize = guardaddr - th->p_stackaddr;        guardaddr = th->p_stackaddr;  # else @@ -900,7 +900,7 @@ static void pthread_free(pthread_descr th)  #else        /* Guardaddr is always set, even if guardsize is 0.  This allows  	 us to compute everything else.  */ -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__        size_t stacksize = th->p_stackaddr - guardaddr - guardsize;  # else        size_t stacksize = (char *)(th+1) - guardaddr - guardsize; @@ -916,7 +916,7 @@ static void pthread_free(pthread_descr th)      } -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  # if defined(TLS_DTV_AT_TP)    th = (pthread_descr) ((char *) th + TLS_PRE_TCB_SIZE);  # endif diff --git a/libpthread/linuxthreads/pthread.c b/libpthread/linuxthreads/pthread.c index 941bb6646..043146bfa 100644 --- a/libpthread/linuxthreads/pthread.c +++ b/libpthread/linuxthreads/pthread.c @@ -37,7 +37,7 @@  # error "This must not happen"  #endif -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__  /* These variables are used by the setup code.  */  extern int _errno;  extern int _h_errno; @@ -50,7 +50,7 @@ extern struct __res_state *__resp;  # endif  #endif -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  /* We need only a few variables.  */  #define manager_thread __pthread_manager_threadp @@ -67,7 +67,7 @@ struct _pthread_descr_struct __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) +#ifndef __UCLIBC_HAS_TLS__    .p_errnop = &_errno,    .p_h_errnop = &_h_errno,  #endif @@ -86,7 +86,7 @@ struct _pthread_descr_struct __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) +#ifndef __UCLIBC_HAS_TLS__    .p_errnop = &__pthread_manager_thread.p_errno,  #endif    .p_nr = 1, @@ -98,7 +98,7 @@ struct _pthread_descr_struct __pthread_manager_thread = {  /* 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 +#ifdef __UCLIBC_HAS_TLS__  pthread_descr __pthread_main_thread;  #else  pthread_descr __pthread_main_thread = &__pthread_initial_thread; @@ -224,13 +224,13 @@ extern void *__dso_handle __attribute__ ((weak));  #endif -#if defined USE_TLS && !defined SHARED +#if defined __UCLIBC_HAS_TLS__ && !defined SHARED  extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign);  #endif  struct pthread_functions __pthread_functions =    { -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__      .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, @@ -292,7 +292,7 @@ static int *__libc_multiple_threads_ptr;  void  __pthread_initialize_minimal(void)  { -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    pthread_descr self;    /* First of all init __pthread_handles[0] and [1] if needed.  */ @@ -304,7 +304,7 @@ __pthread_initialize_minimal(void)    /* 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 +# elif !defined __UCLIBC_HAS_TLS__    if (__builtin_expect (GL(dl_tls_dtv_slotinfo_list) == NULL, 0))      {        tcbhead_t *tcbp; @@ -360,7 +360,7 @@ cannot allocate TLS data structures for initial thread\n";    self->p_nextlive = self->p_prevlive = self;    self->p_tid = PTHREAD_THREADS_MAX;    self->p_lock = &__pthread_handles[0].h_lock; -# ifndef HAVE___THREAD +# ifndef __UCLIBC_HAS_TLS__    self->p_errnop = &_errno;    self->p_h_errnop = &_h_errno;  # endif @@ -377,7 +377,7 @@ cannot allocate TLS data structures for initial thread\n";    /* And fill in the pointer the the thread __pthread_handles array.  */    __pthread_handles[0].h_descr = self; -#else  /* USE_TLS */ +#else  /* __UCLIBC_HAS_TLS__ */    /* First of all init __pthread_handles[0] and [1].  */  # if __LT_SPINLOCK_INIT != 0 @@ -395,7 +395,7 @@ cannot allocate TLS data structures for initial thread\n";  #endif  #if HP_TIMING_AVAIL -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__    self->p_cpuclock_offset = GL(dl_cpuclock_offset);  # else    __pthread_initial_thread.p_cpuclock_offset = GL(dl_cpuclock_offset); @@ -439,7 +439,7 @@ __pthread_init_max_stacksize(void)    __pthread_max_stacksize = max_stack;    if (max_stack / 4 < __MAX_ALLOCA_CUTOFF)      { -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__        pthread_descr self = THREAD_SELF;        self->p_alloca_cutoff = max_stack / 4;  #else @@ -448,10 +448,8 @@ __pthread_init_max_stacksize(void)      }  } -/* psm: we do not have any ld.so support yet - *	 remove the USE_TLS guard if nptl is added */ -#if defined SHARED && defined USE_TLS -# if USE___THREAD +#if defined SHARED && defined __UCLIBC_HAS_TLS__ +# ifdef __UCLIBC_HAS_TLS__  /* 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)); @@ -464,7 +462,7 @@ __libc_dl_error_tsd (void)  # endif  #endif -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  static __inline__ void __attribute__((always_inline))  init_one_static_tls (pthread_descr descr, struct link_map *map)  { @@ -533,10 +531,10 @@ static void pthread_initialize(void)      (char *)(((long)CURRENT_STACK_FRAME - 2 * STACK_SIZE) & ~(STACK_SIZE - 1));  # endif  #endif -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    /* Update the descriptor for the initial thread. */    THREAD_SETMEM (((pthread_descr) NULL), p_pid, __getpid()); -# if !defined HAVE___THREAD && defined __UCLIBC_HAS_RESOLVER_SUPPORT__ +# if defined __UCLIBC_HAS_RESOLVER_SUPPORT__    /* Likewise for the resolver state _res.  */    THREAD_SETMEM (((pthread_descr) NULL), p_resp, __resp);  # endif @@ -587,9 +585,7 @@ static void pthread_initialize(void)    /* How many processors.  */    __pthread_smp_kernel = is_smp_system (); -/* psm: we do not have any ld.so support yet - *	 remove the USE_TLS guard if nptl is added */ -#if defined SHARED && defined USE_TLS +#if defined SHARED && defined __UCLIBC_HAS_TLS__    /* Transfer the old value from the dynamic linker's internal location.  */    *__libc_dl_error_tsd () = *(*GL(dl_error_catch_tsd)) ();    GL(dl_error_catch_tsd) = &__libc_dl_error_tsd; @@ -604,7 +600,7 @@ static void pthread_initialize(void)      __pthread_mutex_lock (&GL(dl_load_lock).mutex);  #endif -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    GL(dl_init_static_tls) = &__pthread_init_static_tls;  #endif @@ -632,12 +628,12 @@ int __pthread_initialize_manager(void)    struct pthread_request request;    int report_events;    pthread_descr mgr; -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_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 || !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP    __pthread_main_thread->p_multiple_threads = 1;  #endif    *__libc_multiple_threads_ptr = 1; @@ -664,7 +660,7 @@ int __pthread_initialize_manager(void)      return -1;    } -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    /* Allocate memory for the thread descriptor and the dtv.  */    tcbp = _dl_allocate_tls (NULL);    if (tcbp == NULL) { @@ -684,7 +680,7 @@ int __pthread_initialize_manager(void)    __pthread_handles[1].h_descr = manager_thread = mgr;    /* Initialize the descriptor.  */ -#if !defined USE_TLS || !TLS_DTV_AT_TP +#if !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP    mgr->p_header.data.tcb = tcbp;    mgr->p_header.data.self = mgr;    mgr->p_header.data.multiple_threads = 1; @@ -692,7 +688,7 @@ int __pthread_initialize_manager(void)    mgr->p_multiple_threads = 1;  #endif    mgr->p_lock = &__pthread_handles[1].h_lock; -# ifndef HAVE___THREAD +# ifndef __UCLIBC_HAS_TLS__    mgr->p_errnop = &mgr->p_errno;  # endif    mgr->p_start_args = (struct pthread_start_args) PTHREAD_START_ARGS_INITIALIZER(__pthread_manager); @@ -710,7 +706,7 @@ int __pthread_initialize_manager(void)    /* Start the thread manager */    pid = 0; -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__    if (__linuxthreads_initial_report_events != 0)      THREAD_SETMEM (((pthread_descr) NULL), p_report_events,  		   __linuxthreads_initial_report_events); @@ -729,7 +725,7 @@ int __pthread_initialize_manager(void)        uint32_t mask = __td_eventmask (TD_CREATE);        uint32_t event_bits; -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__        event_bits = THREAD_GETMEM_NC (((pthread_descr) NULL),  				     p_eventbuf.eventmask.event_bits[idx]);  #else @@ -795,7 +791,7 @@ int __pthread_initialize_manager(void)  #endif      }    if (__builtin_expect (pid, 0) == -1) { -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__      _dl_deallocate_tls (tcbp, true);  #endif      free(__pthread_manager_thread_bos); @@ -897,7 +893,7 @@ pthread_descr __pthread_self_stack(void)    if (sp >= __pthread_manager_thread_bos && sp < __pthread_manager_thread_tos)      return manager_thread;    h = __pthread_handles + 2; -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__  #  ifdef _STACK_GROWS_UP    while (h->h_descr == NULL  	 || ! (sp >= h->h_descr->p_stackaddr && sp < h->h_descr->p_guardaddr)) @@ -991,7 +987,7 @@ static void pthread_onexit_process(int retcode, void *arg)         children, so that timings for main thread account for all threads. */      if (self == __pthread_main_thread)        { -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  	waitpid(manager_thread->p_pid, NULL, __WCLONE);  #else  	waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE); @@ -999,7 +995,7 @@ static void pthread_onexit_process(int retcode, void *arg)  	/* 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 +	/* #ifdef __UCLIBC_HAS_TLS__  	   tcbhead_t *tcbp = (tcbhead_t *) manager_thread;  	   # if defined(TLS_DTV_AT_TP)  	   tcbp = (tcbhead_t) ((char *) tcbp + TLS_PRE_TCB_SIZE); @@ -1057,7 +1053,7 @@ static void pthread_handle_sigcancel(int sig)      /* 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 +#ifdef __UCLIBC_HAS_TLS__        waitpid(manager_thread->p_pid, NULL, __WCLONE);  #else        waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE); @@ -1118,7 +1114,7 @@ void __pthread_reset_main_thread(void)    __pthread_main_thread = self;    THREAD_SETMEM(self, p_nextlive, self);    THREAD_SETMEM(self, p_prevlive, self); -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__    /* Now this thread modifies the global variables.  */    THREAD_SETMEM(self, p_errnop, &_errno);    THREAD_SETMEM(self, p_h_errnop, &_h_errno); diff --git a/libpthread/linuxthreads/specific.c b/libpthread/linuxthreads/specific.c index 764bf1e95..4a6dad308 100644 --- a/libpthread/linuxthreads/specific.c +++ b/libpthread/linuxthreads/specific.c @@ -212,7 +212,7 @@ void __pthread_destroy_specifics()    __pthread_unlock(THREAD_GETMEM(self, p_lock));  } -#if !(USE_TLS && HAVE___THREAD) +#ifndef __UCLIBC_HAS_TLS__  /* Thread-specific data for libc. */ diff --git a/libpthread/linuxthreads/sysdeps/i386/useldt.h b/libpthread/linuxthreads/sysdeps/i386/useldt.h index fa9a2a528..c72a7c8f7 100644 --- a/libpthread/linuxthreads/sysdeps/i386/useldt.h +++ b/libpthread/linuxthreads/sysdeps/i386/useldt.h @@ -87,7 +87,7 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);     because we inherited the value set up in the main thread by TLS setup.     We need to extract that value and set up the same segment in this     thread.  */ -#if defined (USE_TLS) && USE_TLS +#ifdef __UCLIBC_HAS_TLS__  # define DO_SET_THREAD_AREA_REUSE(nr)	1  #else  /* Without TLS, we do the initialization of the main thread, where NR == 0.  */ diff --git a/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym index f7793f766..1000ad0a9 100644 --- a/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym +++ b/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym @@ -2,7 +2,7 @@  #include <tls.h>  -- -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads) - sizeof (struct _pthread_descr_struct)  #else  MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads) diff --git a/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym index 7c5cca01e..7940cf620 100644 --- a/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym +++ b/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym @@ -3,7 +3,7 @@  -- This line separates the #include lines from conditionals. -# ifdef USE_TLS +# ifdef __UCLIBC_HAS_TLS__  -- Abuse tls.h macros to derive offsets relative to the thread register.  #  undef __thread_register diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h index fa6eb4be2..6155280b1 100644 --- a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h +++ b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h @@ -21,10 +21,9 @@  #define _BITS_LIBC_TSD_H 1  #include <linuxthreads/descr.h> +#ifdef __UCLIBC_HAS_TLS__  #include <tls.h> -#if USE_TLS && HAVE___THREAD -  /* When __thread works, the generic definition is what we want.  */  # include <sysdeps/generic/bits/libc-tsd.h> diff --git a/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c b/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c index c3b3087e4..69352ea32 100644 --- a/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c +++ b/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c @@ -22,18 +22,18 @@  #include <linuxthreads/internals.h>  #include <sysdep-cancel.h> -#if ! USE___THREAD && !RTLD_PRIVATE_ERRNO +#if !defined __UCLIBC_HAS_TLS__ && !RTLD_PRIVATE_ERRNO  #undef errno  extern int errno;  #endif  int * -#if ! USE___THREAD +#ifndef __UCLIBC_HAS_TLS__  weak_const_function  #endif  __errno_location (void)  { -#if ! USE___THREAD && !defined NOT_IN_libc +#if !defined __UCLIBC_HAS_TLS__ && !defined NOT_IN_libc    if (! SINGLE_THREAD_P)      {        pthread_descr self = thread_self(); diff --git a/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c index fbc557616..5a2657639 100644 --- a/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c +++ b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c @@ -21,7 +21,7 @@  #include <linuxthreads/internals.h>  #include <sysdep-cancel.h> -#if ! USE___THREAD +#ifndef __UCLIBC_HAS_TLS__  # undef h_errno  extern int h_errno;  #endif @@ -31,7 +31,7 @@ int *  weak_const_function  __h_errno_location (void)  { -#if ! USE___THREAD +#ifndef __UCLIBC_HAS_TLS__    if (! SINGLE_THREAD_P)      {        pthread_descr self = thread_self(); diff --git a/libpthread/linuxthreads/sysdeps/pthread/res-state.c b/libpthread/linuxthreads/sysdeps/pthread/res-state.c index 016e20b4e..6eb77637b 100644 --- a/libpthread/linuxthreads/sysdeps/pthread/res-state.c +++ b/libpthread/linuxthreads/sysdeps/pthread/res-state.c @@ -21,19 +21,19 @@  #include <linuxthreads/internals.h>  #include <sysdep-cancel.h> -#if ! USE___THREAD +#ifndef __UCLIBC_HAS_TLS__  # undef _res  extern struct __res_state _res;  #endif  /* When threaded, _res may be a per-thread variable.  */  struct __res_state * -#if ! USE___THREAD +#ifndef __UCLIBC_HAS_TLS__  weak_const_function  #endif  __res_state (void)  { -#if ! USE___THREAD +#ifndef __UCLIBC_HAS_TLS__    if (! SINGLE_THREAD_P)      {        pthread_descr self = thread_self(); diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h index d52d600ad..685d688ae 100644 --- a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h @@ -58,7 +58,7 @@ testandset (int *spinlock)  #define CURRENT_STACK_FRAME  stack_pointer  register char * stack_pointer __asm__ ("15"); -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  /* Return the thread descriptor for the current thread.  */  # define THREAD_SELF ((pthread_descr) __builtin_thread_pointer ()) diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h index 187e1f872..366482c0f 100644 --- a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h @@ -58,7 +58,7 @@ testandset (int *spinlock)  #define CURRENT_STACK_FRAME  stack_pointer  register char * stack_pointer __asm__ ("15"); -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  /* Return the thread descriptor for the current thread.  */  # define THREAD_SELF ((pthread_descr) __builtin_thread_pointer ()) diff --git a/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym index 328eb0573..6324a016c 100644 --- a/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym +++ b/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym @@ -2,7 +2,7 @@  #include <tls.h>  -- -#ifdef USE_TLS +#ifdef __UCLIBC_HAS_TLS__  MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads)  TLS_PRE_TCB_SIZE	sizeof (struct _pthread_descr_struct)  #else diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h index 0bb16e453..220a925e6 100644 --- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h +++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h @@ -139,7 +139,7 @@  #endif  # ifndef __ASSEMBLER__ -#  if defined FLOATING_STACKS && USE___THREAD && defined __PIC__ +#  if defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__ && defined __PIC__  #   define SINGLE_THREAD_P \    __builtin_expect (THREAD_GETMEM (THREAD_SELF,				      \  				   p_header.data.multiple_threads) == 0, 1) @@ -155,7 +155,7 @@ extern int __local_multiple_threads  # else  #  if !defined __PIC__  #   define SINGLE_THREAD_P cmpl $0, __local_multiple_threads -#  elif defined FLOATING_STACKS && USE___THREAD +#  elif defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__  #   define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET  #  else  #   if !defined NOT_IN_libc || defined IS_IN_libpthread @@ -165,7 +165,7 @@ extern int __local_multiple_threads    movl __local_multiple_threads@GOT(%ecx), %ecx;\    cmpl $0, (%ecx)  #   endif -#   if !defined HAVE_HIDDEN || !USE___THREAD +#   if !defined HAVE_HIDDEN || !defined __UCLIBC_HAS_TLS__  #    define SINGLE_THREAD_P \    SETUP_PIC_REG (cx);				\    addl $_GLOBAL_OFFSET_TABLE_, %ecx;		\ diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S index fec902752..fb7596f27 100644 --- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S +++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S @@ -32,7 +32,7 @@ ENTRY (__vfork)  #ifdef __NR_vfork  # ifdef SHARED -#  if !defined HAVE_HIDDEN || !USE___THREAD +#  if !defined HAVE_HIDDEN || !defined __UCLIBC_HAS_TLS__  	SETUP_PIC_REG (cx)  #  else  	call	__i686.get_pc_thunk.cx diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h index 48b2caadd..224c0e4d8 100644 --- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h +++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h @@ -155,7 +155,7 @@  # endif  # ifndef __ASSEMBLER__ -#  if defined FLOATING_STACKS && USE___THREAD && defined __PIC__ +#  if defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__ && defined __PIC__  #   define SINGLE_THREAD_P \    __builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)  #  else @@ -172,7 +172,7 @@ extern int __local_multiple_threads attribute_hidden;  	.align 2; \       1: .long __local_multiple_threads; \       2: -#  elif defined FLOATING_STACKS && USE___THREAD +#  elif defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__  #   define SINGLE_THREAD_P \  	stc gbr,r0; \  	mov.w 0f,r1; \  | 
