diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-02-03 11:52:43 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-02-14 21:09:12 -0300 |
commit | cf1e05f5990aba073864cd0bc681cd017e663351 (patch) | |
tree | 01f40ffae3c92767f861c19d7ce623d3b5649841 /sysdeps/unix | |
parent | ebb4aed873de6ee6ce3c0d2f55660808a04c9e68 (diff) | |
download | glibc-cf1e05f5990aba073864cd0bc681cd017e663351.tar glibc-cf1e05f5990aba073864cd0bc681cd017e663351.tar.gz glibc-cf1e05f5990aba073864cd0bc681cd017e663351.tar.bz2 glibc-cf1e05f5990aba073864cd0bc681cd017e663351.zip |
mips: Use Linux kABI for syscall return
It changes the mips INTERNAL_SYSCALL* and internal_syscall* macros
to return a negative value instead of the 'a3' register value on then
'err' macro argument.
The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P macro follows the other Linux kABIs.
The redefinition of INTERNAL_VSYSCALL_CALL is also no longer
required.
Checked on mips64-linux-gnu, mips64n32-linux-gnu, and mips-linux-gnu.
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/sysv/linux/mips/mips32/sysdep.h | 32 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/mips/mips64/sysdep.h | 28 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/mips/sysdep.h | 16 |
3 files changed, 23 insertions, 53 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h index 0c6a83e9b3..78534a5799 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h @@ -61,13 +61,14 @@ result_var; }) #undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused)) +#define INTERNAL_SYSCALL_DECL(err) do { } while (0) #undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long int) (err)) +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned long int) (val) > -4096UL) #undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val) +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) /* Note that the original Linux syscall restart convention required the instruction immediately preceding SYSCALL to initialize $v0 with the @@ -128,7 +129,6 @@ union __mips_syscall_return ({ \ union __mips_syscall_return _sc_ret; \ _sc_ret.val = __mips16_syscall##nr (args, number); \ - err = _sc_ret.reg.v1; \ _sc_ret.reg.v0; \ }) @@ -167,8 +167,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -192,8 +191,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -219,8 +217,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -249,8 +246,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -280,8 +276,7 @@ union __mips_syscall_return : "=r" (__v0), "+r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -311,8 +306,7 @@ libc_hidden_proto (__mips_syscall5, nomips16) (long int) (arg4), \ (long int) (arg5), \ (long int) (number)); \ - err = _sc_ret.reg.v1; \ - _sc_ret.reg.v0; \ + _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \ }) long long int __nomips16 __mips_syscall6 (long int arg1, long int arg2, @@ -332,8 +326,7 @@ libc_hidden_proto (__mips_syscall6, nomips16) (long int) (arg5), \ (long int) (arg6), \ (long int) (number)); \ - err = _sc_ret.reg.v1; \ - _sc_ret.reg.v0; \ + _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \ }) long long int __nomips16 __mips_syscall7 (long int arg1, long int arg2, @@ -355,8 +348,7 @@ libc_hidden_proto (__mips_syscall7, nomips16) (long int) (arg6), \ (long int) (arg7), \ (long int) (number)); \ - err = _sc_ret.reg.v1; \ - _sc_ret.reg.v0; \ + _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \ }) #if __mips_isa_rev >= 6 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h index 0c1fda50ce..2c8ddcfc1b 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h @@ -69,13 +69,14 @@ typedef long int __syscall_arg_t; result_var; }) #undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused)) +#define INTERNAL_SYSCALL_DECL(err) do { } while (0) #undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long int) (err)) +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned long int) (val) > -4096UL) #undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val) +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) /* Note that the original Linux syscall restart convention required the instruction immediately preceding SYSCALL to initialize $v0 with the @@ -133,8 +134,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -158,8 +158,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -185,8 +184,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -215,8 +213,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -246,8 +243,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "+r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -279,8 +275,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "+r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -315,8 +310,7 @@ typedef long int __syscall_arg_t; : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \ "r" (__a5) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h index a4cf1540fe..877768a249 100644 --- a/sysdeps/unix/sysv/linux/mips/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h @@ -28,19 +28,3 @@ #endif #define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" #define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" - -#ifndef __ASSEMBLER__ - -/* Standard MIPS syscalls have an error flag, and return a positive errno - when the error flag is set. Emulate this behaviour for vsyscalls so that - the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly. */ -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ - ({ \ - long int _ret = funcptr (args); \ - err = ((unsigned long int) (_ret) >= (unsigned long int) -4095L); \ - if (err) \ - _ret = -_ret; \ - _ret; \ - }) - -#endif /* __ASSEMBLER__ */ |