diff options
| author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-01-29 17:36:58 +0000 |
|---|---|---|
| committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-02-14 21:09:12 -0300 |
| commit | fcb78a55058fd4e3477d9e4c6a5083d650aefa31 (patch) | |
| tree | 888c34d043ee64bc43da8e8fca7d61966cb22df6 | |
| parent | 9a973da617772eff1f351989f8995f4305a2e63c (diff) | |
| download | glibc-fcb78a55058fd4e3477d9e4c6a5083d650aefa31.tar.xz glibc-fcb78a55058fd4e3477d9e4c6a5083d650aefa31.zip | |
linux: Consolidate INLINE_SYSCALL
With all Linux ABIs using the expected Linux kABI to indicate
syscalls errors, there is no need to replicate the INLINE_SYSCALL.
The generic Linux sysdep.h includes errno.h even for !__ASSEMBLER__,
which is ok now and it allows cleanup some archaic code that assume
otherwise.
Checked with a build against all affected ABIs.
33 files changed, 60 insertions, 486 deletions
diff --git a/sysdeps/i386/pthread_spin_trylock.S b/sysdeps/i386/pthread_spin_trylock.S index 949879c603..8edb676381 100644 --- a/sysdeps/i386/pthread_spin_trylock.S +++ b/sysdeps/i386/pthread_spin_trylock.S @@ -17,7 +17,7 @@ <https://www.gnu.org/licenses/>. */ #include <sysdep.h> -#include <pthread-errnos.h> +#include <errno.h> #ifdef UP diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h index ba0efe8af6..ae85984f95 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -35,7 +35,7 @@ # define READ_THREAD_POINTER() (__builtin_thread_pointer ()) #else /* Note: rd must be $v1 to be ABI-conformant. */ -# if __mips_isa_rev >= 2 +# if defined (__mips_isa_rev) && __mips_isa_rev >= 2 # define READ_THREAD_POINTER() \ ({ void *__result; \ asm volatile ("rdhwr\t%0, $29" : "=v" (__result)); \ diff --git a/sysdeps/sh/nptl/pthread_spin_trylock.S b/sysdeps/sh/nptl/pthread_spin_trylock.S index c8c453ca9f..142908cf32 100644 --- a/sysdeps/sh/nptl/pthread_spin_trylock.S +++ b/sysdeps/sh/nptl/pthread_spin_trylock.S @@ -15,7 +15,7 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ -#include <pthread-errnos.h> +#include <errno.h> .globl pthread_spin_trylock .type pthread_spin_trylock,@function diff --git a/sysdeps/sparc/sparc32/pthread_spin_trylock.S b/sysdeps/sparc/sparc32/pthread_spin_trylock.S index bd31fad711..4b992e78bf 100644 --- a/sysdeps/sparc/sparc32/pthread_spin_trylock.S +++ b/sysdeps/sparc/sparc32/pthread_spin_trylock.S @@ -16,7 +16,7 @@ <https://www.gnu.org/licenses/>. */ #include <sysdep.h> -#include <pthread-errnos.h> +#include <errno.h> .text ENTRY(pthread_spin_trylock) diff --git a/sysdeps/sparc/sparc64/pthread_spin_trylock.S b/sysdeps/sparc/sparc64/pthread_spin_trylock.S index fd33946aec..b6cfa52b51 100644 --- a/sysdeps/sparc/sparc64/pthread_spin_trylock.S +++ b/sysdeps/sparc/sparc64/pthread_spin_trylock.S @@ -16,7 +16,7 @@ <https://www.gnu.org/licenses/>. */ #include <sysdep.h> -#include <pthread-errnos.h> +#include <errno.h> .text ENTRY(pthread_spin_trylock) diff --git a/sysdeps/unix/arm/sysdep.S b/sysdeps/unix/arm/sysdep.S index 514937bd4b..5c9022a869 100644 --- a/sysdeps/unix/arm/sysdep.S +++ b/sysdeps/unix/arm/sysdep.S @@ -16,8 +16,7 @@ <https://www.gnu.org/licenses/>. */ #include <sysdep.h> -#define _ERRNO_H -#include <bits/errno.h> +#include <errno.h> #if IS_IN (rtld) # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */ diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S index fca1091cda..744d1620b3 100644 --- a/sysdeps/unix/mips/sysdep.S +++ b/sysdeps/unix/mips/sysdep.S @@ -17,8 +17,7 @@ <https://www.gnu.org/licenses/>. */ #include <sysdep.h> -#define _ERRNO_H -#include <bits/errno.h> +#include <errno.h> #include <sys/asm.h> .set nomips16 diff --git a/sysdeps/unix/sh/sysdep.S b/sysdeps/unix/sh/sysdep.S index 7facc028d6..dc9a230ee0 100644 --- a/sysdeps/unix/sh/sysdep.S +++ b/sysdeps/unix/sh/sysdep.S @@ -16,8 +16,7 @@ <https://www.gnu.org/licenses/>. */ #include <sysdep.h> -#define _ERRNO_H -#include <bits/errno.h> +#include <errno.h> ENTRY(__syscall_error) #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index 00b8e241c8..79fa0bda27 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -170,21 +170,6 @@ # define SINGLE_THREAD_BY_GLOBAL 1 -/* Define a macro which expands into the inline wrapper code for a system - call. */ -# undef INLINE_SYSCALL -# define INLINE_SYSCALL(name, nr, args...) \ - ({ unsigned long _sys_result = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \ - _sys_result = (unsigned long) -1; \ - } \ - (long) _sys_result; }) - -# undef INTERNAL_SYSCALL_DECL -# define INTERNAL_SYSCALL_DECL(err) do { } while (0) - # undef INTERNAL_SYSCALL_RAW # define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \ ({ long _sys_result; \ @@ -205,13 +190,6 @@ # define INTERNAL_SYSCALL_AARCH64(name, err, nr, args...) \ INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args) -# undef INTERNAL_SYSCALL_ERROR_P -# define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((unsigned long) (val) >= (unsigned long) -4095) - -# undef INTERNAL_SYSCALL_ERRNO -# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) - # define LOAD_ARGS_0() \ register long _x0 asm ("x0"); # define LOAD_ARGS_1(x0) \ diff --git a/sysdeps/unix/sysv/linux/alpha/brk.S b/sysdeps/unix/sysv/linux/alpha/brk.S index 45ecbbea1b..5596b346d8 100644 --- a/sysdeps/unix/sysv/linux/alpha/brk.S +++ b/sysdeps/unix/sysv/linux/alpha/brk.S @@ -21,8 +21,7 @@ break value (instead of the new, requested one). */ #include <sysdep.h> -#define _ERRNO_H -#include <bits/errno.h> +#include <errno.h> #ifdef PIC .section .bss diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h index 218e207e50..f5bcd851f0 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h @@ -92,6 +92,7 @@ # define USEPV_PROF no #endif +#undef SYSCALL_ERROR_LABEL #if RTLD_PRIVATE_ERRNO # define SYSCALL_ERROR_LABEL $syscall_error # define SYSCALL_ERROR_HANDLER \ @@ -169,42 +170,18 @@ __LABEL(name) \ #else /* !ASSEMBLER */ -/* In order to get __set_errno() definition in INLINE_SYSCALL. */ -#include <errno.h> - -#undef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) \ -({ \ - INTERNAL_SYSCALL_DECL (_sc_err); \ - long int _sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \ - if (INTERNAL_SYSCALL_ERROR_P (_sc_ret, _sc_err)) \ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (_sc_ret, _sc_err)); \ - _sc_ret = -1L; \ - } \ - _sc_ret; \ -}) - #define INTERNAL_SYSCALL(name, err_out, nr, args...) \ internal_syscall##nr(__NR_##name, args) #define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \ internal_syscall##nr(name, args) -#define INTERNAL_SYSCALL_DECL(err) do { } while (0) - /* The normal Alpha calling convention sign-extends 32-bit quantties no matter what the "real" sign of the 32-bit type. We want to preserve that when filling in values for the kernel. */ #define syscall_promote(arg) \ (sizeof (arg) == 4 ? (long int)(int)(long int)(arg) : (long int)(arg)) -/* Make sure and "use" the variable that we're not returning, - in order to suppress unused variable warnings. */ -#define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((unsigned long) (val) > -4096UL) -#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) - #define internal_syscall_clobbers \ "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \ "$22", "$23", "$24", "$25", "$27", "$28", "memory" diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h index 0c5f498583..f6e6b63959 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -29,11 +29,6 @@ #include <tls.h> -/* In order to get __set_errno() definition in INLINE_SYSCALL. */ -#ifndef __ASSEMBLER__ -#include <errno.h> -#endif - /* For Linux we can use the system call table in the header file /usr/include/asm/unistd.h of the kernel. But these symbols do not follow the SYS_* syntax @@ -317,21 +312,6 @@ __local_syscall_error: \ #else /* not __ASSEMBLER__ */ -/* Define a macro which expands into the inline wrapper code for a system - call. */ -#undef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) \ - ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0)) \ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \ - _sys_result = (unsigned int) -1; \ - } \ - (int) _sys_result; }) - -#undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) do { } while (0) - #if defined(__thumb__) /* We can not expose the use of r7 to the compiler. GCC (as of 4.5) uses r7 as the hard frame pointer for Thumb - although @@ -377,13 +357,6 @@ __local_syscall_error: \ #define INTERNAL_SYSCALL(name, err, nr, args...) \ INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args) -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((unsigned int) (val) >= 0xfffff001u) - -#undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) - #define VDSO_NAME "LINUX_2.6" #define VDSO_HASH 61765110 diff --git a/sysdeps/unix/sysv/linux/csky/sysdep.h b/sysdeps/unix/sysv/linux/csky/sysdep.h index fa1dbd6614..7ebb19dce8 100644 --- a/sysdeps/unix/sysv/linux/csky/sysdep.h +++ b/sysdeps/unix/sysv/linux/csky/sysdep.h @@ -293,28 +293,6 @@ __local_syscall_error: \ #else /* not __ASSEMBLER__ */ -/* Define a macro which expands into the inline wrapper code for a system - call. */ -# undef INLINE_SYSCALL -# define INLINE_SYSCALL(name, nr, args...) \ - ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result,), 0)) \ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \ - _sys_result = (unsigned int) -1; \ - } \ - (int) _sys_result; }) - -# undef INTERNAL_SYSCALL_DECL -# define INTERNAL_SYSCALL_DECL(err) do { } while (0) - -# undef INTERNAL_SYSCALL_ERROR_P -# define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((unsigned int) (val) >= 0xffffff01u) - -# undef INTERNAL_SYSCALL_ERRNO -# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) - # undef INTERNAL_SYSCALL_RAW # define INTERNAL_SYSCALL_RAW0(name, err, dummy...) \ ({unsigned int __sys_result; \ diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h index 6c34189eca..88e368db4d 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.h +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h @@ -360,36 +360,6 @@ L(pre_end): ASM_LINE_SEP \ #define CALL_CLOB_REGS "%r1", "%r2", CLOB_TREG \ "%r20", "%r29", "%r31" -#undef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) \ -({ \ - long __sys_res = INTERNAL_SYSCALL (name, , nr, args); \ - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__sys_res, ))) \ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (__sys_res, )); \ - __sys_res = -1; \ - } \ - __sys_res; \ -}) - -/* INTERNAL_SYSCALL_DECL - Allows us to setup some function static - value to use within the context of the syscall - INTERNAL_SYSCALL_ERROR_P - Returns 0 if it wasn't an error, 1 otherwise - You are allowed to use the syscall result (val) and the DECL error - variable to determine what went wrong. - INTERLAL_SYSCALL_ERRNO - Munges the val/err pair into the error number. - In our case we just flip the sign. */ - -#undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) - -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((val < 0) && (val > -4095)) - -#undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) - /* Similar to INLINE_SYSCALL but we don't set errno */ #undef INTERNAL_SYSCALL #define INTERNAL_SYSCALL(name, err, nr, args...) \ diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 420b6a7912..2387a4a144 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -67,6 +67,7 @@ /* We don't want the label for the error handle to be global when we define it here. */ +#undef SYSCALL_ERROR_LABEL #define SYSCALL_ERROR_LABEL __syscall_error #undef PSEUDO @@ -280,35 +281,6 @@ struct libc_do_syscall_args }; #endif -/* Define a macro which expands inline into the wrapper code for a system - call. */ -#undef INLINE_SYSCALL -#if IS_IN (libc) -# define INLINE_SYSCALL(name, nr, args...) \ - ({ \ - unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \ - __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, )) \ - ? __syscall_error (-INTERNAL_SYSCALL_ERRNO (resultvar, )) \ - : (int) resultvar; }) -#else -# define INLINE_SYSCALL(name, nr, args...) \ - ({ \ - unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \ - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \ - resultvar = 0xffffffff; \ - } \ - (int) resultvar; }) -#endif - -/* Set error number and return -1. Return the internal function, - __syscall_error, which sets errno from the negative error number - and returns -1, to avoid PIC. */ -#undef INLINE_SYSCALL_ERROR_RETURN_VALUE -#define INLINE_SYSCALL_ERROR_RETURN_VALUE(resultvar) \ - __syscall_error (-(resultvar)) - # define VDSO_NAME "LINUX_2.6" # define VDSO_HASH 61765110 @@ -490,16 +462,6 @@ struct libc_do_syscall_args # endif /* GCC 5 */ #endif -#undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) do { } while (0) - -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((unsigned int) (val) >= 0xfffff001u) - -#undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, |
