The current api from safe_syscall_base() is to return -errno, which is
the interface provided by *some* linux kernel abis. The wrapper macro,
safe_syscall(), detects error, stores into errno, and returns -1, to
match the api of the system syscall().
For those kernel abis that do not return -errno natively, this leads
to double syscall error detection. E.g. Linux ppc64, which sets the
SO flag for error.
Simplify the usage from C by moving the error detection into assembly,
and usage from assembly by providing a C helper with which to set errno.
Reviewed-by: Warner Losh <imp@bsdimp.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/safe-syscall.h | 16 +++-------
linux-user/safe-syscall-error.c | 28 ++++++++++++++++
linux-user/host/aarch64/safe-syscall.inc.S | 20 ++++++------
linux-user/host/arm/safe-syscall.inc.S | 27 ++++++++++------
linux-user/host/i386/safe-syscall.inc.S | 37 +++++++++++++++-------
linux-user/host/ppc64/safe-syscall.inc.S | 24 +++++++-------
linux-user/host/riscv/safe-syscall.inc.S | 20 ++++++------
linux-user/host/s390x/safe-syscall.inc.S | 32 ++++++++++++-------
linux-user/host/x86_64/safe-syscall.inc.S | 29 +++++++++--------
linux-user/meson.build | 1 +
10 files changed, 147 insertions(+), 87 deletions(-)
create mode 100644 linux-user/safe-syscall-error.c