* [PATCH v2 00/24] Simplify internal Linux syscall
@ 2020-11-13 16:58 Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 01/23] linux: Remove INTERNAL_SYSCALL_ERRNO Adhemerval Zanella
` (22 more replies)
0 siblings, 23 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Changes from previous version [1]:
- Removed syscall_error check, instead check the value to either 0
(success) or negative (failure).
- Always define SYSCALL_ERROR_FUNC.
---
This refactor aims to remove and simplify the Linux internal syscall
mechanism by using inline functions instead of macros and by removing
the possible requirement to each architecture to define a
__syscall_error routine to handle errno setting.
Instead of issuing the following for syscalls that don't set the
errno:
int r = INTERNAL_SYSCALL_CALL (syscall, ...);
if (! INTERNAL_SYSCALL_ERROR_P (r)
|| INTERNAL_SYSCALL_ERRNO (r) != ENOSYS)
return INTERNAL_SYSCALL_ERRNO (r);
r = INTERNAL_SYSCALL_CALL (fallback, ...);
return INTERNAL_SYSCALL_ERRNO (r) ? -r : 0;
It would be written as:
int r = INTERNAL_SYSCALL_CALL (syscall, ...);
if (r == 0 || r != -ENOSYS)
return -r;
return -INTERNAL_SYSCALL_CALL (fallback, ...);
For syscall which sets the errno, instead of:
int r = INTERNAL_SYSCALL_CALL (syscall, ...);
if (! INTERNAL_SYSCALL_ERROR_P (r)
|| INTERNAL_SYSCALL_ERRNO (r) != ENOSYS)
return INLINE_SYSCALL_ERROR_RETURN_VALUE (r);
r = INTERNAL_SYSCALL_CALL (fallback, ...);
[...]
__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret))
? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret))
: sc_ret;
It would be written as:
int r = INTERNAL_SYSCALL_CALL (syscall, ...);
if (r == 0 || r != -ENOSYS)
return syscall_ret (r);
r = INTERNAL_SYSCALL_CALL (fallback, ...);
[...]
return syscall_ret (r);
The compiler should easily optimize the first syscall_ret to just call
__syscall_error in first case.
Another optimization is to avoid require each architecture to define an
arch-specific __syscall_error for the case where calling an external
symbols yields faster or more compact code (for instance on i386). Each
architecture might define SYSCALL_ERROR_FUNC, which in turn will build
and link to each library that issues syscall a local __syscall_error
routine.
I checked each architecture whether inline or outline __syscall_error
results or not in a better code size and enable it accordingly. Some
ABIs only enables for static case (x86_64), even when the gain is
minimal.
This is a first step to move the syscall to proper inline implementation
instead of the macro hell and to move the auto-generation to use C
generated instead of the assembly ones.
[1] https://sourceware.org/pipermail/libc-alpha/2020-November/119456.html
Adhemerval Zanella (23):
linux: Remove INTERNAL_SYSCALL_ERRNO
linux: Remove INTERNAL_SYSCALL_ERROR_P
linux: Add syscall_ret and use it on INLINE_SYSCALL
linux: Replace INLINE_SYSCALL_ERROR_RETURN_VALUE with __syscall_error
linux: Use generic __syscall_error for aarch64
linux: Use generic __syscall_error for i386
linux: Use generic __syscall_error for arc
linux: Use generic __syscall_error for powerpc
linux: Use generic __syscall_error for sparc
linux: Use generic __syscall_error for hppa
linux: Use generic __syscall_error for arm
linux: Use generic __syscall_error for x86_64
linux: Use generic __syscall_error for s390
linux: Use generic __syscall_error for sh
linux: Use generic __syscall_error for microblaze
linux: Use generic __syscall_error for ia64
linux: Use generic __syscall_error for m68k
linux: Use generic __syscall_error for csky
linux: Use generic __syscall_error for riscv
linux: Use generic __syscall_error for nios2
linux: Use generic __syscall_error for alpha
linux: Use generic __syscall_error for mips
linux: Make SYSCALL_ERROR_FUNC as default
nptl/allocatestack.c | 6 +-
nptl/nptl-init.c | 6 +-
nptl/pthread_cancel.c | 4 +-
nptl/pthread_getaffinity.c | 4 +-
nptl/pthread_mutex_trylock.c | 3 +-
nptl/pthread_setaffinity.c | 9 +-
nptl/pthread_sigmask.c | 8 +-
sysdeps/arc/Versions | 3 -
sysdeps/arc/nptl/tls.h | 4 +-
sysdeps/csky/nptl/tls.h | 8 +-
sysdeps/ia64/nptl/Makefile | 5 -
sysdeps/m68k/nptl/tls.h | 9 +-
sysdeps/mips/Makefile | 5 -
sysdeps/mips/nptl/Makefile | 5 -
sysdeps/mips/nptl/nptl-sysdep.S | 2 -
sysdeps/mips/nptl/tls.h | 8 +-
sysdeps/nptl/lowlevellock-futex.h | 7 +-
sysdeps/powerpc/nofpu/sfp-machine.h | 2 +-
sysdeps/powerpc/powerpc32/sysdep.h | 1 +
sysdeps/powerpc/powerpc64/sysdep.h | 7 +-
sysdeps/riscv/nptl/Makefile | 5 -
sysdeps/riscv/nptl/nptl-sysdep.S | 2 -
sysdeps/s390/nptl/Makefile | 5 -
sysdeps/unix/alpha/Makefile | 8 +-
sysdeps/unix/alpha/rt-sysdep.S | 1 -
.../alpha/{sysdep.S => syscall_error_asm.S} | 8 +-
sysdeps/unix/arm/sysdep.S | 62 ----------
sysdeps/unix/mips/mips32/sysdep.h | 5 +-
sysdeps/unix/mips/mips64/sysdep.h | 3 +-
sysdeps/unix/mips/rt-sysdep.S | 1 -
sysdeps/unix/mips/sysdep.S | 99 ---------------
sysdeps/unix/sh/sysdep.S | 115 ------------------
sysdeps/unix/sysv/linux/Makefile | 9 +-
sysdeps/unix/sysv/linux/aarch64/sysdep.c | 33 -----
sysdeps/unix/sysv/linux/adjtime.c | 2 +-
sysdeps/unix/sysv/linux/alpha/Makefile | 3 +-
sysdeps/unix/sysv/linux/alpha/fxstat64.c | 2 +-
sysdeps/unix/sysv/linux/alpha/lxstat64.c | 2 +-
.../{arc/sysdep.c => alpha/syscall_error.h} | 18 +--
sysdeps/unix/sysv/linux/alpha/sysdep.h | 4 +-
sysdeps/unix/sysv/linux/alpha/xstat64.c | 2 +-
sysdeps/unix/sysv/linux/arc/sysdep.h | 17 +--
sysdeps/unix/sysv/linux/arm/sysdep.S | 33 -----
sysdeps/unix/sysv/linux/arm/tls.h | 6 +-
sysdeps/unix/sysv/linux/clock_nanosleep.c | 2 +-
sysdeps/unix/sysv/linux/createthread.c | 6 +-
sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S | 65 ----------
sysdeps/unix/sysv/linux/dl-origin.c | 2 +-
sysdeps/unix/sysv/linux/dl-write.c | 5 +-
sysdeps/unix/sysv/linux/faccessat.c | 4 +-
sysdeps/unix/sysv/linux/fchmodat.c | 2 +-
sysdeps/unix/sysv/linux/fcntl_nocancel.c | 5 +-
sysdeps/unix/sysv/linux/fstatat.c | 8 +-
sysdeps/unix/sysv/linux/fstatat64.c | 6 +-
sysdeps/unix/sysv/linux/futimens.c | 2 +-
sysdeps/unix/sysv/linux/fxstat.c | 2 +-
sysdeps/unix/sysv/linux/fxstat64.c | 2 +-
sysdeps/unix/sysv/linux/fxstatat.c | 2 +-
sysdeps/unix/sysv/linux/fxstatat64.c | 2 +-
sysdeps/unix/sysv/linux/generic/dl-origin.c | 2 +-
sysdeps/unix/sysv/linux/getdents.c | 2 +-
.../unix/sysv/linux/hppa/____longjmp_chk.c | 2 +-
sysdeps/unix/sysv/linux/hppa/clone.S | 6 +-
sysdeps/unix/sysv/linux/i386/Makefile | 13 --
sysdeps/unix/sysv/linux/i386/brk.c | 2 +-
sysdeps/unix/sysv/linux/i386/sysdep.h | 3 -
sysdeps/unix/sysv/linux/ia64/Makefile | 5 -
sysdeps/unix/sysv/linux/ia64/rt-sysdep.S | 1 -
sysdeps/unix/sysv/linux/ia64/syscall_error.c | 5 +
.../{hppa/sysdep.c => ia64/syscall_error.h} | 22 ++--
sysdeps/unix/sysv/linux/ia64/sysdep.S | 58 ---------
sysdeps/unix/sysv/linux/libc_fatal.c | 3 +-
sysdeps/unix/sysv/linux/lxstat.c | 2 +-
sysdeps/unix/sysv/linux/lxstat64.c | 2 +-
.../unix/sysv/linux/m68k/____longjmp_chk.c | 2 +-
sysdeps/unix/sysv/linux/m68k/getpagesize.c | 9 +-
sysdeps/unix/sysv/linux/m68k/sysdep.S | 50 --------
sysdeps/unix/sysv/linux/m68k/sysdep.h | 9 +-
sysdeps/unix/sysv/linux/microblaze/Makefile | 6 -
sysdeps/unix/sysv/linux/microblaze/sysdep.S | 39 ------
sysdeps/unix/sysv/linux/mips/clone.S | 1 +
sysdeps/unix/sysv/linux/mips/getcontext.S | 1 +
.../unix/sysv/linux/mips/mips64/fxstatat64.c | 2 +-
.../unix/sysv/linux/mips/mips64/n64/ioctl.S | 3 +-
sysdeps/unix/sysv/linux/mips/mips64/syscall.S | 3 +-
sysdeps/unix/sysv/linux/mips/setcontext.S | 1 +
sysdeps/unix/sysv/linux/mips/swapcontext.S | 1 +
sysdeps/unix/sysv/linux/mips/syscall_error.c | 5 +
.../{i386/sysdep.c => mips/syscall_error.h} | 21 ++--
sysdeps/unix/sysv/linux/mips/vfork.S | 1 +
sysdeps/unix/sysv/linux/mknodat.c | 2 +-
sysdeps/unix/sysv/linux/mmap.c | 2 +-
sysdeps/unix/sysv/linux/mmap64.c | 2 +-
sysdeps/unix/sysv/linux/mq_open.c | 2 +-
sysdeps/unix/sysv/linux/mq_unlink.c | 14 +--
sysdeps/unix/sysv/linux/nios2/sysdep.S | 50 --------
sysdeps/unix/sysv/linux/not-errno.h | 14 +--
sysdeps/unix/sysv/linux/nscd_setup_thread.c | 2 +-
sysdeps/unix/sysv/linux/personality.c | 10 +-
sysdeps/unix/sysv/linux/posix_fadvise.c | 19 ++-
sysdeps/unix/sysv/linux/posix_fadvise64.c | 13 +-
sysdeps/unix/sysv/linux/posix_fallocate.c | 6 +-
sysdeps/unix/sysv/linux/posix_fallocate64.c | 6 +-
sysdeps/unix/sysv/linux/posix_madvise.c | 3 +-
sysdeps/unix/sysv/linux/powerpc/Makefile | 7 --
.../unix/sysv/linux/powerpc/powerpc32/brk.S | 1 +
.../unix/sysv/linux/powerpc/powerpc32/clone.S | 3 +-
.../sysv/linux/powerpc/powerpc32/getcontext.S | 2 +
.../linux/powerpc/powerpc32/makecontext.S | 2 +-
.../powerpc/powerpc32/nofpu/getcontext.S | 2 +-
.../powerpc/powerpc32/nofpu/setcontext.S | 2 +-
.../powerpc/powerpc32/nofpu/swapcontext.S | 2 +-
.../sysv/linux/powerpc/powerpc32/setcontext.S | 3 +-
.../linux/powerpc/powerpc32/swapcontext.S | 3 +-
sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c | 1 -
sysdeps/unix/sysv/linux/prlimit.c | 4 +-
sysdeps/unix/sysv/linux/pthread_kill.c | 4 +-
sysdeps/unix/sysv/linux/pthread_sigqueue.c | 5 +-
sysdeps/unix/sysv/linux/riscv/syscall.c | 2 +-
sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 --------
sysdeps/unix/sysv/linux/s390/Makefile | 5 -
sysdeps/unix/sysv/linux/s390/rt-sysdep.S | 1 -
.../sysv/linux/s390/s390-32/____longjmp_chk.c | 2 +-
.../sysv/linux/s390/s390-32/posix_fadvise64.c | 5 +-
sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S | 74 -----------
.../sysv/linux/s390/s390-64/____longjmp_chk.c | 2 +-
sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S | 75 ------------
sysdeps/unix/sysv/linux/s390/syscall_error.c | 7 ++
sysdeps/unix/sysv/linux/setegid.c | 2 +-
sysdeps/unix/sysv/linux/seteuid.c | 2 +-
sysdeps/unix/sysv/linux/sh/localplt.data | 1 -
sysdeps/unix/sysv/linux/shmat.c | 6 +-
sysdeps/unix/sysv/linux/sparc/Makefile | 9 +-
sysdeps/unix/sysv/linux/sparc/rt-sysdep.c | 1 -
sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 1 +
.../unix/sysv/linux/sparc/sparc32/syscall.S | 1 +
.../unix/sysv/linux/sparc/sparc32/sysdep.h | 1 +
sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S | 1 +
sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 1 +
.../unix/sysv/linux/sparc/sparc64/syscall.S | 1 +
.../unix/sysv/linux/sparc/sparc64/sysdep.h | 1 +
sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 1 +
sysdeps/unix/sysv/linux/sparc/sysdep.c | 1 -
sysdeps/unix/sysv/linux/speed.c | 4 +-
.../{powerpc/sysdep.c => syscall_error.c} | 16 +--
.../linux/{sh/sysdep.S => syscall_error.h} | 26 ++--
sysdeps/unix/sysv/linux/sysdep-vdso.h | 26 +---
sysdeps/unix/sysv/linux/sysdep.h | 62 +++++-----
sysdeps/unix/sysv/linux/tcsendbrk.c | 2 +-
sysdeps/unix/sysv/linux/tcsetattr.c | 2 +-
sysdeps/unix/sysv/linux/timer_create.c | 4 +-
sysdeps/unix/sysv/linux/times.c | 4 +-
sysdeps/unix/sysv/linux/ustat.c | 4 +-
sysdeps/unix/sysv/linux/utimensat.c | 2 +-
.../unix/sysv/linux/x86_64/syscall_error.c | 7 ++
.../unix/sysv/linux/x86_64/syscall_error.h | 25 ++++
sysdeps/unix/sysv/linux/x86_64/sysdep.S | 40 ------
sysdeps/unix/sysv/linux/x86_64/x32/times.c | 4 -
sysdeps/unix/sysv/linux/xmknod.c | 2 +-
sysdeps/unix/sysv/linux/xmknodat.c | 2 +-
sysdeps/unix/sysv/linux/xstat.c | 2 +-
sysdeps/unix/sysv/linux/xstat64.c | 2 +-
sysdeps/unix/sysv/linux/xstatconv.c | 12 +-
sysdeps/unix/x86_64/sysdep.S | 49 --------
164 files changed, 330 insertions(+), 1355 deletions(-)
delete mode 100644 sysdeps/mips/nptl/nptl-sysdep.S
delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S
delete mode 100644 sysdeps/unix/alpha/rt-sysdep.S
rename sysdeps/unix/alpha/{sysdep.S => syscall_error_asm.S} (94%)
delete mode 100644 sysdeps/unix/arm/sysdep.S
delete mode 100644 sysdeps/unix/mips/rt-sysdep.S
delete mode 100644 sysdeps/unix/mips/sysdep.S
delete mode 100644 sysdeps/unix/sh/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/aarch64/sysdep.c
rename sysdeps/unix/sysv/linux/{arc/sysdep.c => alpha/syscall_error.h} (70%)
delete mode 100644 sysdeps/unix/sysv/linux/arm/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/ia64/rt-sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/ia64/syscall_error.c
rename sysdeps/unix/sysv/linux/{hppa/sysdep.c => ia64/syscall_error.h} (66%)
delete mode 100644 sysdeps/unix/sysv/linux/ia64/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/m68k/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/microblaze/sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/mips/syscall_error.c
rename sysdeps/unix/sysv/linux/{i386/sysdep.c => mips/syscall_error.h} (66%)
delete mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c
delete mode 100644 sysdeps/unix/sysv/linux/riscv/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/s390/rt-sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/s390/syscall_error.c
delete mode 100644 sysdeps/unix/sysv/linux/sparc/rt-sysdep.c
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sysdep.c
rename sysdeps/unix/sysv/linux/{powerpc/sysdep.c => syscall_error.c} (77%)
rename sysdeps/unix/sysv/linux/{sh/sysdep.S => syscall_error.h} (55%)
create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_error.c
create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/x86_64/sysdep.S
delete mode 100644 sysdeps/unix/x86_64/sysdep.S
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 01/23] linux: Remove INTERNAL_SYSCALL_ERRNO
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 02/23] linux: Remove INTERNAL_SYSCALL_ERROR_P Adhemerval Zanella
` (21 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
All architectures now returns the error code on the INTERNAL_SYSCALL
value and follow the Linux de-facto ABI (error are signaled with a
value between -4096UL and -1UL). This make the INTERNAL_SYSCALL_ERRNO
superflous and some implementations already checks for either values
different than 0 or for an specific errno in the failure case.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
---
nptl/allocatestack.c | 2 +-
nptl/nptl-init.c | 2 +-
nptl/pthread_cancel.c | 2 +-
nptl/pthread_getaffinity.c | 2 +-
nptl/pthread_mutex_trylock.c | 3 +--
nptl/pthread_setaffinity.c | 2 +-
nptl/pthread_sigmask.c | 2 +-
sysdeps/nptl/lowlevellock-futex.h | 2 +-
sysdeps/unix/sysv/linux/createthread.c | 2 +-
sysdeps/unix/sysv/linux/dl-write.c | 5 +----
sysdeps/unix/sysv/linux/fcntl_nocancel.c | 3 +--
sysdeps/unix/sysv/linux/libc_fatal.c | 3 +--
sysdeps/unix/sysv/linux/mq_unlink.c | 7 +++----
sysdeps/unix/sysv/linux/not-errno.h | 4 ++--
sysdeps/unix/sysv/linux/personality.c | 10 +---------
sysdeps/unix/sysv/linux/posix_fadvise.c | 4 +---
sysdeps/unix/sysv/linux/posix_fadvise64.c | 4 +---
sysdeps/unix/sysv/linux/posix_fallocate.c | 4 ++--
sysdeps/unix/sysv/linux/posix_fallocate64.c | 4 ++--
sysdeps/unix/sysv/linux/posix_madvise.c | 3 +--
sysdeps/unix/sysv/linux/pthread_kill.c | 3 +--
sysdeps/unix/sysv/linux/pthread_sigqueue.c | 3 +--
sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c | 4 +---
sysdeps/unix/sysv/linux/shmat.c | 2 +-
sysdeps/unix/sysv/linux/sysdep-vdso.h | 4 ++--
sysdeps/unix/sysv/linux/sysdep.h | 5 +----
sysdeps/unix/sysv/linux/timer_create.c | 2 +-
sysdeps/unix/sysv/linux/times.c | 2 +-
28 files changed, 34 insertions(+), 61 deletions(-)
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 4b45f8c884..a9e9d39354 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -1174,7 +1174,7 @@ __nptl_setxid (struct xid_command *cmdp)
int error = 0;
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
{
- error = INTERNAL_SYSCALL_ERRNO (result);
+ error = -result;
__set_errno (error);
result = -1;
}
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 4aa1231bec..cbf9cda989 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -191,7 +191,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
__xidcmd->id[1], __xidcmd->id[2]);
int error = 0;
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
- error = INTERNAL_SYSCALL_ERRNO (result);
+ error = -result;
__nptl_setxid_error (__xidcmd, error);
/* Reset the SETXID flag. */
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 88c1ab8f6a..7daf4f8c15 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -70,7 +70,7 @@ __pthread_cancel (pthread_t th)
int val = INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid,
SIGCANCEL);
if (INTERNAL_SYSCALL_ERROR_P (val))
- result = INTERNAL_SYSCALL_ERRNO (val);
+ result = -val;
break;
}
diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c
index 6ebd1ded2d..ffeb878c7c 100644
--- a/nptl/pthread_getaffinity.c
+++ b/nptl/pthread_getaffinity.c
@@ -34,7 +34,7 @@ __pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)
int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid,
MIN (INT_MAX, cpusetsize), cpuset);
if (INTERNAL_SYSCALL_ERROR_P (res))
- return INTERNAL_SYSCALL_ERRNO (res);
+ return -res;
/* Clean the rest of the memory the kernel didn't do. */
memset ((char *) cpuset + res, '\0', cpusetsize - res);
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 2130f52529..5c294a3eea 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -301,8 +301,7 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
__lll_private_flag (FUTEX_TRYLOCK_PI,
private), 0, 0);
- if (INTERNAL_SYSCALL_ERROR_P (e)
- && INTERNAL_SYSCALL_ERRNO (e) == EWOULDBLOCK)
+ if (INTERNAL_SYSCALL_ERROR_P (e) && e == -EWOULDBLOCK)
{
/* The kernel has not yet finished the mutex owner death.
We do not need to ensure ordering wrt another memory
diff --git a/nptl/pthread_setaffinity.c b/nptl/pthread_setaffinity.c
index b0bd90c324..aaaa4f0194 100644
--- a/nptl/pthread_setaffinity.c
+++ b/nptl/pthread_setaffinity.c
@@ -34,7 +34,7 @@ __pthread_setaffinity_new (pthread_t th, size_t cpusetsize,
cpuset);
return (INTERNAL_SYSCALL_ERROR_P (res)
- ? INTERNAL_SYSCALL_ERRNO (res)
+ ? -res
: 0);
}
versioned_symbol (libpthread, __pthread_setaffinity_new,
diff --git a/nptl/pthread_sigmask.c b/nptl/pthread_sigmask.c
index 7b65ae1f27..1d6d753af4 100644
--- a/nptl/pthread_sigmask.c
+++ b/nptl/pthread_sigmask.c
@@ -42,7 +42,7 @@ __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask)
oldmask, __NSIG_BYTES);
return (INTERNAL_SYSCALL_ERROR_P (result)
- ? INTERNAL_SYSCALL_ERRNO (result)
+ ? -result
: 0);
}
libc_hidden_def (__pthread_sigmask)
diff --git a/sysdeps/nptl/lowlevellock-futex.h b/sysdeps/nptl/lowlevellock-futex.h
index 2209ca76a1..dd36997021 100644
--- a/sysdeps/nptl/lowlevellock-futex.h
+++ b/sysdeps/nptl/lowlevellock-futex.h
@@ -70,7 +70,7 @@
long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, \
__VA_ARGS__); \
(__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret)) \
- ? -INTERNAL_SYSCALL_ERRNO (__ret) : 0); \
+ ? __ret : 0); \
})
/* For most of these macros, the return value is never really used.
diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c
index 6588893ba5..01cf2ff42a 100644
--- a/sysdeps/unix/sysv/linux/createthread.c
+++ b/sysdeps/unix/sysv/linux/createthread.c
@@ -132,7 +132,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
pid_t pid = __getpid ();
INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid, SIGCANCEL);
- return INTERNAL_SYSCALL_ERRNO (res);
+ return -res;
}
}
diff --git a/sysdeps/unix/sysv/linux/dl-write.c b/sysdeps/unix/sysv/linux/dl-write.c
index 1c6298fb41..cce5a55e68 100644
--- a/sysdeps/unix/sysv/linux/dl-write.c
+++ b/sysdeps/unix/sysv/linux/dl-write.c
@@ -23,8 +23,5 @@
ssize_t
_dl_write (int fd, const void *buffer, size_t length)
{
- long int r = INTERNAL_SYSCALL_CALL (write, fd, buffer, length);
- if (INTERNAL_SYSCALL_ERROR_P (r))
- r = - INTERNAL_SYSCALL_ERRNO (r);
- return r;
+ return INTERNAL_SYSCALL_CALL (write, fd, buffer, length);
}
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index ed9211001f..1bf3030f75 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -56,8 +56,7 @@ __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg)
if (!INTERNAL_SYSCALL_ERROR_P (res))
return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
- return INLINE_SYSCALL_ERROR_RETURN_VALUE
- (INTERNAL_SYSCALL_ERRNO (res));
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (-res);
}
return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg);
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index 6f568eed51..e9e0fde23d 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -27,8 +27,7 @@ writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total)
ssize_t cnt;
do
cnt = INTERNAL_SYSCALL_CALL (writev, fd, iov, niov);
- while (INTERNAL_SYSCALL_ERROR_P (cnt)
- && INTERNAL_SYSCALL_ERRNO (cnt) == EINTR);
+ while (INTERNAL_SYSCALL_ERROR_P (cnt) && cnt == -EINTR);
return cnt == total;
}
#define WRITEV_FOR_FATAL writev_for_fatal
diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c
index 85fb5d0951..ed7858dc9d 100644
--- a/sysdeps/unix/sysv/linux/mq_unlink.c
+++ b/sysdeps/unix/sysv/linux/mq_unlink.c
@@ -32,10 +32,9 @@ mq_unlink (const char *name)
return just EACCES. */
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
{
- ret = INTERNAL_SYSCALL_ERRNO (ret);
- if (ret == EPERM)
- ret = EACCES;
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (ret);
+ if (ret == -EPERM)
+ ret = -EACCES;
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (-ret);
}
return ret;
diff --git a/sysdeps/unix/sysv/linux/not-errno.h b/sysdeps/unix/sysv/linux/not-errno.h
index 394dabeb93..fc0eda09d9 100644
--- a/sysdeps/unix/sysv/linux/not-errno.h
+++ b/sysdeps/unix/sysv/linux/not-errno.h
@@ -32,7 +32,7 @@ __access_noerrno (const char *pathname, int mode)
res = INTERNAL_SYSCALL_CALL (faccessat, AT_FDCWD, pathname, mode);
#endif
if (INTERNAL_SYSCALL_ERROR_P (res))
- return INTERNAL_SYSCALL_ERRNO (res);
+ return -res;
return 0;
}
@@ -42,6 +42,6 @@ __kill_noerrno (pid_t pid, int sig)
int res;
res = INTERNAL_SYSCALL_CALL (kill, pid, sig);
if (INTERNAL_SYSCALL_ERROR_P (res))
- return INTERNAL_SYSCALL_ERRNO (res);
+ return -res;
return 0;
}
diff --git a/sysdeps/unix/sysv/linux/personality.c b/sysdeps/unix/sysv/linux/personality.c
index e45fffa1c2..75f9d0adb2 100644
--- a/sysdeps/unix/sysv/linux/personality.c
+++ b/sysdeps/unix/sysv/linux/personality.c
@@ -35,14 +35,6 @@ __personality (unsigned long persona)
persona = (unsigned int) persona;
#endif
- long int ret = INTERNAL_SYSCALL_CALL (personality, persona);
-
- /* Starting with kernel commit v2.6.29-6609-g11d06b2, the personality syscall
- never fails. However, 32-bit kernels might flag valid values as errors, so
- we need to reverse the error setting. We can't use the raw result as some
- arches split the return/error values. */
- if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
- ret = -INTERNAL_SYSCALL_ERRNO (ret);
- return ret;
+ return INTERNAL_SYSCALL_CALL (personality, persona);
}
weak_alias (__personality, personality)
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c
index bada96b697..1191ab3db5 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise.c
@@ -60,8 +60,6 @@ posix_fadvise (int fd, off_t offset, off_t len, int advise)
SYSCALL_LL (len), advise);
# endif
# endif
- if (INTERNAL_SYSCALL_ERROR_P (ret))
- return INTERNAL_SYSCALL_ERRNO (ret);
- return 0;
+ return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0;
}
#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c
index 7323c82a07..e6f2d5c1fd 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c
@@ -49,9 +49,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
__ALIGNMENT_ARG SYSCALL_LL64 (offset),
SYSCALL_LL64 (len), advise);
#endif
- if (!INTERNAL_SYSCALL_ERROR_P (ret))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret);
+ return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0;
}
/* The type of the len argument was changed from size_t to off_t in
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c
index 7238b00038..87532668cd 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate.c
@@ -30,7 +30,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len)
SYSCALL_LL (offset), SYSCALL_LL (len));
if (! INTERNAL_SYSCALL_ERROR_P (res))
return 0;
- if (INTERNAL_SYSCALL_ERRNO (res) != EOPNOTSUPP)
- return INTERNAL_SYSCALL_ERRNO (res);
+ if (res != -EOPNOTSUPP)
+ return -res;
return internal_fallocate (fd, offset, len);
}
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c
index 2de63ac277..517fee14f4 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate64.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c
@@ -32,8 +32,8 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
if (! INTERNAL_SYSCALL_ERROR_P (res))
return 0;
- if (INTERNAL_SYSCALL_ERRNO (res) != EOPNOTSUPP)
- return INTERNAL_SYSCALL_ERRNO (res);
+ if (res != -EOPNOTSUPP)
+ return -res;
return internal_fallocate64 (fd, offset, len);
}
libc_hidden_def (__posix_fallocate64_l64)
diff --git a/sysdeps/unix/sysv/linux/posix_madvise.c b/sysdeps/unix/sysv/linux/posix_madvise.c
index 0e49f3b7ac..5fe2e5f653 100644
--- a/sysdeps/unix/sysv/linux/posix_madvise.c
+++ b/sysdeps/unix/sysv/linux/posix_madvise.c
@@ -31,6 +31,5 @@ posix_madvise (void *addr, size_t len, int advice)
if (advice == POSIX_MADV_DONTNEED)
return 0;
- int result = INTERNAL_SYSCALL_CALL (madvise, addr, len, advice);
- return INTERNAL_SYSCALL_ERRNO (result);
+ return -INTERNAL_SYSCALL_CALL (madvise, addr, len, advice);
}
diff --git a/sysdeps/unix/sysv/linux/pthread_kill.c b/sysdeps/unix/sysv/linux/pthread_kill.c
index 4dfe08ffcd..defdeaecac 100644
--- a/sysdeps/unix/sysv/linux/pthread_kill.c
+++ b/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -51,7 +51,6 @@ __pthread_kill (pthread_t threadid, int signo)
pid_t pid = __getpid ();
int val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
- return (INTERNAL_SYSCALL_ERROR_P (val)
- ? INTERNAL_SYSCALL_ERRNO (val) : 0);
+ return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0;
}
strong_alias (__pthread_kill, pthread_kill)
diff --git a/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
index 4b32be2d64..fbbd9fee20 100644
--- a/sysdeps/unix/sysv/linux/pthread_sigqueue.c
+++ b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
@@ -63,8 +63,7 @@ pthread_sigqueue (pthread_t threadid, int signo, const union sigval value)
/* We have a special syscall to do the work. */
int val = INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, pid, tid, signo,
&info);
- return (INTERNAL_SYSCALL_ERROR_P (val)
- ? INTERNAL_SYSCALL_ERRNO (val) : 0);
+ return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0;
#else
return ENOSYS;
#endif
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
index b556a6caae..6199589307 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
@@ -43,9 +43,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
parameters.len = len;
parameters.advise = advise;
int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, ¶meters);
- if (!INTERNAL_SYSCALL_ERROR_P (ret))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret);
+ return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0;
}
#include <shlib-compat.h>
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index 89df350d84..d5a65c06c1 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -36,7 +36,7 @@ shmat (int shmid, const void *shmaddr, int shmflg)
resultvar = INTERNAL_SYSCALL_CALL (ipc, IPCOP_shmat, shmid, shmflg,
&raddr, shmaddr);
if (INTERNAL_SYSCALL_ERROR_P (resultvar))
- return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (resultvar));
+ return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar);
return raddr;
#endif
diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index a9215494dc..88db076184 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -38,7 +38,7 @@
sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \
if (!INTERNAL_SYSCALL_ERROR_P (sc_ret)) \
goto out; \
- if (INTERNAL_SYSCALL_ERRNO (sc_ret) != ENOSYS) \
+ if (sc_ret != -ENOSYS) \
goto iserr; \
} \
\
@@ -46,7 +46,7 @@
if (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \
{ \
iserr: \
- __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret)); \
+ __set_errno (-sc_ret); \
sc_ret = -1L; \
} \
out: \
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index 71ecc19cd5..a47f47526d 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -43,13 +43,10 @@
({ \
long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \
- ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret)) \
+ ? SYSCALL_ERROR_LABEL (-sc_ret) \
: sc_ret; \
})
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val) (-(val))
-
/* Set error number and return -1. A target may choose to return the
internal function, __syscall_error, which sets errno and returns -1.
We use -1l, instead of -1, so that it can be casted to (void *). */
diff --git a/sysdeps/unix/sysv/linux/timer_create.c b/sysdeps/unix/sysv/linux/timer_create.c
index 18fb00c6e6..d8289d1dc7 100644
--- a/sysdeps/unix/sysv/linux/timer_create.c
+++ b/sysdeps/unix/sysv/linux/timer_create.c
@@ -127,7 +127,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
if (INTERNAL_SYSCALL_ERROR_P (res))
{
free (newp);
- __set_errno (INTERNAL_SYSCALL_ERRNO (res));
+ __set_errno (-res);
return -1;
}
diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c
index e3db9cb400..b5eb6404c9 100644
--- a/sysdeps/unix/sysv/linux/times.c
+++ b/sysdeps/unix/sysv/linux/times.c
@@ -25,7 +25,7 @@ __times (struct tms *buf)
{
clock_t ret = INTERNAL_SYSCALL_CALL (times, buf);
if (INTERNAL_SYSCALL_ERROR_P (ret)
- && __glibc_unlikely (INTERNAL_SYSCALL_ERRNO (ret) == EFAULT)
+ && __glibc_unlikely (ret == -EFAULT)
&& buf)
{
/* This might be an error or not. For architectures which have no
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 02/23] linux: Remove INTERNAL_SYSCALL_ERROR_P
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 01/23] linux: Remove INTERNAL_SYSCALL_ERRNO Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 03/23] linux: Add syscall_ret and use it on INLINE_SYSCALL Adhemerval Zanella
` (20 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
All usages can be replaced by either checking for equal to zero
(success) or negative (failure). The possible outliers (lseek on x32)
are already handled by specific implementations. It also allows
simplify some posix and pthread implementations.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
nptl/allocatestack.c | 4 ++--
nptl/nptl-init.c | 4 ++--
nptl/pthread_cancel.c | 2 +-
nptl/pthread_getaffinity.c | 2 +-
nptl/pthread_mutex_trylock.c | 2 +-
nptl/pthread_setaffinity.c | 9 ++-------
nptl/pthread_sigmask.c | 8 ++------
sysdeps/arc/nptl/tls.h | 4 +---
sysdeps/csky/nptl/tls.h | 8 +++-----
sysdeps/m68k/nptl/tls.h | 8 +++-----
sysdeps/mips/nptl/tls.h | 8 +++-----
sysdeps/nptl/lowlevellock-futex.h | 7 +------
sysdeps/powerpc/nofpu/sfp-machine.h | 2 +-
sysdeps/unix/sysv/linux/arm/tls.h | 6 ++----
sysdeps/unix/sysv/linux/clock_nanosleep.c | 2 +-
sysdeps/unix/sysv/linux/createthread.c | 4 ++--
sysdeps/unix/sysv/linux/dl-origin.c | 2 +-
sysdeps/unix/sysv/linux/fcntl_nocancel.c | 2 +-
sysdeps/unix/sysv/linux/fstatat.c | 4 +---
sysdeps/unix/sysv/linux/fstatat64.c | 4 +---
sysdeps/unix/sysv/linux/generic/dl-origin.c | 2 +-
sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c | 2 +-
sysdeps/unix/sysv/linux/libc_fatal.c | 2 +-
sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c | 2 +-
sysdeps/unix/sysv/linux/m68k/getpagesize.c | 7 +------
sysdeps/unix/sysv/linux/mq_unlink.c | 2 +-
sysdeps/unix/sysv/linux/not-errno.h | 14 +++-----------
sysdeps/unix/sysv/linux/nscd_setup_thread.c | 2 +-
sysdeps/unix/sysv/linux/posix_fadvise.c | 17 ++++++++---------
sysdeps/unix/sysv/linux/posix_fadvise64.c | 11 +++++------
sysdeps/unix/sysv/linux/posix_fallocate.c | 4 +---
sysdeps/unix/sysv/linux/posix_fallocate64.c | 4 +---
sysdeps/unix/sysv/linux/pthread_kill.c | 3 +--
sysdeps/unix/sysv/linux/pthread_sigqueue.c | 4 +---
sysdeps/unix/sysv/linux/riscv/syscall.c | 2 +-
.../sysv/linux/s390/s390-32/____longjmp_chk.c | 2 +-
.../sysv/linux/s390/s390-32/posix_fadvise64.c | 3 +--
.../sysv/linux/s390/s390-64/____longjmp_chk.c | 2 +-
sysdeps/unix/sysv/linux/shmat.c | 6 +++---
sysdeps/unix/sysv/linux/sysdep-vdso.h | 4 ++--
sysdeps/unix/sysv/linux/sysdep.h | 8 +++-----
sysdeps/unix/sysv/linux/timer_create.c | 2 +-
sysdeps/unix/sysv/linux/times.c | 4 +---
sysdeps/unix/sysv/linux/x86_64/x32/times.c | 4 ----
44 files changed, 73 insertions(+), 132 deletions(-)
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index a9e9d39354..15d8d5098d 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -1043,7 +1043,7 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
val = INTERNAL_SYSCALL_CALL (tgkill, pid, t->tid, SIGSETXID);
/* If this failed, it must have had not started yet or else exited. */
- if (!INTERNAL_SYSCALL_ERROR_P (val))
+ if (val == 0)
{
atomic_increment (&cmdp->cntr);
return 1;
@@ -1172,7 +1172,7 @@ __nptl_setxid (struct xid_command *cmdp)
result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, 3,
cmdp->id[0], cmdp->id[1], cmdp->id[2]);
int error = 0;
- if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
+ if (__glibc_unlikely (result < 0))
{
error = -result;
__set_errno (error);
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index cbf9cda989..d1a242503c 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -190,7 +190,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
result = INTERNAL_SYSCALL_NCS (__xidcmd->syscall_no, 3, __xidcmd->id[0],
__xidcmd->id[1], __xidcmd->id[2]);
int error = 0;
- if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
+ if (__glibc_unlikely (result < 0))
error = -result;
__nptl_setxid_error (__xidcmd, error);
@@ -242,7 +242,7 @@ __pthread_initialize_minimal_internal (void)
__data.__list.__next));
int res = INTERNAL_SYSCALL_CALL (set_robust_list, &pd->robust_head,
sizeof (struct robust_list_head));
- if (INTERNAL_SYSCALL_ERROR_P (res))
+ if (res < 0)
set_robust_list_not_avail ();
}
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 7daf4f8c15..2927af8375 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -69,7 +69,7 @@ __pthread_cancel (pthread_t th)
int val = INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid,
SIGCANCEL);
- if (INTERNAL_SYSCALL_ERROR_P (val))
+ if (val < 0)
result = -val;
break;
diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c
index ffeb878c7c..3ee5f54c3d 100644
--- a/nptl/pthread_getaffinity.c
+++ b/nptl/pthread_getaffinity.c
@@ -33,7 +33,7 @@ __pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)
int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid,
MIN (INT_MAX, cpusetsize), cpuset);
- if (INTERNAL_SYSCALL_ERROR_P (res))
+ if (res < 0)
return -res;
/* Clean the rest of the memory the kernel didn't do. */
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 5c294a3eea..492f011cae 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -301,7 +301,7 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
__lll_private_flag (FUTEX_TRYLOCK_PI,
private), 0, 0);
- if (INTERNAL_SYSCALL_ERROR_P (e) && e == -EWOULDBLOCK)
+ if (e == -EWOULDBLOCK)
{
/* The kernel has not yet finished the mutex owner death.
We do not need to ensure ordering wrt another memory
diff --git a/nptl/pthread_setaffinity.c b/nptl/pthread_setaffinity.c
index aaaa4f0194..bcf8ac1376 100644
--- a/nptl/pthread_setaffinity.c
+++ b/nptl/pthread_setaffinity.c
@@ -28,14 +28,9 @@ __pthread_setaffinity_new (pthread_t th, size_t cpusetsize,
const cpu_set_t *cpuset)
{
const struct pthread *pd = (const struct pthread *) th;
- int res;
- res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize,
- cpuset);
-
- return (INTERNAL_SYSCALL_ERROR_P (res)
- ? -res
- : 0);
+ return -INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize,
+ cpuset);
}
versioned_symbol (libpthread, __pthread_setaffinity_new,
pthread_setaffinity_np, GLIBC_2_3_4);
diff --git a/nptl/pthread_sigmask.c b/nptl/pthread_sigmask.c
index 1d6d753af4..7939a6cfe6 100644
--- a/nptl/pthread_sigmask.c
+++ b/nptl/pthread_sigmask.c
@@ -38,12 +38,8 @@ __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask)
}
/* We know that realtime signals are available if NPTL is used. */
- int result = INTERNAL_SYSCALL_CALL (rt_sigprocmask, how, newmask,
- oldmask, __NSIG_BYTES);
-
- return (INTERNAL_SYSCALL_ERROR_P (result)
- ? -result
- : 0);
+ return -INTERNAL_SYSCALL_CALL (rt_sigprocmask, how, newmask, oldmask,
+ __NSIG_BYTES);
}
libc_hidden_def (__pthread_sigmask)
diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
index 184b550ab5..ca01db01b4 100644
--- a/sysdeps/arc/nptl/tls.h
+++ b/sysdeps/arc/nptl/tls.h
@@ -78,10 +78,8 @@ typedef struct
/* Code to initially initialize the thread pointer. */
# define TLS_INIT_TP(tcbp) \
({ \
- long result_var; \
__builtin_set_thread_pointer (tcbp); \
- result_var = INTERNAL_SYSCALL_CALL (arc_settls, (tcbp));\
- INTERNAL_SYSCALL_ERROR_P (result_var) \
+ INTERNAL_SYSCALL_CALL (arc_settls, (tcbp)) < 0 \
? "settls syscall error" : NULL; \
})
diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
index bcca9674a1..60a59898c4 100644
--- a/sysdeps/csky/nptl/tls.h
+++ b/sysdeps/csky/nptl/tls.h
@@ -96,11 +96,9 @@ 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) \
- ({ 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; })
+ ({ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \
+ (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \
+ ? "unknown error" : NULL; })
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h
index 68ea952e79..53cf33fbb9 100644
--- a/sysdeps/m68k/nptl/tls.h
+++ b/sysdeps/m68k/nptl/tls.h
@@ -95,11 +95,9 @@ typedef struct
operation can cause a failure 'errno' must not be touched. */
# define TLS_INIT_TP(tcbp) \
({ \
- int _sys_result; \
- \
- _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, \
- ((void *) (tcbp)) + TLS_TCB_OFFSET); \
- INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "unknown error" : NULL; })
+ INTERNAL_SYSCALL_CALL (set_thread_area, \
+ ((void *) (tcbp)) + TLS_TCB_OFFSET) < 0; \
+ "unknown error" : NULL; })
# define TLS_DEFINE_INIT_TP(tp, pd) \
void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE
diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h
index 8b55f19c37..a6986192dd 100644
--- a/sysdeps/mips/nptl/tls.h
+++ b/sysdeps/mips/nptl/tls.h
@@ -120,11 +120,9 @@ 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) \
- ({ 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_CALL (set_thread_area, \
+ (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \
+ ? "unknown error" : NULL; })
/* Value passed to 'clone' for initialization of the thread register. */
# define TLS_DEFINE_INIT_TP(tp, pd) \
diff --git a/sysdeps/nptl/lowlevellock-futex.h b/sysdeps/nptl/lowlevellock-futex.h
index dd36997021..c6a0908ff1 100644
--- a/sysdeps/nptl/lowlevellock-futex.h
+++ b/sysdeps/nptl/lowlevellock-futex.h
@@ -66,12 +66,7 @@
# endif
# define lll_futex_syscall(nargs, futexp, op, ...) \
- ({ \
- long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, \
- __VA_ARGS__); \
- (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret)) \
- ? __ret : 0); \
- })
+ INTERNAL_SYSCALL (futex, nargs, futexp, op, __VA_ARGS__)
/* For most of these macros, the return value is never really used.
Nevertheless, the protocol is that each one returns a negated errno
diff --git a/sysdeps/powerpc/nofpu/sfp-machine.h b/sysdeps/powerpc/nofpu/sfp-machine.h
index 8489c0f1c0..ab15254944 100644
--- a/sysdeps/powerpc/nofpu/sfp-machine.h
+++ b/sysdeps/powerpc/nofpu/sfp-machine.h
@@ -70,7 +70,7 @@ libc_hidden_proto (__feraiseexcept_soft)
\
_spefscr = fegetenv_register (); \
_r = INTERNAL_SYSCALL_CALL (prctl, PR_GET_FPEXC, &_ftrapex); \
- if (INTERNAL_SYSCALL_ERROR_P (_r)) \
+ if (r < 0) \
_ftrapex = 0; \
} \
while (0)
diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h
index 57b583dbd8..69c8f0d1fa 100644
--- a/sysdeps/unix/sysv/linux/arm/tls.h
+++ b/sysdeps/unix/sysv/linux/arm/tls.h
@@ -31,10 +31,8 @@
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) \
- ({ long int result_var; \
- result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp)); \
- INTERNAL_SYSCALL_ERROR_P (result_var) \
- ? "unknown error" : NULL; })
+ ({ INTERNAL_SYSCALL_CALL (set_tls, (tcbp)) < 0 \
+ ? "unknown error" : NULL; })
#endif /* __ASSEMBLER__ */
diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 6ad3321435..ee757d6215 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -57,7 +57,7 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
struct timespec ts32 = valid_timespec64_to_timespec (*req);
r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, clock_id, flags,
&ts32, &tr32);
- if (INTERNAL_SYSCALL_ERROR_P (r))
+ if (r < 0)
{
if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
*rem = valid_timespec_to_timespec64 (tr32);
diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c
index 01cf2ff42a..fa86a173aa 100644
--- a/sysdeps/unix/sysv/linux/createthread.c
+++ b/sysdeps/unix/sysv/linux/createthread.c
@@ -123,7 +123,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
attr->extension->cpusetsize,
attr->extension->cpuset);
- if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res)))
+ if (__glibc_unlikely (res < 0))
err_out:
{
/* The operation failed. We have to kill the thread.
@@ -144,7 +144,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
res = INTERNAL_SYSCALL_CALL (sched_setscheduler, pd->tid,
pd->schedpolicy, &pd->schedparam);
- if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res)))
+ if (__glibc_unlikely (res < 0))
goto err_out;
}
}
diff --git a/sysdeps/unix/sysv/linux/dl-origin.c b/sysdeps/unix/sysv/linux/dl-origin.c
index 515ed6fc8c..165b14e08d 100644
--- a/sysdeps/unix/sysv/linux/dl-origin.c
+++ b/sysdeps/unix/sysv/linux/dl-origin.c
@@ -40,7 +40,7 @@ _dl_get_origin (void)
len = INTERNAL_SYSCALL_CALL (readlink, "/proc/self/exe", linkval,
sizeof (linkval));
- if (! INTERNAL_SYSCALL_ERROR_P (len) && len > 0 && linkval[0] != '[')
+ if (len > 0 && linkval[0] != '[')
{
/* We can use this value. */
assert (linkval[0] == '/');
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index 1bf3030f75..fb3e7a614c 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -53,7 +53,7 @@ __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg)
{
struct f_owner_ex fex;
int res = INTERNAL_SYSCALL_CALL (fcntl64, fd, F_GETOWN_EX, &fex);
- if (!INTERNAL_SYSCALL_ERROR_P (res))
+ if (res == 0)
return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
return INLINE_SYSCALL_ERROR_RETURN_VALUE (-res);
diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
index db49e3155c..87e5c0fc8f 100644
--- a/sysdeps/unix/sysv/linux/fstatat.c
+++ b/sysdeps/unix/sysv/linux/fstatat.c
@@ -80,9 +80,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag)
# endif /* __nr_fstatat64 */
# endif /* STAT_IS_KERNEL_STAT */
- return INTERNAL_SYSCALL_ERROR_P (r)
- ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r)
- : 0;
+ return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
}
weak_alias (__fstatat, fstatat)
diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index 44347603b4..71216e43f5 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -102,9 +102,7 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf,
# endif
#endif
- return INTERNAL_SYSCALL_ERROR_P (r)
- ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r)
- : 0;
+ return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
}
#if __TIMESIZE != 64
hidden_def (__fstatat64_time64)
diff --git a/sysdeps/unix/sysv/linux/generic/dl-origin.c b/sysdeps/unix/sysv/linux/generic/dl-origin.c
index 1ab02bbf10..f705c92acb 100644
--- a/sysdeps/unix/sysv/linux/generic/dl-origin.c
+++ b/sysdeps/unix/sysv/linux/generic/dl-origin.c
@@ -41,7 +41,7 @@ _dl_get_origin (void)
len = INTERNAL_SYSCALL_CALL (readlinkat, AT_FDCWD, "/proc/self/exe",
linkval, sizeof (linkval));
- if (! INTERNAL_SYSCALL_ERROR_P (len) && len > 0 && linkval[0] != '[')
+ if (len > 0 && linkval[0] != '[')
{
/* We can use this value. */
assert (linkval[0] == '/');
diff --git a/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c b/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
index eae0a7fe31..7f2c90adb1 100644
--- a/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
@@ -35,7 +35,7 @@
that we are jumping *out* of the alternate stack. Note that \
the check for that is the same as that for _STACK_GROWS_UP \
as for _STACK_GROWS_DOWN. */ \
- if (!INTERNAL_SYSCALL_ERROR_P (result) \
+ if (result == 0 \
&& ((oss.ss_flags & SS_ONSTACK) == 0 \
|| ((unsigned long) oss.ss_sp + oss.ss_size \
- (unsigned long) (sp)) < oss.ss_size)) \
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index e9e0fde23d..29bc0444e9 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -27,7 +27,7 @@ writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total)
ssize_t cnt;
do
cnt = INTERNAL_SYSCALL_CALL (writev, fd, iov, niov);
- while (INTERNAL_SYSCALL_ERROR_P (cnt) && cnt == -EINTR);
+ while (cnt < 0 && cnt == -EINTR);
return cnt == total;
}
#define WRITEV_FOR_FATAL writev_for_fatal
diff --git a/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c b/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c
index 1e9c5259ab..3d3b495dca 100644
--- a/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c
@@ -26,7 +26,7 @@
{ \
stack_t oss; \
int result = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss); \
- if (!INTERNAL_SYSCALL_ERROR_P (result) \
+ if (result == 0 \
&& ((oss.ss_flags & SS_ONSTACK) == 0 \
|| ((unsigned long) oss.ss_sp + oss.ss_size \
- (unsigned long) (sp)) < oss.ss_size)) \
diff --git a/sysdeps/unix/sysv/linux/m68k/getpagesize.c b/sysdeps/unix/sysv/linux/m68k/getpagesize.c
index 99c83313d2..6d9d90ab24 100644
--- a/sysdeps/unix/sysv/linux/m68k/getpagesize.c
+++ b/sysdeps/unix/sysv/linux/m68k/getpagesize.c
@@ -33,12 +33,7 @@ __getpagesize (void)
if (GLRO(dl_pagesize) != 0)
return GLRO(dl_pagesize);
- result = INTERNAL_SYSCALL_CALL (getpagesize);
- /* The only possible error is ENOSYS. */
- if (!INTERNAL_SYSCALL_ERROR_P (result))
- return result;
-
- return 4096;
+ return INTERNAL_SYSCALL_CALL (getpagesize);
}
libc_hidden_def (__getpagesize)
weak_alias (__getpagesize, getpagesize)
diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c
index ed7858dc9d..bfba6ccfec 100644
--- a/sysdeps/unix/sysv/linux/mq_unlink.c
+++ b/sysdeps/unix/sysv/linux/mq_unlink.c
@@ -30,7 +30,7 @@ mq_unlink (const char *name)
/* While unlink can return either EPERM or EACCES, mq_unlink should
return just EACCES. */
- if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
+ if (ret < 0)
{
if (ret == -EPERM)
ret = -EACCES;
diff --git a/sysdeps/unix/sysv/linux/not-errno.h b/sysdeps/unix/sysv/linux/not-errno.h
index fc0eda09d9..07330a83ca 100644
--- a/sysdeps/unix/sysv/linux/not-errno.h
+++ b/sysdeps/unix/sysv/linux/not-errno.h
@@ -25,23 +25,15 @@
static inline int
__access_noerrno (const char *pathname, int mode)
{
- int res;
#ifdef __NR_access
- res = INTERNAL_SYSCALL_CALL (access, pathname, mode);
+ return -INTERNAL_SYSCALL_CALL (access, pathname, mode);
#else
- res = INTERNAL_SYSCALL_CALL (faccessat, AT_FDCWD, pathname, mode);
+ return -INTERNAL_SYSCALL_CALL (faccessat, AT_FDCWD, pathname, mode);
#endif
- if (INTERNAL_SYSCALL_ERROR_P (res))
- return -res;
- return 0;
}
static inline int
__kill_noerrno (pid_t pid, int sig)
{
- int res;
- res = INTERNAL_SYSCALL_CALL (kill, pid, sig);
- if (INTERNAL_SYSCALL_ERROR_P (res))
- return -res;
- return 0;
+ return -INTERNAL_SYSCALL_CALL (kill, pid, sig);
}
diff --git a/sysdeps/unix/sysv/linux/nscd_setup_thread.c b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
index 2ba64ebea5..eeb4b0d13f 100644
--- a/sysdeps/unix/sysv/linux/nscd_setup_thread.c
+++ b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
@@ -36,7 +36,7 @@ setup_thread (struct database_dyn *db)
since none of the threads ever terminates. */
int r = INTERNAL_SYSCALL_CALL (set_tid_address,
&db->head->nscd_certainly_running);
- if (!INTERNAL_SYSCALL_ERROR_P (r))
+ if (r == 0)
/* We know the kernel can reset this field when nscd terminates.
So, set the field to a nonzero value which indicates that nscd
is certainly running and clients can skip the test. */
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c
index 1191ab3db5..3d6bf4b972 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise.c
@@ -42,24 +42,23 @@ int
posix_fadvise (int fd, off_t offset, off_t len, int advise)
{
# if defined (__NR_fadvise64) && !defined (__ASSUME_FADVISE64_AS_64_64)
- int ret = INTERNAL_SYSCALL_CALL (fadvise64, fd,
- __ALIGNMENT_ARG SYSCALL_LL (offset),
- len, advise);
+ return -INTERNAL_SYSCALL_CALL (fadvise64, fd,
+ __ALIGNMENT_ARG SYSCALL_LL (offset),
+ len, advise);
# else
# ifdef __ASSUME_FADVISE64_64_6ARG
- int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise,
- SYSCALL_LL (offset), SYSCALL_LL (len));
+ return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise,
+ SYSCALL_LL (offset), SYSCALL_LL (len));
# else
# ifndef __NR_fadvise64_64
# define __NR_fadvise64_64 __NR_fadvise64
# endif
- int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd,
- __ALIGNMENT_ARG SYSCALL_LL (offset),
- SYSCALL_LL (len), advise);
+ return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd,
+ __ALIGNMENT_ARG SYSCALL_LL (offset),
+ SYSCALL_LL (len), advise);
# endif
# endif
- return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0;
}
#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c
index e6f2d5c1fd..4a1fc0225b 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c
@@ -42,14 +42,13 @@ int
__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
{
#ifdef __ASSUME_FADVISE64_64_6ARG
- int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise,
- SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
+ return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise,
+ SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
#else
- int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd,
- __ALIGNMENT_ARG SYSCALL_LL64 (offset),
- SYSCALL_LL64 (len), advise);
+ return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd,
+ __ALIGNMENT_ARG SYSCALL_LL64 (offset),
+ SYSCALL_LL64 (len), advise);
#endif
- return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0;
}
/* The type of the len argument was changed from size_t to off_t in
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c
index 87532668cd..af8dc8fb8c 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate.c
@@ -28,9 +28,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len)
{
int res = INTERNAL_SYSCALL_CALL (fallocate, fd, 0,
SYSCALL_LL (offset), SYSCALL_LL (len));
- if (! INTERNAL_SYSCALL_ERROR_P (res))
- return 0;
- if (res != -EOPNOTSUPP)
+ if (res == 0 || res != -EOPNOTSUPP)
return -res;
return internal_fallocate (fd, offset, len);
}
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c
index 517fee14f4..704fe63794 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate64.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c
@@ -30,9 +30,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
{
int res = INTERNAL_SYSCALL_CALL (fallocate, fd, 0,
SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
- if (! INTERNAL_SYSCALL_ERROR_P (res))
- return 0;
- if (res != -EOPNOTSUPP)
+ if (res == 0 || res != -EOPNOTSUPP)
return -res;
return internal_fallocate64 (fd, offset, len);
}
diff --git a/sysdeps/unix/sysv/linux/pthread_kill.c b/sysdeps/unix/sysv/linux/pthread_kill.c
index defdeaecac..525383f960 100644
--- a/sysdeps/unix/sysv/linux/pthread_kill.c
+++ b/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -50,7 +50,6 @@ __pthread_kill (pthread_t threadid, int signo)
/* We have a special syscall to do the work. */
pid_t pid = __getpid ();
- int val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
- return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0;
+ return -INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
}
strong_alias (__pthread_kill, pthread_kill)
diff --git a/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
index fbbd9fee20..814f449b63 100644
--- a/sysdeps/unix/sysv/linux/pthread_sigqueue.c
+++ b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
@@ -61,9 +61,7 @@ pthread_sigqueue (pthread_t threadid, int signo, const union sigval value)
info.si_value = value;
/* We have a special syscall to do the work. */
- int val = INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, pid, tid, signo,
- &info);
- return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0;
+ return -INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, pid, tid, signo, &info);
#else
return ENOSYS;
#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/syscall.c b/sysdeps/unix/sysv/linux/riscv/syscall.c
index a99375c054..f45924d895 100644
--- a/sysdeps/unix/sysv/linux/riscv/syscall.c
+++ b/sysdeps/unix/sysv/linux/riscv/syscall.c
@@ -27,7 +27,7 @@ syscall (long int syscall_number, long int arg1, long int arg2, long int arg3,
ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4,
arg5, arg6, arg7);
- if (INTERNAL_SYSCALL_ERROR_P (ret))
+ if (ret < 0)
return __syscall_error (ret);
return ret;
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c
index 1f214173fe..c1e01a61f3 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c
@@ -40,7 +40,7 @@
{ \
stack_t oss; \
int res = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss); \
- if (!INTERNAL_SYSCALL_ERROR_P (res)) \
+ if (res == 0) \
{ \
if ((oss.ss_flags & SS_ONSTACK) == 0 \
|| ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
index 6199589307..75c1318d83 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
@@ -42,8 +42,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
parameters.offset = offset;
parameters.len = len;
parameters.advise = advise;
- int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, ¶meters);
- return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0;
+ return -INTERNAL_SYSCALL_CALL (fadvise64_64, ¶meters);
}
#include <shlib-compat.h>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c
index bc74408135..c42dc5e56a 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c
@@ -40,7 +40,7 @@
{ \
stack_t oss; \
int res = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss); \
- if (!INTERNAL_SYSCALL_ERROR_P (res)) \
+ if (res == 0) \
{ \
if ((oss.ss_flags & SS_ONSTACK) == 0 \
|| ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index d5a65c06c1..40c3416ec5 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -35,9 +35,9 @@ shmat (int shmid, const void *shmaddr, int shmflg)
resultvar = INTERNAL_SYSCALL_CALL (ipc, IPCOP_shmat, shmid, shmflg,
&raddr, shmaddr);
- if (INTERNAL_SYSCALL_ERROR_P (resultvar))
- return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar);
+ if (resultvar == 0)
+ return raddr;
- return raddr;
+ return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar);
#endif
}
diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index 88db076184..17ed99d495 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -36,14 +36,14 @@
if (vdsop != NULL) \
{ \
sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \
- if (!INTERNAL_SYSCALL_ERROR_P (sc_ret)) \
+ if (sc_ret == 0) \
goto out; \
if (sc_ret != -ENOSYS) \
goto iserr; \
} \
\
sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \
- if (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \
+ if (sc_ret < 0) \
{ \
iserr: \
__set_errno (-sc_ret); \
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index a47f47526d..d09e5ee532 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -23,10 +23,6 @@
#include <endian.h>
#include <errno.h>
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val) \
- ((unsigned long int) (val) > -4096UL)
-
#ifndef SYSCALL_ERROR_LABEL
# define SYSCALL_ERROR_LABEL(sc_err) \
({ \
@@ -35,6 +31,7 @@
})
#endif
+#ifndef __ASSEMBLER__
/* 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. */
@@ -42,10 +39,11 @@
#define INLINE_SYSCALL(name, nr, args...) \
({ \
long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
- __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \
+ __glibc_unlikely (sc_ret > -4096UL) \
? SYSCALL_ERROR_LABEL (-sc_ret) \
: sc_ret; \
})
+#endif
/* Set error number and return -1. A target may choose to return the
internal function, __syscall_error, which sets errno and returns -1.
diff --git a/sysdeps/unix/sysv/linux/timer_create.c b/sysdeps/unix/sysv/linux/timer_create.c
index d8289d1dc7..9bf68f5ad7 100644
--- a/sysdeps/unix/sysv/linux/timer_create.c
+++ b/sysdeps/unix/sysv/linux/timer_create.c
@@ -124,7 +124,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
int res;
res = INTERNAL_SYSCALL_CALL (timer_create, syscall_clockid, &sev,
&newp->ktimerid);
- if (INTERNAL_SYSCALL_ERROR_P (res))
+ if (res < 0)
{
free (newp);
__set_errno (-res);
diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c
index b5eb6404c9..9ef95b7d8b 100644
--- a/sysdeps/unix/sysv/linux/times.c
+++ b/sysdeps/unix/sysv/linux/times.c
@@ -19,13 +19,11 @@
#include <sys/times.h>
#include <sysdep.h>
-
clock_t
__times (struct tms *buf)
{
clock_t ret = INTERNAL_SYSCALL_CALL (times, buf);
- if (INTERNAL_SYSCALL_ERROR_P (ret)
- && __glibc_unlikely (ret == -EFAULT)
+ if (__glibc_unlikely (ret == -EFAULT)
&& buf)
{
/* This might be an error or not. For architectures which have no
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/times.c b/sysdeps/unix/sysv/linux/x86_64/x32/times.c
index 864c123117..e207fb1cf2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/times.c
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/times.c
@@ -33,8 +33,4 @@
(long long int) resultvar; \
})
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val) \
- ((unsigned long long int) (val) >= -4095LL)
-
#include <sysdeps/unix/sysv/linux/times.c>
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 03/23] linux: Add syscall_ret and use it on INLINE_SYSCALL
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 01/23] linux: Remove INTERNAL_SYSCALL_ERRNO Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 02/23] linux: Remove INTERNAL_SYSCALL_ERROR_P Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 04/23] linux: Replace INLINE_SYSCALL_ERROR_RETURN_VALUE with __syscall_error Adhemerval Zanella
` (19 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
It check the resulting value from INTERNAL_SYSCALL_CALL and sets the
errno accordingly.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/unix/sysv/linux/fstatat.c | 2 +-
sysdeps/unix/sysv/linux/fstatat64.c | 2 +-
sysdeps/unix/sysv/linux/mq_unlink.c | 11 +++--------
sysdeps/unix/sysv/linux/sysdep-vdso.h | 26 +++++--------------------
sysdeps/unix/sysv/linux/sysdep.h | 28 +++++++++++++--------------
5 files changed, 23 insertions(+), 46 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
index 87e5c0fc8f..5ba1b99372 100644
--- a/sysdeps/unix/sysv/linux/fstatat.c
+++ b/sysdeps/unix/sysv/linux/fstatat.c
@@ -80,7 +80,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag)
# endif /* __nr_fstatat64 */
# endif /* STAT_IS_KERNEL_STAT */
- return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return syscall_ret (r);
}
weak_alias (__fstatat, fstatat)
diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index 71216e43f5..a788940390 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -102,7 +102,7 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf,
# endif
#endif
- return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return syscall_ret (r);
}
#if __TIMESIZE != 64
hidden_def (__fstatat64_time64)
diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c
index bfba6ccfec..701bc86438 100644
--- a/sysdeps/unix/sysv/linux/mq_unlink.c
+++ b/sysdeps/unix/sysv/linux/mq_unlink.c
@@ -30,12 +30,7 @@ mq_unlink (const char *name)
/* While unlink can return either EPERM or EACCES, mq_unlink should
return just EACCES. */
- if (ret < 0)
- {
- if (ret == -EPERM)
- ret = -EACCES;
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-ret);
- }
-
- return ret;
+ if (ret == -EPERM)
+ ret = -EACCES;
+ return syscall_ret (ret);
}
diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index 17ed99d495..9f59198444 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -28,29 +28,13 @@
#define INLINE_VSYSCALL(name, nr, args...) \
({ \
- __label__ out; \
- __label__ iserr; \
- long int sc_ret; \
- \
+ long int sc_ret = -ENOSYS; \
__typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \
if (vdsop != NULL) \
- { \
- sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \
- if (sc_ret == 0) \
- goto out; \
- if (sc_ret != -ENOSYS) \
- goto iserr; \
- } \
- \
- sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \
- if (sc_ret < 0) \
- { \
- iserr: \
- __set_errno (-sc_ret); \
- sc_ret = -1L; \
- } \
- out: \
- sc_ret; \
+ sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \
+ if (sc_ret == -ENOSYS) \
+ sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \
+ syscall_ret (sc_ret); \
})
#endif /* SYSDEP_VDSO_LINUX_H */
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index d09e5ee532..e423b5e7b1 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -23,26 +23,24 @@
#include <endian.h>
#include <errno.h>
-#ifndef SYSCALL_ERROR_LABEL
-# define SYSCALL_ERROR_LABEL(sc_err) \
- ({ \
- __set_errno (sc_err); \
- -1L; \
- })
-#endif
-
#ifndef __ASSEMBLER__
+static inline long int
+syscall_ret (unsigned long int val)
+{
+ if (val > -4096UL)
+ {
+ __set_errno (-val);
+ return -1;
+ }
+ return val;
+}
+
/* 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...) \
- ({ \
- long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
- __glibc_unlikely (sc_ret > -4096UL) \
- ? SYSCALL_ERROR_LABEL (-sc_ret) \
- : sc_ret; \
- })
+#define INLINE_SYSCALL(...) \
+ syscall_ret (INTERNAL_SYSCALL (__VA_ARGS__))
#endif
/* Set error number and return -1. A target may choose to return the
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 04/23] linux: Replace INLINE_SYSCALL_ERROR_RETURN_VALUE with __syscall_error
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (2 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 03/23] linux: Add syscall_ret and use it on INLINE_SYSCALL Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 05/23] linux: Use generic __syscall_error for aarch64 Adhemerval Zanella
` (18 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The INLINE_SYSCALL_ERROR_RETURN_VALUE macro was added as a way to
optimize i686 errno setting when {INTERNAL,INLINE}_SYSCALL is called
(since calling__x86.get_pc_thunk.reg to load PC into reg to access
errno is costly for the cases where there is no error).
However this i686 optimizations was also remove by fcb78a55058f,
which consolidate INLINE_SYSCALL semantic and removed i686
INLINE_SYSCALL_ERROR_RETURN_VALUE definition.
This patch adds this optimization back, but in a more generic way.
Each architecture/ABI might select how __syscall_error is emitted,
either by using a static inline or using a external call. To avoid
the potential PLT call overhead, for the latter __syscall_error is
added on each library that issues {INTERNAL,INLINE}_SYSCALL as a
hidden symbol (and this follow the idea of moving all the libpthread
and librt to libc).
No semantic changes expected, checked with a build against all
affected ABIs.
---
sysdeps/csky/nptl/tls.h | 4 +--
sysdeps/m68k/nptl/tls.h | 7 ++--
sysdeps/unix/sysv/linux/Makefile | 9 +++--
sysdeps/unix/sysv/linux/aarch64/sysdep.c | 1 -
sysdeps/unix/sysv/linux/adjtime.c | 2 +-
sysdeps/unix/sysv/linux/alpha/fxstat64.c | 2 +-
sysdeps/unix/sysv/linux/alpha/lxstat64.c | 2 +-
sysdeps/unix/sysv/linux/alpha/xstat64.c | 2 +-
sysdeps/unix/sysv/linux/arc/sysdep.c | 8 ++---
sysdeps/unix/sysv/linux/arc/sysdep.h | 5 ---
sysdeps/unix/sysv/linux/faccessat.c | 4 +--
sysdeps/unix/sysv/linux/fchmodat.c | 2 +-
sysdeps/unix/sysv/linux/fcntl_nocancel.c | 2 +-
sysdeps/unix/sysv/linux/fstatat.c | 4 +--
sysdeps/unix/sysv/linux/fstatat64.c | 2 +-
sysdeps/unix/sysv/linux/futimens.c | 2 +-
sysdeps/unix/sysv/linux/fxstat.c | 2 +-
sysdeps/unix/sysv/linux/fxstat64.c | 2 +-
sysdeps/unix/sysv/linux/fxstatat.c | 2 +-
sysdeps/unix/sysv/linux/fxstatat64.c | 2 +-
sysdeps/unix/sysv/linux/getdents.c | 2 +-
sysdeps/unix/sysv/linux/hppa/sysdep.c | 2 --
sysdeps/unix/sysv/linux/i386/brk.c | 2 +-
sysdeps/unix/sysv/linux/i386/sysdep.c | 1 -
sysdeps/unix/sysv/linux/i386/sysdep.h | 3 --
sysdeps/unix/sysv/linux/lxstat.c | 2 +-
sysdeps/unix/sysv/linux/lxstat64.c | 2 +-
sysdeps/unix/sysv/linux/m68k/getpagesize.c | 2 --
.../unix/sysv/linux/mips/mips64/fxstatat64.c | 2 +-
sysdeps/unix/sysv/linux/mknodat.c | 2 +-
sysdeps/unix/sysv/linux/mmap.c | 2 +-
sysdeps/unix/sysv/linux/mmap64.c | 2 +-
sysdeps/unix/sysv/linux/mq_open.c | 2 +-
sysdeps/unix/sysv/linux/mq_unlink.c | 2 +-
sysdeps/unix/sysv/linux/powerpc/sysdep.c | 1 -
sysdeps/unix/sysv/linux/prlimit.c | 4 +--
sysdeps/unix/sysv/linux/setegid.c | 2 +-
sysdeps/unix/sysv/linux/seteuid.c | 2 +-
sysdeps/unix/sysv/linux/shmat.c | 2 +-
sysdeps/unix/sysv/linux/speed.c | 4 +--
sysdeps/unix/sysv/linux/syscall_error.c | 30 ++++++++++++++++
sysdeps/unix/sysv/linux/syscall_error.h | 32 +++++++++++++++++
sysdeps/unix/sysv/linux/sysdep.h | 35 ++++++++++++-------
sysdeps/unix/sysv/linux/tcsendbrk.c | 2 +-
sysdeps/unix/sysv/linux/tcsetattr.c | 2 +-
sysdeps/unix/sysv/linux/ustat.c | 4 +--
sysdeps/unix/sysv/linux/utimensat.c | 2 +-
sysdeps/unix/sysv/linux/xmknod.c | 2 +-
sysdeps/unix/sysv/linux/xmknodat.c | 2 +-
sysdeps/unix/sysv/linux/xstat.c | 2 +-
sysdeps/unix/sysv/linux/xstat64.c | 2 +-
sysdeps/unix/sysv/linux/xstatconv.c | 12 +++----
52 files changed, 148 insertions(+), 88 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/syscall_error.c
create mode 100644 sysdeps/unix/sysv/linux/syscall_error.h
diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
index 60a59898c4..f8ee464db3 100644
--- a/sysdeps/csky/nptl/tls.h
+++ b/sysdeps/csky/nptl/tls.h
@@ -96,8 +96,8 @@ 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) \
- ({ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \
- (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \
+ ({ INTERNAL_SYSCALL_CALL (set_thread_area, \
+ (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \
? "unknown error" : NULL; })
/* 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 53cf33fbb9..bc98f42916 100644
--- a/sysdeps/m68k/nptl/tls.h
+++ b/sysdeps/m68k/nptl/tls.h
@@ -94,10 +94,9 @@ 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) \
- ({ \
- INTERNAL_SYSCALL_CALL (set_thread_area, \
- ((void *) (tcbp)) + TLS_TCB_OFFSET) < 0; \
- "unknown error" : NULL; })
+ ({ INTERNAL_SYSCALL_CALL (set_thread_area, \
+ ((void *) (tcbp)) + TLS_TCB_OFFSET) < 0 \
+ ? "unknown error" : NULL; })
# define TLS_DEFINE_INIT_TP(tp, pd) \
void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 09604e128b..241b5f2c53 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -41,7 +41,7 @@ update-syscall-lists: arch-syscall.h
endif
ifeq ($(subdir),csu)
-sysdep_routines += errno-loc
+sysdep_routines += errno-loc syscall_error
endif
ifeq ($(subdir),assert)
@@ -283,7 +283,8 @@ tests += tst-fallocate tst-fallocate64 tst-o_path-locks
endif
ifeq ($(subdir),elf)
-sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir
+sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir \
+ syscall_error
libof-lddlibc4 = lddlibc4
@@ -295,6 +296,8 @@ endif
ifeq ($(subdir),rt)
CFLAGS-mq_send.c += -fexceptions
CFLAGS-mq_receive.c += -fexceptions
+librt-routines += syscall_error
+librt-shared-only-routines += syscall_error
endif
ifeq ($(subdir),nscd)
@@ -303,5 +306,7 @@ CFLAGS-gai.c += -DNEED_NETLINK
endif
ifeq ($(subdir),nptl)
+libpthread-routines += syscall_error
+libpthread-shared-only-routines += syscall_error
tests += tst-align-clone tst-getpid1
endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.c b/sysdeps/unix/sysv/linux/aarch64/sysdep.c
index b6c01e1aec..6b88f3484f 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.c
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.c
@@ -16,7 +16,6 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
-#include <sysdep.h>
#include <errno.h>
long __syscall_error (long err);
diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c
index 8e7c8cc5da..1a1a37acd3 100644
--- a/sysdeps/unix/sysv/linux/adjtime.c
+++ b/sysdeps/unix/sysv/linux/adjtime.c
@@ -37,7 +37,7 @@ __adjtime64 (const struct __timeval64 *itv, struct __timeval64 *otv)
tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L;
tmp.tv_usec = itv->tv_usec % 1000000L;
if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L;
tntx.modes = ADJ_OFFSET_SINGLESHOT;
}
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
index bcfb55050c..806ef66598 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c
@@ -40,7 +40,7 @@ __fxstat64 (int vers, int fd, struct stat64 *buf)
int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
if (r == 0)
return __xstat_conv (vers, &kbuf, buf);
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return __syscall_error (r);
}
}
}
diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat64.c b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
index 7424b2f621..0499b0f8f1 100644
--- a/sysdeps/unix/sysv/linux/alpha/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/lxstat64.c
@@ -41,7 +41,7 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf)
int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
if (r == 0)
return __xstat_conv (vers, &kbuf, buf);
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return __syscall_error (r);
}
}
}
diff --git a/sysdeps/unix/sysv/linux/alpha/xstat64.c b/sysdeps/unix/sysv/linux/alpha/xstat64.c
index 59f7ddae7f..b08ade68d4 100644
--- a/sysdeps/unix/sysv/linux/alpha/xstat64.c
+++ b/sysdeps/unix/sysv/linux/alpha/xstat64.c
@@ -41,7 +41,7 @@ __xstat64 (int vers, const char *name, struct stat64 *buf)
int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
if (r == 0)
return __xstat_conv (vers, &kbuf, buf);
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return __syscall_error (r);
}
}
}
diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.c b/sysdeps/unix/sysv/linux/arc/sysdep.c
index f33d646798..fe904d723b 100644
--- a/sysdeps/unix/sysv/linux/arc/sysdep.c
+++ b/sysdeps/unix/sysv/linux/arc/sysdep.c
@@ -16,9 +16,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <sysdep.h>
#include <errno.h>
+extern long int __syscall_error (long int);
+libc_hidden_proto (__syscall_error)
+
/* All syscall handlers land here to avoid generated code bloat due to
GOT reference to errno_location or it's equivalent. */
long int
@@ -28,6 +30,4 @@ __syscall_error (long int err_no)
return -1;
}
-#if IS_IN (libc)
-hidden_def (__syscall_error)
-#endif
+libc_hidden_def (__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h b/sysdeps/unix/sysv/linux/arc/sysdep.h
index 8465a2f623..4ab44f6925 100644
--- a/sysdeps/unix/sysv/linux/arc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arc/sysdep.h
@@ -134,11 +134,6 @@ L (call_syscall_err): ASM_LINE_SEP \
# define SINGLE_THREAD_BY_GLOBAL 1
-# if IS_IN (libc)
-extern long int __syscall_error (long int);
-hidden_proto (__syscall_error)
-# endif
-
# define ARC_TRAP_INSN "trap_s 0 \n\t"
# undef INTERNAL_SYSCALL_NCS
diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c
index 5d078371b5..a54cc65767 100644
--- a/sysdeps/unix/sysv/linux/faccessat.c
+++ b/sysdeps/unix/sysv/linux/faccessat.c
@@ -34,7 +34,7 @@ faccessat (int fd, const char *file, int mode, int flag)
return ret;
if (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS))
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
if ((flag == 0 || ((flag & ~AT_EACCESS) == 0 && ! __libc_enable_secure)))
return INLINE_SYSCALL (faccessat, 3, fd, file, mode);
@@ -70,6 +70,6 @@ faccessat (int fd, const char *file, int mode, int flag)
if (granted == mode)
return 0;
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EACCES);
+ return __syscall_error (-EACCES);
#endif /* !__ASSUME_FACCESSAT2 */
}
diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c
index 5531f1aa6f..f1408b6f6a 100644
--- a/sysdeps/unix/sysv/linux/fchmodat.c
+++ b/sysdeps/unix/sysv/linux/fchmodat.c
@@ -31,7 +31,7 @@ fchmodat (int fd, const char *file, mode_t mode, int flag)
if (flag == 0)
return INLINE_SYSCALL (fchmodat, 3, fd, file, mode);
else if (flag != AT_SYMLINK_NOFOLLOW)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
else
{
/* The kernel system call does not have a mode argument.
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index fb3e7a614c..d4554ea9bf 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -56,7 +56,7 @@ __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg)
if (res == 0)
return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-res);
+ return __syscall_error (res);
}
return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg);
diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
index 5ba1b99372..ba58232472 100644
--- a/sysdeps/unix/sysv/linux/fstatat.c
+++ b/sysdeps/unix/sysv/linux/fstatat.c
@@ -35,7 +35,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag)
if (r == 0 && (buf->__st_ino_pad != 0
|| buf->__st_size_pad != 0
|| buf->__st_blocks_pad != 0))
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
# else
# ifdef __NR_fstatat64
/* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32,
@@ -47,7 +47,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag)
if (! in_ino_t_range (st64.st_ino)
|| ! in_off_t_range (st64.st_size)
|| ! in_blkcnt_t_range (st64.st_blocks))
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
/* Clear internal pad and reserved fields. */
memset (buf, 0, sizeof (*buf));
diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c
index a788940390..831a5b8e54 100644
--- a/sysdeps/unix/sysv/linux/fstatat64.c
+++ b/sysdeps/unix/sysv/linux/fstatat64.c
@@ -47,7 +47,7 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf,
return 0;
}
if (-r != ENOSYS)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return __syscall_error (r);
#endif
#if XSTAT_IS_XSTAT64
diff --git a/sysdeps/unix/sysv/linux/futimens.c b/sysdeps/unix/sysv/linux/futimens.c
index 2c698b4e85..756a61a935 100644
--- a/sysdeps/unix/sysv/linux/futimens.c
+++ b/sysdeps/unix/sysv/linux/futimens.c
@@ -32,7 +32,7 @@ int
__futimens64 (int fd, const struct __timespec64 tsp64[2])
{
if (fd < 0)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EBADF);
+ return __syscall_error (-EBADF);
return __utimensat64_helper (fd, NULL, &tsp64[0], 0);
}
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index 649bb95252..fabf8e66f8 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -52,7 +52,7 @@ __fxstat (int vers, int fd, struct stat *buf)
default:
{
# if STAT_IS_KERNEL_STAT
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
# else
struct stat64 buf64;
int r = INLINE_SYSCALL_CALL (fstat64, fd, &buf64);
diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c
index 4bd926bf01..5a81f87e2a 100644
--- a/sysdeps/unix/sysv/linux/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/fxstat64.c
@@ -50,7 +50,7 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf)
and x86_64. */
if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX)
return INLINE_SYSCALL_CALL (fstat, fd, buf);
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
# else
/* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */
struct statx tmp;
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index 2083e18eac..b3a1750e1b 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -41,7 +41,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
return r ?: stat_overflow (st);
}
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
#else
/* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32,
microblaze, s390, sh, powerpc32, and sparc32. */
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index 8a505451d9..a0bdb137f1 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -63,7 +63,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
if (vers == _STAT_VER_LINUX)
return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
#endif
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
diff --git a/sysdeps/unix/sysv/linux/getdents.c b/sysdeps/unix/sysv/linux/getdents.c
index a76be2e5e7..a5041e4ebb 100644
--- a/sysdeps/unix/sysv/linux/getdents.c
+++ b/sysdeps/unix/sysv/linux/getdents.c
@@ -98,7 +98,7 @@ __getdents (int fd, void *buf0, size_t nbytes)
__lseek64 (fd, last_offset, SEEK_SET);
return outp->b - buf;
}
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
}
last_offset = d_off;
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.c b/sysdeps/unix/sysv/linux/hppa/sysdep.c
index 8f05bfc9c9..8c06b6fc80 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep.c
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep.c
@@ -15,8 +15,6 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
-#include <stdarg.h>
-#include <sysdep.h>
#include <errno.h>
/* This routine is jumped to by all the syscall handlers, to stash
diff --git a/sysdeps/unix/sysv/linux/i386/brk.c b/sysdeps/unix/sysv/linux/i386/brk.c
index 021b6d37a0..900fb0a031 100644
--- a/sysdeps/unix/sysv/linux/i386/brk.c
+++ b/sysdeps/unix/sysv/linux/i386/brk.c
@@ -39,7 +39,7 @@ __brk (void *addr)
void *newbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);
__curbrk = newbrk;
if (newbrk < addr)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOMEM);
+ return __syscall_error (-ENOMEM);
return 0;
}
weak_alias (__brk, brk)
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.c b/sysdeps/unix/sysv/linux/i386/sysdep.c
index 0a9058d505..e6228406dd 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.c
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.c
@@ -16,7 +16,6 @@
<https://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <sysdep.h>
/* This routine is jumped to by all the syscall handlers, to stash
an error number into errno. ERROR is the negative error number
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index bfb5de3b45..4680013de4 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -236,9 +236,6 @@
#else /* !__ASSEMBLER__ */
-extern int __syscall_error (int)
- attribute_hidden __attribute__ ((__regparm__ (1)));
-
#ifndef OPTIMIZE_FOR_GCC_5
/* We need some help from the assembler to generate optimal code. We
define some macros here which later will be used. */
diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
index 913618eab9..c86cfb349a 100644
--- a/sysdeps/unix/sysv/linux/lxstat.c
+++ b/sysdeps/unix/sysv/linux/lxstat.c
@@ -53,7 +53,7 @@ __lxstat (int vers, const char *name, struct stat *buf)
default:
{
# if STAT_IS_KERNEL_STAT
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
# else
struct stat64 buf64;
int r = INLINE_SYSCALL_CALL (lstat64, name, &buf64);
diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
index 277b54b305..3e0fb8b25d 100644
--- a/sysdeps/unix/sysv/linux/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/lxstat64.c
@@ -81,7 +81,7 @@ ___lxstat64 (int vers, const char *name, struct stat64 *buf)
# endif /* STAT_IS_KERNEL_STAT */
#endif /* XSTAT_IS_XSTAT64 */
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
diff --git a/sysdeps/unix/sysv/linux/m68k/getpagesize.c b/sysdeps/unix/sysv/linux/m68k/getpagesize.c
index 6d9d90ab24..d80bc7e870 100644
--- a/sysdeps/unix/sysv/linux/m68k/getpagesize.c
+++ b/sysdeps/unix/sysv/linux/m68k/getpagesize.c
@@ -28,8 +28,6 @@
int
__getpagesize (void)
{
- int result;
-
if (GLRO(dl_pagesize) != 0)
return GLRO(dl_pagesize);
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
index f40a2c5aa8..6bea711cd0 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
@@ -35,7 +35,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);;
return r ?: __xstat64_conv (vers, &kst, st);
}
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4);
diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c
index 279a4404f5..aa298483d5 100644
--- a/sysdeps/unix/sysv/linux/mknodat.c
+++ b/sysdeps/unix/sysv/linux/mknodat.c
@@ -28,7 +28,7 @@ __mknodat (int fd, const char *path, mode_t mode, dev_t dev)
32-bit. */
unsigned int k_dev = dev;
if (k_dev != dev)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
return INLINE_SYSCALL_CALL (mknodat, fd, path, mode, k_dev);
}
diff --git a/sysdeps/unix/sysv/linux/mmap.c b/sysdeps/unix/sysv/linux/mmap.c
index 22f276bb14..9952625219 100644
--- a/sysdeps/unix/sysv/linux/mmap.c
+++ b/sysdeps/unix/sysv/linux/mmap.c
@@ -36,7 +36,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
MMAP_CHECK_PAGE_UNIT ();
if (offset & MMAP_OFF_LOW_MASK)
- return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return (void *) __syscall_error (-EINVAL);
#ifdef __NR_mmap2
return (void *) MMAP_CALL (mmap2, addr, len, prot, flags, fd,
diff --git a/sysdeps/unix/sysv/linux/mmap64.c b/sysdeps/unix/sysv/linux/mmap64.c
index 8074deb466..0eed429e48 100644
--- a/sysdeps/unix/sysv/linux/mmap64.c
+++ b/sysdeps/unix/sysv/linux/mmap64.c
@@ -49,7 +49,7 @@ __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
MMAP_CHECK_PAGE_UNIT ();
if (offset & MMAP_OFF_MASK)
- return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return (void *) __syscall_error (-EINVAL);
MMAP_PREPARE (addr, len, prot, flags, fd, offset);
#ifdef __NR_mmap2
diff --git a/sysdeps/unix/sysv/linux/mq_open.c b/sysdeps/unix/sysv/linux/mq_open.c
index c88dc580e4..542f9b7097 100644
--- a/sysdeps/unix/sysv/linux/mq_open.c
+++ b/sysdeps/unix/sysv/linux/mq_open.c
@@ -33,7 +33,7 @@ mqd_t
__mq_open (const char *name, int oflag, ...)
{
if (name[0] != '/')
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
mode_t mode = 0;
struct mq_attr *attr = NULL;
diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c
index 701bc86438..741c4e5776 100644
--- a/sysdeps/unix/sysv/linux/mq_unlink.c
+++ b/sysdeps/unix/sysv/linux/mq_unlink.c
@@ -24,7 +24,7 @@ int
mq_unlink (const char *name)
{
if (name[0] != '/')
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
int ret = INTERNAL_SYSCALL_CALL (mq_unlink, name + 1);
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.c b/sysdeps/unix/sysv/linux/powerpc/sysdep.c
index 37f0f1f53e..1bf5ea6f62 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.c
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.c
@@ -15,7 +15,6 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <sysdep.h>
#include <errno.h>
/* This routine is jumped to by all the syscall handlers, to stash
diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c
index e12eb4e9bc..0a8e6a519e 100644
--- a/sysdeps/unix/sysv/linux/prlimit.c
+++ b/sysdeps/unix/sysv/linux/prlimit.c
@@ -58,7 +58,7 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
{
if ((new_rlimit == NULL)
&& (old_rlimit64_mem.rlim_cur != RLIM64_INFINITY))
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
old_rlimit->rlim_cur = RLIM_INFINITY;
}
old_rlimit->rlim_max = old_rlimit64_mem.rlim_max;
@@ -66,7 +66,7 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
{
if ((new_rlimit == NULL)
&& (old_rlimit64_mem.rlim_max != RLIM64_INFINITY))
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
old_rlimit->rlim_max = RLIM_INFINITY;
}
}
diff --git a/sysdeps/unix/sysv/linux/setegid.c b/sysdeps/unix/sysv/linux/setegid.c
index ce8bead278..ea135b9084 100644
--- a/sysdeps/unix/sysv/linux/setegid.c
+++ b/sysdeps/unix/sysv/linux/setegid.c
@@ -26,7 +26,7 @@ setegid (gid_t gid)
int result;
if (gid == (gid_t) ~0)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
#ifdef __NR_setresgid32
result = INLINE_SETXID_SYSCALL (setresgid32, 3, -1, gid, -1);
diff --git a/sysdeps/unix/sysv/linux/seteuid.c b/sysdeps/unix/sysv/linux/seteuid.c
index 4519ac2db6..5259adee85 100644
--- a/sysdeps/unix/sysv/linux/seteuid.c
+++ b/sysdeps/unix/sysv/linux/seteuid.c
@@ -26,7 +26,7 @@ seteuid (uid_t uid)
int result;
if (uid == (uid_t) ~0)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
#ifdef __NR_setresuid32
result = INLINE_SETXID_SYSCALL (setresuid32, 3, -1, uid, -1);
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index 40c3416ec5..bf9c142ae5 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -38,6 +38,6 @@ shmat (int shmid, const void *shmaddr, int shmflg)
if (resultvar == 0)
return raddr;
- return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar);
+ return (void *) __syscall_error (resultvar);
#endif
}
diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c
index d7d74ddb67..9df2f250c6 100644
--- a/sysdeps/unix/sysv/linux/speed.c
+++ b/sysdeps/unix/sysv/linux/speed.c
@@ -56,7 +56,7 @@ cfsetospeed (struct termios *termios_p, speed_t speed)
{
if ((speed & ~CBAUD) != 0
&& (speed < B57600 || speed > __MAX_BAUD))
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
#if _HAVE_STRUCT_TERMIOS_C_OSPEED
termios_p->c_ospeed = speed;
@@ -78,7 +78,7 @@ cfsetispeed (struct termios *termios_p, speed_t speed)
{
if ((speed & ~CBAUD) != 0
&& (speed < B57600 || speed > __MAX_BAUD))
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
#if _HAVE_STRUCT_TERMIOS_C_ISPEED
termios_p->c_ispeed = speed;
diff --git a/sysdeps/unix/sysv/linux/syscall_error.c b/sysdeps/unix/sysv/linux/syscall_error.c
new file mode 100644
index 0000000000..b5647f89d3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/syscall_error.c
@@ -0,0 +1,30 @@
+/* Linux wrappers for setting errno.
+ Copyright (C) 2020 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 <sysdep.h>
+#include <errno.h>
+
+#if SYSCALL_ERROR_FUNC
+long int
+SYSCALL_ERROR_FUNC_ATTR
+__syscall_error (long int error)
+{
+ __set_errno (-error);
+ return -1L;
+}
+#endif
diff --git a/sysdeps/unix/sysv/linux/syscall_error.h b/sysdeps/unix/sysv/linux/syscall_error.h
new file mode 100644
index 0000000000..6523eb5269
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/syscall_error.h
@@ -0,0 +1,32 @@
+/* Linux wrappers for setting errno.
+ Copyright (C) 2020 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/>. */
+
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
+
+/* Each architecture might how __syscall_error is called, either by defining
+ an inline function (default) or by calling a hidden function. Check the
+ sysdep.h file for the implementation. */
+#define SYSCALL_ERROR_FUNC 0
+
+/* Any function attribute used to define the __syscall_error in case of
+ __SYSCALL_ERROR_FUNC (for instance by using a different calling covention
+ for intra-DSO calls. */
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index e423b5e7b1..474c4e209e 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -20,18 +20,36 @@
#include <bits/wordsize.h>
#include <kernel-features.h>
+#include <syscall_error.h>
#include <endian.h>
#include <errno.h>
#ifndef __ASSEMBLER__
+/* The errno setting might be set either inline or with a helper function.
+ For some ABIs (x86_64 for instance), handling it inline might generate
+ less code; while for others (i686) a function call is preferable.
+
+ To use the helper function the ABI must define SYSCALL_ERROR_FUNC, it will
+ build a hidden function on each shared object that issue direct syscall
+ with {INLINE,INTERNAL}_SYSCALL_CALL. */
+
+# if SYSCALL_ERROR_FUNC
+long int __syscall_error (long int err) attribute_hidden
+ SYSCALL_ERROR_FUNC_ATTR;
+# else
+static inline long int
+__syscall_error (long int err)
+{
+ __set_errno (-err);
+ return -1L;
+}
+# endif
+
static inline long int
syscall_ret (unsigned long int val)
{
if (val > -4096UL)
- {
- __set_errno (-val);
- return -1;
- }
+ return __syscall_error (val);
return val;
}
@@ -43,15 +61,6 @@ syscall_ret (unsigned long int val)
syscall_ret (INTERNAL_SYSCALL (__VA_ARGS__))
#endif
-/* Set error number and return -1. A target may choose to return the
- internal function, __syscall_error, which sets errno and returns -1.
- We use -1l, instead of -1, so that it can be casted to (void *). */
-#define INLINE_SYSCALL_ERROR_RETURN_VALUE(err) \
- ({ \
- __set_errno (err); \
- -1l; \
- })
-
/* Provide a dummy argument that can be used to force register
alignment for register pairs if required by the syscall ABI. */
#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
diff --git a/sysdeps/unix/sysv/linux/tcsendbrk.c b/sysdeps/unix/sysv/linux/tcsendbrk.c
index 5d81d86bb2..d77acd064d 100644
--- a/sysdeps/unix/sysv/linux/tcsendbrk.c
+++ b/sysdeps/unix/sysv/linux/tcsendbrk.c
@@ -39,6 +39,6 @@ tcsendbreak (int fd, int duration)
/* ioctl can't send a break of any other duration for us.
This could be changed to use trickery (e.g. lower speed and
send a '\0') to send the break, but for now just return an error. */
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
#endif
}
diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c
index 50b2b0af8a..978e182e17 100644
--- a/sysdeps/unix/sysv/linux/tcsetattr.c
+++ b/sysdeps/unix/sysv/linux/tcsetattr.c
@@ -58,7 +58,7 @@ __tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
cmd = TCSETSF;
break;
default:
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
k_termios.c_iflag = termios_p->c_iflag & ~IBAUD0;
diff --git a/sysdeps/unix/sysv/linux/ustat.c b/sysdeps/unix/sysv/linux/ustat.c
index e38b792705..1df6f28794 100644
--- a/sysdeps/unix/sysv/linux/ustat.c
+++ b/sysdeps/unix/sysv/linux/ustat.c
@@ -31,7 +31,7 @@
unsigned long long int k_dev; \
k_dev = dev & ((1ULL << 32) - 1); \
if (k_dev != dev) \
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); \
+ return __syscall_error (-EINVAL); \
(unsigned int) k_dev; \
})
# endif
@@ -50,7 +50,7 @@ __old_ustat (dev_t dev, struct ustat *ubuf)
# ifdef __NR_ustat
return INLINE_SYSCALL_CALL (ustat, DEV_TO_KDEV (dev), ubuf);
# else
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS);
+ return __syscall_error (-ENOSYS);
# endif
}
compat_symbol (libc, __old_ustat, ustat, GLIBC_2_0);
diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c
index aef34916e8..15a40a6174 100644
--- a/sysdeps/unix/sysv/linux/utimensat.c
+++ b/sysdeps/unix/sysv/linux/utimensat.c
@@ -71,7 +71,7 @@ __utimensat64 (int fd, const char *file, const struct __timespec64 tsp64[2],
int flags)
{
if (file == NULL)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
return __utimensat64_helper (fd, file, &tsp64[0], flags);
}
diff --git a/sysdeps/unix/sysv/linux/xmknod.c b/sysdeps/unix/sysv/linux/xmknod.c
index 10e874a514..c3b31f9c97 100644
--- a/sysdeps/unix/sysv/linux/xmknod.c
+++ b/sysdeps/unix/sysv/linux/xmknod.c
@@ -31,7 +31,7 @@ attribute_compat_text_section
__xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
{
if (vers != _MKNOD_VER)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
return __mknodat (AT_FDCWD, path, mode, *dev);
}
diff --git a/sysdeps/unix/sysv/linux/xmknodat.c b/sysdeps/unix/sysv/linux/xmknodat.c
index 17ffea16c9..9b2bdd872f 100644
--- a/sysdeps/unix/sysv/linux/xmknodat.c
+++ b/sysdeps/unix/sysv/linux/xmknodat.c
@@ -28,7 +28,7 @@ int
__xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev)
{
if (vers != _MKNOD_VER)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
return __mknodat (fd, file, mode, *dev);
}
diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
index 3eb2d8c51b..1394d6235c 100644
--- a/sysdeps/unix/sysv/linux/xstat.c
+++ b/sysdeps/unix/sysv/linux/xstat.c
@@ -52,7 +52,7 @@ __xstat (int vers, const char *name, struct stat *buf)
default:
{
# if STAT_IS_KERNEL_STAT
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
# else
struct stat64 buf64;
int r = INLINE_SYSCALL_CALL (stat64, name, &buf64);
diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c
index dd4f808c7a..06579c9d63 100644
--- a/sysdeps/unix/sysv/linux/xstat64.c
+++ b/sysdeps/unix/sysv/linux/xstat64.c
@@ -78,7 +78,7 @@ ___xstat64 (int vers, const char *name, struct stat64 *buf)
# endif /* STAT_IS_KERNEL_STAT */
#endif /* XSTAT_IS_XSTAT64 */
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
#if XSTAT_IS_XSTAT64
diff --git a/sysdeps/unix/sysv/linux/xstatconv.c b/sysdeps/unix/sysv/linux/xstatconv.c
index b100e07783..552e762fda 100644
--- a/sysdeps/unix/sysv/linux/xstatconv.c
+++ b/sysdeps/unix/sysv/linux/xstatconv.c
@@ -96,7 +96,7 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
break;
default:
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
return 0;
@@ -169,7 +169,7 @@ __xstat64_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
_STAT_VER_KERNEL does not make sense. */
case _STAT_VER_KERNEL:
default:
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
return 0;
@@ -192,7 +192,7 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
buf->st_ino = kbuf->st_ino;
if (sizeof (buf->st_ino) != sizeof (kbuf->st_ino)
&& buf->st_ino != kbuf->st_ino)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
buf->st_mode = kbuf->st_mode;
buf->st_nlink = kbuf->st_nlink;
buf->st_uid = kbuf->st_uid;
@@ -205,13 +205,13 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
/* Check for overflow. */
if (sizeof (buf->st_size) != sizeof (kbuf->st_size)
&& buf->st_size != kbuf->st_size)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
buf->st_blksize = kbuf->st_blksize;
buf->st_blocks = kbuf->st_blocks;
/* Check for overflow. */
if (sizeof (buf->st_blocks) != sizeof (kbuf->st_blocks)
&& buf->st_blocks != kbuf->st_blocks)
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+ return __syscall_error (-EOVERFLOW);
#ifdef _HAVE_STAT_NSEC
buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
@@ -247,7 +247,7 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
_STAT_VER_KERNEL does not make sense. */
case _STAT_VER_KERNEL:
default:
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+ return __syscall_error (-EINVAL);
}
return 0;
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 05/23] linux: Use generic __syscall_error for aarch64
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (3 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 04/23] linux: Replace INLINE_SYSCALL_ERROR_RETURN_VALUE with __syscall_error Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 06/23] linux: Use generic __syscall_error for i386 Adhemerval Zanella
` (17 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The auto-generated syscalls calls the __syscall_error, although setting
using inline function generates slight less code:
--- sizes-aarch64-linux-gnu.outline
+++ sizes-aarch64-linux-gnu.inline
text data bss dec hex filename
1388874 19096 14520 1422490 15b49a libc.so
- 138509 7136 344 145989 23a45 elf/ld.so
- 98439 1636 16656 116731 1c7fb nptl/libpthread.so
- 23942 1236 248 25426 6352 rt/librt.so
+ 138449 7136 344 145929 23a09 elf/ld.so
+ 98567 1636 16656 116859 1c87b nptl/libpthread.so
+ 23918 1236 248 25402 633a rt/librt.so
Checked on aarch64-linux-gnu.
---
.../aarch64/{sysdep.c => syscall_error.h} | 23 +++++++------------
1 file changed, 8 insertions(+), 15 deletions(-)
rename sysdeps/unix/sysv/linux/aarch64/{sysdep.c => syscall_error.h} (63%)
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.c b/sysdeps/unix/sysv/linux/aarch64/syscall_error.h
similarity index 63%
rename from sysdeps/unix/sysv/linux/aarch64/sysdep.c
rename to sysdeps/unix/sysv/linux/aarch64/syscall_error.h
index 6b88f3484f..a45e02dbe4 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.c
+++ b/sysdeps/unix/sysv/linux/aarch64/syscall_error.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
-
+/* Linux wrappers for setting errno. AArch64 version.
+ Copyright (C) 2020 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
@@ -13,20 +13,13 @@
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
+ License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
-long __syscall_error (long err);
-hidden_proto (__syscall_error)
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
-/* This routine is jumped to by all the syscall handlers, to stash
- an error number into errno. */
-long
-__syscall_error (long err)
-{
- __set_errno (- err);
- return -1;
-}
-hidden_def (__syscall_error)
+#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 06/23] linux: Use generic __syscall_error for i386
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (4 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 05/23] linux: Use generic __syscall_error for aarch64 Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 07/23] linux: Use generic __syscall_error for arc Adhemerval Zanella
` (16 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The auto-generated syscalls calls the __syscall_error, and for i686
it results in much less compat code:
--- sizes-i686-linux-gnu.outline
+++ sizes-i686-linux-gnu.inline
text data bss dec hex filename
-1933727 11324 10172 1955223 1dd597 libc.so
- 175366 4768 184 180318 2c05e elf/ld.so
- 109851 832 8408 119091 1d133 nptl/libpthread.so
- 27983 628 184 28795 707b rt/librt.so
+1937875 11324 10172 1959371 1de5cb libc.so
+ 175790 4768 184 180742 2c206 elf/ld.so
+ 110179 832 8408 119419 1d27b nptl/libpthread.so
+ 28139 628 184 28951 7117 rt/librt.so
This patch enabled SYSCALL_ERROR_FUNC with the expected abi by also
defining SYSCALL_ERROR_FUNC_ATTR.
Checked on i686-linux-gnu.
---
sysdeps/unix/sysv/linux/i386/Makefile | 13 ------------
.../linux/i386/{sysdep.c => syscall_error.h} | 20 ++++++++-----------
2 files changed, 8 insertions(+), 25 deletions(-)
rename sysdeps/unix/sysv/linux/i386/{sysdep.c => syscall_error.h} (67%)
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index da716e2c1b..983b02e081 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -28,22 +28,9 @@ gen-as-const-headers += ucontext_i.sym
endif
ifeq ($(subdir),csu)
-sysdep-dl-routines += sysdep
ifeq (yes,$(build-shared))
sysdep_routines += divdi3
shared-only-routines += divdi3
CPPFLAGS-divdi3.c = -Din_divdi3_c
endif
endif
-
-ifeq ($(subdir),nptl)
-# pull in __syscall_error routine
-libpthread-routines += sysdep
-libpthread-shared-only-routines += sysdep
-endif
-
-ifeq ($(subdir),rt)
-# pull in __syscall_error routine
-librt-routines += sysdep
-librt-shared-only-routines += sysdep
-endif
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.c b/sysdeps/unix/sysv/linux/i386/syscall_error.h
similarity index 67%
rename from sysdeps/unix/sysv/linux/i386/sysdep.c
rename to sysdeps/unix/sysv/linux/i386/syscall_error.h
index e6228406dd..0b63c07a4e 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.c
+++ b/sysdeps/unix/sysv/linux/i386/syscall_error.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2020 Free Software Foundation, Inc.
+/* Linux wrappers for setting errno. i386 version.
+ Copyright (C) 2020 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
@@ -15,15 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
-/* This routine is jumped to by all the syscall handlers, to stash
- an error number into errno. ERROR is the negative error number
- returned from the x86 kernel. */
-int
-__attribute__ ((__regparm__ (1)))
-__syscall_error (int error)
-{
- __set_errno (-error);
- return -1;
-}
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR __attribute__ ((__regparm__ (1)))
+
+#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 07/23] linux: Use generic __syscall_error for arc
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (5 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 06/23] linux: Use generic __syscall_error for i386 Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 08/23] linux: Use generic __syscall_error for powerpc Adhemerval Zanella
` (15 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Moving to intra DSO calls generates slight better code and avoid
a GLIBC_PRIVATE symbol (only librt increases because it issues
syscalls only in specific places).
--- sizes-arc-linux-gnuhf.before
+++ sizes-arc-linux-gnuhf.after
text data bss dec hex filename
- 962196 9400 8116 979712 ef300 libc.so
- 110145 3724 192 114061 1bd8d elf/ld.so
- 75099 796 8348 84243 14913 nptl/libpthread.so
- 18882 600 156 19638 4cb6 rt/librt.so
+ 961186 9400 8116 978702 eef0e libc.so
+ 109745 3724 192 113661 1bbfd elf/ld.so
+ 75463 796 8348 84607 14a7f nptl/libpthread.so
+ 18704 596 156 19456 4c00 rt/librt.so
Checked with build for arc-linux-gnuabihf.
---
sysdeps/arc/Versions | 3 ---
.../linux/arc/{sysdep.c => syscall_error.h} | 20 ++++++-------------
sysdeps/unix/sysv/linux/arc/sysdep.h | 12 +----------
3 files changed, 7 insertions(+), 28 deletions(-)
rename sysdeps/unix/sysv/linux/arc/{sysdep.c => syscall_error.h} (67%)
diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions
index 6ac7b8e495..ff157421a5 100644
--- a/sysdeps/arc/Versions
+++ b/sysdeps/arc/Versions
@@ -2,7 +2,4 @@ libc {
GLIBC_2.32 {
__mcount;
}
- GLIBC_PRIVATE {
- __syscall_error;
- }
}
diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.c b/sysdeps/unix/sysv/linux/arc/syscall_error.h
similarity index 67%
rename from sysdeps/unix/sysv/linux/arc/sysdep.c
rename to sysdeps/unix/sysv/linux/arc/syscall_error.h
index fe904d723b..a45e02dbe4 100644
--- a/sysdeps/unix/sysv/linux/arc/sysdep.c
+++ b/sysdeps/unix/sysv/linux/arc/syscall_error.h
@@ -1,4 +1,4 @@
-/* ARC wrapper for setting errno.
+/* Linux wrappers for setting errno. AArch64 version.
Copyright (C) 2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -16,18 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
-extern long int __syscall_error (long int);
-libc_hidden_proto (__syscall_error)
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
-/* All syscall handlers land here to avoid generated code bloat due to
- GOT reference to errno_location or it's equivalent. */
-long int
-__syscall_error (long int err_no)
-{
- __set_errno (-err_no);
- return -1;
-}
-
-libc_hidden_def (__syscall_error)
+#endif
diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h b/sysdeps/unix/sysv/linux/arc/sysdep.h
index 4ab44f6925..7b36b72963 100644
--- a/sysdeps/unix/sysv/linux/arc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arc/sysdep.h
@@ -103,22 +103,12 @@
# define PSEUDO_END_ERRVAL(name) \
END (name)
-
-/* To reduce the code footprint, we confine the actual errno access
- to single place in __syscall_error().
- This takes raw kernel error value, sets errno and returns -1. */
-# if IS_IN (libc)
-# define CALL_ERRNO_SETTER_C bl PLTJMP(HIDDEN_JUMPTARGET(__syscall_error))
-# else
-# define CALL_ERRNO_SETTER_C bl PLTJMP(__syscall_error)
-# endif
-
# define SYSCALL_ERROR_HANDLER \
L (call_syscall_err): ASM_LINE_SEP \
push_s blink ASM_LINE_SEP \
cfi_adjust_cfa_offset (4) ASM_LINE_SEP \
cfi_rel_offset (blink, 0) ASM_LINE_SEP \
- CALL_ERRNO_SETTER_C ASM_LINE_SEP \
+ bl __syscall_error ASM_LINE_SEP \
pop_s blink ASM_LINE_SEP \
cfi_adjust_cfa_offset (-4) ASM_LINE_SEP \
cfi_restore (blink) ASM_LINE_SEP \
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 08/23] linux: Use generic __syscall_error for powerpc
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (6 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 07/23] linux: Use generic __syscall_error for arc Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 09/23] linux: Use generic __syscall_error for sparc Adhemerval Zanella
` (14 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The powerpc kABI returns a positive value on 'r3' register for failure
case (the syscall error is signaled on CR0), different than usual Linux
kABI with return a negative value in range of [-4096,0). The arch
specific__syscall_error thus has a different ABI than the generic one,
which requires fixing both the inline syscall wrappers and some assembly
implementation that calls __syscall_error directly.
Using an inline function for __syscall_error is slight better for
powerpc64{le} and only a small code increase on powerpc32:
--- sizes-powerpc-linux-gnu.outline
+++ sizes-powerpc-linux-gnu.inline
@@ -1,8 +1,8 @@
text data bss dec hex filename
-1759918 19900 9348 1789166 1b4cee libc.so
- 176605 7516 188 184309 2cff5 elf/ld.so
- 131959 1776 8352 142087 22b07 nptl/libpthread.so
- 32058 872 160 33090 8142 rt/librt.so
+1767602 19900 9348 1796850 1b6af2 libc.so
+ 177221 7516 188 184925 2d25d elf/ld.so
+ 132575 1776 8352 142703 22d6f nptl/libpthread.so
+ 32350 872 160 33382 8266 rt/librt.so
--- sizes-powerpc64-linux-gnu.outline
+++ sizes-powerpc64-linux-gnu.inline
@@ -1,8 +1,8 @@
text data bss dec hex filename
-2035762 95184 15048 2145994 20beca libc.so
- 258573 13104 504 272181 42735 elf/ld.so
- 154913 8240 18656 181809 2c631 nptl/libpthread.so
- 36875 2404 3704 42983 a7e7 rt/librt.so
+2031758 95184 15048 2141990 20af26 libc.so
+ 257881 13104 504 271489 42481 elf/ld.so
+ 154349 8240 18656 181245 2c3fd nptl/libpthread.so
+ 36511 2404 3704 42619 a67b rt/librt.so
--- sizes-powerpc64le-linux-gnu.outline
+++ sizes-powerpc64le-linux-gnu.inline
@@ -1,8 +1,8 @@
text data bss dec hex filename
-2031374 22464 14872 2068710 1f90e6 libc.so
- 208066 7832 416 216314 34cfa elf/ld.so
- 137717 1248 17328 156293 26285 nptl/libpthread.so
- 31918 716 728 33362 8252 rt/librt.so
+2027838 22464 14872 2065174 1f8316 libc.so
+ 207426 7832 416 215674 34a7a elf/ld.so
+ 137149 1248 17328 155725 2604d nptl/libpthread.so
+ 31490 716 728 32934 80a6 rt/librt.so
Checked on powerpc-linux-gnu, powerpc64-linux-gnu, and
powerpc64le-linux-gnu.
---
sysdeps/powerpc/powerpc32/sysdep.h | 1 +
sysdeps/powerpc/powerpc64/sysdep.h | 7 +++--
sysdeps/unix/sysv/linux/powerpc/Makefile | 7 -----
.../unix/sysv/linux/powerpc/powerpc32/brk.S | 1 +
.../unix/sysv/linux/powerpc/powerpc32/clone.S | 3 +-
.../sysv/linux/powerpc/powerpc32/getcontext.S | 2 ++
.../linux/powerpc/powerpc32/makecontext.S | 2 +-
.../powerpc/powerpc32/nofpu/getcontext.S | 2 +-
.../powerpc/powerpc32/nofpu/setcontext.S | 2 +-
.../powerpc/powerpc32/nofpu/swapcontext.S | 2 +-
.../sysv/linux/powerpc/powerpc32/setcontext.S | 3 +-
.../linux/powerpc/powerpc32/swapcontext.S | 3 +-
sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c | 1 -
.../powerpc/{sysdep.c => syscall_error.h} | 18 ++++++------
sysdeps/unix/sysv/linux/sparc/sysdep.c | 28 ++++++++++++++++++-
15 files changed, 54 insertions(+), 28 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c
rename sysdeps/unix/sysv/linux/powerpc/{sysdep.c => syscall_error.h} (74%)
diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h
index 829eec266a..47d3aa4339 100644
--- a/sysdeps/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/powerpc/powerpc32/sysdep.h
@@ -113,6 +113,7 @@ GOT_LABEL: ; \
#define PSEUDO_RET \
bnslr+; \
+ neg 3,3; \
b __syscall_error@local
#define ret PSEUDO_RET
diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h
index d557098898..e7496a979a 100644
--- a/sysdeps/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/powerpc/powerpc64/sysdep.h
@@ -277,13 +277,13 @@ LT_LABELSUFFIX(name,_name_end): ; \
DO_CALL (SYS_ify (syscall_name))
#ifdef SHARED
-#define TAIL_CALL_SYSCALL_ERROR \
+#define _TAIL_CALL_SYSCALL_ERROR \
b JUMPTARGET (NOTOC (__syscall_error))
#else
/* Static version might be linked into a large app with a toc exceeding
64k. We can't put a toc adjusting stub on a plain branch, so can't
tail call __syscall_error. */
-#define TAIL_CALL_SYSCALL_ERROR \
+#define _TAIL_CALL_SYSCALL_ERROR \
.ifdef .Local_syscall_error; \
b .Local_syscall_error; \
.else; \
@@ -303,6 +303,9 @@ LT_LABELSUFFIX(name,_name_end): ; \
blr; \
.endif
#endif
+#define TAIL_CALL_SYSCALL_ERROR \
+ neg 3,3; \
+ _TAIL_CALL_SYSCALL_ERROR
#define PSEUDO_RET \
bnslr+; \
diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile
index cc2f804d86..9610edd305 100644
--- a/sysdeps/unix/sysv/linux/powerpc/Makefile
+++ b/sysdeps/unix/sysv/linux/powerpc/Makefile
@@ -3,11 +3,6 @@ abi-32-condition := __WORDSIZE == 32
abi-64-v1-condition := __WORDSIZE == 64 && _CALL_ELF != 2
abi-64-v2-condition := __WORDSIZE == 64 && _CALL_ELF == 2
-ifeq ($(subdir),rt)
-librt-routines += rt-sysdep
-librt-shared-only-routines += rt-sysdep
-endif
-
ifeq ($(subdir),stdlib)
gen-as-const-headers += ucontext_i.sym
endif
@@ -31,8 +26,6 @@ tests += test-powerpc-linux-sysconf
endif
ifeq ($(subdir),nptl)
-libpthread-routines += sysdep
libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \
elision-trylock
-libpthread-shared-only-routines += sysdep
endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S
index f3b960795e..8cbe17ef1e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S
@@ -46,6 +46,7 @@ ENTRY (__brk)
li r3,0
blelr+
li r3,ENOMEM
+ neg r3,r3
b __syscall_error@local
END (__brk)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
index ba0faaf69c..41e5e5fe2e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
@@ -83,10 +83,11 @@ L(parent):
lmw r28,16(r1)
addi r1,r1,32
bnslr+
+ neg r3,r3
b __syscall_error@local
L(badargs):
- li r3,EINVAL
+ li r3,-EINVAL
b __syscall_error@local
cfi_startproc
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S
index 9f65033b7e..c7c78d63c5 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S
@@ -41,6 +41,7 @@ ENTRY (__getcontext)
li r3,0
blr
1:
+ neg r3,r3
b __syscall_error@local
END(__getcontext)
@@ -69,6 +70,7 @@ compat_symbol (libc, __novec_getcontext, getcontext, GLIBC_2_3_3)
compat_text_section
ENTRY (__getcontext_stub)
li r3,ENOSYS
+ neg r3,r3
b __syscall_error@local
END (__getcontext_stub)
.previous
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S
index 873edf14a8..43cc88cb9f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S
@@ -216,7 +216,7 @@ compat_symbol (libc, __novec_makecontext, makecontext, GLIBC_2_3_3)
compat_text_section
ENTRY (__makecontext_stub)
- li r3,ENOSYS
+ li r3,-ENOSYS
b __syscall_error@local
END (__makecontext_stub)
.previous
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S
index 3cbbd32c31..a2126f4627 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S
@@ -48,7 +48,7 @@ compat_symbol (libc, __novec_getcontext, getcontext, GLIBC_2_3_3)
compat_text_section
ENTRY (__getcontext_stub)
- li r3,ENOSYS
+ li r3,-ENOSYS
b __syscall_error@local
END (__getcontext_stub)
.previous
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S
index 5adf7fb5ba..b9f9c21b66 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S
@@ -48,7 +48,7 @@ compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3_3)
compat_text_section
ENTRY (__setcontext_stub)
- li r3,ENOSYS
+ li r3,-ENOSYS
b __syscall_error@local
END (__setcontext_stub)
.previous
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S
index e4aec0ff96..d7263e5fb8 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S
@@ -48,7 +48,7 @@ compat_symbol (libc, __novec_swapcontext, swapcontext, GLIBC_2_3_3)
compat_text_section
ENTRY (__swapcontext_stub)
- li r3,ENOSYS
+ li r3,-ENOSYS
b __syscall_error@local
END (__swapcontext_stub)
.previous
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S
index 7bcb2d990b..3cb5021917 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S
@@ -42,6 +42,7 @@ ENTRY (__setcontext)
li r3,0
blr
1:
+ neg r3,r3
b __syscall_error@local
END(__setcontext)
@@ -70,7 +71,7 @@ compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3_3)
compat_text_section
ENTRY (__setcontext_stub)
- li r3,ENOSYS
+ li r3,-ENOSYS
b __syscall_error@local
END (__setcontext_stub)
.previous
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S
index cd359d4a8a..53190028c5 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S
@@ -40,6 +40,7 @@ ENTRY (__swapcontext)
li r3,0
blr
1:
+ neg r3,r3
b __syscall_error@local
END(__swapcontext)
@@ -68,7 +69,7 @@ compat_symbol (libc, __novec_swapcontext, swapcontext, GLIBC_2_3_3)
compat_text_section
ENTRY (__swapcontext_stub)
- li r3,ENOSYS
+ li r3,-ENOSYS
b __syscall_error@local
END (__swapcontext_stub)
.previous
diff --git a/sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c b/sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c
deleted file mode 100644
index 3ff55952e2..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdep.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.c b/sysdeps/unix/sysv/linux/powerpc/syscall_error.h
similarity index 74%
rename from sysdeps/unix/sysv/linux/powerpc/sysdep.c
rename to sysdeps/unix/sysv/linux/powerpc/syscall_error.h
index 1bf5ea6f62..924f12435d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.c
+++ b/sysdeps/unix/sysv/linux/powerpc/syscall_error.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
+/* Linux wrappers for setting errno. PowerPC version.
+ Copyright (C) 2020 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
@@ -15,13 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
-/* This routine is jumped to by all the syscall handlers, to stash
- an error number into errno. */
-int
-__syscall_error (int err_no)
-{
- __set_errno (err_no);
- return -1;
-}
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.c b/sysdeps/unix/sysv/linux/sparc/sysdep.c
index f86414570d..1bf5ea6f62 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.c
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.c
@@ -1 +1,27 @@
-#include <sysdeps/unix/sysv/linux/powerpc/sysdep.c>
+/* Copyright (C) 1997-2020 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 <errno.h>
+
+/* This routine is jumped to by all the syscall handlers, to stash
+ an error number into errno. */
+int
+__syscall_error (int err_no)
+{
+ __set_errno (err_no);
+ return -1;
+}
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 09/23] linux: Use generic __syscall_error for sparc
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (7 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 08/23] linux: Use generic __syscall_error for powerpc Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 10/23] linux: Use generic __syscall_error for hppa Adhemerval Zanella
` (13 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The sparc kABI returns a positive errno value in 'o0' register for
failure case (the syscall error is signal on conditional register),
different than usual Linux kABI with return a negative value in range
of [-4096,0). The __syscall_error thus has a different ABI than the
generic one, which requires fixing both the inline syscall wrappers
and some assembly implementation that calls __syscall_error directly.
Using inline function for __syscall_error does not yield any gain:
--- sizes-sparc64-linux-gnu.outline
+++ sizes-sparc64-linux-gnu.inline
text data bss dec hex filename
-1469609 20464 14496 1504569 16f539 libc.so
- 152853 6960 352 160165 271a5 elf/ld.so
- 101586 1220 16672 119478 1d2b6 nptl/libpthread.so
- 27282 836 2296 30414 76ce rt/librt.so
+1473545 20464 14496 1508505 170499 libc.so
+ 153077 6960 352 160389 27285 elf/ld.so
+ 102578 1220 16672 120470 1d696 nptl/libpthread.so
+ 27474 836 2296 30606 778e rt/librt.so
--- sizes-sparcv9-linux-gnu.outline
+++ sizes-sparcv9-linux-gnu.inline
text data bss dec hex filename
-1557171 11208 9440 1577819 18135b libc.so
- 149507 4448 192 154147 25a23 elf/ld.so
- 101518 588 8356 110462 1af7e nptl/libpthread.so
- 26546 404 160 27110 69e6 rt/librt.so
+1563315 11208 9440 1583963 182b5b libc.so
+ 149795 4448 192 154435 25b43 elf/ld.so
+ 102286 588 8356 111230 1b27e nptl/libpthread.so
+ 26930 404 160 27494 6b66 rt/librt.so
Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
---
sysdeps/unix/sysv/linux/sparc/Makefile | 9 ++-------
sysdeps/unix/sysv/linux/sparc/rt-sysdep.c | 1 -
sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 1 +
.../unix/sysv/linux/sparc/sparc32/syscall.S | 1 +
sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h | 1 +
sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S | 1 +
sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 1 +
.../unix/sysv/linux/sparc/sparc64/syscall.S | 1 +
sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h | 1 +
sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 1 +
.../linux/sparc/{sysdep.c => syscall_error.h} | 18 ++++++++----------
11 files changed, 18 insertions(+), 18 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/sparc/rt-sysdep.c
rename sysdeps/unix/sysv/linux/sparc/{sysdep.c => syscall_error.h} (74%)
diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile
index 1475039677..3a47cd2da4 100644
--- a/sysdeps/unix/sysv/linux/sparc/Makefile
+++ b/sysdeps/unix/sysv/linux/sparc/Makefile
@@ -2,11 +2,6 @@ abi-variants := 32 64
abi-32-condition := __WORDSIZE == 32
abi-64-condition := __WORDSIZE == 64
-ifeq ($(subdir),rt)
-librt-routines += rt-sysdep
-librt-shared-only-routines += rt-sysdep
-endif
-
ifeq ($(subdir),sysvipc)
sysdep_routines += getshmlba
endif
@@ -17,6 +12,6 @@ endif
ifeq ($(subdir),nptl)
# pull in __syscall_error routine
-libpthread-routines += sysdep sigreturn_stub
-libpthread-shared-only-routines += sysdep sigreturn_stub
+libpthread-routines += sigreturn_stub
+libpthread-shared-only-routines += sigreturn_stub
endif
diff --git a/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c b/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c
deleted file mode 100644
index 3ff55952e2..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdep.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
index 0b10f1522b..d693527e7b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
@@ -26,6 +26,7 @@ ENTRY(__libc_pipe)
ta 0x10
bcc 1f
mov %o7, %g1
+ neg %o0, %o0
call __syscall_error
mov %g1, %o7
1: st %o0, [%o2] /* PIPEDES[0] = %o0; */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S
index 90c639f043..a2b608179a 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S
@@ -30,6 +30,7 @@ ENTRY(syscall)
ta 0x10
bcc 1f
mov %o7, %g1
+ neg %o0, %o0
call __syscall_error
mov %g1, %o7
1: retl
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
index 2c3754770b..3e7671c391 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
@@ -65,6 +65,7 @@ ENTRY(name); \
#ifndef PIC
# define SYSCALL_ERROR_HANDLER \
mov %o7, %g1; \
+ neg %o0, %o0; \
call __syscall_error; \
mov %g1, %o7;
#else
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
index be48386016..c8d26a49a7 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
@@ -26,6 +26,7 @@ ENTRY(__libc_vfork)
ta 0x10
bcc 2f
mov %o7, %g1
+ neg %o0, %o0
call __syscall_error
mov %g1, %o7
2: sub %o1, 1, %o1
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
index 072a1936ea..ba75629261 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
@@ -27,6 +27,7 @@ ENTRY(__libc_pipe)
ta 0x6d
bcc,pt %xcc, 1f
mov %o7, %g1
+ neg %o0, %o0
call __syscall_error
mov %g1, %o7
1: st %o0, [%o2] /* PIPEDES[0] = %o0; */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S
index fca114371f..63a28f65ee 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S
@@ -32,6 +32,7 @@ ENTRY(syscall)
bcc,pt %xcc, 1f
mov %o7, %g1
+ neg %o0, %o0
call __syscall_error
mov %g1, %o7
1: retl
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
index 2010faf50f..329ec144cf 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
@@ -65,6 +65,7 @@ ENTRY(name); \
#ifndef PIC
# define SYSCALL_ERROR_HANDLER \
mov %o7, %g1; \
+ neg %o0, %o0; \
call __syscall_error; \
mov %g1, %o7;
#else
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
index 56a491f3de..0a34a3e68c 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
@@ -26,6 +26,7 @@ ENTRY(__libc_vfork)
ta 0x6d
bcc,pt %xcc, 2f
mov %o7, %g1
+ neg %o0, %o0
call __syscall_error
mov %g1, %o7
2: sub %o1, 1, %o1
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.c b/sysdeps/unix/sysv/linux/sparc/syscall_error.h
similarity index 74%
rename from sysdeps/unix/sysv/linux/sparc/sysdep.c
rename to sysdeps/unix/sysv/linux/sparc/syscall_error.h
index 1bf5ea6f62..6a9fac278a 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.c
+++ b/sysdeps/unix/sysv/linux/sparc/syscall_error.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
+/* Linux wrappers for setting errno. SPARC version.
+ Copyright (C) 2020 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
@@ -15,13 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
-/* This routine is jumped to by all the syscall handlers, to stash
- an error number into errno. */
-int
-__syscall_error (int err_no)
-{
- __set_errno (err_no);
- return -1;
-}
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 10/23] linux: Use generic __syscall_error for hppa
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (8 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 09/23] linux: Use generic __syscall_error for sparc Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 11/23] linux: Use generic __syscall_error for arm Adhemerval Zanella
` (12 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
HPPA issues inline error handling for auto-generated syscall,
the __syscall_error is used solely on clone implementation and
it differs from generic implementation by passing positive errno
numbers.
Also, inline error handling does not really produce the most
compat code.
--- sizes-hppa-linux-gnu.outline
+++ sizes-hppa-linux-gnu.inline
text data bss dec hex filename
-1576515 22028 9424 1607967 18891f libc.so
- 174755 15524 448 190727 2e907 elf/ld.so
- 132799 1296 8364 142459 22c7b nptl/libpthread.so
- 30993 788 236 32017 7d11 rt/librt.so
+1579367 22028 9424 1610819 189443 libc.so
+ 174835 15524 448 190807 2e957 elf/ld.so
+ 133055 1296 8364 142715 22d7b nptl/libpthread.so
+ 31297 788 236 32321 7e41 rt/librt.so
Checked on hppa-linux-gnu.
---
sysdeps/unix/sysv/linux/hppa/clone.S | 6 ++++--
.../linux/hppa/{sysdep.c => syscall_error.h} | 20 +++++++++----------
2 files changed, 13 insertions(+), 13 deletions(-)
rename sysdeps/unix/sysv/linux/hppa/{sysdep.c => syscall_error.h} (68%)
diff --git a/sysdeps/unix/sysv/linux/hppa/clone.S b/sysdeps/unix/sysv/linux/hppa/clone.S
index 4eda812dd0..fcfafe1d2b 100644
--- a/sysdeps/unix/sysv/linux/hppa/clone.S
+++ b/sysdeps/unix/sysv/linux/hppa/clone.S
@@ -124,7 +124,8 @@ ENTRY(__clone)
.LerrorRest:
/* Something bad happened -- no child created */
bl __syscall_error, %rp
- sub %r0, %ret0, %arg0
+ copy %ret0, %arg0
+
ldw -84(%sp), %rp
/* Return after setting errno, ret0 is set to -1 by __syscall_error. */
bv %r0(%rp)
@@ -133,7 +134,8 @@ ENTRY(__clone)
.LerrorSanity:
/* Sanity checks failed, return -1, and set errno to EINVAL. */
bl __syscall_error, %rp
- ldi EINVAL, %arg0
+ ldi -EINVAL, %arg0
+
ldw -84(%sp), %rp
bv %r0(%rp)
ldwm -64(%sp), %r4
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.c b/sysdeps/unix/sysv/linux/hppa/syscall_error.h
similarity index 68%
rename from sysdeps/unix/sysv/linux/hppa/sysdep.c
rename to sysdeps/unix/sysv/linux/hppa/syscall_error.h
index 8c06b6fc80..f5947ccd7c 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep.c
+++ b/sysdeps/unix/sysv/linux/hppa/syscall_error.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
+/* Linux wrappers for setting errno. HPPA version.
+ Copyright (C) 2020 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
@@ -12,16 +13,13 @@
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
+ License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <errno.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
-/* This routine is jumped to by all the syscall handlers, to stash
- an error number into errno. */
-int
-__syscall_error (int err_no)
-{
- __set_errno (err_no);
- return -1;
-}
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 11/23] linux: Use generic __syscall_error for arm
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (9 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 10/23] linux: Use generic __syscall_error for hppa Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 12/23] linux: Use generic __syscall_error for x86_64 Adhemerval Zanella
` (11 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The auto-generated syscalls issue the __syscall_erro and the ARM
resulting binary using inline __syscall_error results in a large
code size:
--- sizes-arm-linux-gnueabihf.outline
+++ sizes-arm-linux-gnueabihf.inline
@@ -1,5 +1,5 @@
text data bss dec hex filename
-1260061 9912 9256 1279229 1384fd libc.so
- 143107 4336 208 147651 240c3 elf/ld.so
- 97335 844 8352 106531 1a023 nptl/libpthread.so
- 22516 656 160 23332 5b24 rt/librt.so
+1265565 9912 9256 1284733 139a7d libc.so
+ 143491 4336 208 148035 24243 elf/ld.so
+ 98103 844 8352 107299 1a323 nptl/libpthread.so
+ 22996 656 160 23812 5d04 rt/librt.so
The assembly sysdep.S is replaced the by the generic syscall_error.c.
Checked on arm-linux-gnueabihf.
---
sysdeps/unix/arm/sysdep.S | 62 -------------------
.../linux/arm/{sysdep.S => syscall_error.h} | 24 +++----
2 files changed, 8 insertions(+), 78 deletions(-)
delete mode 100644 sysdeps/unix/arm/sysdep.S
rename sysdeps/unix/sysv/linux/arm/{sysdep.S => syscall_error.h} (55%)
diff --git a/sysdeps/unix/arm/sysdep.S b/sysdeps/unix/arm/sysdep.S
deleted file mode 100644
index 5c9022a869..0000000000
--- a/sysdeps/unix/arm/sysdep.S
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (C) 1991-2020 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 <sysdep.h>
-#include <errno.h>
-
-#if IS_IN (rtld)
-# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
-#endif
-
-#include <tls.h>
-
-#undef syscall_error
-__syscall_error:
-#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
- /* We translate the system's EWOULDBLOCK error into EAGAIN.
- The GNU C library always defines EWOULDBLOCK==EAGAIN.
- EWOULDBLOCK_sys is the original number. */
- cmp r0, $EWOULDBLOCK_sys /* Is it the old EWOULDBLOCK? */
- it eq
- moveq r0, $EAGAIN /* Yes; translate it to EAGAIN. */
-#endif
-
-#if !IS_IN (rtld)
- mov r1, r0
- GET_TLS (r2)
- ldr r2, 1f
-#ifdef __thumb__
-2: add r2, r2, pc
- ldr r2, [r2]
-#else
-2: ldr r2, [pc, r2]
-#endif
- str r1, [r0, r2]
- mvn r0, #0
- DO_RET(lr)
-
-1: .word errno(gottpoff) + (. - 2b - PC_OFS)
-#elif RTLD_PRIVATE_ERRNO
- LDST_PCREL(str, r0, r1, C_SYMBOL_NAME(rtld_errno))
- mvn r0, #0
- DO_RET(r14)
-#else
-#error "Unsupported non-TLS case"
-#endif
-
-#undef __syscall_error
-END (__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.S b/sysdeps/unix/sysv/linux/arm/syscall_error.h
similarity index 55%
rename from sysdeps/unix/sysv/linux/arm/sysdep.S
rename to sysdeps/unix/sysv/linux/arm/syscall_error.h
index 94c877b31d..71f74e2bd3 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.S
+++ b/sysdeps/unix/sysv/linux/arm/syscall_error.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
+/* Linux wrappers for setting errno. ARM version.
+ Copyright (C) 2020 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
@@ -12,22 +13,13 @@
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
+ License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <sysdep.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
- .text
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
-/* The syscall stubs jump here when they detect an error.
- The code for Linux is almost identical to the canonical Unix
- code, except that the error number in R0 is negated. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */
-
-ENTRY (__syscall_error)
- rsb r0, r0, $0
-
-#define __syscall_error __syscall_error_1
-#include <sysdeps/unix/arm/sysdep.S>
+#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 12/23] linux: Use generic __syscall_error for x86_64
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (10 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 11/23] linux: Use generic __syscall_error for arm Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 13/23] linux: Use generic __syscall_error for s390 Adhemerval Zanella
` (10 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The auto-generated syscalls issue the __syscall_error only for
static objects, so a arch specific syscall_error is added. The
size of using extern __syscall_error is just slight better for
static case:
--- size-fstatat64.o.inline
+++ size-fstatat64.o.outline
@@ -1,2 +1,2 @@
text data bss dec hex filename
- 100 0 0 100 64 io/fstatat64.o
+ 94 0 0 94 5e io/fstatat64.o
For shared objects the inline __syscall_error does generate more
compact code:
--- sizes-x86_64-linux-gnu.inline
+++ sizes-x86_64-linux-gnu.outline
@@ -1,5 +1,5 @@
text data bss dec hex filename
-1774028 20520 15896 1810444 1ba00c libc.so
- 167499 7280 392 175171 2ac43 elf/ld.so
- 99261 1640 16728 117629 1cb7d nptl/libpthread.so
- 24751 1188 2400 28339 6eb3 rt/librt.so
+1776260 20520 15896 1812676 1ba8c4 libc.so
+ 167758 7280 392 175430 2ad46 elf/ld.so
+ 100221 1640 16728 118589 1cf3d nptl/libpthread.so
+ 24927 1188 2400 28515 6f63 rt/librt.so
A possible option might be to use the same strategy for both static
and PIC code, which allow to remove the arch-specific syscall_error.c
with a slight increase of code size in static library.
Checked on x86_64-linux-gnu.
---
.../unix/sysv/linux/x86_64/syscall_error.c | 7 +++
sysdeps/unix/sysv/linux/x86_64/sysdep.S | 40 ---------------
sysdeps/unix/x86_64/sysdep.S | 49 -------------------
3 files changed, 7 insertions(+), 89 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_error.c
delete mode 100644 sysdeps/unix/sysv/linux/x86_64/sysdep.S
delete mode 100644 sysdeps/unix/x86_64/sysdep.S
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall_error.c b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c
new file mode 100644
index 0000000000..de5491dc50
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c
@@ -0,0 +1,7 @@
+/* The auto-generated syscalls calls __syscall_error for static objects. */
+#include <syscall_error.h>
+#ifndef SHARED
+# undef SYSCALL_ERROR_FUNC
+# define SYSCALL_ERROR_FUNC 1
+#endif
+#include <sysdeps/unix/sysv/linux/syscall_error.c>
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.S b/sysdeps/unix/sysv/linux/x86_64/sysdep.S
deleted file mode 100644
index 2d3592296d..0000000000
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright (C) 2001-2020 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 <sysdep.h>
-
-/* The following code is only used in the shared library when we
- compile the reentrant version. Otherwise each system call defines
- each own version. */
-
-#ifndef PIC
-
-/* The syscall stubs jump here when they detect an error.
- The code for Linux is almost identical to the canonical Unix
- code, except that the error number in %rax is negated. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %rax. */
-
- .text
-ENTRY (__syscall_error)
- neg %RAX_LP
-
-#define __syscall_error __syscall_error_1
-#include <sysdeps/unix/x86_64/sysdep.S>
-
-#endif /* !PIC */
diff --git a/sysdeps/unix/x86_64/sysdep.S b/sysdeps/unix/x86_64/sysdep.S
deleted file mode 100644
index 2278fce9e4..0000000000
--- a/sysdeps/unix/x86_64/sysdep.S
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (C) 2001-2020 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 <sysdep.h>
-#include <errno.h>
-#include <tls.h>
-
-#if IS_IN (rtld)
-# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
-#endif
-
-.globl C_SYMBOL_NAME(errno)
-.globl syscall_error
-
-__syscall_error:
-#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
- /* We translate the system's EWOULDBLOCK error into EAGAIN.
- The GNU C library always defines EWOULDBLOCK==EAGAIN.
- EWOULDBLOCK_sys is the original number. */
- cmp $EWOULDBLOCK_sys, %RAX_LP /* Is it the old EWOULDBLOCK? */
- jne notb /* Branch if not. */
- movl $EAGAIN, %eax /* Yes; translate it to EAGAIN. */
-notb:
-#endif
-#ifdef PIC
- movq C_SYMBOL_NAME(errno@GOTTPOFF)(%rip), %rcx
- movl %eax, %fs:0(%rcx)
-#else
- movl %eax, %fs:C_SYMBOL_NAME(errno@TPOFF)
-#endif
- or $-1, %RAX_LP
- ret
-
-#undef __syscall_error
-END (__syscall_error)
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 13/23] linux: Use generic __syscall_error for s390
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (11 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 12/23] linux: Use generic __syscall_error for x86_64 Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 14/23] linux: Use generic __syscall_error for sh Adhemerval Zanella
` (9 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The auto-generated syscalls issue the __syscall_error only for
static objects, so an arch specific syscall_error is added. However
the size of using inline __syscall_error is slight better even for
static case:
--- size-fstatat64.inline
+++ size-fstatat64.outline
@@ -1,2 +1,2 @@
text data bss dec hex filename
- 120 0 0 120 78 io/fstatat64.o
+ 128 0 0 128 80 io/fstatat64.o
For shared objects the inline syscall generates slight large code
(specially for libc.so).
--- sizes-s390x-linux-gnu.outline
+++ sizes-s390x-linux-gnu.inline
text data bss dec hex filename
-1755806 20232 14544 1790582 1b5276 libc.so
- 169705 6696 336 176737 2b261 elf/ld.so
- 111982 1664 16680 130326 1fd16 nptl/libpthread.so
- 29703 1132 2296 33131 816b rt/librt.so
+1756334 20232 14544 1791110 1b5486 libc.so
+ 169385 6696 336 176417 2b121 elf/ld.so
+ 112198 1664 16680 130542 1fdee nptl/libpthread.so
+ 29719 1132 2296 33147 817b rt/librt.so
Checked on s390x-linux-gnu and s390-linux-gnu.
---
sysdeps/s390/nptl/Makefile | 5 --
sysdeps/unix/sysv/linux/s390/Makefile | 5 --
sysdeps/unix/sysv/linux/s390/rt-sysdep.S | 1 -
sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S | 74 ------------------
sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S | 75 -------------------
sysdeps/unix/sysv/linux/s390/syscall_error.c | 7 ++
6 files changed, 7 insertions(+), 160 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/s390/rt-sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S
delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/s390/syscall_error.c
diff --git a/sysdeps/s390/nptl/Makefile b/sysdeps/s390/nptl/Makefile
index d34cb27699..7869dd571c 100644
--- a/sysdeps/s390/nptl/Makefile
+++ b/sysdeps/s390/nptl/Makefile
@@ -18,8 +18,3 @@
ifeq ($(subdir),csu)
gen-as-const-headers += tcb-offsets.sym
endif
-
-ifeq ($(subdir),nptl)
-libpthread-routines += sysdep
-libpthread-shared-only-routines += sysdep
-endif
diff --git a/sysdeps/unix/sysv/linux/s390/Makefile b/sysdeps/unix/sysv/linux/s390/Makefile
index d9db1b5422..0d88f8d7ff 100644
--- a/sysdeps/unix/sysv/linux/s390/Makefile
+++ b/sysdeps/unix/sysv/linux/s390/Makefile
@@ -2,11 +2,6 @@ abi-variants := 32 64
abi-32-condition := __WORDSIZE == 32
abi-64-condition := __WORDSIZE == 64
-ifeq ($(subdir),rt)
-librt-routines += rt-sysdep
-librt-shared-only-routines += rt-sysdep
-endif
-
ifeq ($(subdir),stdlib)
gen-as-const-headers += ucontext_i.sym
endif
diff --git a/sysdeps/unix/sysv/linux/s390/rt-sysdep.S b/sysdeps/unix/sysv/linux/s390/rt-sysdep.S
deleted file mode 100644
index f966bf1e59..0000000000
--- a/sysdeps/unix/sysv/linux/s390/rt-sysdep.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdep.S>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S
deleted file mode 100644
index f8a6b7901d..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- 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 <sysdep.h>
-#include <tls.h>
-
-/* The following code is only used in the shared library when we
- compile the reentrant version. Otherwise each system call defines
- each own version. */
-
-/* The syscall stubs jump here when they detect an error. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT
-
- .text
-ENTRY(__syscall_error)
-#ifndef PIC
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
- basr %r1,0
-0: l %r1,1f-0b(%r1)
- ear %r3,%a0
- lcr %r2,%r2
- st %r2,0(%r1,%r3)
- lhi %r2,-1
- br %r14
-1: .long SYSCALL_ERROR_ERRNO@ntpoff
-#else
-# if RTLD_PRIVATE_ERRNO
- basr %r1,0
-0: al %r1,1f-0b(%r1)
- lcr %r2,%r2
- st %r2,0(%r1)
- lhi %r2,-1
- br %r14
-1: .long rtld_errno - 0b
-# else
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
- basr %r1,0
-0: al %r1,1f-0b(%r1)
- ear %r3,%a0
- l %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1)
- lcr %r2,%r2
- st %r2,0(%r1,%r3)
- lhi %r2,-1
- br %r14
-1: .long _GLOBAL_OFFSET_TABLE_-0b
-# endif
-#endif
-
-END (__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S
deleted file mode 100644
index 98c8dd3913..0000000000
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- 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 <sysdep.h>
-#include <tls.h>
-
-
-/* The following code is only used in the shared library when we
- compile the reentrant version. Otherwise each system call defines
- each own version. */
-
-/* The syscall stubs jump here when they detect an error. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT
-
-.text
-ENTRY(__syscall_error)
-#ifndef PIC
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
- basr %r1,0
-0: lg %r1,1f-0b(%r1)
- ear %r3,%a0
- sllg %r3,%r3,32
- ear %r3,%a1
- lcr %r2,%r2
- st %r2,0(%r1,%r3)
- lghi %r2,-1
- br %r14
-1: .quad SYSCALL_ERROR_ERRNO@ntpoff
-#else
-# if RTLD_PRIVATE_ERRNO
- larl %r1,rtld_errno
- lcr %r2,%r2
- st %r2,0(%r1)
- lghi %r2,-1
- br %r14
-# else
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
- larl %r1,_GLOBAL_OFFSET_TABLE_
- lg %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1)
- ear %r3,%a0
- sllg %r3,%r3,32
- ear %r3,%a1
- lcr %r2,%r2
- st %r2,0(%r1,%r3)
- lghi %r2,-1
- br %r14
-# endif
-#endif
-
-END (__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/s390/syscall_error.c b/sysdeps/unix/sysv/linux/s390/syscall_error.c
new file mode 100644
index 0000000000..de5491dc50
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/syscall_error.c
@@ -0,0 +1,7 @@
+/* The auto-generated syscalls calls __syscall_error for static objects. */
+#include <syscall_error.h>
+#ifndef SHARED
+# undef SYSCALL_ERROR_FUNC
+# define SYSCALL_ERROR_FUNC 1
+#endif
+#include <sysdeps/unix/sysv/linux/syscall_error.c>
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 14/23] linux: Use generic __syscall_error for sh
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (12 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 13/23] linux: Use generic __syscall_error for s390 Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 15/23] linux: Use generic __syscall_error for microblaze Adhemerval Zanella
` (8 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Although the auto-generated syscall sets errno directly for dynamic
case, using a function call generates more compact code:
--- sizes-sh4-linux-gnu.outline
+++ sizes-sh4-linux-gnu.inline
text data bss dec hex filename
-1242446 9948 9240 1261634 134042 libc.so
- 122480 3764 176 126420 1edd4 elf/ld.so
- 91548 804 8348 100700 1895c nptl/libpthread.so
- 23613 608 160 24381 5f3d rt/librt.so
+1244638 9948 9240 1263826 1348d2 libc.so
+ 122416 3764 176 126356 1ed94 elf/ld.so
+ 91460 804 8348 100612 18904 nptl/libpthread.so
+ 23805 608 160 24573 5ffd rt/librt.so
It also removes the PLT call done by the generic unix syscall.S
which calls __errno_location instead of the accessing it directly
(as done by C implementation through syscall_error.c).
Checked with some basic tests to see if errno is set correctly
on both static and dynamic binaries with auto-generated syscals
and C implementation (which uses INTERNAL_SYSCALL_CALL).
---
sysdeps/unix/sh/sysdep.S | 115 ------------------
sysdeps/unix/sysv/linux/sh/localplt.data | 1 -
.../linux/sh/{sysdep.S => syscall_error.h} | 21 ++--
3 files changed, 7 insertions(+), 130 deletions(-)
delete mode 100644 sysdeps/unix/sh/sysdep.S
rename sysdeps/unix/sysv/linux/sh/{sysdep.S => syscall_error.h} (60%)
diff --git a/sysdeps/unix/sh/sysdep.S b/sysdeps/unix/sh/sysdep.S
deleted file mode 100644
index dc9a230ee0..0000000000
--- a/sysdeps/unix/sh/sysdep.S
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright (C) 1999-2020 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 <sysdep.h>
-#include <errno.h>
-
-ENTRY(__syscall_error)
-#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
- /* We translate the system's EWOULDBLOCK error into EAGAIN.
- The GNU C library always defines EWOULDBLOCK==EAGAIN.
- EWOULDBLOCK_sys is the original number. */
- mov.l .L1, r1
- cmp/eq r1, r0
- bf skip
- nop
- mov.l .L2, r0
-skip:
-#endif
- /* Store it in errno... */
-#ifndef SHARED
-#ifndef _LIBC_REENTRANT
- mov.l .L3, r1
- mov.l r0, @r1
-#else
- mov.l .L3, r1
- sts.l pr, @-r15
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (pr, 0)
- mov.l r0, @-r15
- cfi_adjust_cfa_offset (4)
- jsr @r1
- nop
- mov.l @r15+, r1
- cfi_adjust_cfa_offset (-4)
- lds.l @r15+, pr
- cfi_adjust_cfa_offset (-4)
- cfi_restore (pr)
- mov.l r1, @r0
-#endif
-#else
- mov.l r12, @-r15
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (r12, 0)
-#ifndef _LIBC_REENTRANT
- mov r0, r2
- mov.l 0f, r12
- mova 0f, r0
- add r0, r12
- mov.l .L3, r0
- mov.l @(r0,r12), r1
- mov.l r2, @r1
-#else
- mov.l r0, @-r15
- cfi_adjust_cfa_offset (4)
- sts.l pr, @-r15
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (pr, 0)
- mov.l 0f, r12
- mova 0f, r0
- add r0, r12
- mov.l .L3, r1
- mova .L3, r0
- add r0, r1
- jsr @r1
- nop
- lds.l @r15+, pr
- cfi_adjust_cfa_offset (-4)
- cfi_restore (pr)
- mov.l @r15+, r1
- cfi_adjust_cfa_offset (-4)
- mov.l r1, @r0
-#endif
- mov.l @r15+, r12
- cfi_adjust_cfa_offset (-4)
- cfi_restore (r12)
-#endif
- /* And just kick back a -1. */
- rts
- mov #-1, r0
-
- .align 2
-#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
-.L1: .long EWOULDBLOCK_sys
-.L2: .long EAGAIN
-#endif
-#ifndef SHARED
-#ifndef _LIBC_REENTRANT
-.L3: .long C_SYMBOL_NAME(errno)
-#else
-.L3: .long C_SYMBOL_NAME(__errno_location)
-#endif
-#else
-0:
- .long _GLOBAL_OFFSET_TABLE_
-#ifndef _LIBC_REENTRANT
-.L3: .long C_SYMBOL_NAME(errno@GOT)
-#else
-.L3: .long C_SYMBOL_NAME(__errno_location@PLT)
-#endif
-#endif
-END(__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/sh/localplt.data b/sysdeps/unix/sysv/linux/sh/localplt.data
index 3225177c50..9d8154648b 100644
--- a/sysdeps/unix/sysv/linux/sh/localplt.data
+++ b/sysdeps/unix/sysv/linux/sh/localplt.data
@@ -8,7 +8,6 @@ libc.so: memalign
libc.so: realloc
libc.so: _Unwind_Find_FDE
libc.so: _exit
-libc.so: __errno_location
libm.so: matherr
# Generated by the compiler because there is no trap insn pattern.
libc.so: abort ?
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/syscall_error.h
similarity index 60%
rename from sysdeps/unix/sysv/linux/sh/sysdep.S
rename to sysdeps/unix/sysv/linux/sh/syscall_error.h
index 85ff3f900e..5b75619168 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.S
+++ b/sysdeps/unix/sysv/linux/sh/syscall_error.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
+/* Linux wrappers for setting errno. SH version.
+ Copyright (C) 2020 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
@@ -15,18 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <sysdep.h>
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
-/* The syscall stubs jump here when they detect an error.
- The code for Linux is almost identical to the canonical Unix
- code, except that the error number in R0 is negated. */
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */
-
-ENTRY (__syscall_error)
- neg r4, r0
- cfi_endproc
-
-#define __syscall_error __syscall_error_1
-#include <sysdeps/unix/sh/sysdep.S>
+#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 15/23] linux: Use generic __syscall_error for microblaze
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (13 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 14/23] linux: Use generic __syscall_error for sh Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 16/23] linux: Use generic __syscall_error for ia64 Adhemerval Zanella
` (7 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Although the auto-generated syscall sets errno directly for dynamic
case, using a function call generates more compact code:
--- sizes-microblaze-linux-gnu.inline
+++ sizes-microblaze-linux-gnu.outline
text data bss dec hex filename
-1835305 52738 9216 1897259 1cf32b libc.so
- 188644 7236 176 196056 2fdd8 elf/ld.so
- 121772 5872 8356 136000 21340 nptl/libpthread.so
- 30836 1724 160 32720 7fd0 rt/librt.so
+1831025 52714 9216 1892955 1ce25b libc.so
+ 188904 7240 176 196320 2fee0 elf/ld.so
+ 121540 5864 8356 135760 21250 nptl/libpthread.so
+ 30640 1720 160 32520 7f08 rt/librt.so
Checked with a cross make check for microblaze-linux-gnu.
---
sysdeps/unix/sysv/linux/microblaze/Makefile | 6 ---
.../sysv/linux/microblaze/syscall_error.h | 25 ++++++++++++
sysdeps/unix/sysv/linux/microblaze/sysdep.S | 39 -------------------
3 files changed, 25 insertions(+), 45 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/microblaze/sysdep.S
diff --git a/sysdeps/unix/sysv/linux/microblaze/Makefile b/sysdeps/unix/sysv/linux/microblaze/Makefile
index d178bc6f34..614553204f 100644
--- a/sysdeps/unix/sysv/linux/microblaze/Makefile
+++ b/sysdeps/unix/sysv/linux/microblaze/Makefile
@@ -1,9 +1,3 @@
ifeq ($(subdir),resource)
sysdep_routines += backtrace_linux
endif
-
-ifeq ($(subdir),nptl)
-# pull in __syscall_error routine
-libpthread-routines += sysdep
-libpthread-shared-only-routines += sysdep
-endif
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscall_error.h b/sysdeps/unix/sysv/linux/microblaze/syscall_error.h
new file mode 100644
index 0000000000..3632dfddd7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/microblaze/syscall_error.h
@@ -0,0 +1,25 @@
+/* Linux wrappers for setting errno. Microblaze version.
+ Copyright (C) 2020 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/>. */
+
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
+
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.S b/sysdeps/unix/sysv/linux/microblaze/sysdep.S
deleted file mode 100644
index c3157880d8..0000000000
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 2009-2020 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 <sysdep.h>
-
-
-/* The following code is only used in the shared library when we
- compile the reentrant version. Otherwise each system call defines
- each own version. */
-
-#ifndef PIC
-
-/* The syscall stubs jump here when they detect an error. */
-
-# undef CALL_MCOUNT
-# define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %d0. */
-
- .text
-ENTRY (__syscall_error)
- rsubk r3,r3,r0
- rtsd r15,8
- addik r3,r0,-1 /* delay slot. */
-END (__syscall_error)
-#endif /* PIC. */
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 16/23] linux: Use generic __syscall_error for ia64
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (14 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 15/23] linux: Use generic __syscall_error for microblaze Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 17/23] linux: Use generic __syscall_error for m68k Adhemerval Zanella
` (6 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Although the auto-generated syscall issues __syscall_errno, using
an inline function generates much more compact code:
--- sizes-ia64-linux-gnu.inline
+++ sizes-ia64-linux-gnu.outline
text data bss dec hex filename
-2940053 20776 14424 2975253 2d6615 libc.so
- 301887 23190 1968 327045 4fd85 elf/ld.so
- 203203 2472 16640 222315 3646b nptl/libpthread.so
- 47153 1764 2272 51189 c7f5 rt/librt.so
+2947445 20776 14424 2982645 2d82f5 libc.so
+ 302591 23190 1968 327749 50045 elf/ld.so
+ 204987 2472 16640 224099 36b63 nptl/libpthread.so
+ 47609 1764 2272 51645 c9bd rt/librt.so
Checked with a cross make check for ia64-linux-gnu.
---
sysdeps/ia64/nptl/Makefile | 5 --
sysdeps/unix/sysv/linux/ia64/Makefile | 5 --
sysdeps/unix/sysv/linux/ia64/rt-sysdep.S | 1 -
sysdeps/unix/sysv/linux/ia64/syscall_error.c | 5 ++
sysdeps/unix/sysv/linux/ia64/sysdep.S | 58 --------------------
5 files changed, 5 insertions(+), 69 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/ia64/rt-sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/ia64/syscall_error.c
delete mode 100644 sysdeps/unix/sysv/linux/ia64/sysdep.S
diff --git a/sysdeps/ia64/nptl/Makefile b/sysdeps/ia64/nptl/Makefile
index d34cb27699..7869dd571c 100644
--- a/sysdeps/ia64/nptl/Makefile
+++ b/sysdeps/ia64/nptl/Makefile
@@ -18,8 +18,3 @@
ifeq ($(subdir),csu)
gen-as-const-headers += tcb-offsets.sym
endif
-
-ifeq ($(subdir),nptl)
-libpthread-routines += sysdep
-libpthread-shared-only-routines += sysdep
-endif
diff --git a/sysdeps/unix/sysv/linux/ia64/Makefile b/sysdeps/unix/sysv/linux/ia64/Makefile
index 97fc7df0b1..57917e78db 100644
--- a/sysdeps/unix/sysv/linux/ia64/Makefile
+++ b/sysdeps/unix/sysv/linux/ia64/Makefile
@@ -17,11 +17,6 @@ ifeq ($(subdir),elf)
sysdep-dl-routines += dl-static
endif
-ifeq ($(subdir),rt)
-librt-routines += rt-sysdep
-librt-shared-only-routines += rt-sysdep
-endif
-
ifeq ($(subdir),nptl)
libpthread-sysdep_routines += __ia64_longjmp unwind_longjmp __sigstack_longjmp
endif
diff --git a/sysdeps/unix/sysv/linux/ia64/rt-sysdep.S b/sysdeps/unix/sysv/linux/ia64/rt-sysdep.S
deleted file mode 100644
index f966bf1e59..0000000000
--- a/sysdeps/unix/sysv/linux/ia64/rt-sysdep.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdep.S>
diff --git a/sysdeps/unix/sysv/linux/ia64/syscall_error.c b/sysdeps/unix/sysv/linux/ia64/syscall_error.c
new file mode 100644
index 0000000000..2cd3e3a200
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/syscall_error.c
@@ -0,0 +1,5 @@
+/* The auto-generated syscalls calls __syscall_error. */
+#include <syscall_error.h>
+#undef SYSCALL_ERROR_FUNC
+#define SYSCALL_ERROR_FUNC 1
+#include <sysdeps/unix/sysv/linux/syscall_error.c>
diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.S b/sysdeps/unix/sysv/linux/ia64/sysdep.S
deleted file mode 100644
index 75fc3d6456..0000000000
--- a/sysdeps/unix/sysv/linux/ia64/sysdep.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
-
- 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 <sysdep.h>
-#include <features.h>
-#include <tls.h>
-
-ENTRY(__syscall_error)
-#if RTLD_PRIVATE_ERRNO
- /*
- * Note that the gp has to be set properly for this to work.
- * As long as all syscalls are in the same load unit
- * (executable or shared library) as this routine, we should
- * be fine. Otherwise, we would have to first load the global
- * pointer register from __gp.
- */
- addl r2=@gprel(rtld_errno),gp
- ;;
- st4 [r2]=r8
- mov r8=-1
-#else
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
- addl r2=@ltoff(@tprel(SYSCALL_ERROR_ERRNO)), gp;;
- ld8 r2=[r2]
- mov r3=r8;;
- mov r8=-1
- add r2=r2,r13;;
- st4 [r2]=r3
-#endif
- ret // ret is #define'd in syscall.h!
-END(__syscall_error)
-
-ENTRY(__ia64_syscall)
- mov r15=r37 /* syscall number */
- break __IA64_BREAK_SYSCALL
- cmp.eq p6,p0=-1,r10 /* r10 = -1 on error */
-(p6) br.cond.spnt.few __syscall_error
- ret
-PSEUDO_END(__ia64_syscall)
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 17/23] linux: Use generic __syscall_error for m68k
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (15 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 16/23] linux: Use generic __syscall_error for ia64 Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 18/23] linux: Use generic __syscall_error for csky Adhemerval Zanella
` (5 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Although the auto-generated syscall sets errno directly for dynamic
case, using a function call generates more compact code:
--- sizes-m68k-linux-gnu.inline
+++ sizes-m68k-linux-gnu.outline
text data bss dec hex filename
-1283686 20376 9304 1313366 140a56 libc.so
- 119206 5960 184 125350 1e9a6 elf/ld.so
- 87078 1456 8360 96894 17a7e nptl/libpthread.so
- 23918 888 160 24966 6186 rt/librt.so
+1277602 20376 9304 1307282 13f292 libc.so
+ 119174 5960 184 125318 1e986 elf/ld.so
+ 86314 1456 8360 96130 17782 nptl/libpthread.so
+ 23562 888 160 24610 6022 rt/librt.so
Checked with some basic tests to see if errno is set correctly
on both static and dynamic binaries with auto-generated syscals
and C implementation (which uses INTERNAL_SYSCALL_CALL).
---
sysdeps/unix/sysv/linux/m68k/syscall_error.h | 25 ++++++++++
sysdeps/unix/sysv/linux/m68k/sysdep.S | 50 --------------------
sysdeps/unix/sysv/linux/m68k/sysdep.h | 9 ++--
3 files changed, 29 insertions(+), 55 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/m68k/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/m68k/sysdep.S
diff --git a/sysdeps/unix/sysv/linux/m68k/syscall_error.h b/sysdeps/unix/sysv/linux/m68k/syscall_error.h
new file mode 100644
index 0000000000..4ea7cbdad5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/m68k/syscall_error.h
@@ -0,0 +1,25 @@
+/* Linux wrappers for setting errno. m68k version.
+ Copyright (C) 2020 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/>. */
+
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
+
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.S b/sysdeps/unix/sysv/linux/m68k/sysdep.S
deleted file mode 100644
index 1313ab17c3..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.S
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (C) 1996-2020 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 <sysdep.h>
-
-
-/* The following code is only used in the shared library when we
- compile the reentrant version. Otherwise each system call defines
- each own version. */
-
-#ifndef PIC
-
-/* The syscall stubs jump here when they detect an error. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %d0. */
-
- .text
-ENTRY (__syscall_error)
- neg.l %d0
-#ifndef _LIBC_REENTRANT
- move.l %d0, errno
-#else
- move.l %d0, -(%sp)
- cfi_adjust_cfa_offset (4)
- jbsr __errno_location
- move.l (%sp)+, (%a0)
- cfi_adjust_cfa_offset (-4)
-#endif
- move.l #-1, %d0
- /* Copy return value to %a0 for syscalls that are declared to
- return a pointer. */
- move.l %d0, %a0
- rts
-END (__syscall_error)
-#endif /* PIC */
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h
index 3e0ab605de..24835be910 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -45,11 +45,7 @@
/* We don't want the label for the error handler to be visible in the symbol
table when we define it here. */
#undef SYSCALL_ERROR_LABEL
-#ifdef PIC
#define SYSCALL_ERROR_LABEL .Lsyscall_error
-#else
-#define SYSCALL_ERROR_LABEL __syscall_error
-#endif
#undef PSEUDO
#define PSEUDO(name, syscall_name, args) \
@@ -137,7 +133,10 @@ SYSCALL_ERROR_LABEL: \
rts;
# endif /* _LIBC_REENTRANT */
#else
-# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+# define SYSCALL_ERROR_HANDLER \
+SYSCALL_ERROR_LABEL: \
+ move.l %d0,4(%sp); \
+ bra.l __syscall_error
#endif /* PIC */
/* Linux takes system call arguments in registers:
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 18/23] linux: Use generic __syscall_error for csky
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (16 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 17/23] linux: Use generic __syscall_error for m68k Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 19/23] linux: Use generic __syscall_error for riscv Adhemerval Zanella
` (4 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Although the auto-generated syscall issue __syscall_error, using
an inline function generates slight more compact code:
--- sizes-csky-linux-gnuabiv2-soft.outline
+++ sizes-csky-linux-gnuabiv2-soft.inline
text data bss dec hex filename
-1210010 10408 9212 1229630 12c33e libc.so
- 121439 3876 184 125499 1ea3b elf/ld.so
- 93074 920 8348 102342 18fc6 nptl/libpthread.so
- 24971 648 156 25775 64af rt/librt.so
+1209202 10408 9212 1228822 12c016 libc.so
+ 121171 3876 184 125231 1e92f elf/ld.so
+ 93630 920 8348 102898 191f2 nptl/libpthread.so
+ 24967 648 156 25771 64ab rt/librt.so
Checked with a cross make check for csky-linux-gnuabiv2-soft.
---
sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S | 65 --------------------
sysdeps/unix/sysv/linux/csky/syscall_error.h | 25 ++++++++
2 files changed, 25 insertions(+), 65 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/csky/syscall_error.h
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S b/sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S
deleted file mode 100644
index fe6b600bdc..0000000000
--- a/sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S
+++ /dev/null
@@ -1,65 +0,0 @@
-/* syscall error handlers. C-SKY ABIV2 version.
- Copyright (C) 2018-2020 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 <sysdep.h>
-
-/* The syscall stubs jump here when they detect an error.
- The code for Linux is almost identical to the canonical Unix
- code, except that the error number in R0 is negated. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */
-
- .text
-ENTRY (__syscall_error)
- movi a1, 0
- rsub a0, a0, a1
-
-#if !IS_IN (rtld)
- mov a1, a0
- mov a0, tls
-
- grs t1, .Lgetpc1
-.Lgetpc1:
- lrw t0, errno@gottpoff
- add t1, t1, t0
- ldw t1, (t1)
- add t1, a0
- stw a1, (t1)
- bmaski a0, 0
- rts
-#elif RTLD_PRIVATE_ERRNO /* !IS_IN (rtld) */
-# ifdef __PIC__
- grs t1, .Lgetpc2
-.Lgetpc2:
- lrw t0, .Lgetpc2@GOTPC
- addu t1, t1, t0
- lrw t0, rtld_errno@PLT
- ldr.w t0, (t1, t0 << 0)
-# else
- lrw t0, rtld_errno
-# endif /* __PIC__ */
- stw a0, (t0)
- bmaski a0, 0
- rts
-#else
-# error "Unsupported non-TLS case"
-#endif /* RTLD_PRIVATE_ERRNO */
-
-#undef __syscall_error
-END (__syscall_error)
diff --git a/sysdeps/unix/sysv/linux/csky/syscall_error.h b/sysdeps/unix/sysv/linux/csky/syscall_error.h
new file mode 100644
index 0000000000..dbdd6ab44f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/syscall_error.h
@@ -0,0 +1,25 @@
+/* Linux wrappers for setting errno. CSKY version.
+ Copyright (C) 2020 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/>. */
+
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
+
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 19/23] linux: Use generic __syscall_error for riscv
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (17 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 18/23] linux: Use generic __syscall_error for csky Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 20/23] linux: Use generic __syscall_error for nios2 Adhemerval Zanella
` (3 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The outline __syscall_error already generate the most compact
code for riscv64 and riscv32:
--- sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.outline
+++ sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.inline
text data bss dec hex filename
- 973220 9460 8840 991520 f2120 libc.so
- 98209 4124 176 102509 1906d elf/ld.so
- 71063 800 8348 80211 13953 nptl/libpthread.so
- 17011 608 168 17787 457b rt/librt.so
+ 974466 9460 8840 992766 f25fe libc.so
+ 98331 4124 176 102631 190e7 elf/ld.so
+ 70939 800 8348 80087 138d7 nptl/libpthread.so
+ 17095 608 168 17871 45cf rt/librt.so
--- sizes-riscv64-linux-gnu-rv64imafdc-lp64d.outline
+++ sizes-riscv64-linux-gnu-rv64imafdc-lp64d.inline
text data bss dec hex filename
-1030902 18632 14472 1064006 103c46 libc.so
- 98320 6232 336 104888 199b8 elf/ld.so
- 76588 1596 16664 94848 17280 nptl/libpthread.so
- 18016 1156 232 19404 4bcc rt/librt.so
+1031680 18632 14472 1064784 103f50 libc.so
+ 98374 6232 336 104942 199ee elf/ld.so
+ 76544 1596 16664 94804 17254 nptl/libpthread.so
+ 18106 1156 232 19494 4c26 rt/librt.so
Checked with some basic tests to see if errno is set correctly
on both static and dynamic binaries with auto-generated syscals
and C implementation (which uses INTERNAL_SYSCALL_CALL).
---
sysdeps/riscv/nptl/Makefile | 5 --
sysdeps/riscv/nptl/nptl-sysdep.S | 2 -
sysdeps/unix/sysv/linux/riscv/syscall_error.h | 25 +++++++++
sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 -------------------
4 files changed, 25 insertions(+), 58 deletions(-)
delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/riscv/sysdep.S
diff --git a/sysdeps/riscv/nptl/Makefile b/sysdeps/riscv/nptl/Makefile
index 1af6fa6a55..3f6428b0de 100644
--- a/sysdeps/riscv/nptl/Makefile
+++ b/sysdeps/riscv/nptl/Makefile
@@ -19,8 +19,3 @@
ifeq ($(subdir),csu)
gen-as-const-headers += tcb-offsets.sym
endif
-
-ifeq ($(subdir),nptl)
-libpthread-sysdep_routines += nptl-sysdep
-libpthread-shared-only-routines += nptl-sysdep
-endif
diff --git a/sysdeps/riscv/nptl/nptl-sysdep.S b/sysdeps/riscv/nptl/nptl-sysdep.S
deleted file mode 100644
index 3f5c2a364a..0000000000
--- a/sysdeps/riscv/nptl/nptl-sysdep.S
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Pull in __syscall_error. */
-#include <sysdep.S>
diff --git a/sysdeps/unix/sysv/linux/riscv/syscall_error.h b/sysdeps/unix/sysv/linux/riscv/syscall_error.h
new file mode 100644
index 0000000000..932f34aa0f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/riscv/syscall_error.h
@@ -0,0 +1,25 @@
+/* Linux wrappers for setting errno. RISCV version.
+ Copyright (C) 2020 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/>. */
+
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
+
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.S b/sysdeps/unix/sysv/linux/riscv/sysdep.S
deleted file mode 100644
index 64daa84aac..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/* syscall error handlers
- Copyright (C) 2011-2020 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 <sysdep.h>
-
-#if IS_IN (libc)
-# define errno __libc_errno
-#endif
-
-ENTRY (__syscall_error)
- mv t0, ra
- /* Fall through to __syscall_set_errno. */
-END (__syscall_error)
-
-/* Non-standard calling convention: argument in a0, return address in t0,
- and clobber only t1. */
-ENTRY (__syscall_set_errno)
- /* We got here because a0 < 0, but only codes in the range [-4095, -1]
- represent errors. Otherwise, just return the result normally. */
- li t1, -4096
- bleu a0, t1, 1f
- neg a0, a0
-#if RTLD_PRIVATE_ERRNO
- sw a0, rtld_errno, t1
-#elif defined(__PIC__)
- la.tls.ie t1, errno
- add t1, t1, tp
- sw a0, 0(t1)
-#else
- lui t1, %tprel_hi(errno)
- add t1, t1, tp, %tprel_add(errno)
- sw a0, %tprel_lo(errno)(t1)
-#endif
- li a0, -1
-1: jr t0
-END (__syscall_set_errno)
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 20/23] linux: Use generic __syscall_error for nios2
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (18 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 19/23] linux: Use generic __syscall_error for riscv Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 21/23] linux: Use generic __syscall_error for alpha Adhemerval Zanella
` (2 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The usage of __syscall_error function on dynamic objects only
increases the total size slightly:
--- sizes-nios2-linux-gnu.inline
+++ sizes-nios2-linux-gnu.outline
text data bss dec hex filename
-1425296 78844 9224 1513364 171794 libc.so
- 143824 8138 184 152146 25252 elf/ld.so
- 101762 9260 8356 119378 1d252 nptl/libpthread.so
- 26183 2392 160 28735 703f rt/librt.so
+1425592 80724 9224 1515540 172014 libc.so
+ 143960 8142 184 152286 252de elf/ld.so
+ 102278 10552 8356 121186 1d962 nptl/libpthread.so
+ 26175 2396 160 28731 703b rt/librt.so
And since the port already issues the function call for static
object it simplifies the implementation since it avoid add an
arch-specific syscall_error.c.
Checked with cross make check for nios2-linux-gnu.
---
sysdeps/unix/sysv/linux/nios2/syscall_error.h | 25 ++++++++++
sysdeps/unix/sysv/linux/nios2/sysdep.S | 50 -------------------
2 files changed, 25 insertions(+), 50 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep.S
diff --git a/sysdeps/unix/sysv/linux/nios2/syscall_error.h b/sysdeps/unix/sysv/linux/nios2/syscall_error.h
new file mode 100644
index 0000000000..c13958a07d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/syscall_error.h
@@ -0,0 +1,25 @@
+/* Linux wrappers for setting errno. NIOS2 version.
+ Copyright (C) 2020 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/>. */
+
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
+
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.S b/sysdeps/unix/sysv/linux/nios2/sysdep.S
deleted file mode 100644
index 6efbb5aff6..0000000000
--- a/sysdeps/unix/sysv/linux/nios2/sysdep.S
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Static library error handling code fragment for Nios II.
- Copyright (C) 2015-2020 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 <sysdep.h>
-
-/* The following code is only used in the static library. In the shared
- library, the error handling code is at the end of each function. */
-
-#ifndef PIC
-
-/* In the static library, the syscall stubs jump here when they detect
- an error. */
-
-# undef CALL_MCOUNT
-# define CALL_MCOUNT /* Don't insert the profiling call, it clobbers r2. */
-
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
- .text
-ENTRY (__syscall_error)
- nextpc r3
-1:
- movhi r8, %hiadj(_gp_got - 1b)
- addi r8, r8, %lo(_gp_got - 1b)
- add r3, r3, r8
- ldw r3, %tls_ie(SYSCALL_ERROR_ERRNO)(r3)
- add r3, r23, r3
- stw r2, 0(r3)
- movi r2, -1
- ret
-END (__syscall_error)
-#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 21/23] linux: Use generic __syscall_error for alpha
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (19 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 20/23] linux: Use generic __syscall_error for nios2 Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 22/23] linux: Use generic __syscall_error for mips Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 23/23] linux: Make SYSCALL_ERROR_FUNC as default Adhemerval Zanella
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
Alpha __syscall_error uses an optimization to avoid load de GP
register and assumes small code size (-fpic). Its implementation
is moved to arch-specific one (syscall_error_asm.S) to avoid
rewritting the inline asm wrapper to call the generic
__syscall_error.
Checked on alpha-linux-gnu.
---
sysdeps/unix/alpha/Makefile | 8 ++++++--
sysdeps/unix/alpha/rt-sysdep.S | 1 -
sysdeps/unix/alpha/{sysdep.S => syscall_error_asm.S} | 8 ++++----
sysdeps/unix/sysv/linux/alpha/Makefile | 3 +--
sysdeps/unix/sysv/linux/alpha/sysdep.h | 4 ++--
5 files changed, 13 insertions(+), 11 deletions(-)
delete mode 100644 sysdeps/unix/alpha/rt-sysdep.S
rename sysdeps/unix/alpha/{sysdep.S => syscall_error_asm.S} (94%)
diff --git a/sysdeps/unix/alpha/Makefile b/sysdeps/unix/alpha/Makefile
index 0660847f15..823ff2d90f 100644
--- a/sysdeps/unix/alpha/Makefile
+++ b/sysdeps/unix/alpha/Makefile
@@ -1,4 +1,8 @@
+ifeq ($(subdir),csu)
+sysdep_routines += syscall_error_asm
+endif
+
ifeq ($(subdir),rt)
-librt-sysdep_routines += rt-sysdep
-librt-shared-only-routines += rt-sysdep
+librt-routines += syscall_error_asm
+librt-shared-only-routines += syscall_error_asm
endif
diff --git a/sysdeps/unix/alpha/rt-sysdep.S b/sysdeps/unix/alpha/rt-sysdep.S
deleted file mode 100644
index f966bf1e59..0000000000
--- a/sysdeps/unix/alpha/rt-sysdep.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdep.S>
diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/syscall_error_asm.S
similarity index 94%
rename from sysdeps/unix/alpha/sysdep.S
rename to sysdeps/unix/alpha/syscall_error_asm.S
index 67968623ac..ddc86c56d6 100644
--- a/sysdeps/unix/alpha/sysdep.S
+++ b/sysdeps/unix/alpha/syscall_error_asm.S
@@ -35,9 +35,9 @@
#endif
.align 4
- .globl __syscall_error
- .ent __syscall_error
-__syscall_error:
+ .globl __syscall_error_asm
+ .ent __syscall_error_asm
+__syscall_error_asm:
/* When building a shared library, we branch here without having
loaded the GP. Nor, since it was a direct branch, have we
loaded PV with our address.
@@ -62,4 +62,4 @@ __syscall_error:
stl t0, 0(t1)
ret
- .end __syscall_error
+ .end __syscall_error_asm
diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile
index 92484bbe65..20c673b644 100644
--- a/sysdeps/unix/sysv/linux/alpha/Makefile
+++ b/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -31,8 +31,7 @@ libm-routines += multc3 divtc3
endif # math
ifeq ($(subdir),nptl)
-# pull in __syscall_error routine, sigaction stubs.
-libpthread-routines += sysdep rt_sigaction
+libpthread-routines += rt_sigaction
libpthread-shared-only-routines += sysdep rt_sigaction
endif
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h
index 7daf445068..86bab2ed4c 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h
@@ -102,14 +102,14 @@ $syscall_error: \
ret
# define SYSCALL_ERROR_FALLTHRU
#elif defined(PIC)
-# define SYSCALL_ERROR_LABEL __syscall_error !samegp
+# define SYSCALL_ERROR_LABEL __syscall_error_asm !samegp
# define SYSCALL_ERROR_HANDLER
# define SYSCALL_ERROR_FALLTHRU br SYSCALL_ERROR_LABEL
#else
# define SYSCALL_ERROR_LABEL $syscall_error
# define SYSCALL_ERROR_HANDLER \
$syscall_error: \
- jmp $31, __syscall_error
+ jmp $31, __syscall_error_asm
# define SYSCALL_ERROR_FALLTHRU
#endif /* RTLD_PRIVATE_ERRNO */
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 22/23] linux: Use generic __syscall_error for mips
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (20 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 21/23] linux: Use generic __syscall_error for alpha Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 23/23] linux: Make SYSCALL_ERROR_FUNC as default Adhemerval Zanella
22 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
The mips kABI returns a positive value on 'v0 ($2)' register
for failure case, different than usual Linux kABI with return
a negative value in range of [-4096,0). To adjust mips to use
the generic __syscall_error requires to change both the inline
syscall and some assembly implementation that call __syscall_error
directly.
Also, using an extern call to __syscall_error on mips results in
more code size:
--- sizes-mips64-linux-gnu.inline
+++ sizes-mips64-linux-gnu.outline
text data bss dec hex filename
-1706692 39428 15584 1761704 1ae1a8 libc.so
- 164384 7904 396 172684 2a28c elf/ld.so
- 126357 1912 16720 144989 2365d nptl/libpthread.so
- 30260 988 272 31520 7b20 rt/librt.so
+1708116 39436 15584 1763136 1ae740 libc.so
+ 164592 7904 396 172892 2a35c elf/ld.so
+ 127093 1920 16720 145733 23945 nptl/libpthread.so
+ 30380 988 272 31640 7b98 rt/librt.so
--- sizes-mips-linux-gnu.inline
+++ sizes-mips-linux-gnu.outline
text data bss dec hex filename
-1644339 21129 10824 1676292 199404 libc.so
- 173460 4856 264 178580 2b994 elf/ld.so
- 120945 1016 8420 130381 1fd4d nptl/libpthread.so
- 30822 560 192 31574 7b56 rt/librt.so
+1644411 21137 10824 1676372 199454 libc.so
+ 173652 4856 264 178772 2ba54 elf/ld.so
+ 121357 1020 8420 130797 1feed nptl/libpthread.so
+ 30830 560 192 31582 7b5e rt/librt.so
The inline __syscall_error is used on C syscall implementations
and a arch-specific syscall_error.c is added to handle the
auto-generated ones.
Checked on mips64-linux-gnu and mips-linux-gnu.
---
sysdeps/mips/Makefile | 5 -
sysdeps/mips/nptl/Makefile | 5 -
sysdeps/mips/nptl/nptl-sysdep.S | 2 -
sysdeps/unix/mips/mips32/sysdep.h | 5 +-
sysdeps/unix/mips/mips64/sysdep.h | 3 +-
sysdeps/unix/mips/rt-sysdep.S | 1 -
sysdeps/unix/mips/sysdep.S | 99 -------------------
sysdeps/unix/sysv/linux/mips/clone.S | 1 +
sysdeps/unix/sysv/linux/mips/getcontext.S | 1 +
.../unix/sysv/linux/mips/mips64/n64/ioctl.S | 3 +-
sysdeps/unix/sysv/linux/mips/mips64/syscall.S | 3 +-
sysdeps/unix/sysv/linux/mips/setcontext.S | 1 +
sysdeps/unix/sysv/linux/mips/swapcontext.S | 1 +
sysdeps/unix/sysv/linux/mips/syscall_error.c | 5 +
sysdeps/unix/sysv/linux/mips/vfork.S | 1 +
15 files changed, 19 insertions(+), 117 deletions(-)
delete mode 100644 sysdeps/mips/nptl/nptl-sysdep.S
delete mode 100644 sysdeps/unix/mips/rt-sysdep.S
delete mode 100644 sysdeps/unix/mips/sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/mips/syscall_error.c
diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile
index 6ad69e9ef9..70c599ec95 100644
--- a/sysdeps/mips/Makefile
+++ b/sysdeps/mips/Makefile
@@ -7,11 +7,6 @@ ifeq ($(subdir),setjmp)
sysdep_routines += setjmp_aux
endif
-ifeq ($(subdir),rt)
-librt-sysdep_routines += rt-sysdep
-librt-shared-only-routines += rt-sysdep
-endif
-
ifeq ($(subdir),csu)
CPPFLAGS-crti.S += $(pic-ccflag)
CPPFLAGS-crtn.S += $(pic-ccflag)
diff --git a/sysdeps/mips/nptl/Makefile b/sysdeps/mips/nptl/Makefile
index e9d279a530..eb5d51c450 100644
--- a/sysdeps/mips/nptl/Makefile
+++ b/sysdeps/mips/nptl/Makefile
@@ -18,8 +18,3 @@
ifeq ($(subdir),csu)
gen-as-const-headers += tcb-offsets.sym
endif
-
-ifeq ($(subdir),nptl)
-libpthread-sysdep_routines += nptl-sysdep
-libpthread-shared-only-routines += nptl-sysdep
-endif
diff --git a/sysdeps/mips/nptl/nptl-sysdep.S b/sysdeps/mips/nptl/nptl-sysdep.S
deleted file mode 100644
index 3f5c2a364a..0000000000
--- a/sysdeps/mips/nptl/nptl-sysdep.S
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Pull in __syscall_error. */
-#include <sysdep.S>
diff --git a/sysdeps/unix/mips/mips32/sysdep.h b/sysdeps/unix/mips/mips32/sysdep.h
index b09367347e..8f3d561abf 100644
--- a/sysdeps/unix/mips/mips32/sysdep.h
+++ b/sysdeps/unix/mips/mips32/sysdep.h
@@ -26,7 +26,8 @@
.align 2; \
.set nomips16; \
cfi_startproc; \
- 99: la t9,__syscall_error; \
+ 99: subu a0, zero, v0; \
+ la t9,__syscall_error; \
jr t9; \
cfi_endproc; \
ENTRY(name) \
@@ -44,7 +45,7 @@ L(syse1):
.align 2; \
cfi_startproc; \
99: j __syscall_error; \
- nop; \
+ subu a0, zero, v0; \
cfi_endproc; \
ENTRY(name) \
.set noreorder; \
diff --git a/sysdeps/unix/mips/mips64/sysdep.h b/sysdeps/unix/mips/mips64/sysdep.h
index fb5f27daf3..ff14bcceec 100644
--- a/sysdeps/unix/mips/mips64/sysdep.h
+++ b/sysdeps/unix/mips/mips64/sysdep.h
@@ -30,6 +30,7 @@
.set nomips16; \
cfi_startproc; \
99:; \
+ dsubu a0, zero, v0; \
.set noat; \
.cpsetup t9, $1, name; \
cfi_register (gp, $1); \
@@ -51,7 +52,7 @@ L(syse1):
.set nomips16; \
cfi_startproc; \
99: j __syscall_error; \
- nop; \
+ dsubu a0, zero, v0; \
cfi_endproc; \
ENTRY(name) \
.set noreorder; \
diff --git a/sysdeps/unix/mips/rt-sysdep.S b/sysdeps/unix/mips/rt-sysdep.S
deleted file mode 100644
index f966bf1e59..0000000000
--- a/sysdeps/unix/mips/rt-sysdep.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdep.S>
diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S
deleted file mode 100644
index 744d1620b3..0000000000
--- a/sysdeps/unix/mips/sysdep.S
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Brendan Kehoe (brendan@zen.org).
-
- 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 <sysdep.h>
-#include <errno.h>
-#include <sys/asm.h>
-
- .set nomips16
-
-#ifdef _LIBC_REENTRANT
-
-LOCALSZ= 3
-FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
-RAOFF= FRAMESZ-(1*SZREG)
-GPOFF= FRAMESZ-(2*SZREG)
-V0OFF= FRAMESZ-(3*SZREG)
-
-ENTRY(__syscall_error)
-#ifdef __PIC__
- .set noat
- SETUP_GPX (AT)
- .set at
-#endif
- PTR_SUBU sp, FRAMESZ
- .set noat
- SETUP_GPX64(GPOFF,AT)
- .set at
-#ifdef __PIC__
- SAVE_GP(GPOFF)
-#endif
- REG_S v0, V0OFF(sp)
- REG_S ra, RAOFF(sp)
-
-#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
- /* We translate the system's EWOULDBLOCK error into EAGAIN.
- The GNU C library always defines EWOULDBLOCK==EAGAIN.
- EWOULDBLOCK_sys is the original number. */
- bne v0, EWOULDBLOCK_sys, L(skip)
- nop
- li v0, EAGAIN
-L(skip):
-#endif
- /* Find our per-thread errno address */
- jal __errno_location
-
- /* Store the error value. */
- REG_L t0, V0OFF(sp)
- sw t0, 0(v0)
-
- /* And just kick back a -1. */
- REG_L ra, RAOFF(sp)
- RESTORE_GP64
- PTR_ADDU sp, FRAMESZ
- li v0, -1
- j ra
- END(__syscall_error)
-
-#else /* _LIBC_REENTRANT */
-
-
-ENTRY(__syscall_error)
-#ifdef __PIC__
- SETUP_GPX (AT)
-#endif
- SETUP_GPX64 (t9, AT)
-
-#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
- /* We translate the system's EWOULDBLOCK error into EAGAIN.
- The GNU C library always defines EWOULDBLOCK==EAGAIN.
- EWOULDBLOCK_sys is the original number. */
- bne v0, EWOULDBLOCK_sys, L(skip)
- li v0, EAGAIN
-L(skip):
-#endif
- /* Store it in errno... */
- sw v0, errno
-
- /* And just kick back a -1. */
- li v0, -1
-
- RESTORE_GP64
- j ra
- END(__syscall_error)
-#endif /* _LIBC_REENTRANT */
diff --git a/sysdeps/unix/sysv/linux/mips/clone.S b/sysdeps/unix/sysv/linux/mips/clone.S
index 6a5ec84870..3dd181b6f9 100644
--- a/sysdeps/unix/sysv/linux/mips/clone.S
+++ b/sysdeps/unix/sysv/linux/mips/clone.S
@@ -102,6 +102,7 @@ NESTED(__clone,4*SZREG,sp)
/* Something bad happened -- no child created */
L(error):
cfi_restore_state
+ INT_SUBU a0, zero, v0
#ifdef __PIC__
PTR_LA t9,__syscall_error
RESTORE_GP64_STACK
diff --git a/sysdeps/unix/sysv/linux/mips/getcontext.S b/sysdeps/unix/sysv/linux/mips/getcontext.S
index 69f62d4a75..edb5063647 100644
--- a/sysdeps/unix/sysv/linux/mips/getcontext.S
+++ b/sysdeps/unix/sysv/linux/mips/getcontext.S
@@ -140,6 +140,7 @@ NESTED (__getcontext, FRAMESZ, ra)
99:
cfi_restore_state
+ INT_SUBU a0, zero, v0
#ifdef __PIC__
PTR_LA t9, JUMPTARGET (__syscall_error)
RESTORE_GP64_STACK
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S b/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
index ed58abe7e9..c911abee2a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
@@ -31,7 +31,8 @@ ENTRY (__ioctl)
ret
L(error):
- SETUP_GP64_REG (a0, __ioctl)
+ INT_SUBU a0, zero, v0
+ SETUP_GP64_REG (v0, __ioctl)
PTR_LA t9, __syscall_error
RESTORE_GP64_REG
jr t9
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscall.S b/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
index a9baff3c17..8fc6caea71 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
@@ -55,7 +55,8 @@ NESTED (syscall, SZREG, ra)
ret
L(error):
- SETUP_GP64_REG (a0, syscall)
+ INT_SUBU a0, zero, v0
+ SETUP_GP64_REG (v0, syscall)
PTR_LA t9, __syscall_error
RESTORE_GP64_REG
jr t9
diff --git a/sysdeps/unix/sysv/linux/mips/setcontext.S b/sysdeps/unix/sysv/linux/mips/setcontext.S
index 3609af7780..cd058c4390 100644
--- a/sysdeps/unix/sysv/linux/mips/setcontext.S
+++ b/sysdeps/unix/sysv/linux/mips/setcontext.S
@@ -149,6 +149,7 @@ NESTED (__setcontext, FRAMESZ, ra)
jr t9
99:
+ INT_SUBU a0, zero, v0
#ifdef __PIC__
PTR_LA t9, JUMPTARGET (__syscall_error)
RESTORE_GP64_STACK
diff --git a/sysdeps/unix/sysv/linux/mips/swapcontext.S b/sysdeps/unix/sysv/linux/mips/swapcontext.S
index bcc66be068..ca3bcddfb7 100644
--- a/sysdeps/unix/sysv/linux/mips/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/mips/swapcontext.S
@@ -200,6 +200,7 @@ NESTED (__swapcontext, FRAMESZ, ra)
jr t9
99:
+ INT_SUBU a0, zero, v0;
#ifdef __PIC__
PTR_LA t9, JUMPTARGET (__syscall_error)
RESTORE_GP64_STACK
diff --git a/sysdeps/unix/sysv/linux/mips/syscall_error.c b/sysdeps/unix/sysv/linux/mips/syscall_error.c
new file mode 100644
index 0000000000..b6026395b2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/syscall_error.c
@@ -0,0 +1,5 @@
+/* The auto-generated syscalls call __syscall_error. */
+#include <syscall_error.h>
+#undef SYSCALL_ERROR_FUNC
+#define SYSCALL_ERROR_FUNC 1
+#include <sysdeps/unix/sysv/linux/syscall_error.c>
diff --git a/sysdeps/unix/sysv/linux/mips/vfork.S b/sysdeps/unix/sysv/linux/mips/vfork.S
index ba3c64ae1e..f579ffe46f 100644
--- a/sysdeps/unix/sysv/linux/mips/vfork.S
+++ b/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -76,6 +76,7 @@ NESTED(__libc_vfork,FRAMESZ,sp)
/* Something bad happened -- no child created. */
L(error):
cfi_restore_state
+ INT_SUBU a0, zero, v0
#ifdef __PIC__
PTR_LA t9, __syscall_error
RESTORE_GP64_REG
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v2 23/23] linux: Make SYSCALL_ERROR_FUNC as default
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
` (21 preceding siblings ...)
2020-11-13 16:58 ` [PATCH v2 22/23] linux: Use generic __syscall_error for mips Adhemerval Zanella
@ 2020-11-13 16:58 ` Adhemerval Zanella
2020-11-16 13:45 ` Adhemerval Zanella
22 siblings, 1 reply; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-13 16:58 UTC (permalink / raw)
To: libc-alpha
It is the more common option overall, only alpha, ia64, mips, and
x86_64 inline the __syscall_erro call.
---
.../unix/sysv/linux/aarch64/syscall_error.h | 25 -------------------
.../sysv/linux/{arm => alpha}/syscall_error.h | 4 +--
sysdeps/unix/sysv/linux/arc/syscall_error.h | 25 -------------------
sysdeps/unix/sysv/linux/i386/syscall_error.h | 25 -------------------
.../sysv/linux/{hppa => ia64}/syscall_error.h | 4 +--
.../sysv/linux/microblaze/syscall_error.h | 25 -------------------
.../sysv/linux/{m68k => mips}/syscall_error.h | 4 +--
sysdeps/unix/sysv/linux/nios2/syscall_error.h | 25 -------------------
.../unix/sysv/linux/powerpc/syscall_error.h | 25 -------------------
sysdeps/unix/sysv/linux/riscv/syscall_error.h | 25 -------------------
sysdeps/unix/sysv/linux/sh/syscall_error.h | 25 -------------------
sysdeps/unix/sysv/linux/sparc/syscall_error.h | 25 -------------------
sysdeps/unix/sysv/linux/syscall_error.h | 4 +--
.../linux/{csky => x86_64}/syscall_error.h | 4 +--
14 files changed, 10 insertions(+), 235 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/aarch64/syscall_error.h
rename sysdeps/unix/sysv/linux/{arm => alpha}/syscall_error.h (90%)
delete mode 100644 sysdeps/unix/sysv/linux/arc/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/i386/syscall_error.h
rename sysdeps/unix/sysv/linux/{hppa => ia64}/syscall_error.h (90%)
delete mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_error.h
rename sysdeps/unix/sysv/linux/{m68k => mips}/syscall_error.h (90%)
delete mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/sh/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/sparc/syscall_error.h
rename sysdeps/unix/sysv/linux/{csky => x86_64}/syscall_error.h (90%)
diff --git a/sysdeps/unix/sysv/linux/aarch64/syscall_error.h b/sysdeps/unix/sysv/linux/aarch64/syscall_error.h
deleted file mode 100644
index a45e02dbe4..0000000000
--- a/sysdeps/unix/sysv/linux/aarch64/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. AArch64 version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/arm/syscall_error.h b/sysdeps/unix/sysv/linux/alpha/syscall_error.h
similarity index 90%
rename from sysdeps/unix/sysv/linux/arm/syscall_error.h
rename to sysdeps/unix/sysv/linux/alpha/syscall_error.h
index 71f74e2bd3..28ca78de91 100644
--- a/sysdeps/unix/sysv/linux/arm/syscall_error.h
+++ b/sysdeps/unix/sysv/linux/alpha/syscall_error.h
@@ -1,4 +1,4 @@
-/* Linux wrappers for setting errno. ARM version.
+/* Linux wrappers for setting errno. Alpha version.
Copyright (C) 2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -19,7 +19,7 @@
#ifndef _SYSCALL_ERROR_H
#define _SYSCALL_ERROR_H
-#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC 0
#define SYSCALL_ERROR_FUNC_ATTR
#endif
diff --git a/sysdeps/unix/sysv/linux/arc/syscall_error.h b/sysdeps/unix/sysv/linux/arc/syscall_error.h
deleted file mode 100644
index a45e02dbe4..0000000000
--- a/sysdeps/unix/sysv/linux/arc/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. AArch64 version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/i386/syscall_error.h b/sysdeps/unix/sysv/linux/i386/syscall_error.h
deleted file mode 100644
index 0b63c07a4e..0000000000
--- a/sysdeps/unix/sysv/linux/i386/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. i386 version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR __attribute__ ((__regparm__ (1)))
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/syscall_error.h b/sysdeps/unix/sysv/linux/ia64/syscall_error.h
similarity index 90%
rename from sysdeps/unix/sysv/linux/hppa/syscall_error.h
rename to sysdeps/unix/sysv/linux/ia64/syscall_error.h
index f5947ccd7c..82d37a0d35 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscall_error.h
+++ b/sysdeps/unix/sysv/linux/ia64/syscall_error.h
@@ -1,4 +1,4 @@
-/* Linux wrappers for setting errno. HPPA version.
+/* Linux wrappers for setting errno. IA64 version.
Copyright (C) 2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -19,7 +19,7 @@
#ifndef _SYSCALL_ERROR_H
#define _SYSCALL_ERROR_H
-#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC 0
#define SYSCALL_ERROR_FUNC_ATTR
#endif
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscall_error.h b/sysdeps/unix/sysv/linux/microblaze/syscall_error.h
deleted file mode 100644
index 3632dfddd7..0000000000
--- a/sysdeps/unix/sysv/linux/microblaze/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. Microblaze version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/m68k/syscall_error.h b/sysdeps/unix/sysv/linux/mips/syscall_error.h
similarity index 90%
rename from sysdeps/unix/sysv/linux/m68k/syscall_error.h
rename to sysdeps/unix/sysv/linux/mips/syscall_error.h
index 4ea7cbdad5..2e3536c0ab 100644
--- a/sysdeps/unix/sysv/linux/m68k/syscall_error.h
+++ b/sysdeps/unix/sysv/linux/mips/syscall_error.h
@@ -1,4 +1,4 @@
-/* Linux wrappers for setting errno. m68k version.
+/* Linux wrappers for setting errno. MIPS version.
Copyright (C) 2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -19,7 +19,7 @@
#ifndef _SYSCALL_ERROR_H
#define _SYSCALL_ERROR_H
-#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC 0
#define SYSCALL_ERROR_FUNC_ATTR
#endif
diff --git a/sysdeps/unix/sysv/linux/nios2/syscall_error.h b/sysdeps/unix/sysv/linux/nios2/syscall_error.h
deleted file mode 100644
index c13958a07d..0000000000
--- a/sysdeps/unix/sysv/linux/nios2/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. NIOS2 version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall_error.h b/sysdeps/unix/sysv/linux/powerpc/syscall_error.h
deleted file mode 100644
index 924f12435d..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. PowerPC version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/syscall_error.h b/sysdeps/unix/sysv/linux/riscv/syscall_error.h
deleted file mode 100644
index 932f34aa0f..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. RISCV version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/sh/syscall_error.h b/sysdeps/unix/sysv/linux/sh/syscall_error.h
deleted file mode 100644
index 5b75619168..0000000000
--- a/sysdeps/unix/sysv/linux/sh/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. SH version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/syscall_error.h b/sysdeps/unix/sysv/linux/sparc/syscall_error.h
deleted file mode 100644
index 6a9fac278a..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/syscall_error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Linux wrappers for setting errno. SPARC version.
- Copyright (C) 2020 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/>. */
-
-#ifndef _SYSCALL_ERROR_H
-#define _SYSCALL_ERROR_H
-
-#define SYSCALL_ERROR_FUNC 1
-#define SYSCALL_ERROR_FUNC_ATTR
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/syscall_error.h b/sysdeps/unix/sysv/linux/syscall_error.h
index 6523eb5269..3c9737b734 100644
--- a/sysdeps/unix/sysv/linux/syscall_error.h
+++ b/sysdeps/unix/sysv/linux/syscall_error.h
@@ -20,9 +20,9 @@
#define _SYSCALL_ERROR_H
/* Each architecture might how __syscall_error is called, either by defining
- an inline function (default) or by calling a hidden function. Check the
+ an inline function or by calling a hidden function (default). Check the
sysdep.h file for the implementation. */
-#define SYSCALL_ERROR_FUNC 0
+#define SYSCALL_ERROR_FUNC 1
/* Any function attribute used to define the __syscall_error in case of
__SYSCALL_ERROR_FUNC (for instance by using a different calling covention
diff --git a/sysdeps/unix/sysv/linux/csky/syscall_error.h b/sysdeps/unix/sysv/linux/x86_64/syscall_error.h
similarity index 90%
rename from sysdeps/unix/sysv/linux/csky/syscall_error.h
rename to sysdeps/unix/sysv/linux/x86_64/syscall_error.h
index dbdd6ab44f..94ae05cf58 100644
--- a/sysdeps/unix/sysv/linux/csky/syscall_error.h
+++ b/sysdeps/unix/sysv/linux/x86_64/syscall_error.h
@@ -1,4 +1,4 @@
-/* Linux wrappers for setting errno. CSKY version.
+/* Linux wrappers for setting errno. x86_64 version.
Copyright (C) 2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -19,7 +19,7 @@
#ifndef _SYSCALL_ERROR_H
#define _SYSCALL_ERROR_H
-#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC 0
#define SYSCALL_ERROR_FUNC_ATTR
#endif
--
2.25.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v2 23/23] linux: Make SYSCALL_ERROR_FUNC as default
2020-11-13 16:58 ` [PATCH v2 23/23] linux: Make SYSCALL_ERROR_FUNC as default Adhemerval Zanella
@ 2020-11-16 13:45 ` Adhemerval Zanella
0 siblings, 0 replies; 25+ messages in thread
From: Adhemerval Zanella @ 2020-11-16 13:45 UTC (permalink / raw)
To: libc-alpha
On 13/11/2020 13:58, Adhemerval Zanella wrote:
> diff --git a/sysdeps/unix/sysv/linux/i386/syscall_error.h b/sysdeps/unix/sysv/linux/i386/syscall_error.h
> deleted file mode 100644
> index 0b63c07a4e..0000000000
> --- a/sysdeps/unix/sysv/linux/i386/syscall_error.h
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -/* Linux wrappers for setting errno. i386 version.
> - Copyright (C) 2020 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/>. */
> -
> -#ifndef _SYSCALL_ERROR_H
> -#define _SYSCALL_ERROR_H
> -
> -#define SYSCALL_ERROR_FUNC 1
> -#define SYSCALL_ERROR_FUNC_ATTR __attribute__ ((__regparm__ (1)))
> -
> -#endif
This is wrong since some assembly routines call __syscall_error assuming
the __regparm__ (1) attribute. This file can't be removed without changing
the assembly implementations.
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2020-11-16 13:45 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 16:58 [PATCH v2 00/24] Simplify internal Linux syscall Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 01/23] linux: Remove INTERNAL_SYSCALL_ERRNO Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 02/23] linux: Remove INTERNAL_SYSCALL_ERROR_P Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 03/23] linux: Add syscall_ret and use it on INLINE_SYSCALL Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 04/23] linux: Replace INLINE_SYSCALL_ERROR_RETURN_VALUE with __syscall_error Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 05/23] linux: Use generic __syscall_error for aarch64 Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 06/23] linux: Use generic __syscall_error for i386 Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 07/23] linux: Use generic __syscall_error for arc Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 08/23] linux: Use generic __syscall_error for powerpc Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 09/23] linux: Use generic __syscall_error for sparc Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 10/23] linux: Use generic __syscall_error for hppa Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 11/23] linux: Use generic __syscall_error for arm Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 12/23] linux: Use generic __syscall_error for x86_64 Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 13/23] linux: Use generic __syscall_error for s390 Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 14/23] linux: Use generic __syscall_error for sh Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 15/23] linux: Use generic __syscall_error for microblaze Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 16/23] linux: Use generic __syscall_error for ia64 Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 17/23] linux: Use generic __syscall_error for m68k Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 18/23] linux: Use generic __syscall_error for csky Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 19/23] linux: Use generic __syscall_error for riscv Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 20/23] linux: Use generic __syscall_error for nios2 Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 21/23] linux: Use generic __syscall_error for alpha Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 22/23] linux: Use generic __syscall_error for mips Adhemerval Zanella
2020-11-13 16:58 ` [PATCH v2 23/23] linux: Make SYSCALL_ERROR_FUNC as default Adhemerval Zanella
2020-11-16 13:45 ` Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).