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 /sysdeps/unix/sysv/linux/sysdep.h | |
parent | 9a973da617772eff1f351989f8995f4305a2e63c (diff) | |
download | glibc-fcb78a55058fd4e3477d9e4c6a5083d650aefa31.tar glibc-fcb78a55058fd4e3477d9e4c6a5083d650aefa31.tar.gz glibc-fcb78a55058fd4e3477d9e4c6a5083d650aefa31.tar.bz2 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.
Diffstat (limited to 'sysdeps/unix/sysv/linux/sysdep.h')
-rw-r--r-- | sysdeps/unix/sysv/linux/sysdep.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index c7f3e54d37..ca3d84f66b 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -15,8 +15,43 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#ifndef _SYSDEP_LINUX_H +#define _SYSDEP_LINUX_H + #include <bits/wordsize.h> #include <kernel-features.h> +#include <errno.h> + +#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 long int) (val) > -4096UL) + +#ifndef SYSCALL_ERROR_LABEL +# define SYSCALL_ERROR_LABEL(sc_err) \ + ({ \ + __set_errno (sc_err); \ + -1L; \ + }) +#endif + +/* Define a macro which expands into the inline wrapper code for a system + call. It sets the errno and returns -1 on a failure, or the syscall + return value otherwise. */ +#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); \ + __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ + ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)) \ + : sc_ret; \ + }) + +#undef INTERNAL_SYSCALL_ERRNO +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) /* Set error number and return -1. A target may choose to return the internal function, __syscall_error, which sets errno and returns -1. @@ -66,3 +101,5 @@ /* Exports the __send symbol on send.c linux implementation (some ABI have it missing due the usage of a old generic version without it). */ #define HAVE_INTERNAL_SEND_SYMBOL 1 + +#endif /* _SYSDEP_LINUX_H */ |