diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/aarch64/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/alpha/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/arc/nptl/tls.h | 3 | ||||
-rw-r--r-- | sysdeps/csky/nptl/tls.h | 3 | ||||
-rw-r--r-- | sysdeps/generic/dl-call_tls_init_tp.h | 34 | ||||
-rw-r--r-- | sysdeps/generic/startup.h | 2 | ||||
-rw-r--r-- | sysdeps/hppa/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/i386/nptl/tls.h | 3 | ||||
-rw-r--r-- | sysdeps/ia64/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/loongarch/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/m68k/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/mach/hurd/i386/tls.h | 10 | ||||
-rw-r--r-- | sysdeps/microblaze/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/mips/nptl/tls.h | 3 | ||||
-rw-r--r-- | sysdeps/nios2/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/or1k/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/powerpc/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/riscv/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/s390/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/sh/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/sparc/nptl/tls.h | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/arm/tls.h | 3 | ||||
-rw-r--r-- | sysdeps/x86_64/nptl/tls.h | 2 |
23 files changed, 60 insertions, 31 deletions
diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h index 08aa2ef..6fe084c 100644 --- a/sysdeps/aarch64/nptl/tls.h +++ b/sysdeps/aarch64/nptl/tls.h @@ -72,7 +72,7 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); NULL; }) + ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); true; }) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h index 8f5b69a..48dc136 100644 --- a/sysdeps/alpha/nptl/tls.h +++ b/sysdeps/alpha/nptl/tls.h @@ -69,7 +69,7 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - (__builtin_set_thread_pointer ((void *)(tcbp)), NULL) + (__builtin_set_thread_pointer ((void *)(tcbp)), true) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h index 7fc6602..948e618 100644 --- a/sysdeps/arc/nptl/tls.h +++ b/sysdeps/arc/nptl/tls.h @@ -75,8 +75,7 @@ typedef struct long result_var; \ __builtin_set_thread_pointer (tcbp); \ result_var = INTERNAL_SYSCALL_CALL (arc_settls, (tcbp));\ - INTERNAL_SYSCALL_ERROR_P (result_var) \ - ? "settls syscall error" : NULL; \ + !INTERNAL_SYSCALL_ERROR_P (result_var); \ }) /* Value passed to 'clone' for initialization of the thread register. */ diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h index 58d6ab0..3f7afc9 100644 --- a/sysdeps/csky/nptl/tls.h +++ b/sysdeps/csky/nptl/tls.h @@ -92,8 +92,7 @@ typedef struct ({ long int result_var; \ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ (char *) (tcbp) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ - ? "unknown error" : NULL; }) + !INTERNAL_SYSCALL_ERROR_P (result_var); }) /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ diff --git a/sysdeps/generic/dl-call_tls_init_tp.h b/sysdeps/generic/dl-call_tls_init_tp.h new file mode 100644 index 0000000..411feda --- /dev/null +++ b/sysdeps/generic/dl-call_tls_init_tp.h @@ -0,0 +1,34 @@ +/* Invoke TLS_INIT_TP and __tls_init_tp with error handling. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <startup.h> +#include <tls.h> + +static inline void +_startup_fatal_tls_error (void) +{ + _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n"); +} + +static inline void +call_tls_init_tp (void *addr) +{ + if (!TLS_INIT_TP (addr)) + _startup_fatal_tls_error (); + __tls_init_tp (); +} diff --git a/sysdeps/generic/startup.h b/sysdeps/generic/startup.h index 45979ab..4b44451 100644 --- a/sysdeps/generic/startup.h +++ b/sysdeps/generic/startup.h @@ -19,7 +19,7 @@ /* Targets should override this file if the default definitions below will not work correctly very early before TLS is initialized. */ -#include <unistd.h> +#include <stdio.h> /* Use macro instead of inline function to avoid including <stdio.h>. */ #define _startup_fatal(message) __libc_fatal ((message)) diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h index e6b0bd5..6af22cd 100644 --- a/sysdeps/hppa/nptl/tls.h +++ b/sysdeps/hppa/nptl/tls.h @@ -74,7 +74,7 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ __set_cr27(tcbp); NULL; }) + ({ __set_cr27(tcbp); true; }) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h index 91090bf..553b55b 100644 --- a/sysdeps/i386/nptl/tls.h +++ b/sysdeps/i386/nptl/tls.h @@ -203,8 +203,7 @@ tls_fill_user_desc (union user_desc_init *desc, which is necessary since we have changed it. */ \ TLS_SET_GS (_segdescr.desc.entry_number * 8 + 3); \ \ - _result == 0 ? NULL \ - : "set_thread_area failed when setting up thread-local storage\n"; }) + _result == 0; }) # define TLS_DEFINE_INIT_TP(tp, pd) \ union user_desc_init _segdescr; \ diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h index d2411b3..4085c56 100644 --- a/sysdeps/ia64/nptl/tls.h +++ b/sysdeps/ia64/nptl/tls.h @@ -105,7 +105,7 @@ register struct pthread *__thread_self __asm__("r13"); special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(thrdescr) \ - (__thread_self = (thrdescr), INIT_SYSINFO, NULL) + (__thread_self = (thrdescr), INIT_SYSINFO, true) /* Value passed to 'clone2' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) \ diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h index 24bffe3..e8b6168 100644 --- a/sysdeps/loongarch/nptl/tls.h +++ b/sysdeps/loongarch/nptl/tls.h @@ -83,7 +83,7 @@ typedef struct #define TLS_INIT_TP(tcbp) \ ({ \ __thread_self = (char *) tcbp + TLS_TCB_OFFSET; \ - NULL; \ + true; \ }) /* Return the address of the dtv for the current thread. */ diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h index 742e1b6..ebcc118 100644 --- a/sysdeps/m68k/nptl/tls.h +++ b/sysdeps/m68k/nptl/tls.h @@ -90,7 +90,7 @@ typedef struct \ _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, \ ((void *) (tcbp)) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "unknown error" : NULL; }) + !INTERNAL_SYSCALL_ERROR_P (_sys_result); }) # define TLS_DEFINE_INIT_TP(tp, pd) \ void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index 602bacc..2847e3e 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -117,12 +117,12 @@ extern unsigned short __init1_desc; # define HURD_SEL_LDT(sel) (__builtin_expect ((sel) & 4, 0)) -static inline const char * __attribute__ ((unused)) +static inline bool __attribute__ ((unused)) _hurd_tls_init (tcbhead_t *tcb) { HURD_TLS_DESC_DECL (desc, tcb); thread_t self = __mach_thread_self (); - const char *msg = NULL; + bool success = true; /* This field is used by TLS accesses to get our "thread pointer" from the TLS point of view. */ @@ -141,14 +141,14 @@ _hurd_tls_init (tcbhead_t *tcb) assert_perror (err); if (err) { - msg = "i386_set_ldt failed"; + success = false; goto out; } } else if (err) { assert_perror (err); /* Separate from above with different line #. */ - msg = "i386_set_gdt failed"; + success = false; goto out; } @@ -157,7 +157,7 @@ _hurd_tls_init (tcbhead_t *tcb) out: __mach_port_deallocate (__mach_task_self (), self); - return msg; + return success; } /* Code to initially initialize the thread pointer. This might need diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h index 588fd1c..d8be193 100644 --- a/sysdeps/microblaze/nptl/tls.h +++ b/sysdeps/microblaze/nptl/tls.h @@ -75,7 +75,7 @@ typedef struct /* Code to initially initialize the thread pointer. r21 is reserved for thread pointer. */ # define TLS_INIT_TP(tcbp) \ - ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); NULL; }) + ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); true; }) # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h index 2aa7cb4..bac6e87 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -116,8 +116,7 @@ typedef struct ({ long int result_var; \ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ (char *) (tcbp) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ - ? "unknown error" : NULL; }) + !INTERNAL_SYSCALL_ERROR_P (result_var); }) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) \ diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h index cb231e2..f5a9713 100644 --- a/sysdeps/nios2/nptl/tls.h +++ b/sysdeps/nios2/nptl/tls.h @@ -88,7 +88,7 @@ register struct pthread *__thread_self __asm__("r23"); /* Code to initially initialize the thread pointer. */ # define TLS_INIT_TP(tcbp) \ - (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), NULL) + (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), true) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) \ diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h index e82f444..eda0e89 100644 --- a/sysdeps/or1k/nptl/tls.h +++ b/sysdeps/or1k/nptl/tls.h @@ -112,7 +112,7 @@ register tcbhead_t *__thread_self __asm__("r10"); It's hard to fail this, so return NULL always. */ # define TLS_INIT_TP(tcbp) \ - ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;}) + ({__thread_self = ((tcbhead_t *)tcbp + 1); true;}) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) \ diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h index e62a962..68a1d8b 100644 --- a/sysdeps/powerpc/nptl/tls.h +++ b/sysdeps/powerpc/nptl/tls.h @@ -139,7 +139,7 @@ typedef struct __thread_register = (void *) (tcbp) + TLS_TCB_OFFSET; \ THREAD_SET_HWCAP (__tcb.hwcap); \ THREAD_SET_AT_PLATFORM (__tcb.at_platform); \ - NULL; \ + true; \ }) /* Value passed to 'clone' for initialization of the thread register. */ diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h index 700c2f5..b221980 100644 --- a/sysdeps/riscv/nptl/tls.h +++ b/sysdeps/riscv/nptl/tls.h @@ -79,7 +79,7 @@ typedef struct /* Code to initially initialize the thread pointer. */ # define TLS_INIT_TP(tcbp) \ - ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; NULL; }) + ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; true; }) /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h index 98d7870..937c49d 100644 --- a/sysdeps/s390/nptl/tls.h +++ b/sysdeps/s390/nptl/tls.h @@ -112,7 +112,7 @@ typedef struct INIT_SYSINFO; \ \ __builtin_set_thread_pointer (_thrdescr); \ - NULL; \ + true; \ }) /* Value passed to 'clone' for initialization of the thread register. */ diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h index 1530489..3882114 100644 --- a/sysdeps/sh/nptl/tls.h +++ b/sysdeps/sh/nptl/tls.h @@ -83,7 +83,7 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); NULL; }) + ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); true; }) # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h index 95a69cb..e8fbe40 100644 --- a/sysdeps/sparc/nptl/tls.h +++ b/sysdeps/sparc/nptl/tls.h @@ -89,7 +89,7 @@ register struct pthread *__thread_self __asm__("%g7"); /* Code to initially initialize the thread pointer. */ # define TLS_INIT_TP(descr) \ - (__thread_self = (__typeof (__thread_self)) (descr), NULL) + (__thread_self = (__typeof (__thread_self)) (descr), true) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h index 9d1601a..045fad2 100644 --- a/sysdeps/unix/sysv/linux/arm/tls.h +++ b/sysdeps/unix/sysv/linux/arm/tls.h @@ -33,8 +33,7 @@ # define TLS_INIT_TP(tcbp) \ ({ long int result_var; \ result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp)); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ - ? "unknown error" : NULL; }) + !INTERNAL_SYSCALL_ERROR_P (result_var); }) #endif /* __ASSEMBLER__ */ diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h index 75f8020..63744f6 100644 --- a/sysdeps/x86_64/nptl/tls.h +++ b/sysdeps/x86_64/nptl/tls.h @@ -156,7 +156,7 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80, "S" (_thrdescr) \ : "memory", "cc", "r11", "cx"); \ \ - _result ? "cannot set %fs base address for thread-local storage" : 0; \ + _result == 0; \ }) # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) |