diff options
-rw-r--r-- | ldso/ldso/dl-tls.c | 14 | ||||
-rw-r--r-- | ldso/libdl/libdl.c | 4 | ||||
-rw-r--r-- | libc/misc/elf/dl-support.c | 4 | ||||
-rw-r--r-- | libpthread/linuxthreads/manager.c | 8 | ||||
-rw-r--r-- | libpthread/linuxthreads/pthread.c | 10 | ||||
-rw-r--r-- | libpthread/linuxthreads_db/td_thr_tlsbase.c | 4 | ||||
-rw-r--r-- | libpthread/nptl/allocatestack.c | 24 | ||||
-rw-r--r-- | libpthread/nptl/descr.h | 2 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/generic/dl-tls.c | 22 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/generic/libc-tls.c | 18 | ||||
-rw-r--r-- | libpthread/nptl_db/db_info.c | 4 | ||||
-rw-r--r-- | test/nptl/tst-tls5.c | 4 |
12 files changed, 59 insertions, 59 deletions
diff --git a/ldso/ldso/dl-tls.c b/ldso/ldso/dl-tls.c index 66bfd3428..e718373cd 100644 --- a/ldso/ldso/dl-tls.c +++ b/ldso/ldso/dl-tls.c @@ -145,7 +145,7 @@ fail: - map->l_tls_firstbyte_offset); map->l_tls_offset = _dl_tls_static_used = offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) size_t used; size_t check; @@ -193,7 +193,7 @@ _dl_nothread_init_static_tls (struct link_map *map) { # ifdef TLS_TCB_AT_TP void *dest = (char *) THREAD_SELF - map->l_tls_offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) void *dest = (char *) THREAD_SELF + map->l_tls_offset + TLS_PRE_TCB_SIZE; # else # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" @@ -375,7 +375,7 @@ _dl_determine_tlsoffset (void) _dl_tls_static_used = offset; _dl_tls_static_size = (roundup_pow2 (offset + TLS_STATIC_SURPLUS, max_align) + TLS_TCB_SIZE); -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) /* The TLS blocks start right after the TCB. */ size_t offset = TLS_TCB_SIZE; size_t cnt; @@ -505,7 +505,7 @@ _dl_allocate_tls_storage (void) void *result; size_t size = _dl_tls_static_size; -# if TLS_DTV_AT_TP +# if defined(TLS_DTV_AT_TP) /* Memory layout is: [ TLS_PRE_TCB_SIZE ] [ TLS_TCB_SIZE ] [ TLS blocks ] ^ This should be returned. */ @@ -527,7 +527,7 @@ _dl_allocate_tls_storage (void) /* Clear the TCB data structure. We can't ask the caller (i.e. libpthread) to do it, because we will initialize the DTV et al. */ _dl_memset (result, '\0', TLS_TCB_SIZE); -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) result = (char *) result + size - _dl_tls_static_size; /* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it. @@ -598,7 +598,7 @@ _dl_allocate_tls_init (void *result) # ifdef TLS_TCB_AT_TP _dl_assert ((size_t) map->l_tls_offset >= map->l_tls_blocksize); dest = (char *) result - map->l_tls_offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) dest = (char *) result + map->l_tls_offset; # else # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" @@ -658,7 +658,7 @@ _dl_deallocate_tls (void *tcb, bool dealloc_tcb) # ifdef TLS_TCB_AT_TP /* The TCB follows the TLS blocks. Back up to free the whole block. */ tcb -= _dl_tls_static_size - TLS_TCB_SIZE; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) /* Back up the TLS_PRE_TCB_SIZE bytes. */ tcb -= (TLS_PRE_TCB_SIZE + _dl_tls_static_align - 1) & ~(_dl_tls_static_align - 1); diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index fe84059e2..7f7f70bd9 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -804,7 +804,7 @@ static int do_dlclose(void *vhandle, int need_fini) * whole chunk is at the end of the used area then we can * reclaim it. */ -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) if (tls_free_start == NO_TLS_OFFSET || (size_t) tls_lmap->l_tls_offset == tls_free_start) { @@ -849,7 +849,7 @@ static int do_dlclose(void *vhandle, int need_fini) tls_lmap->l_tls_blocksize; } } -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) if ((size_t) tls_lmap->l_tls_offset == tls_free_end) /* Extend the contiguous chunk being reclaimed. */ tls_free_end -= tls_lmap->l_tls_blocksize; diff --git a/libc/misc/elf/dl-support.c b/libc/misc/elf/dl-support.c index 002262a3a..3f5248128 100644 --- a/libc/misc/elf/dl-support.c +++ b/libc/misc/elf/dl-support.c @@ -47,9 +47,9 @@ void internal_function _dl_nothread_init_static_tls (struct link_map *map) { -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) void *dest = (char *) THREAD_SELF - map->l_tls_offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) void *dest = (char *) THREAD_SELF + map->l_tls_offset + TLS_PRE_TCB_SIZE; # else # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" diff --git a/libpthread/linuxthreads/manager.c b/libpthread/linuxthreads/manager.c index b068d6c66..4293741ac 100644 --- a/libpthread/linuxthreads/manager.c +++ b/libpthread/linuxthreads/manager.c @@ -601,7 +601,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, new_thread = _dl_allocate_tls (NULL); if (new_thread == NULL) return EAGAIN; -# if TLS_DTV_AT_TP +# if defined(TLS_DTV_AT_TP) /* pthread_descr is below TP. */ new_thread = (pthread_descr) ((char *) new_thread - TLS_PRE_TCB_SIZE); # endif @@ -622,7 +622,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, if (sseg >= PTHREAD_THREADS_MAX) { #ifdef USE_TLS -# if TLS_DTV_AT_TP +# if defined(TLS_DTV_AT_TP) new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE); # endif _dl_deallocate_tls (new_thread, true); @@ -824,7 +824,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, #endif } #ifdef USE_TLS -# if TLS_DTV_AT_TP +# if defined(TLS_DTV_AT_TP) new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE); # endif _dl_deallocate_tls (new_thread, true); @@ -917,7 +917,7 @@ static void pthread_free(pthread_descr th) } #ifdef USE_TLS -# if TLS_DTV_AT_TP +# if defined(TLS_DTV_AT_TP) th = (pthread_descr) ((char *) th + TLS_PRE_TCB_SIZE); # endif _dl_deallocate_tls (th, true); diff --git a/libpthread/linuxthreads/pthread.c b/libpthread/linuxthreads/pthread.c index 4d1d9062a..6ae9a10d9 100644 --- a/libpthread/linuxthreads/pthread.c +++ b/libpthread/linuxthreads/pthread.c @@ -474,10 +474,10 @@ __libc_dl_error_tsd (void) static __inline__ void __attribute__((always_inline)) init_one_static_tls (pthread_descr descr, struct link_map *map) { -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) dtv_t *dtv = GET_DTV (descr); void *dest = (char *) descr - map->l_tls_offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) dtv_t *dtv = GET_DTV ((pthread_descr) ((char *) descr + TLS_PRE_TCB_SIZE)); void *dest = (char *) descr + map->l_tls_offset + TLS_PRE_TCB_SIZE; # else @@ -669,9 +669,9 @@ int __pthread_initialize_manager(void) return -1; } -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) mgr = (pthread_descr) tcbp; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) /* pthread_descr is located right below tcbhead_t which _dl_allocate_tls returns. */ mgr = (pthread_descr) ((char *) tcbp - TLS_PRE_TCB_SIZE); @@ -996,7 +996,7 @@ static void pthread_onexit_process(int retcode, void *arg) For mtrace, we'd like to print something though. */ /* #ifdef USE_TLS tcbhead_t *tcbp = (tcbhead_t *) manager_thread; - # if TLS_DTV_AT_TP + # if defined(TLS_DTV_AT_TP) tcbp = (tcbhead_t) ((char *) tcbp + TLS_PRE_TCB_SIZE); # endif _dl_deallocate_tls (tcbp, true); diff --git a/libpthread/linuxthreads_db/td_thr_tlsbase.c b/libpthread/linuxthreads_db/td_thr_tlsbase.c index 5a7e31b9e..00c863de2 100644 --- a/libpthread/linuxthreads_db/td_thr_tlsbase.c +++ b/libpthread/linuxthreads_db/td_thr_tlsbase.c @@ -36,9 +36,9 @@ td_thr_tlsbase (const td_thrhandle_t *th, LOG ("td_thr_tlsbase"); psaddr_t dtvpp = th->th_unique; -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) dtvpp += offsetof (struct _pthread_descr_struct, p_header.data.dtvp); -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) /* Special case hack. If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB containing the DTV at the TP, but actually the TCB lies behind the TP, i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. */ diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c index f0acf3b3a..dab9f08ed 100644 --- a/libpthread/nptl/allocatestack.c +++ b/libpthread/nptl/allocatestack.c @@ -91,9 +91,9 @@ #endif /* This yields the pointer that TLS support code calls the thread pointer. */ -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) # define TLS_TPADJ(pd) (pd) -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) # define TLS_TPADJ(pd) ((struct pthread *)((char *) (pd) + TLS_PRE_TCB_SIZE)) #endif @@ -315,11 +315,11 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, return EINVAL; /* Adjust stack size for alignment of the TLS block. */ -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) adj = ((uintptr_t) attr->stackaddr - TLS_TCB_SIZE) & __static_tls_align_m1; assert (size > adj + TLS_TCB_SIZE); -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) adj = ((uintptr_t) attr->stackaddr - __static_tls_size) & __static_tls_align_m1; assert (size > adj); @@ -329,10 +329,10 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, size... We do not allocate guard pages if the user provided the stack. It is the user's responsibility to do this if it is wanted. */ -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) pd = (struct pthread *) ((uintptr_t) attr->stackaddr - TLS_TCB_SIZE - adj); -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) pd = (struct pthread *) (((uintptr_t) attr->stackaddr - __static_tls_size - adj) - TLS_PRE_TCB_SIZE); @@ -466,9 +466,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, #endif /* Place the thread descriptor at the end of the stack. */ -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) pd = (struct pthread *) ((char *) mem + size - coloring) - 1; -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) pd = (struct pthread *) ((((uintptr_t) mem + size - coloring - __static_tls_size) & ~__static_tls_align_m1) @@ -602,10 +602,10 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* We place the thread descriptor at the end of the stack. */ *pdp = pd; -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) /* The stack begins before the TCB and the static TLS block. */ stacktop = ((char *) (pd + 1) - __static_tls_size); -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) stacktop = (char *) (pd - 1); #endif @@ -889,9 +889,9 @@ static inline void __attribute__((always_inline)) init_one_static_tls (struct pthread *curp, struct link_map *map) { dtv_t *dtv = GET_DTV (TLS_TPADJ (curp)); -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) void *dest = (char *) curp - map->l_tls_offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) void *dest = (char *) curp + map->l_tls_offset + TLS_PRE_TCB_SIZE; # else # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" diff --git a/libpthread/nptl/descr.h b/libpthread/nptl/descr.h index 12e48a83c..1a8d91be8 100644 --- a/libpthread/nptl/descr.h +++ b/libpthread/nptl/descr.h @@ -106,7 +106,7 @@ struct pthread { union { -#if !TLS_DTV_AT_TP +#if !defined(TLS_DTV_AT_TP) /* This overlaps the TCB as used for TLS without threads (see tls.h). */ tcbhead_t header; #else diff --git a/libpthread/nptl/sysdeps/generic/dl-tls.c b/libpthread/nptl/sysdeps/generic/dl-tls.c index ad2e84ea3..3ac73d151 100644 --- a/libpthread/nptl/sysdeps/generic/dl-tls.c +++ b/libpthread/nptl/sysdeps/generic/dl-tls.c @@ -93,7 +93,7 @@ fail: _dl_exit(30); } -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) size_t freebytes; size_t n; size_t blsize; @@ -110,7 +110,7 @@ fail: - map->l_tls_firstbyte_offset); map->l_tls_offset = _dl_tls_static_used = offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) size_t used; size_t check; @@ -254,7 +254,7 @@ _dl_determine_tlsoffset (void) memory requirement for the next TLS block is smaller than the gap. */ -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) /* We simply start with zero. */ size_t offset = 0; @@ -301,7 +301,7 @@ _dl_determine_tlsoffset (void) GL(dl_tls_static_used) = offset; GL(dl_tls_static_size) = (roundup (offset + TLS_STATIC_SURPLUS, max_align) + TLS_TCB_SIZE); -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) /* The TLS blocks start right after the TCB. */ size_t offset = TLS_TCB_SIZE; size_t cnt; @@ -433,7 +433,7 @@ _dl_allocate_tls_storage (void) void *result; size_t size = GL(dl_tls_static_size); -# if TLS_DTV_AT_TP +# if defined(TLS_DTV_AT_TP) /* Memory layout is: [ TLS_PRE_TCB_SIZE ] [ TLS_TCB_SIZE ] [ TLS blocks ] ^ This should be returned. */ @@ -448,14 +448,14 @@ _dl_allocate_tls_storage (void) /* Allocate the DTV. */ void *allocated = result; -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) /* The TCB follows the TLS blocks. */ result = (char *) result + size - TLS_TCB_SIZE; /* Clear the TCB data structure. We can't ask the caller (i.e. libpthread) to do it, because we will initialize the DTV et al. */ _dl_memset (result, '\0', TLS_TCB_SIZE); -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) result = (char *) result + size - GL(dl_tls_static_size); /* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it. @@ -524,10 +524,10 @@ _dl_allocate_tls_init (void *result) assert (map->l_tls_modid == cnt); assert (map->l_tls_blocksize >= map->l_tls_initimage_size); -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) assert ((size_t) map->l_tls_offset >= map->l_tls_blocksize); dest = (char *) result - map->l_tls_offset; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) dest = (char *) result + map->l_tls_offset; # else # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" @@ -586,10 +586,10 @@ _dl_deallocate_tls (void *tcb, bool dealloc_tcb) if (dealloc_tcb) { -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) /* The TCB follows the TLS blocks. Back up to free the whole block. */ tcb -= GL(dl_tls_static_size) - TLS_TCB_SIZE; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) /* Back up the TLS_PRE_TCB_SIZE bytes. */ tcb -= (TLS_PRE_TCB_SIZE + GL(dl_tls_static_align) - 1) & ~(GL(dl_tls_static_align) - 1); diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c index d302d31c9..b78d96483 100644 --- a/libpthread/nptl/sysdeps/generic/libc-tls.c +++ b/libpthread/nptl/sysdeps/generic/libc-tls.c @@ -146,10 +146,10 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) The initialized value of _dl_tls_static_size is provided by dl-open.c to request some surplus that permits dynamic loading of modules with IE-model TLS. */ -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign); tlsblock = sbrk (tcb_offset + tcbsize + max_align); -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) tcb_offset = roundup (tcbsize, align ?: 1); tlsblock = sbrk (tcb_offset + memsz + max_align + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); @@ -169,11 +169,11 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) // static_dtv[1].counter = 0; would be needed if not already done /* Initialize the TLS block. */ -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) static_dtv[2].pointer.val = ((char *) tlsblock + tcb_offset - roundup (memsz, align ?: 1)); static_map.l_tls_offset = roundup (memsz, align ?: 1); -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) static_dtv[2].pointer.val = (char *) tlsblock + tcb_offset; static_map.l_tls_offset = tcb_offset; # else @@ -186,11 +186,11 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) /* Install the pointer to the dtv. */ /* Initialize the thread pointer. */ -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) INSTALL_DTV ((char *) tlsblock + tcb_offset, static_dtv); const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset, 0); -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) INSTALL_DTV (tlsblock, static_dtv); const char *lossage = (char *)TLS_INIT_TP (tlsblock, 0); # else @@ -214,9 +214,9 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) memsz = roundup (memsz, align ?: 1); -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) memsz += tcbsize; -# elif TLS_DTV_AT_TP +# elif defined(TLS_DTV_AT_TP) memsz += tcb_offset; # endif @@ -232,7 +232,7 @@ _dl_tls_setup (void) { init_slotinfo (); init_static_tls ( -# if TLS_TCB_AT_TP +# if defined(TLS_TCB_AT_TP) TLS_TCB_SIZE, # else 0, diff --git a/libpthread/nptl_db/db_info.c b/libpthread/nptl_db/db_info.c index 5000b99ba..5aec152d5 100644 --- a/libpthread/nptl_db/db_info.c +++ b/libpthread/nptl_db/db_info.c @@ -51,9 +51,9 @@ typedef struct link_map link_map; 8 * sizeof (obj)[0], sizeof (obj) / sizeof (obj)[0], \ offset); -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) # define dtvp header.dtv -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) /* Special case hack. If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB containing the DTV at the TP, but actually the TCB lies behind the TP, i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. */ diff --git a/test/nptl/tst-tls5.c b/test/nptl/tst-tls5.c index 9ffc0a1e7..476f09aa1 100644 --- a/test/nptl/tst-tls5.c +++ b/test/nptl/tst-tls5.c @@ -85,7 +85,7 @@ do_test (void) if (cnt > 1) { -#if TLS_TCB_AT_TP +#if defined(TLS_TCB_AT_TP) if (tls_registry[cnt - 1].name) { puts ("pthread_self () not larger than all TLS addresses"); @@ -93,7 +93,7 @@ do_test (void) } else max_addr = MAX (tls_registry[cnt - 1].addr, max_addr); -#elif TLS_DTV_AT_TP +#elif defined(TLS_DTV_AT_TP) if (tls_registry[0].name) { puts ("pthread_self () not smaller than all TLS addresses"); |