unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 01/15] powerpc: Consolidate Linux syscall definition
@ 2020-02-10 19:20 Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 02/15] powerpc: Use Linux kABI for syscall return Adhemerval Zanella
                   ` (14 more replies)
  0 siblings, 15 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

The diferences between powerpc64{le} and powerpc32 Linux sysdep.h
are:

  1. On both vDSO and syscall macros the volatile registers r9, r10,
     r11, and r12 are used as input operands on powerpc32 and as
     clobber registers on powerpc64.  However the outcome is essentially
     the same, it advertise the register might be clobbered by the
     kernel (although Linux won't leak register information to userland
     in such case).

  2. The LOADARGS* macros uses a different size to check for invalid
     types.

  3. The pointer mangling support guard pointer loading uses ABI
     specific instruction and register.

This patch consolidates on only one sysdep by using the the powerpc64
version as default and add the adjustments required for powerpc32.

Checked on powerpc64-linux-gnu, powerpc64le-linux-gnu, and
powerpc-linux-gnu-power4.
---
 .../sysv/linux/powerpc/powerpc32/sysdep.h     | 214 ------------------
 .../sysv/linux/powerpc/powerpc64/sysdep.h     | 196 +---------------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 212 ++++++++++++++++-
 3 files changed, 213 insertions(+), 409 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h

diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
deleted file mode 100644
index 725dfafde8..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* Copyright (C) 1992-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 _LINUX_POWERPC_SYSDEP_H
-#define _LINUX_POWERPC_SYSDEP_H 1
-
-#include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
-#include <sysdeps/unix/sysv/linux/sysdep.h>
-#include <sysdeps/unix/powerpc/sysdep.h>
-#include <tls.h>
-
-/* For Linux we can use the system call table in the header file
-	/usr/include/asm/unistd.h
-   of the kernel.  But these symbols do not follow the SYS_* syntax
-   so we have to redefine the `SYS_ify' macro here.  */
-#undef SYS_ify
-#define SYS_ify(syscall_name)	__NR_##syscall_name
-
-#ifndef __ASSEMBLER__
-
-# include <errno.h>
-
-/* Define a macro which expands inline into the wrapper code for a VDSO
-   call. This use is for internal calls that do not need to handle errors
-   normally. It will never touch errno.
-   On powerpc a system call basically clobbers the same registers like a
-   function call, with the exception of LR (which is needed for the
-   "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
-   an error return status).  */
-# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...)	      \
-  ({									      \
-    register void *r0  __asm__ ("r0");					      \
-    register long int r3  __asm__ ("r3");				      \
-    register long int r4  __asm__ ("r4");				      \
-    register long int r5  __asm__ ("r5");				      \
-    register long int r6  __asm__ ("r6");				      \
-    register long int r7  __asm__ ("r7");				      \
-    register long int r8  __asm__ ("r8");				      \
-    register long int r9  __asm__ ("r9");				      \
-    register long int r10 __asm__ ("r10");				      \
-    register long int r11 __asm__ ("r11");				      \
-    register long int r12 __asm__ ("r12");				      \
-    register type rval  __asm__ ("r3");					      \
-    LOADARGS_##nr (funcptr, args);					      \
-    __asm__ __volatile__						      \
-      ("mtctr %0\n\t"							      \
-       "bctrl\n\t"							      \
-       "mfcr %0"							      \
-       : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),  "+r" (r7),  \
-	 "+r" (r8), "+r" (r9), "+r" (r10), "+r" (r11), "+r" (r12)	      \
-       : : "cr0", "ctr", "lr", "memory");				      \
-    err = (long int) r0;						      \
-    __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3), "r" (r4));	      \
-    rval;								      \
-  })
-
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
-  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
-
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...)				\
-  ({									\
-    INTERNAL_SYSCALL_DECL (sc_err);					\
-    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
-    if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			\
-      {									\
-	__set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));		\
-	sc_ret = -1L;							\
-      }									\
-    sc_ret;								\
-  })
-
-/* Define a macro which expands inline into the wrapper code for a system
-   call. This use is for internal calls that do not need to handle errors
-   normally. It will never touch errno.
-   On powerpc a system call basically clobbers the same registers like a
-   function call, with the exception of LR (which is needed for the
-   "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
-   an error return status).  */
-
-# undef INTERNAL_SYSCALL_DECL
-# define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
-
-# undef INTERNAL_SYSCALL
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...)			\
-  ({									\
-    register long int r0  __asm__ ("r0");				\
-    register long int r3  __asm__ ("r3");				\
-    register long int r4  __asm__ ("r4");				\
-    register long int r5  __asm__ ("r5");				\
-    register long int r6  __asm__ ("r6");				\
-    register long int r7  __asm__ ("r7");				\
-    register long int r8  __asm__ ("r8");				\
-    register long int r9  __asm__ ("r9");				\
-    register long int r10 __asm__ ("r10");				\
-    register long int r11 __asm__ ("r11");				\
-    register long int r12 __asm__ ("r12");				\
-    LOADARGS_##nr(name, args);						\
-    __asm__ __volatile__						\
-      ("sc   \n\t"							\
-       "mfcr %0"							\
-       : "=&r" (r0),							\
-	 "=&r" (r3), "=&r" (r4), "=&r" (r5),  "=&r" (r6),  "=&r" (r7),	\
-	 "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12)	\
-       : ASM_INPUT_##nr							\
-       : "cr0", "ctr", "memory");					\
-    err = r0;								\
-    (int) r3;								\
-  })
-# define INTERNAL_SYSCALL(name, err, nr, args...) \
-  INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
-
-# undef INTERNAL_SYSCALL_ERROR_P
-# define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
-
-# undef INTERNAL_SYSCALL_ERRNO
-# define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
-
-# define LOADARGS_0(name, dummy)					      \
-	r0 = name
-# define LOADARGS_1(name, __arg1) \
-	long int arg1 = (long int) (__arg1);	\
-  LOADARGS_0(name, 0);					   \
-	extern void __illegally_sized_syscall_arg1 (void); \
-	if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
-	  __illegally_sized_syscall_arg1 (); \
-	r3 = arg1
-# define LOADARGS_2(name, __arg1, __arg2) \
-	long int arg2 = (long int) (__arg2); \
-	LOADARGS_1(name, __arg1); \
-	extern void __illegally_sized_syscall_arg2 (void); \
-	if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
-	  __illegally_sized_syscall_arg2 (); \
-	r4 = arg2
-# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
-	long int arg3 = (long int) (__arg3); \
-	LOADARGS_2(name, __arg1, __arg2); \
-	extern void __illegally_sized_syscall_arg3 (void); \
-	if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
-	  __illegally_sized_syscall_arg3 (); \
-	r5 = arg3
-# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
-	long int arg4 = (long int) (__arg4); \
-	LOADARGS_3(name, __arg1, __arg2, __arg3); \
-	extern void __illegally_sized_syscall_arg4 (void); \
-	if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
-	  __illegally_sized_syscall_arg4 (); \
-	r6 = arg4
-# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
-	long int arg5 = (long int) (__arg5); \
-	LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
-	extern void __illegally_sized_syscall_arg5 (void); \
-	if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
-	  __illegally_sized_syscall_arg5 (); \
-	r7 = arg5
-# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
-	long int arg6 = (long int) (__arg6); \
-	LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
-	extern void __illegally_sized_syscall_arg6 (void); \
-	if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
-	  __illegally_sized_syscall_arg6 (); \
-	r8 = arg6
-
-# define ASM_INPUT_0 "0" (r0)
-# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
-# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
-# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
-# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
-# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
-# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
-
-#endif /* __ASSEMBLER__ */
-
-
-/* Pointer mangling support.  */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
-   earlier than the descriptor is initialized.  */
-#else
-# ifdef __ASSEMBLER__
-#  define PTR_MANGLE(reg, tmpreg) \
-	lwz	tmpreg,POINTER_GUARD(r2); \
-	xor	reg,tmpreg,reg
-#  define PTR_MANGLE2(reg, tmpreg) \
-	xor	reg,tmpreg,reg
-#  define PTR_MANGLE3(destreg, reg, tmpreg) \
-	lwz	tmpreg,POINTER_GUARD(r2); \
-	xor	destreg,tmpreg,reg
-#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-#  define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
-#  define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
-# else
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
-# endif
-#endif
-
-#endif /* linux/powerpc/powerpc32/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index ee7f43653d..0d6b98518b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -17,202 +17,10 @@
 
 /* Alan Modra <amodra@bigpond.net.au> rewrote the INLINE_SYSCALL macro */
 
-#ifndef _LINUX_POWERPC_SYSDEP_H
-#define _LINUX_POWERPC_SYSDEP_H 1
+#ifndef _LINUX_POWERPC64_SYSDEP_H
+#define _LINUX_POWERPC64_SYSDEP_H 1
 
 #include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
-#include <sysdeps/unix/sysv/linux/sysdep.h>
-#include <sysdeps/unix/powerpc/sysdep.h>
-#include <tls.h>
-
-/* Define __set_errno() for INLINE_SYSCALL macro below.  */
-#ifndef __ASSEMBLER__
-#include <errno.h>
-#endif
-
-/* For Linux we can use the system call table in the header file
-	/usr/include/asm/unistd.h
-   of the kernel.  But these symbols do not follow the SYS_* syntax
-   so we have to redefine the `SYS_ify' macro here.  */
-#undef SYS_ify
-#define SYS_ify(syscall_name)	__NR_##syscall_name
-
-#ifdef __ASSEMBLER__
-
-/* This seems to always be the case on PPC.  */
-# define ALIGNARG(log2) log2
-# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
-
-#endif /* __ASSEMBLER__ */
-
-/* Define a macro which expands inline into the wrapper code for a system
-   call. This use is for internal calls that do not need to handle errors
-   normally. It will never touch errno. This returns just what the kernel
-   gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
-   the negation of the return value in the kernel gets reverted.  */
-
-#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...)    \
-  ({									\
-    register void *r0  __asm__ ("r0");					\
-    register long int r3  __asm__ ("r3");				\
-    register long int r4  __asm__ ("r4");				\
-    register long int r5  __asm__ ("r5");				\
-    register long int r6  __asm__ ("r6");				\
-    register long int r7  __asm__ ("r7");				\
-    register long int r8  __asm__ ("r8");				\
-    register type rval  __asm__ ("r3");				        \
-    LOADARGS_##nr (funcptr, args);					\
-    __asm__ __volatile__						\
-      ("mtctr %0\n\t"							\
-       "bctrl\n\t"							\
-       "mfcr  %0\n\t"							\
-       "0:"								\
-       : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
-         "+r" (r7), "+r" (r8)						\
-       : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
-    err = (long int) r0;						\
-    __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
-    rval;								\
-  })
-
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
-
-/* This version is for kernels that implement system calls that
-   behave like function calls as far as register saving.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-  ({									\
-    INTERNAL_SYSCALL_DECL (sc_err);					\
-    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
-    if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			\
-      {									\
-        __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));		\
-        sc_ret = -1L;							\
-      }									\
-    sc_ret;								\
-  })
-
-/* Define a macro which expands inline into the wrapper code for a system
-   call. This use is for internal calls that do not need to handle errors
-   normally. It will never touch errno. This returns just what the kernel
-   gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
-   the negation of the return value in the kernel gets reverted.  */
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  ({									\
-    register long int r0  __asm__ ("r0");				\
-    register long int r3  __asm__ ("r3");				\
-    register long int r4  __asm__ ("r4");				\
-    register long int r5  __asm__ ("r5");				\
-    register long int r6  __asm__ ("r6");				\
-    register long int r7  __asm__ ("r7");				\
-    register long int r8  __asm__ ("r8");				\
-    LOADARGS_##nr (name, ##args);					\
-    __asm__ __volatile__						\
-      ("sc\n\t"								\
-       "mfcr  %0\n\t"							\
-       "0:"								\
-       : "=&r" (r0),							\
-         "=&r" (r3), "=&r" (r4), "=&r" (r5),				\
-         "=&r" (r6), "=&r" (r7), "=&r" (r8)				\
-       : ASM_INPUT_##nr							\
-       : "r9", "r10", "r11", "r12",					\
-         "cr0", "ctr", "memory");					\
-	  err = r0;  \
-    r3;  \
-  })
-#define INTERNAL_SYSCALL(name, err, nr, args...)			\
-  INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
-
-#define LOADARGS_0(name, dummy) \
-	r0 = name
-#define LOADARGS_1(name, __arg1) \
-	long int arg1 = (long int) (__arg1); \
-	LOADARGS_0(name, 0); \
-	extern void __illegally_sized_syscall_arg1 (void); \
-	if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 8) \
-	  __illegally_sized_syscall_arg1 (); \
-	r3 = arg1
-#define LOADARGS_2(name, __arg1, __arg2) \
-	long int arg2 = (long int) (__arg2); \
-	LOADARGS_1(name, __arg1); \
-	extern void __illegally_sized_syscall_arg2 (void); \
-	if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 8) \
-	  __illegally_sized_syscall_arg2 (); \
-	r4 = arg2
-#define LOADARGS_3(name, __arg1, __arg2, __arg3) \
-	long int arg3 = (long int) (__arg3); \
-	LOADARGS_2(name, __arg1, __arg2); \
-	extern void __illegally_sized_syscall_arg3 (void); \
-	if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 8) \
-	  __illegally_sized_syscall_arg3 (); \
-	r5 = arg3
-#define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
-	long int arg4 = (long int) (__arg4); \
-	LOADARGS_3(name, __arg1, __arg2, __arg3); \
-	extern void __illegally_sized_syscall_arg4 (void); \
-	if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 8) \
-	  __illegally_sized_syscall_arg4 (); \
-	r6 = arg4
-#define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
-	long int arg5 = (long int) (__arg5); \
-	LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
-	extern void __illegally_sized_syscall_arg5 (void); \
-	if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 8) \
-	  __illegally_sized_syscall_arg5 (); \
-	r7 = arg5
-#define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
-	long int arg6 = (long int) (__arg6); \
-	LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
-	extern void __illegally_sized_syscall_arg6 (void); \
-	if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 8) \
-	  __illegally_sized_syscall_arg6 (); \
-	r8 = arg6
-
-#define ASM_INPUT_0 "0" (r0)
-#define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
-#define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
-#define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
-#define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
-#define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
-#define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
-
-
-/* Pointer mangling support.  */
-#if IS_IN (rtld)
-/* We cannot use the thread descriptor because in ld.so we use setjmp
-   earlier than the descriptor is initialized.  */
-#else
-# ifdef __ASSEMBLER__
-#  define PTR_MANGLE(reg, tmpreg) \
-	ld	tmpreg,POINTER_GUARD(r13); \
-	xor	reg,tmpreg,reg
-#  define PTR_MANGLE2(reg, tmpreg) \
-	xor	reg,tmpreg,reg
-#  define PTR_MANGLE3(destreg, reg, tmpreg) \
-	ld	tmpreg,POINTER_GUARD(r13); \
-	xor	destreg,tmpreg,reg
-#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-#  define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
-#  define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
-# else
-#  define PTR_MANGLE(var) \
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
-# endif
-#endif
 
 /* In the PowerPC64 ABI, the unadorned F_GETLK* opcodes should be used
    even by largefile64 code.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 1f477a945d..01c26be24b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -16,10 +16,218 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _LINUX_POWERPC_SYSDEP_H
+#define _LINUX_POWERPC_SYSDEP_H 1
+
+#include <sysdeps/unix/sysv/linux/sysdep.h>
+#include <sysdeps/unix/powerpc/sysdep.h>
+#include <tls.h>
+
+/* Define __set_errno() for INLINE_SYSCALL macro below.  */
+#ifndef __ASSEMBLER__
+#include <errno.h>
+#endif
+
+/* For Linux we can use the system call table in the header file
+       /usr/include/asm/unistd.h
+   of the kernel.  But these symbols do not follow the SYS_* syntax
+   so we have to redefine the `SYS_ify' macro here.  */
+#undef SYS_ify
+#define SYS_ify(syscall_name)  __NR_##syscall_name
+
+/* Define a macro which expands inline into the wrapper code for a system
+   call. This use is for internal calls that do not need to handle errors
+   normally. It will never touch errno. This returns just what the kernel
+   gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
+   the negation of the return value in the kernel gets reverted.  */
+
+#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...)    \
+  ({									\
+    register void *r0  __asm__ ("r0");					\
+    register long int r3  __asm__ ("r3");				\
+    register long int r4  __asm__ ("r4");				\
+    register long int r5  __asm__ ("r5");				\
+    register long int r6  __asm__ ("r6");				\
+    register long int r7  __asm__ ("r7");				\
+    register long int r8  __asm__ ("r8");				\
+    register type rval  __asm__ ("r3");				        \
+    LOADARGS_##nr (funcptr, args);					\
+    __asm__ __volatile__						\
+      ("mtctr %0\n\t"							\
+       "bctrl\n\t"							\
+       "mfcr  %0\n\t"							\
+       "0:"								\
+       : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
+         "+r" (r7), "+r" (r8)						\
+       : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
+    err = (long int) r0;						\
+    __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
+    rval;								\
+  })
+
+#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
+  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
+
+/* This version is for kernels that implement system calls that
+   behave like function calls as far as register saving.  */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...)				\
+  ({									\
+    INTERNAL_SYSCALL_DECL (sc_err);					\
+    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
+    if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			\
+      {									\
+        __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));		\
+        sc_ret = -1L;							\
+      }									\
+    sc_ret;								\
+  })
+
+/* Define a macro which expands inline into the wrapper code for a system
+   call. This use is for internal calls that do not need to handle errors
+   normally. It will never touch errno. This returns just what the kernel
+   gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
+   the negation of the return value in the kernel gets reverted.  */
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+  ({									\
+    register long int r0  __asm__ ("r0");				\
+    register long int r3  __asm__ ("r3");				\
+    register long int r4  __asm__ ("r4");				\
+    register long int r5  __asm__ ("r5");				\
+    register long int r6  __asm__ ("r6");				\
+    register long int r7  __asm__ ("r7");				\
+    register long int r8  __asm__ ("r8");				\
+    LOADARGS_##nr (name, ##args);					\
+    __asm__ __volatile__						\
+      ("sc\n\t"								\
+       "mfcr  %0\n\t"							\
+       "0:"								\
+       : "=&r" (r0),							\
+         "=&r" (r3), "=&r" (r4), "=&r" (r5),				\
+         "=&r" (r6), "=&r" (r7), "=&r" (r8)				\
+       : ASM_INPUT_##nr							\
+       : "r9", "r10", "r11", "r12",					\
+         "cr0", "ctr", "memory");					\
+	  err = r0;  \
+    r3;  \
+  })
+#define INTERNAL_SYSCALL(name, err, nr, args...)			\
+  INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
+
+#if defined(__PPC64__) || defined(__powerpc64__)
+# define SYSCALL_ARG_SIZE 8
+#else
+# define SYSCALL_ARG_SIZE 4
+#endif
+
+#define LOADARGS_0(name, dummy) \
+	r0 = name
+#define LOADARGS_1(name, __arg1) \
+	long int arg1 = (long int) (__arg1); \
+	LOADARGS_0(name, 0); \
+	extern void __illegally_sized_syscall_arg1 (void); \
+	if (__builtin_classify_type (__arg1) != 5 \
+	    && sizeof (__arg1) > SYSCALL_ARG_SIZE) \
+	  __illegally_sized_syscall_arg1 (); \
+	r3 = arg1
+#define LOADARGS_2(name, __arg1, __arg2) \
+	long int arg2 = (long int) (__arg2); \
+	LOADARGS_1(name, __arg1); \
+	extern void __illegally_sized_syscall_arg2 (void); \
+	if (__builtin_classify_type (__arg2) != 5 \
+	    && sizeof (__arg2) > SYSCALL_ARG_SIZE) \
+	  __illegally_sized_syscall_arg2 (); \
+	r4 = arg2
+#define LOADARGS_3(name, __arg1, __arg2, __arg3) \
+	long int arg3 = (long int) (__arg3); \
+	LOADARGS_2(name, __arg1, __arg2); \
+	extern void __illegally_sized_syscall_arg3 (void); \
+	if (__builtin_classify_type (__arg3) != 5 \
+	    && sizeof (__arg3) > SYSCALL_ARG_SIZE) \
+	  __illegally_sized_syscall_arg3 (); \
+	r5 = arg3
+#define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
+	long int arg4 = (long int) (__arg4); \
+	LOADARGS_3(name, __arg1, __arg2, __arg3); \
+	extern void __illegally_sized_syscall_arg4 (void); \
+	if (__builtin_classify_type (__arg4) != 5 \
+	    && sizeof (__arg4) > SYSCALL_ARG_SIZE) \
+	  __illegally_sized_syscall_arg4 (); \
+	r6 = arg4
+#define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
+	long int arg5 = (long int) (__arg5); \
+	LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
+	extern void __illegally_sized_syscall_arg5 (void); \
+	if (__builtin_classify_type (__arg5) != 5 \
+	    && sizeof (__arg5) > SYSCALL_ARG_SIZE) \
+	  __illegally_sized_syscall_arg5 (); \
+	r7 = arg5
+#define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
+	long int arg6 = (long int) (__arg6); \
+	LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
+	extern void __illegally_sized_syscall_arg6 (void); \
+	if (__builtin_classify_type (__arg6) != 5 \
+	    && sizeof (__arg6) > SYSCALL_ARG_SIZE) \
+	  __illegally_sized_syscall_arg6 (); \
+	r8 = arg6
+
+#define ASM_INPUT_0 "0" (r0)
+#define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
+#define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
+#define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
+#define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
+#define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
+#define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
+
+
+/* Pointer mangling support.  */
+#if defined(__PPC64__) || defined(__powerpc64__)
+# define LOAD  ld
+# define TPREG r13
+#else
+# define LOAD  lwz
+# define TPREG r2
+#endif
+
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+   earlier than the descriptor is initialized.  */
+#else
+# ifdef __ASSEMBLER__
+#  define PTR_MANGLE(reg, tmpreg) \
+	LOAD	tmpreg,POINTER_GUARD(TPREG); \
+	xor	reg,tmpreg,reg
+#  define PTR_MANGLE2(reg, tmpreg) \
+	xor	reg,tmpreg,reg
+#  define PTR_MANGLE3(destreg, reg, tmpreg) \
+	LOAD	tmpreg,POINTER_GUARD(TPREG); \
+	xor	destreg,tmpreg,reg
+#  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
+#  define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
+#  define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
+# else
+#  define PTR_MANGLE(var) \
+  (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+#  define PTR_DEMANGLE(var)	PTR_MANGLE (var)
+# endif
+#endif
+
+/* List of system calls which are supported as vsyscalls.  */
 #define VDSO_NAME  "LINUX_2.6.15"
 #define VDSO_HASH  123718565
 
-/* List of system calls which are supported as vsyscalls.  */
 #if defined(__PPC64__) || defined(__powerpc64__)
 #define HAVE_CLOCK_GETRES64_VSYSCALL	"__kernel_clock_getres"
 #define HAVE_CLOCK_GETTIME64_VSYSCALL	"__kernel_clock_gettime"
@@ -38,3 +246,5 @@
 # define HAVE_SIGTRAMP_32		"__kernel_sigtramp32"
 # define HAVE_SIGTRAMP_RT32		"__kernel_sigtramp_rt32"
 #endif
+
+#endif /* _LINUX_POWERPC_SYSDEP_H  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 11:18   ` Florian Weimer
  2020-02-11 19:45   ` Florian Weimer
  2020-02-10 19:20 ` [PATCH 03/15] sparc: " Adhemerval Zanella
                   ` (13 subsequent siblings)
  14 siblings, 2 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

It changes the powerpc INTERNAL_VSYSCALL_CALL and INTERNAL_SYSCALL_NCS
to return a negative value instead of returning the CR value on 'err'
macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.

Checked on powerpc64-linux-gnu, powerpc64le-linux-gnu, and
powerpc-linux-gnu-power4.
---
 sysdeps/unix/sysv/linux/powerpc/sysdep.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 01c26be24b..abdcfd4a63 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -60,9 +60,8 @@
        : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
          "+r" (r7), "+r" (r8)						\
        : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
-    err = (long int) r0;						\
     __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
-    rval;								\
+    (long int) r0 & (1 << 28) ? -rval : rval;				\
   })
 
 #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
@@ -110,21 +109,20 @@
        : ASM_INPUT_##nr							\
        : "r9", "r10", "r11", "r12",					\
          "cr0", "ctr", "memory");					\
-	  err = r0;  \
-    r3;  \
+    r0 & (1 << 28) ? -r3 : r3;						\
   })
 #define INTERNAL_SYSCALL(name, err, nr, args...)			\
   INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 #undef INTERNAL_SYSCALL_ERROR_P
 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
+  ((unsigned long) (val) >= (unsigned long) -4095)
 
 #undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
+#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
 
 #if defined(__PPC64__) || defined(__powerpc64__)
 # define SYSCALL_ARG_SIZE 8
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 02/15] powerpc: Use Linux kABI for syscall return Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 11:15   ` Florian Weimer
  2020-02-10 19:20 ` [PATCH 04/15] alpha: Refactor syscall and " Adhemerval Zanella
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

It changes the sparc internal_syscall* macros to a negative value
instead the 'g1' register value on 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.  The
redefinition of INTERNAL_VSYSCALL_CALL is also no longer
required.

Checked on sparc64-linux-gnu and sparcv9-linux-gnu. It fixes
the sporadic issues on sparc32 where clock_nanosleep does not
act as cancellation entrypoint.
---
 sysdeps/unix/sysv/linux/sparc/sysdep.h | 90 ++++++++++++--------------
 1 file changed, 41 insertions(+), 49 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 0c32780d9c..67efa6f029 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -34,13 +34,6 @@
 
 #else	/* __ASSEMBLER__ */
 
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    _ret;								\
-  })
-
 # define VDSO_NAME  "LINUX_2.6"
 # define VDSO_HASH  61765110
 
@@ -65,112 +58,111 @@
 })
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) \
-	register long err __asm__("g1");
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 #undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
-  inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
+  internal_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
 
 #undef INTERNAL_SYSCALL_NCS
 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  inline_syscall##nr(__SYSCALL_STRING, err, name, args)
+  internal_syscall##nr(__SYSCALL_STRING, err, name, args)
 
 #undef INTERNAL_SYSCALL_ERROR_P
 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((void) (val), __builtin_expect((err) != 0, 0))
+  ((unsigned long) (val) >= (unsigned long) -4095)
 
 #undef INTERNAL_SYSCALL_ERRNO
 #define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
-#define inline_syscall0(string,err,name,dummy...)			\
+#define internal_syscall0(string,err,name,dummy...)			\
 ({									\
+	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0");				\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err) :					\
+	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
+			  "0" (__err) :					\
 			  __SYSCALL_CLOBBERS);				\
-	__o0;								\
+	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define inline_syscall1(string,err,name,arg1)				\
+#define internal_syscall1(string,err,name,arg1)				\
 ({									\
+	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0) :			\
+	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
+			  "0" (__err), "1" (__o0) :			\
 			  __SYSCALL_CLOBBERS);				\
-	__o0;								\
+	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define inline_syscall2(string,err,name,arg1,arg2)			\
+#define internal_syscall2(string,err,name,arg1,arg2)			\
 ({									\
+	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1) :		\
+	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
+			  "0" (__err), "1" (__o0), "r" (__o1) :		\
 			  __SYSCALL_CLOBBERS);				\
-	__o0;								\
+	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define inline_syscall3(string,err,name,arg1,arg2,arg3)			\
+#define internal_syscall3(string,err,name,arg1,arg2,arg3)		\
 ({									\
+	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
+			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2) :					\
 			  __SYSCALL_CLOBBERS);				\
-	__o0;								\
+	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4)		\
+#define internal_syscall4(string,err,name,arg1,arg2,arg3,arg4)		\
 ({									\
+	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
+			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3) :			\
 			  __SYSCALL_CLOBBERS);				\
-	__o0;								\
+	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5)	\
+#define internal_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5)	\
 ({									\
+	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
+			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
 			  __SYSCALL_CLOBBERS);				\
-	__o0;								\
+	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)	\
+#define internal_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)\
 ({									\
+	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
 	register long __o5 __asm__ ("o5") = (long)(arg6);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
+			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4),		\
 			  "r" (__o5) :					\
 			  __SYSCALL_CLOBBERS);				\
-	__o0;								\
+	__err == -1 ? -__o0 : __o0;					\
 })
 
 #define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5)			\
@@ -186,9 +178,9 @@
 			  "0" (__g1), "1" (__o0), "2" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
 			  __SYSCALL_CLOBBERS);				\
-	if (INTERNAL_SYSCALL_ERROR_P (__o0, __g1))			\
+	if (__glibc_unlikely (__g1 != 0)) 				\
 	  {		     			       		   	\
-	    __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1));		\
+	    __set_errno (__o0);						\
 	    __o0 = -1L;			    				\
 	  } 	      							\
 	else								\
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 04/15] alpha: Refactor syscall and Use Linux kABI for syscall return
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 02/15] powerpc: Use Linux kABI for syscall return Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 03/15] sparc: " Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 05/15] ia64: " Adhemerval Zanella
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

It highly unlikely that alpha will be ported to anything else than
Linux, so this patch moves the generic unix syscall definition to
Linux and adapt it to Linux kernel ABI.

It changes the internal_syscall* macros to return a negative value
instead of '$19' register value on 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.

Checked on alpha-linux-gnu.
---
 sysdeps/unix/alpha/sysdep.h            | 382 -------------------------
 sysdeps/unix/sysv/linux/alpha/ioperm.c |   7 +-
 sysdeps/unix/sysv/linux/alpha/sysdep.h | 354 ++++++++++++++++++++++-
 3 files changed, 348 insertions(+), 395 deletions(-)
 delete mode 100644 sysdeps/unix/alpha/sysdep.h

diff --git a/sysdeps/unix/alpha/sysdep.h b/sysdeps/unix/alpha/sysdep.h
deleted file mode 100644
index 74db6b02b2..0000000000
--- a/sysdeps/unix/alpha/sysdep.h
+++ /dev/null
@@ -1,382 +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 <sysdeps/unix/sysdep.h>
-#include <dl-sysdep.h>         /* Defines RTLD_PRIVATE_ERRNO.  */
-
-#ifdef __ASSEMBLER__
-
-#ifdef __linux__
-# include <alpha/regdef.h>
-#else
-# include <regdef.h>
-#endif
-
-#define __LABEL(x)	x##:
-
-#define LEAF(name, framesize)			\
-  .globl name;					\
-  .align 4;					\
-  .ent name, 0;					\
-  __LABEL(name)					\
-  .frame sp, framesize, ra
-
-#define ENTRY(name)				\
-  .globl name;					\
-  .align 4;					\
-  .ent name, 0;					\
-  __LABEL(name)					\
-  .frame sp, 0, ra
-
-/* Mark the end of function SYM.  */
-#undef END
-#define END(sym)	.end sym
-
-#ifdef PROF
-# define PSEUDO_PROF				\
-	.set noat;				\
-	lda	AT, _mcount;			\
-	jsr	AT, (AT), _mcount;		\
-	.set at
-#else
-# define PSEUDO_PROF
-#endif
-
-#ifdef PROF
-# define PSEUDO_PROLOGUE			\
-	.frame sp, 0, ra;			\
-	ldgp	gp,0(pv);			\
-	PSEUDO_PROF;				\
-	.prologue 1
-#elif defined PIC
-# define PSEUDO_PROLOGUE			\
-	.frame sp, 0, ra;			\
-	.prologue 0
-#else
-# define PSEUDO_PROLOGUE			\
-	.frame sp, 0, ra;			\
-	ldgp	gp,0(pv);			\
-	.prologue 1
-#endif /* PROF */
-
-#ifdef PROF
-# define USEPV_PROF	std
-#else
-# define USEPV_PROF	no
-#endif
-
-#if RTLD_PRIVATE_ERRNO
-# define SYSCALL_ERROR_LABEL	$syscall_error
-# define SYSCALL_ERROR_HANDLER			\
-$syscall_error:					\
-	stl	v0, rtld_errno(gp)	!gprel;	\
-	lda	v0, -1;				\
-	ret
-# define SYSCALL_ERROR_FALLTHRU
-#elif defined(PIC)
-# define SYSCALL_ERROR_LABEL		__syscall_error !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
-# define SYSCALL_ERROR_FALLTHRU
-#endif /* RTLD_PRIVATE_ERRNO */
-
-/* Overridden by specific syscalls.  */
-#undef PSEUDO_PREPARE_ARGS
-#define PSEUDO_PREPARE_ARGS	/* Nothing.  */
-
-#define PSEUDO(name, syscall_name, args)	\
-	.globl name;				\
-	.align 4;				\
-	.ent name,0;				\
-__LABEL(name)					\
-	PSEUDO_PROLOGUE;			\
-	PSEUDO_PREPARE_ARGS			\
-	lda	v0, SYS_ify(syscall_name);	\
-	call_pal PAL_callsys;			\
-	bne	a3, SYSCALL_ERROR_LABEL
-
-#undef PSEUDO_END
-#define PSEUDO_END(sym)				\
-	SYSCALL_ERROR_HANDLER;			\
-	END(sym)
-
-#define PSEUDO_NOERRNO(name, syscall_name, args)	\
-	.globl name;					\
-	.align 4;					\
-	.ent name,0;					\
-__LABEL(name)						\
-	PSEUDO_PROLOGUE;				\
-	PSEUDO_PREPARE_ARGS				\
-	lda	v0, SYS_ify(syscall_name);		\
-	call_pal PAL_callsys;
-
-#undef PSEUDO_END_NOERRNO
-#define PSEUDO_END_NOERRNO(sym)  END(sym)
-
-#define ret_NOERRNO ret
-
-#define PSEUDO_ERRVAL(name, syscall_name, args)	\
-	.globl name;					\
-	.align 4;					\
-	.ent name,0;					\
-__LABEL(name)						\
-	PSEUDO_PROLOGUE;				\
-	PSEUDO_PREPARE_ARGS				\
-	lda	v0, SYS_ify(syscall_name);		\
-	call_pal PAL_callsys;
-
-#undef PSEUDO_END_ERRVAL
-#define PSEUDO_END_ERRVAL(sym)  END(sym)
-
-#define ret_ERRVAL ret
-
-#define r0	v0
-#define r1	a4
-
-#define MOVE(x,y)	mov x,y
-
-#else /* !ASSEMBLER */
-
-/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
-#include <errno.h>
-
-/* ??? Linux needs to be able to override INLINE_SYSCALL for one
-   particular special case.  Make this easy.  */
-
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
-	INLINE_SYSCALL1(name, nr, args)
-
-#define INLINE_SYSCALL1(name, nr, args...)	\
-({						\
-	long _sc_ret, _sc_err;			\
-	inline_syscall##nr(__NR_##name, args);	\
-	if (__builtin_expect (_sc_err, 0))	\
-	  {					\
-	    __set_errno (_sc_ret);		\
-	    _sc_ret = -1L;			\
-	  }					\
-	_sc_ret;				\
-})
-
-#define INTERNAL_SYSCALL(name, err_out, nr, args...) \
-	INTERNAL_SYSCALL1(name, err_out, nr, args)
-
-#define INTERNAL_SYSCALL1(name, err_out, nr, args...)	\
-	INTERNAL_SYSCALL_NCS(__NR_##name, err_out, nr, args)
-
-#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
-({							\
-	long _sc_ret, _sc_err;				\
-	inline_syscall##nr(name, args);			\
-	err_out = _sc_err;				\
-	_sc_ret;					\
-})
-
-#define INTERNAL_SYSCALL_DECL(err) \
-	long int err __attribute__((unused))
-
-/* The normal Alpha calling convention sign-extends 32-bit quantties
-   no matter what the "real" sign of the 32-bit type.  We want to
-   preserve that when filling in values for the kernel.  */
-#define syscall_promote(arg) \
-  (sizeof (arg) == 4 ? (long)(int)(long)(arg) : (long)(arg))
-
-/* Make sure and "use" the variable that we're not returning,
-   in order to suppress unused variable warnings.  */
-#define INTERNAL_SYSCALL_ERROR_P(val, err)	((void)val, err)
-#define INTERNAL_SYSCALL_ERRNO(val, err)	((void)err, val)
-
-#define inline_syscall_clobbers				\
-	"$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",	\
-	"$22", "$23", "$24", "$25", "$27", "$28", "memory"
-
-/* It is moderately important optimization-wise to limit the lifetime
-   of the hard-register variables as much as possible.  Thus we copy
-   in/out as close to the asm as possible.  */
-
-#define inline_syscall0(name, args...)				\
-{								\
-	register long _sc_19 __asm__("$19");			\
-	register long _sc_0 = name;				\
-	__asm__ __volatile__					\
-	  ("callsys # %0 %1 <= %2"				\
-	   : "+v"(_sc_0), "=r"(_sc_19)				\
-	   : : inline_syscall_clobbers,				\
-	     "$16", "$17", "$18", "$20", "$21");		\
-	_sc_ret = _sc_0, _sc_err = _sc_19;			\
-}
-
-#define inline_syscall1(name,arg1)				\
-{								\
-	register long _tmp_16 = syscall_promote (arg1);		\
-	register long _sc_0 = name;				\
-	register long _sc_16 __asm__("$16") = _tmp_16;		\
-	register long _sc_19 __asm__("$19");			\
-	__asm__ __volatile__					\
-	  ("callsys # %0 %1 <= %2 %3"				\
-	   : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16)		\
-	   : : inline_syscall_clobbers,				\
-	     "$17", "$18", "$20", "$21");			\
-	_sc_ret = _sc_0, _sc_err = _sc_19;			\
-}
-
-#define inline_syscall2(name,arg1,arg2)				\
-{								\
-	register long _tmp_16 = syscall_promote (arg1);		\
-	register long _tmp_17 = syscall_promote (arg2);		\
-	register long _sc_0 = name;				\
-	register long _sc_16 __asm__("$16") = _tmp_16;		\
-	register long _sc_17 __asm__("$17") = _tmp_17;		\
-	register long _sc_19 __asm__("$19");			\
-	__asm__ __volatile__					\
-	  ("callsys # %0 %1 <= %2 %3 %4"			\
-	   : "+v"(_sc_0), "=r"(_sc_19),				\
-	     "+r"(_sc_16), "+r"(_sc_17)				\
-	   : : inline_syscall_clobbers,				\
-	     "$18", "$20", "$21");				\
-	_sc_ret = _sc_0, _sc_err = _sc_19;			\
-}
-
-#define inline_syscall3(name,arg1,arg2,arg3)			\
-{								\
-	register long _tmp_16 = syscall_promote (arg1);		\
-	register long _tmp_17 = syscall_promote (arg2);		\
-	register long _tmp_18 = syscall_promote (arg3);		\
-	register long _sc_0 = name;				\
-	register long _sc_16 __asm__("$16") = _tmp_16;		\
-	register long _sc_17 __asm__("$17") = _tmp_17;		\
-	register long _sc_18 __asm__("$18") = _tmp_18;		\
-	register long _sc_19 __asm__("$19");			\
-	__asm__ __volatile__					\
-	  ("callsys # %0 %1 <= %2 %3 %4 %5"			\
-	   : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16),		\
-	     "+r"(_sc_17), "+r"(_sc_18)				\
-	   : : inline_syscall_clobbers, "$20", "$21");		\
-	_sc_ret = _sc_0, _sc_err = _sc_19;			\
-}
-
-#define inline_syscall4(name,arg1,arg2,arg3,arg4)		\
-{								\
-	register long _tmp_16 = syscall_promote (arg1);		\
-	register long _tmp_17 = syscall_promote (arg2);		\
-	register long _tmp_18 = syscall_promote (arg3);		\
-	register long _tmp_19 = syscall_promote (arg4);		\
-	register long _sc_0 = name;				\
-	register long _sc_16 __asm__("$16") = _tmp_16;		\
-	register long _sc_17 __asm__("$17") = _tmp_17;		\
-	register long _sc_18 __asm__("$18") = _tmp_18;		\
-	register long _sc_19 __asm__("$19") = _tmp_19;		\
-	__asm__ __volatile__					\
-	  ("callsys # %0 %1 <= %2 %3 %4 %5 %6"			\
-	   : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16),		\
-	     "+r"(_sc_17), "+r"(_sc_18)				\
-	   : : inline_syscall_clobbers, "$20", "$21");		\
-	_sc_ret = _sc_0, _sc_err = _sc_19;			\
-}
-
-#define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5)		\
-{								\
-	register long _tmp_16 = syscall_promote (arg1);		\
-	register long _tmp_17 = syscall_promote (arg2);		\
-	register long _tmp_18 = syscall_promote (arg3);		\
-	register long _tmp_19 = syscall_promote (arg4);		\
-	register long _tmp_20 = syscall_promote (arg5);		\
-	register long _sc_0 = name;				\
-	register long _sc_16 __asm__("$16") = _tmp_16;		\
-	register long _sc_17 __asm__("$17") = _tmp_17;		\
-	register long _sc_18 __asm__("$18") = _tmp_18;		\
-	register long _sc_19 __asm__("$19") = _tmp_19;		\
-	register long _sc_20 __asm__("$20") = _tmp_20;		\
-	__asm__ __volatile__					\
-	  ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7"		\
-	   : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16),		\
-	     "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20)		\
-	   : : inline_syscall_clobbers, "$21");			\
-	_sc_ret = _sc_0, _sc_err = _sc_19;			\
-}
-
-#define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6)	\
-{								\
-	register long _tmp_16 = syscall_promote (arg1);		\
-	register long _tmp_17 = syscall_promote (arg2);		\
-	register long _tmp_18 = syscall_promote (arg3);		\
-	register long _tmp_19 = syscall_promote (arg4);		\
-	register long _tmp_20 = syscall_promote (arg5);		\
-	register long _tmp_21 = syscall_promote (arg6);		\
-	register long _sc_0 = name;				\
-	register long _sc_16 __asm__("$16") = _tmp_16;		\
-	register long _sc_17 __asm__("$17") = _tmp_17;		\
-	register long _sc_18 __asm__("$18") = _tmp_18;		\
-	register long _sc_19 __asm__("$19") = _tmp_19;		\
-	register long _sc_20 __asm__("$20") = _tmp_20;		\
-	register long _sc_21 __asm__("$21") = _tmp_21;		\
-	__asm__ __volatile__					\
-	  ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8"		\
-	   : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16),		\
-	     "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20),		\
-	     "+r"(_sc_21)					\
-	   : : inline_syscall_clobbers);			\
-	_sc_ret = _sc_0, _sc_err = _sc_19;			\
-}
-#endif /* ASSEMBLER */
-
-/* Pointer mangling support.  Note that tls access is slow enough that
-   we don't deoptimize things by placing the pointer check value there.  */
-
-#ifdef __ASSEMBLER__
-# if IS_IN (rtld)
-#  define PTR_MANGLE(dst, src, tmp)				\
-	ldah	tmp, __pointer_chk_guard_local($29) !gprelhigh;	\
-	ldq	tmp, __pointer_chk_guard_local(tmp) !gprellow;	\
-	xor	src, tmp, dst
-#  define PTR_MANGLE2(dst, src, tmp)				\
-	xor	src, tmp, dst
-# elif defined SHARED
-#  define PTR_MANGLE(dst, src, tmp)		\
-	ldq	tmp, __pointer_chk_guard;	\
-	xor	src, tmp, dst
-# else
-#  define PTR_MANGLE(dst, src, tmp)		\
-	ldq	tmp, __pointer_chk_guard_local;	\
-	xor	src, tmp, dst
-# endif
-# define PTR_MANGLE2(dst, src, tmp)		\
-	xor	src, tmp, dst
-# define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
-# define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
-#else
-# include <stdint.h>
-# if (IS_IN (rtld) \
-      || (!defined SHARED && (IS_IN (libc) \
-			      || IS_IN (libpthread))))
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
-#  define PTR_MANGLE(var) \
-	(var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
-# else
-extern uintptr_t __pointer_chk_guard attribute_relro;
-#  define PTR_MANGLE(var) \
-	(var) = (__typeof(var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
-# endif
-# define PTR_DEMANGLE(var)  PTR_MANGLE(var)
-#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/sysv/linux/alpha/ioperm.c b/sysdeps/unix/sysv/linux/alpha/ioperm.c
index 086c782b9f..cf775674b4 100644
--- a/sysdeps/unix/sysv/linux/alpha/ioperm.c
+++ b/sysdeps/unix/sysv/linux/alpha/ioperm.c
@@ -196,12 +196,7 @@ stl_mb(unsigned int val, unsigned long addr)
 static inline void
 __sethae(unsigned long value)
 {
-  register unsigned long r16 __asm__("$16") = value;
-  register unsigned long r0 __asm__("$0") = __NR_sethae;
-  __asm__ __volatile__ ("callsys"
-			: "=r"(r0)
-			: "0"(r0), "r" (r16)
-			: inline_syscall_clobbers, "$19");
+  INLINE_SYSCALL_CALL (sethae, value);
 }
 
 extern long __pciconfig_iobase(enum __pciconfig_iobase_which __which,
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h
index f8c9e589ec..ca0b4e475c 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h
@@ -19,14 +19,10 @@
 #ifndef _LINUX_ALPHA_SYSDEP_H
 #define _LINUX_ALPHA_SYSDEP_H 1
 
-#ifdef __ASSEMBLER__
-#include <asm/pal.h>
-#include <alpha/regdef.h>
-#endif
-
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
-#include <sysdeps/unix/alpha/sysdep.h>
+#include <sysdeps/unix/sysdep.h>
+#include <dl-sysdep.h>         /* Defines RTLD_PRIVATE_ERRNO.  */
 
 #include <tls.h>
 
@@ -39,4 +35,348 @@
 
 #define SINGLE_THREAD_BY_GLOBAL 1
 
-#endif /* _LINUX_ALPHA_SYSDEP_H */
+#ifdef __ASSEMBLER__
+#include <asm/pal.h>
+#include <alpha/regdef.h>
+
+#define __LABEL(x)	x##:
+
+#define LEAF(name, framesize)			\
+  .globl name;					\
+  .align 4;					\
+  .ent name, 0;					\
+  __LABEL(name)					\
+  .frame sp, framesize, ra
+
+#define ENTRY(name)				\
+  .globl name;					\
+  .align 4;					\
+  .ent name, 0;					\
+  __LABEL(name)					\
+  .frame sp, 0, ra
+
+/* Mark the end of function SYM.  */
+#undef END
+#define END(sym)	.end sym
+
+#ifdef PROF
+# define PSEUDO_PROF				\
+	.set noat;				\
+	lda	AT, _mcount;			\
+	jsr	AT, (AT), _mcount;		\
+	.set at
+#else
+# define PSEUDO_PROF
+#endif
+
+#ifdef PROF
+# define PSEUDO_PROLOGUE			\
+	.frame sp, 0, ra;			\
+	ldgp	gp,0(pv);			\
+	PSEUDO_PROF;				\
+	.prologue 1
+#elif defined PIC
+# define PSEUDO_PROLOGUE			\
+	.frame sp, 0, ra;			\
+	.prologue 0
+#else
+# define PSEUDO_PROLOGUE			\
+	.frame sp, 0, ra;			\
+	ldgp	gp,0(pv);			\
+	.prologue 1
+#endif /* PROF */
+
+#ifdef PROF
+# define USEPV_PROF	std
+#else
+# define USEPV_PROF	no
+#endif
+
+#if RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_LABEL	$syscall_error
+# define SYSCALL_ERROR_HANDLER			\
+$syscall_error:					\
+	stl	v0, rtld_errno(gp)	!gprel;	\
+	lda	v0, -1;				\
+	ret
+# define SYSCALL_ERROR_FALLTHRU
+#elif defined(PIC)
+# define SYSCALL_ERROR_LABEL		__syscall_error !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
+# define SYSCALL_ERROR_FALLTHRU
+#endif /* RTLD_PRIVATE_ERRNO */
+
+/* Overridden by specific syscalls.  */
+#undef PSEUDO_PREPARE_ARGS
+#define PSEUDO_PREPARE_ARGS	/* Nothing.  */
+
+#define PSEUDO(name, syscall_name, args)	\
+	.globl name;				\
+	.align 4;				\
+	.ent name,0;				\
+__LABEL(name)					\
+	PSEUDO_PROLOGUE;			\
+	PSEUDO_PREPARE_ARGS			\
+	lda	v0, SYS_ify(syscall_name);	\
+	call_pal PAL_callsys;			\
+	bne	a3, SYSCALL_ERROR_LABEL
+
+#undef PSEUDO_END
+#define PSEUDO_END(sym)				\
+	SYSCALL_ERROR_HANDLER;			\
+	END(sym)
+
+#define PSEUDO_NOERRNO(name, syscall_name, args)	\
+	.globl name;					\
+	.align 4;					\
+	.ent name,0;					\
+__LABEL(name)						\
+	PSEUDO_PROLOGUE;				\
+	PSEUDO_PREPARE_ARGS				\
+	lda	v0, SYS_ify(syscall_name);		\
+	call_pal PAL_callsys;
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(sym)  END(sym)
+
+#define ret_NOERRNO ret
+
+#define PSEUDO_ERRVAL(name, syscall_name, args)	\
+	.globl name;					\
+	.align 4;					\
+	.ent name,0;					\
+__LABEL(name)						\
+	PSEUDO_PROLOGUE;				\
+	PSEUDO_PREPARE_ARGS				\
+	lda	v0, SYS_ify(syscall_name);		\
+	call_pal PAL_callsys;
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(sym)  END(sym)
+
+#define ret_ERRVAL ret
+
+#define r0	v0
+#define r1	a4
+
+#define MOVE(x,y)	mov x,y
+
+#else /* !ASSEMBLER */
+
+/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
+#include <errno.h>
+
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...)				\
+({									\
+	INTERNAL_SYSCALL_DECL (_sc_err);				\
+	long int _sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
+	if (INTERNAL_SYSCALL_ERROR_P (_sc_ret, _sc_err))		\
+	  {								\
+	    __set_errno (INTERNAL_SYSCALL_ERRNO (_sc_ret, _sc_err));	\
+	    _sc_ret = -1L;						\
+	  }								\
+	_sc_ret;							\
+})
+
+#define INTERNAL_SYSCALL(name, err_out, nr, args...) \
+	internal_syscall##nr(__NR_##name, args)
+
+#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
+	internal_syscall##nr(name, args)
+
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+/* The normal Alpha calling convention sign-extends 32-bit quantties
+   no matter what the "real" sign of the 32-bit type.  We want to
+   preserve that when filling in values for the kernel.  */
+#define syscall_promote(arg) \
+  (sizeof (arg) == 4 ? (long)(int)(long)(arg) : (long)(arg))
+
+/* Make sure and "use" the variable that we're not returning,
+   in order to suppress unused variable warnings.  */
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+	((unsigned long) (val) >= (unsigned long) -4095)
+#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
+
+#define internal_syscall_clobbers				\
+	"$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",	\
+	"$22", "$23", "$24", "$25", "$27", "$28", "memory"
+
+/* It is moderately important optimization-wise to limit the lifetime
+   of the hard-register variables as much as possible.  Thus we copy
+   in/out as close to the asm as possible.  */
+
+#define internal_syscall0(name, args...)			\
+({								\
+	register long _sc_19 __asm__("$19");			\
+	register long _sc_0 = name;				\
+	__asm__ __volatile__					\
+	  ("callsys # %0 %1 <= %2"				\
+	   : "+v"(_sc_0), "=r"(_sc_19)				\
+	   : : internal_syscall_clobbers,			\
+	     "$16", "$17", "$18", "$20", "$21");		\
+	_sc_19 != 0 ? -_sc_0 : _sc_0;				\
+})
+
+#define internal_syscall1(name,arg1)				\
+({								\
+	register long _tmp_16 = syscall_promote (arg1);		\
+	register long _sc_0 = name;				\
+	register long _sc_16 __asm__("$16") = _tmp_16;		\
+	register long _sc_19 __asm__("$19");			\
+	__asm__ __volatile__					\
+	  ("callsys # %0 %1 <= %2 %3"				\
+	   : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16)		\
+	   : : internal_syscall_clobbers,			\
+	     "$17", "$18", "$20", "$21");			\
+	_sc_19 != 0 ? -_sc_0 : _sc_0;				\
+})
+
+#define internal_syscall2(name,arg1,arg2)			\
+({								\
+	register long _tmp_16 = syscall_promote (arg1);		\
+	register long _tmp_17 = syscall_promote (arg2);		\
+	register long _sc_0 = name;				\
+	register long _sc_16 __asm__("$16") = _tmp_16;		\
+	register long _sc_17 __asm__("$17") = _tmp_17;		\
+	register long _sc_19 __asm__("$19");			\
+	__asm__ __volatile__					\
+	  ("callsys # %0 %1 <= %2 %3 %4"			\
+	   : "+v"(_sc_0), "=r"(_sc_19),				\
+	     "+r"(_sc_16), "+r"(_sc_17)				\
+	   : : internal_syscall_clobbers,			\
+	     "$18", "$20", "$21");				\
+	_sc_19 != 0 ? -_sc_0 : _sc_0;				\
+})
+
+#define internal_syscall3(name,arg1,arg2,arg3)			\
+({								\
+	register long _tmp_16 = syscall_promote (arg1);		\
+	register long _tmp_17 = syscall_promote (arg2);		\
+	register long _tmp_18 = syscall_promote (arg3);		\
+	register long _sc_0 = name;				\
+	register long _sc_16 __asm__("$16") = _tmp_16;		\
+	register long _sc_17 __asm__("$17") = _tmp_17;		\
+	register long _sc_18 __asm__("$18") = _tmp_18;		\
+	register long _sc_19 __asm__("$19");			\
+	__asm__ __volatile__					\
+	  ("callsys # %0 %1 <= %2 %3 %4 %5"			\
+	   : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16),		\
+	     "+r"(_sc_17), "+r"(_sc_18)				\
+	   : : internal_syscall_clobbers, "$20", "$21");	\
+	_sc_19 != 0 ? -_sc_0 : _sc_0;				\
+})
+
+#define internal_syscall4(name,arg1,arg2,arg3,arg4)		\
+({								\
+	register long _tmp_16 = syscall_promote (arg1);		\
+	register long _tmp_17 = syscall_promote (arg2);		\
+	register long _tmp_18 = syscall_promote (arg3);		\
+	register long _tmp_19 = syscall_promote (arg4);		\
+	register long _sc_0 = name;				\
+	register long _sc_16 __asm__("$16") = _tmp_16;		\
+	register long _sc_17 __asm__("$17") = _tmp_17;		\
+	register long _sc_18 __asm__("$18") = _tmp_18;		\
+	register long _sc_19 __asm__("$19") = _tmp_19;		\
+	__asm__ __volatile__					\
+	  ("callsys # %0 %1 <= %2 %3 %4 %5 %6"			\
+	   : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16),		\
+	     "+r"(_sc_17), "+r"(_sc_18)				\
+	   : : internal_syscall_clobbers, "$20", "$21");	\
+	_sc_19 != 0 ? -_sc_0 : _sc_0;				\
+})
+
+#define internal_syscall5(name,arg1,arg2,arg3,arg4,arg5)	\
+({								\
+	register long _tmp_16 = syscall_promote (arg1);		\
+	register long _tmp_17 = syscall_promote (arg2);		\
+	register long _tmp_18 = syscall_promote (arg3);		\
+	register long _tmp_19 = syscall_promote (arg4);		\
+	register long _tmp_20 = syscall_promote (arg5);		\
+	register long _sc_0 = name;				\
+	register long _sc_16 __asm__("$16") = _tmp_16;		\
+	register long _sc_17 __asm__("$17") = _tmp_17;		\
+	register long _sc_18 __asm__("$18") = _tmp_18;		\
+	register long _sc_19 __asm__("$19") = _tmp_19;		\
+	register long _sc_20 __asm__("$20") = _tmp_20;		\
+	__asm__ __volatile__					\
+	  ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7"		\
+	   : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16),		\
+	     "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20)		\
+	   : : internal_syscall_clobbers, "$21");		\
+	_sc_19 != 0 ? -_sc_0 : _sc_0;				\
+})
+
+#define internal_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6)	\
+({								\
+	register long _tmp_16 = syscall_promote (arg1);		\
+	register long _tmp_17 = syscall_promote (arg2);		\
+	register long _tmp_18 = syscall_promote (arg3);		\
+	register long _tmp_19 = syscall_promote (arg4);		\
+	register long _tmp_20 = syscall_promote (arg5);		\
+	register long _tmp_21 = syscall_promote (arg6);		\
+	register long _sc_0 = name;				\
+	register long _sc_16 __asm__("$16") = _tmp_16;		\
+	register long _sc_17 __asm__("$17") = _tmp_17;		\
+	register long _sc_18 __asm__("$18") = _tmp_18;		\
+	register long _sc_19 __asm__("$19") = _tmp_19;		\
+	register long _sc_20 __asm__("$20") = _tmp_20;		\
+	register long _sc_21 __asm__("$21") = _tmp_21;		\
+	__asm__ __volatile__					\
+	  ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8"		\
+	   : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16),		\
+	     "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20),		\
+	     "+r"(_sc_21)					\
+	   : : internal_syscall_clobbers);			\
+	_sc_19 != 0 ? -_sc_0 : _sc_0;				\
+})
+#endif /* ASSEMBLER */
+
+/* Pointer mangling support.  Note that tls access is slow enough that
+   we don't deoptimize things by placing the pointer check value there.  */
+
+#ifdef __ASSEMBLER__
+# if IS_IN (rtld)
+#  define PTR_MANGLE(dst, src, tmp)				\
+	ldah	tmp, __pointer_chk_guard_local($29) !gprelhigh;	\
+	ldq	tmp, __pointer_chk_guard_local(tmp) !gprellow;	\
+	xor	src, tmp, dst
+#  define PTR_MANGLE2(dst, src, tmp)				\
+	xor	src, tmp, dst
+# elif defined SHARED
+#  define PTR_MANGLE(dst, src, tmp)		\
+	ldq	tmp, __pointer_chk_guard;	\
+	xor	src, tmp, dst
+# else
+#  define PTR_MANGLE(dst, src, tmp)		\
+	ldq	tmp, __pointer_chk_guard_local;	\
+	xor	src, tmp, dst
+# endif
+# define PTR_MANGLE2(dst, src, tmp)		\
+	xor	src, tmp, dst
+# define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
+# define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
+#else
+# include <stdint.h>
+# if (IS_IN (rtld) \
+      || (!defined SHARED && (IS_IN (libc) \
+			      || IS_IN (libpthread))))
+extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
+#  define PTR_MANGLE(var) \
+	(var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
+# else
+extern uintptr_t __pointer_chk_guard attribute_relro;
+#  define PTR_MANGLE(var) \
+	(var) = (__typeof(var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
+# endif
+# define PTR_DEMANGLE(var)  PTR_MANGLE(var)
+#endif /* ASSEMBLER */
+
+#endif /* _LINUX_ALPHA_SYSDEP_H  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 05/15] ia64: Use Linux kABI for syscall return
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 04/15] alpha: Refactor syscall and " Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 06/15] mips64: Consolidate Linux sysdep.h Adhemerval Zanella
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

It changes the ia64 INTERNAL_SYSCALL_NCS macro to return a negative
value instead of 'r10' register value on 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.

Checked on ia64-linux-gnu.
---
 sysdeps/unix/sysv/linux/ia64/sysdep.h | 58 +++++++++++----------------
 1 file changed, 24 insertions(+), 34 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.h b/sysdeps/unix/sysv/linux/ia64/sysdep.h
index 59442c50e9..729bfadad0 100644
--- a/sysdeps/unix/sysv/linux/ia64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/ia64/sysdep.h
@@ -191,13 +191,13 @@
 
 #ifdef IA64_USE_NEW_STUB
 
-# define DO_INLINE_SYSCALL_NCS(name, nr, args...)			      \
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...)			      \
+({									      \
     LOAD_ARGS_##nr (args)						      \
     register long _r8 __asm ("r8");					      \
     register long _r10 __asm ("r10");					      \
     register long _r15 __asm ("r15") = name;				      \
     register void *_b7 __asm ("b7") = ((tcbhead_t *)__thread_self)->__private;\
-    long _retval;							      \
     LOAD_REGS_##nr							      \
     /*									      \
      * Don't specify any unwind info here.  We mark ar.pfs as		      \
@@ -209,60 +209,50 @@
 			ASM_OUTARGS_##nr				      \
 		      : "0" (_b7), "3" (_r15) ASM_ARGS_##nr		      \
 		      : "memory", "ar.pfs" ASM_CLOBBERS_##nr);		      \
-    _retval = _r8;
+    _r10 == -1 ? -_r8 : _r8;						      \
+})
 
 #else /* !IA64_USE_NEW_STUB */
 
-# define DO_INLINE_SYSCALL_NCS(name, nr, args...)		\
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...)		\
+({								\
     LOAD_ARGS_##nr (args)					\
     register long _r8 asm ("r8");				\
     register long _r10 asm ("r10");				\
     register long _r15 asm ("r15") = name;			\
-    long _retval;						\
     LOAD_REGS_##nr						\
     __asm __volatile (BREAK_INSN (__IA64_BREAK_SYSCALL)		\
 		      : "=r" (_r8), "=r" (_r10), "=r" (_r15)	\
 			ASM_OUTARGS_##nr			\
 		      : "2" (_r15) ASM_ARGS_##nr		\
 		      : "memory" ASM_CLOBBERS_##nr);		\
-    _retval = _r8;
+    _r10 == -1 ? -_r8 : _r8;					\
+})
 
 #endif /* !IA64_USE_NEW_STUB */
 
-#define DO_INLINE_SYSCALL(name, nr, args...)	\
-  DO_INLINE_SYSCALL_NCS (__NR_##name, nr, ##args)
-
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)		\
-  ({							\
-    DO_INLINE_SYSCALL_NCS (__NR_##name, nr, args)	\
-    if (_r10 == -1)					\
-      {							\
-	__set_errno (_retval);				\
-	_retval = -1;					\
-      }							\
-    _retval; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...)	\
-  ({							\
-    DO_INLINE_SYSCALL_NCS (name, nr, args)		\
-    err = _r10;						\
-    _retval; })
+# undef INLINE_SYSCALL
+# define INLINE_SYSCALL(name, nr, args...)				\
+  ({ unsigned long _sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
+     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
+       {								\
+	 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, ));		\
+	 _sys_result = (unsigned long) -1;				\
+       }								\
+     (long) _sys_result; })
+
+# undef INTERNAL_SYSCALL_DECL
+# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
 #define INTERNAL_SYSCALL(name, err, nr, args...)	\
   INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)		\
-  ({ (void) (val);					\
-     (err == -1);					\
-  })
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((unsigned long) (val) >= (unsigned long) -4095)
 
 #undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(val)
+#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
 #define LOAD_ARGS_0()
 #define LOAD_REGS_0
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 06/15] mips64: Consolidate Linux sysdep.h
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 05/15] ia64: " Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-10 22:48   ` Joseph Myers
  2020-02-10 19:20 ` [PATCH 07/15] mips: Use Linux kABI for syscall return Adhemerval Zanella
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

The mips64 Linux syscall macros only differs argument type and
the requirement of zero-extending values on n32.  The headers
are consolidate by parameterizing the arguments with a new type,
__syscall_arg_t, and by defining the ARGIFY for n64.

Also, the generic unix mips64 sysdep is essentially the same,
only the load instruction need to be adjusted depending of the
ABI.

Checked on mips64-linux-gnu and mips64n32-linux-gnu.
---
 sysdeps/unix/mips/mips64/n64/sysdep.h         |  64 ----
 sysdeps/unix/mips/mips64/{n32 => }/sysdep.h   |   3 +-
 .../unix/sysv/linux/mips/mips64/n64/sysdep.h  | 307 ------------------
 .../sysv/linux/mips/mips64/{n32 => }/sysdep.h |  88 ++---
 4 files changed, 49 insertions(+), 413 deletions(-)
 delete mode 100644 sysdeps/unix/mips/mips64/n64/sysdep.h
 rename sysdeps/unix/mips/mips64/{n32 => }/sysdep.h (97%)
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
 rename sysdeps/unix/sysv/linux/mips/mips64/{n32 => }/sysdep.h (76%)

diff --git a/sysdeps/unix/mips/mips64/n64/sysdep.h b/sysdeps/unix/mips/mips64/n64/sysdep.h
deleted file mode 100644
index 3d8b254017..0000000000
--- a/sysdeps/unix/mips/mips64/n64/sysdep.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Alexandre Oliva <aoliva@redhat.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 <sysdeps/unix/mips/sysdep.h>
-
-#ifdef __ASSEMBLER__
-
-/* Note that while it's better structurally, going back to call __syscall_error
-   can make things confusing if you're debugging---it looks like it's jumping
-   backwards into the previous fn.  */
-#ifdef __PIC__
-#define PSEUDO(name, syscall_name, args) \
-  .align 2;								      \
-  .set nomips16;							      \
-  cfi_startproc;							      \
-  99:;									      \
-  .set noat;								      \
-  .cpsetup t9, $1, name;						      \
-  cfi_register (gp, $1);						      \
-  .set at;								      \
-  dla t9,__syscall_error;						      \
-  .cpreturn;								      \
-  cfi_restore (gp);							      \
-  jr t9;								      \
-  cfi_endproc;								      \
-  ENTRY(name)								      \
-  li v0, SYS_ify(syscall_name);						      \
-  syscall;								      \
-  bne a3, zero, 99b;							      \
-L(syse1):
-#else
-#define PSEUDO(name, syscall_name, args) \
-  .set noreorder;							      \
-  .align 2;								      \
-  .set nomips16;							      \
-  cfi_startproc;							      \
-  99: j __syscall_error;						      \
-  nop;                                                                        \
-  cfi_endproc;								      \
-  ENTRY(name)								      \
-  .set noreorder;							      \
-  li v0, SYS_ify(syscall_name);						      \
-  syscall;								      \
-  .set reorder;								      \
-  bne a3, zero, 99b;							      \
-L(syse1):
-#endif
-
-#endif
diff --git a/sysdeps/unix/mips/mips64/n32/sysdep.h b/sysdeps/unix/mips/mips64/sysdep.h
similarity index 97%
rename from sysdeps/unix/mips/mips64/n32/sysdep.h
rename to sysdeps/unix/mips/mips64/sysdep.h
index 65ce7c5406..fb5f27daf3 100644
--- a/sysdeps/unix/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/mips/mips64/sysdep.h
@@ -19,6 +19,7 @@
 #include <sysdeps/unix/mips/sysdep.h>
 
 #ifdef __ASSEMBLER__
+#include <sys/asm.h>
 
 /* Note that while it's better structurally, going back to call __syscall_error
    can make things confusing if you're debugging---it looks like it's jumping
@@ -33,7 +34,7 @@
   .cpsetup t9, $1, name;						      \
   cfi_register (gp, $1);						      \
   .set at;								      \
-  la t9,__syscall_error;						      \
+  PTR_LA t9,__syscall_error;						      \
   .cpreturn;								      \
   cfi_restore (gp);							      \
   jr t9;								      \
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
deleted file mode 100644
index 9d30291f84..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/* Copyright (C) 2000-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 _LINUX_MIPS_SYSDEP_H
-#define _LINUX_MIPS_SYSDEP_H 1
-
-/* There is some commonality.  */
-#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
-#include <sysdeps/unix/sysv/linux/sysdep.h>
-#include <sysdeps/unix/mips/mips64/n64/sysdep.h>
-
-#include <tls.h>
-
-/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
-#ifndef __ASSEMBLER__
-#include <errno.h>
-#endif
-
-/* For Linux we can use the system call table in the header file
-	/usr/include/asm/unistd.h
-   of the kernel.  But these symbols do not follow the SYS_* syntax
-   so we have to redefine the `SYS_ify' macro here.  */
-#undef SYS_ify
-#define SYS_ify(syscall_name)	__NR_##syscall_name
-
-#ifdef __ASSEMBLER__
-
-/* We don't want the label for the error handler to be visible in the symbol
-   table when we define it here.  */
-# define SYSCALL_ERROR_LABEL 99b
-
-#else   /* ! __ASSEMBLER__ */
-
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-  ({ INTERNAL_SYSCALL_DECL (_sc_err);					\
-     long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args);	\
-     if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) )		\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err));	\
-	 result_var = -1L;						\
-       }								\
-     result_var; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)   ((void) (val), (long) (err))
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     ((void) (err), val)
-
-/* Note that the original Linux syscall restart convention required the
-   instruction immediately preceding SYSCALL to initialize $v0 with the
-   syscall number.  Then if a restart triggered, $v0 would have been
-   clobbered by the syscall interrupted, and needed to be reinititalized.
-   The kernel would decrement the PC by 4 before switching back to the
-   user mode so that $v0 had been reloaded before SYSCALL was executed
-   again.  This implied the place $v0 was loaded from must have been
-   preserved across a syscall, e.g. an immediate, static register, stack
-   slot, etc.
-
-   The convention was relaxed in Linux with a change applied to the kernel
-   GIT repository as commit 96187fb0bc30cd7919759d371d810e928048249d, that
-   first appeared in the 2.6.36 release.  Since then the kernel has had
-   code that reloads $v0 upon syscall restart and resumes right at the
-   SYSCALL instruction, so no special arrangement is needed anymore.
-
-   For backwards compatibility with existing kernel binaries we support
-   the old convention by choosing the instruction preceding SYSCALL
-   carefully.  This also means we have to force a 32-bit encoding of the
-   microMIPS MOVE instruction if one is used.  */
-
-#ifdef __mips_micromips
-# define MOVE32 "move32"
-#else
-# define MOVE32 "move"
-#endif
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)			\
-	internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t",	\
-			      "IK" (SYS_ify (name)),			\
-			      0, err, args)
-
-#undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
-	internal_syscall##nr (MOVE32 "\t%0, %2\n\t",			\
-			      "r" (__s0),				\
-			      number, err, args)
-
-#define internal_syscall0(v0_init, input, number, err, dummy...)	\
-({									\
-	long _sys_result;						\
-									\
-	{								\
-	register long __s0 asm ("$16") __attribute__ ((unused))		\
-	  = (number);							\
-	register long __v0 asm ("$2");					\
-	register long __a3 asm ("$7");					\
-	__asm__ volatile (						\
-	".set\tnoreorder\n\t"						\
-	v0_init								\
-	"syscall\n\t"							\
-	".set reorder"							\
-	: "=r" (__v0), "=r" (__a3)					\
-	: input								\
-	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
-	}								\
-	_sys_result;							\
-})
-
-#define internal_syscall1(v0_init, input, number, err, arg1)		\
-({									\
-	long _sys_result;						\
-									\
-	{								\
-	register long __s0 asm ("$16") __attribute__ ((unused))		\
-	  = (number);							\
-	register long __v0 asm ("$2");					\
-	register long __a0 asm ("$4") = (long) (arg1);			\
-	register long __a3 asm ("$7");					\
-	__asm__ volatile (						\
-	".set\tnoreorder\n\t"						\
-	v0_init								\
-	"syscall\n\t"							\
-	".set reorder"							\
-	: "=r" (__v0), "=r" (__a3)					\
-	: input, "r" (__a0)						\
-	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
-	}								\
-	_sys_result;							\
-})
-
-#define internal_syscall2(v0_init, input, number, err, arg1, arg2)	\
-({									\
-	long _sys_result;						\
-									\
-	{								\
-	register long __s0 asm ("$16") __attribute__ ((unused))		\
-	  = (number);							\
-	register long __v0 asm ("$2");					\
-	register long __a0 asm ("$4") = (long) (arg1);			\
-	register long __a1 asm ("$5") = (long) (arg2);			\
-	register long __a3 asm ("$7");					\
-	__asm__ volatile (						\
-	".set\tnoreorder\n\t"						\
-	v0_init								\
-	"syscall\n\t"							\
-	".set\treorder"							\
-	: "=r" (__v0), "=r" (__a3)					\
-	: input, "r" (__a0), "r" (__a1)					\
-	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
-	}								\
-	_sys_result;							\
-})
-
-#define internal_syscall3(v0_init, input, number, err,			\
-			  arg1, arg2, arg3)				\
-({									\
-	long _sys_result;						\
-									\
-	{								\
-	register long __s0 asm ("$16") __attribute__ ((unused))		\
-	  = (number);							\
-	register long __v0 asm ("$2");					\
-	register long __a0 asm ("$4") = (long) (arg1);			\
-	register long __a1 asm ("$5") = (long) (arg2);			\
-	register long __a2 asm ("$6") = (long) (arg3);			\
-	register long __a3 asm ("$7");					\
-	__asm__ volatile (						\
-	".set\tnoreorder\n\t"						\
-	v0_init								\
-	"syscall\n\t"							\
-	".set\treorder"							\
-	: "=r" (__v0), "=r" (__a3)					\
-	: input, "r" (__a0), "r" (__a1), "r" (__a2)			\
-	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
-	}								\
-	_sys_result;							\
-})
-
-#define internal_syscall4(v0_init, input, number, err,			\
-			  arg1, arg2, arg3, arg4)			\
-({									\
-	long _sys_result;						\
-									\
-	{								\
-	register long __s0 asm ("$16") __attribute__ ((unused))		\
-	  = (number);							\
-	register long __v0 asm ("$2");					\
-	register long __a0 asm ("$4") = (long) (arg1);			\
-	register long __a1 asm ("$5") = (long) (arg2);			\
-	register long __a2 asm ("$6") = (long) (arg3);			\
-	register long __a3 asm ("$7") = (long) (arg4);			\
-	__asm__ volatile (						\
-	".set\tnoreorder\n\t"						\
-	v0_init								\
-	"syscall\n\t"							\
-	".set\treorder"							\
-	: "=r" (__v0), "+r" (__a3)					\
-	: input, "r" (__a0), "r" (__a1), "r" (__a2)			\
-	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
-	}								\
-	_sys_result;							\
-})
-
-#define internal_syscall5(v0_init, input, number, err,			\
-			  arg1, arg2, arg3, arg4, arg5)			\
-({									\
-	long _sys_result;						\
-									\
-	{								\
-	register long __s0 asm ("$16") __attribute__ ((unused))		\
-	  = (number);							\
-	register long __v0 asm ("$2");					\
-	register long __a0 asm ("$4") = (long) (arg1);			\
-	register long __a1 asm ("$5") = (long) (arg2);			\
-	register long __a2 asm ("$6") = (long) (arg3);			\
-	register long __a3 asm ("$7") = (long) (arg4);			\
-	register long __a4 asm ("$8") = (long) (arg5);			\
-	__asm__ volatile (						\
-	".set\tnoreorder\n\t"						\
-	v0_init								\
-	"syscall\n\t"							\
-	".set\treorder"							\
-	: "=r" (__v0), "+r" (__a3)					\
-	: input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4)		\
-	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
-	}								\
-	_sys_result;							\
-})
-
-#define internal_syscall6(v0_init, input, number, err,			\
-			  arg1, arg2, arg3, arg4, arg5, arg6)		\
-({									\
-	long _sys_result;						\
-									\
-	{								\
-	register long __s0 asm ("$16") __attribute__ ((unused))		\
-	  = (number);							\
-	register long __v0 asm ("$2");					\
-	register long __a0 asm ("$4") = (long) (arg1);			\
-	register long __a1 asm ("$5") = (long) (arg2);			\
-	register long __a2 asm ("$6") = (long) (arg3);			\
-	register long __a3 asm ("$7") = (long) (arg4);			\
-	register long __a4 asm ("$8") = (long) (arg5);			\
-	register long __a5 asm ("$9") = (long) (arg6);			\
-	__asm__ volatile (						\
-	".set\tnoreorder\n\t"						\
-	v0_init								\
-	"syscall\n\t"							\
-	".set\treorder"							\
-	: "=r" (__v0), "+r" (__a3)					\
-	: input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4),	\
-	  "r" (__a5)							\
-	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
-	}								\
-	_sys_result;							\
-})
-
-#if __mips_isa_rev >= 6
-# define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
-	 "$14", "$15", "$24", "$25", "memory"
-#else
-# define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
-	 "$14", "$15", "$24", "$25", "hi", "lo", "memory"
-#endif
-
-#endif /* __ASSEMBLER__ */
-
-/* Pointer mangling is not yet supported for MIPS.  */
-#define PTR_MANGLE(var) (void) (var)
-#define PTR_DEMANGLE(var) (void) (var)
-
-#endif /* linux/mips/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
similarity index 76%
rename from sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
rename to sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
index f96636538a..617e229a67 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
@@ -21,7 +21,7 @@
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/mips/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
-#include <sysdeps/unix/mips/mips64/n32/sysdep.h>
+#include <sysdeps/unix/mips/mips64/sysdep.h>
 
 #include <tls.h>
 
@@ -45,9 +45,15 @@
 
 #else   /* ! __ASSEMBLER__ */
 
+#if _MIPS_SIM == _ABIN32
 /* Convert X to a long long, without losing any bits if it is one
    already or warning if it is a 32-bit pointer.  */
-#define ARGIFY(X) ((long long) (__typeof__ ((X) - (X))) (X))
+# define ARGIFY(X) ((long long int) (__typeof__ ((X) - (X))) (X))
+typedef long long int __syscall_arg_t;
+#else
+# define ARGIFY(X) ((long int) (X))
+typedef long int __syscall_arg_t;
+#endif
 
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
@@ -115,10 +121,10 @@
 	long _sys_result;						\
 									\
 	{								\
-	register long long __s0 asm ("$16") __attribute__ ((unused))	\
+	register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
 	  = (number);							\
-	register long long __v0 asm ("$2");				\
-	register long long __a3 asm ("$7");				\
+	register __syscall_arg_t __v0 asm ("$2");			\
+	register __syscall_arg_t __a3 asm ("$7");			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	v0_init								\
@@ -138,11 +144,11 @@
 	long _sys_result;						\
 									\
 	{								\
-	register long long __s0 asm ("$16") __attribute__ ((unused))	\
+	register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
 	  = (number);							\
-	register long long __v0 asm ("$2");				\
-	register long long __a0 asm ("$4") = ARGIFY (arg1);		\
-	register long long __a3 asm ("$7");				\
+	register __syscall_arg_t __v0 asm ("$2");			\
+	register __syscall_arg_t __a0 asm ("$4") = ARGIFY (arg1);	\
+	register __syscall_arg_t __a3 asm ("$7");			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	v0_init								\
@@ -162,12 +168,12 @@
 	long _sys_result;						\
 									\
 	{								\
-	register long long __s0 asm ("$16") __attribute__ ((unused))	\
+	register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
 	  = (number);							\
-	register long long __v0 asm ("$2");				\
-	register long long __a0 asm ("$4") = ARGIFY (arg1);		\
-	register long long __a1 asm ("$5") = ARGIFY (arg2);		\
-	register long long __a3 asm ("$7");				\
+	register __syscall_arg_t __v0 asm ("$2");			\
+	register __syscall_arg_t __a0 asm ("$4") = ARGIFY (arg1);	\
+	register __syscall_arg_t __a1 asm ("$5") = ARGIFY (arg2);	\
+	register __syscall_arg_t __a3 asm ("$7");			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	v0_init								\
@@ -188,13 +194,13 @@
 	long _sys_result;						\
 									\
 	{								\
-	register long long __s0 asm ("$16") __attribute__ ((unused))	\
+	register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
 	  = (number);							\
-	register long long __v0 asm ("$2");				\
-	register long long __a0 asm ("$4") = ARGIFY (arg1);		\
-	register long long __a1 asm ("$5") = ARGIFY (arg2);		\
-	register long long __a2 asm ("$6") = ARGIFY (arg3);		\
-	register long long __a3 asm ("$7");				\
+	register __syscall_arg_t __v0 asm ("$2");			\
+	register __syscall_arg_t __a0 asm ("$4") = ARGIFY (arg1);	\
+	register __syscall_arg_t __a1 asm ("$5") = ARGIFY (arg2);	\
+	register __syscall_arg_t __a2 asm ("$6") = ARGIFY (arg3);	\
+	register __syscall_arg_t __a3 asm ("$7");			\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	v0_init								\
@@ -215,13 +221,13 @@
 	long _sys_result;						\
 									\
 	{								\
-	register long long __s0 asm ("$16") __attribute__ ((unused))	\
+	register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
 	  = (number);							\
-	register long long __v0 asm ("$2");				\
-	register long long __a0 asm ("$4") = ARGIFY (arg1);		\
-	register long long __a1 asm ("$5") = ARGIFY (arg2);		\
-	register long long __a2 asm ("$6") = ARGIFY (arg3);		\
-	register long long __a3 asm ("$7") = ARGIFY (arg4);		\
+	register __syscall_arg_t __v0 asm ("$2");			\
+	register __syscall_arg_t __a0 asm ("$4") = ARGIFY (arg1);	\
+	register __syscall_arg_t __a1 asm ("$5") = ARGIFY (arg2);	\
+	register __syscall_arg_t __a2 asm ("$6") = ARGIFY (arg3);	\
+	register __syscall_arg_t __a3 asm ("$7") = ARGIFY (arg4);	\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	v0_init								\
@@ -242,14 +248,14 @@
 	long _sys_result;						\
 									\
 	{								\
-	register long long __s0 asm ("$16") __attribute__ ((unused))	\
+	register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
 	  = (number);							\
-	register long long __v0 asm ("$2");				\
-	register long long __a0 asm ("$4") = ARGIFY (arg1);		\
-	register long long __a1 asm ("$5") = ARGIFY (arg2);		\
-	register long long __a2 asm ("$6") = ARGIFY (arg3);		\
-	register long long __a3 asm ("$7") = ARGIFY (arg4);		\
-	register long long __a4 asm ("$8") = ARGIFY (arg5);		\
+	register __syscall_arg_t __v0 asm ("$2");			\
+	register __syscall_arg_t __a0 asm ("$4") = ARGIFY (arg1);	\
+	register __syscall_arg_t __a1 asm ("$5") = ARGIFY (arg2);	\
+	register __syscall_arg_t __a2 asm ("$6") = ARGIFY (arg3);	\
+	register __syscall_arg_t __a3 asm ("$7") = ARGIFY (arg4);	\
+	register __syscall_arg_t __a4 asm ("$8") = ARGIFY (arg5);	\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	v0_init								\
@@ -270,15 +276,15 @@
 	long _sys_result;						\
 									\
 	{								\
-	register long long __s0 asm ("$16") __attribute__ ((unused))	\
+	register __syscall_arg_t __s0 asm ("$16") __attribute__ ((unused))\
 	  = (number);							\
-	register long long __v0 asm ("$2");				\
-	register long long __a0 asm ("$4") = ARGIFY (arg1);		\
-	register long long __a1 asm ("$5") = ARGIFY (arg2);		\
-	register long long __a2 asm ("$6") = ARGIFY (arg3);		\
-	register long long __a3 asm ("$7") = ARGIFY (arg4);		\
-	register long long __a4 asm ("$8") = ARGIFY (arg5);		\
-	register long long __a5 asm ("$9") = ARGIFY (arg6);		\
+	register __syscall_arg_t __v0 asm ("$2");			\
+	register __syscall_arg_t __a0 asm ("$4") = ARGIFY (arg1);	\
+	register __syscall_arg_t __a1 asm ("$5") = ARGIFY (arg2);	\
+	register __syscall_arg_t __a2 asm ("$6") = ARGIFY (arg3);	\
+	register __syscall_arg_t __a3 asm ("$7") = ARGIFY (arg4);	\
+	register __syscall_arg_t __a4 asm ("$8") = ARGIFY (arg5);	\
+	register __syscall_arg_t __a5 asm ("$9") = ARGIFY (arg6);	\
 	__asm__ volatile (						\
 	".set\tnoreorder\n\t"						\
 	v0_init								\
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 07/15] mips: Use Linux kABI for syscall return
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 06/15] mips64: Consolidate Linux sysdep.h Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 08/15] nios2: " Adhemerval Zanella
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

It changes the mips INTERNAL_SYSCALL* and internal_syscall*  macros
to return a negative value instead of 'a3' register value on 'err'
macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.  The
redefinition of INTERNAL_VSYSCALL_CALL is also no longer
required.

Checked on mips64-linux-gnu, mips64n32-linux-gnu, and mips-linux-gnu.
---
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h | 32 ++++++++------------
 sysdeps/unix/sysv/linux/mips/mips64/sysdep.h | 28 +++++++----------
 sysdeps/unix/sysv/linux/mips/sysdep.h        | 16 ----------
 3 files changed, 23 insertions(+), 53 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index beefcf284b..6842ff5211 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -61,13 +61,14 @@
      result_var; })
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)   ((void) (val), (long) (err))
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((unsigned long) (val) >= (unsigned long) -4095)
 
 #undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     ((void) (err), val)
+#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
 
 /* Note that the original Linux syscall restart convention required the
    instruction immediately preceding SYSCALL to initialize $v0 with the
@@ -128,7 +129,6 @@ union __mips_syscall_return
 ({									\
 	union __mips_syscall_return _sc_ret;				\
 	_sc_ret.val = __mips16_syscall##nr (args, number);		\
-	err = _sc_ret.reg.v1;						\
 	_sc_ret.reg.v0;							\
 })
 
@@ -167,8 +167,7 @@ union __mips_syscall_return
 	: "=r" (__v0), "=r" (__a3)					\
 	: input								\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -191,8 +190,7 @@ union __mips_syscall_return
 	: "=r" (__v0), "=r" (__a3)					\
 	: input, "r" (__a0)						\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -216,8 +214,7 @@ union __mips_syscall_return
 	: "=r" (__v0), "=r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1)					\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -243,8 +240,7 @@ union __mips_syscall_return
 	: "=r" (__v0), "=r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2)			\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -270,8 +266,7 @@ union __mips_syscall_return
 	: "=r" (__v0), "+r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2)			\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -300,8 +295,7 @@ libc_hidden_proto (__mips_syscall5, nomips16)
 				       (long) (arg4),			\
 				       (long) (arg5),			\
 				       (long) (number));		\
-	err = _sc_ret.reg.v1;						\
-	_sc_ret.reg.v0;							\
+	_sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0;		\
 })
 
 long long __nomips16 __mips_syscall6 (long arg1, long arg2, long arg3,
@@ -320,8 +314,7 @@ libc_hidden_proto (__mips_syscall6, nomips16)
 				       (long) (arg5),			\
 				       (long) (arg6),			\
 				       (long) (number));		\
-	err = _sc_ret.reg.v1;						\
-	_sc_ret.reg.v0;							\
+	_sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0;		\
 })
 
 long long __nomips16 __mips_syscall7 (long arg1, long arg2, long arg3,
@@ -342,8 +335,7 @@ libc_hidden_proto (__mips_syscall7, nomips16)
 				       (long) (arg6),			\
 				       (long) (arg7),			\
 				       (long) (number));		\
-	err = _sc_ret.reg.v1;						\
-	_sc_ret.reg.v0;							\
+	_sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0;		\
 })
 
 #if __mips_isa_rev >= 6
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
index 617e229a67..072016f07e 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
@@ -69,13 +69,14 @@ typedef long int __syscall_arg_t;
      result_var; })
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)   ((void) (val), (long) (err))
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((unsigned long) (val) >= (unsigned long) -4095)
 
 #undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     ((void) (err), val)
+#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
 
 /* Note that the original Linux syscall restart convention required the
    instruction immediately preceding SYSCALL to initialize $v0 with the
@@ -133,8 +134,7 @@ typedef long int __syscall_arg_t;
 	: "=r" (__v0), "=r" (__a3)					\
 	: input								\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -157,8 +157,7 @@ typedef long int __syscall_arg_t;
 	: "=r" (__v0), "=r" (__a3)					\
 	: input, "r" (__a0)						\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -182,8 +181,7 @@ typedef long int __syscall_arg_t;
 	: "=r" (__v0), "=r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1)					\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -209,8 +207,7 @@ typedef long int __syscall_arg_t;
 	: "=r" (__v0), "=r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2)			\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -236,8 +233,7 @@ typedef long int __syscall_arg_t;
 	: "=r" (__v0), "+r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2)			\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -264,8 +260,7 @@ typedef long int __syscall_arg_t;
 	: "=r" (__v0), "+r" (__a3)					\
 	: input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4)		\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
@@ -294,8 +289,7 @@ typedef long int __syscall_arg_t;
 	: input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4),	\
 	  "r" (__a5)							\
 	: __SYSCALL_CLOBBERS);						\
-	err = __a3;							\
-	_sys_result = __v0;						\
+	_sys_result = __a3 != 0 ? -__v0 : __v0;				\
 	}								\
 	_sys_result;							\
 })
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
index cdfc0b1b58..877768a249 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -28,19 +28,3 @@
 #endif
 #define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_gettimeofday"
 #define HAVE_CLOCK_GETRES_VSYSCALL      "__vdso_clock_getres"
-
-#ifndef __ASSEMBLER__
-
-/* Standard MIPS syscalls have an error flag, and return a positive errno
-   when the error flag is set. Emulate this behaviour for vsyscalls so that
-   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    if (err)								\
-      _ret = -_ret;							\
-    _ret;								\
-  })
-
-#endif /* __ASSEMBLER__  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 07/15] mips: Use Linux kABI for syscall return Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 11:20   ` Florian Weimer
                     ` (2 more replies)
  2020-02-10 19:20 ` [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall Adhemerval Zanella
                   ` (7 subsequent siblings)
  14 siblings, 3 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
value instead of 'r2' register value on 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.

Checked with a build against nios2-linux-gnu.
---
 sysdeps/unix/sysv/linux/nios2/sysdep.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
index b02730bd23..eab888df32 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
@@ -157,13 +157,14 @@
      (int) result_var; })
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((unsigned long) (val) >= (unsigned long) -4095)
 
 #undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)   ((void) (err), val)
+#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
 
 #undef INTERNAL_SYSCALL_RAW
 #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)            \
@@ -180,8 +181,7 @@
                      : "+r" (_r2), "=r" (_err)                  \
                      : ASM_ARGS_##nr				\
                      : __SYSCALL_CLOBBERS);                     \
-       _sys_result = _r2;                                       \
-       err = _err;                                              \
+       _sys_result = _err != 0 ? -_r2 : -_r2;                   \
      }                                                          \
      (int) _sys_result; })
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 08/15] nios2: " Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 11:21   ` Florian Weimer
  2020-02-10 19:20 ` [PATCH 10/15] riscv: " Adhemerval Zanella
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

The microblaze INTERNAL_SYSCALL macro might clobber the register
parameter if the argument itself might clobber any register (a function
call for instance).

This patch fixes it by using temporary variables for the expressions
between the register assignments (as indicated by GCC documentation,
6.47.5.2 Specifying Registers for Local Variables).

It is similar to the fix done for MIPS (BZ#25523).

Checked with microblaze-linux-gnu and microblazeel-linux-gnu build.
---
 sysdeps/unix/sysv/linux/microblaze/sysdep.h | 63 ++++++++++++++-------
 1 file changed, 42 insertions(+), 21 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
index ed873d9dd4..b4a6ee89f1 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
@@ -219,9 +219,10 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 
 # define inline_syscall1(name,arg1)                                           \
   ({                                                                          \
+    long __arg1 = (long) (arg1);                                              \
     register long __ret __asm__("r3");                                        \
     register long __r12 __asm__("r12") = name;                                \
-    register long __r5 __asm__("r5") = (long)(arg1);                          \
+    register long __r5 __asm__("r5") = __arg1;                                \
     __asm__ __volatile__( "brki r14,8; nop;"                                  \
       : "=r"(__ret)                                                           \
       : "r"(__r5), "r"(__r12)                                                 \
@@ -230,10 +231,12 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 
 # define inline_syscall2(name,arg1,arg2)                                      \
   ({                                                                          \
+    long __arg1 = (long) (arg1);                                              \
+    long __arg2 = (long) (arg2);                                              \
     register long __ret __asm__("r3");                                        \
     register long __r12 __asm__("r12") = name;                                \
-    register long __r5 __asm__("r5") = (long)(arg1);                          \
-    register long __r6 __asm__("r6") = (long)(arg2);                          \
+    register long __r5 __asm__("r5") = __arg1;                                \
+    register long __r6 __asm__("r6") = __arg2;                                \
     __asm__ __volatile__( "brki r14,8; nop;"                                  \
       : "=r"(__ret)                                                           \
       : "r"(__r5), "r"(__r6), "r"(__r12)                                      \
@@ -243,11 +246,14 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 
 # define inline_syscall3(name,arg1,arg2,arg3)                                 \
   ({                                                                          \
+    long __arg1 = (long) (arg1);                                              \
+    long __arg2 = (long) (arg2);                                              \
+    long __arg3 = (long) (arg3);                                              \
     register long __ret __asm__("r3");                                        \
     register long __r12 __asm__("r12") = name;                                \
-    register long __r5 __asm__("r5") = (long)(arg1);                          \
-    register long __r6 __asm__("r6") = (long)(arg2);                          \
-    register long __r7 __asm__("r7") = (long)(arg3);                          \
+    register long __r5 __asm__("r5") = __arg1;                                \
+    register long __r6 __asm__("r6") = __arg2;                                \
+    register long __r7 __asm__("r7") = __arg3;                                \
     __asm__ __volatile__( "brki r14,8; nop;"                                  \
       : "=r"(__ret)                                                           \
       : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r12)                           \
@@ -257,12 +263,16 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 
 # define inline_syscall4(name,arg1,arg2,arg3,arg4)                            \
   ({                                                                          \
+    long __arg1 = (long) (arg1);                                              \
+    long __arg2 = (long) (arg2);                                              \
+    long __arg3 = (long) (arg3);                                              \
+    long __arg4 = (long) (arg4);                                              \
     register long __ret __asm__("r3");                                        \
     register long __r12 __asm__("r12") = name;                                \
-    register long __r5 __asm__("r5") = (long)(arg1);                          \
-    register long __r6 __asm__("r6") = (long)(arg2);                          \
-    register long __r7 __asm__("r7") = (long)(arg3);                          \
-    register long __r8 __asm__("r8") = (long)(arg4);                          \
+    register long __r5 __asm__("r5") = __arg1;                                \
+    register long __r6 __asm__("r6") = __arg2;                                \
+    register long __r7 __asm__("r7") = __arg3;                                \
+    register long __r8 __asm__("r8") = __arg4;                                \
     __asm__ __volatile__( "brki r14,8; nop;"                                  \
       : "=r"(__ret)                                                           \
       : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r12)                 \
@@ -272,13 +282,18 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 
 # define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5)                       \
   ({                                                                          \
+    long __arg1 = (long) (arg1);                                              \
+    long __arg2 = (long) (arg2);                                              \
+    long __arg3 = (long) (arg3);                                              \
+    long __arg4 = (long) (arg4);                                              \
+    long __arg5 = (long) (arg5);                                              \
     register long __ret __asm__("r3");                                        \
     register long __r12 __asm__("r12") = name;                                \
-    register long __r5 __asm__("r5") = (long)(arg1);                          \
-    register long __r6 __asm__("r6") = (long)(arg2);                          \
-    register long __r7 __asm__("r7") = (long)(arg3);                          \
-    register long __r8 __asm__("r8") = (long)(arg4);                          \
-    register long __r9 __asm__("r9") = (long)(arg5);                          \
+    register long __r5 __asm__("r5") = __arg1;                                \
+    register long __r6 __asm__("r6") = __arg2;                                \
+    register long __r7 __asm__("r7") = __arg3;                                \
+    register long __r8 __asm__("r8") = __arg4;                                \
+    register long __r9 __asm__("r9") = __arg5;                                \
     __asm__ __volatile__( "brki r14,8; nop;"                                  \
       : "=r"(__ret)                                                           \
       : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r12)      \
@@ -288,14 +303,20 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 
 # define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6)                  \
   ({                                                                          \
+    long __arg1 = (long) (arg1);                                              \
+    long __arg2 = (long) (arg2);                                              \
+    long __arg3 = (long) (arg3);                                              \
+    long __arg4 = (long) (arg4);                                              \
+    long __arg5 = (long) (arg5);                                              \
+    long __arg6 = (long) (arg6);                                              \
     register long __ret __asm__("r3");                                        \
     register long __r12 __asm__("r12") = name;                                \
-    register long __r5 __asm__("r5") = (long)(arg1);                          \
-    register long __r6 __asm__("r6") = (long)(arg2);                          \
-    register long __r7 __asm__("r7") = (long)(arg3);                          \
-    register long __r8 __asm__("r8") = (long)(arg4);                          \
-    register long __r9 __asm__("r9") = (long)(arg5);                          \
-    register long __r10 __asm__("r10") = (long)(arg6);                        \
+    register long __r5 __asm__("r5") = __arg1;                                \
+    register long __r6 __asm__("r6") = __arg2;                                \
+    register long __r7 __asm__("r7") = __arg3;                                \
+    register long __r8 __asm__("r8") = __arg4;                                \
+    register long __r9 __asm__("r9") = __arg5;                                \
+    register long __r10 __asm__("r10") = __arg6;                              \
     __asm__ __volatile__( "brki r14,8; nop;"                                  \
       : "=r"(__ret)                                                           \
       : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r10),     \
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 10/15] riscv: Avoid clobbering register parameters in syscall
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (7 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-10 19:51   ` DJ Delorie
  2020-02-10 19:20 ` [PATCH 11/15] s390: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

The riscv INTERNAL_SYSCALL macro might clobber the register
parameter if the argument itself might clobber any register (a function
call for instance).

This patch fixes it by using temporary variables for the expressions
between the register assignments (as indicated by GCC documentation,
6.47.5.2 Specifying Registers for Local Variables).

It is similar to the fix done for MIPS (BZ#25523).

Checked with riscv64-linux-gnu-rv64imafdc-lp64d build.
---
 sysdeps/unix/sysv/linux/riscv/sysdep.h | 84 +++++++++++++++++---------
 1 file changed, 56 insertions(+), 28 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 201bf9a91b..2bd9b16f32 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -176,10 +176,11 @@
 # define internal_syscall1(number, err, arg0)				\
 ({ 									\
 	long int _sys_result;						\
+	long int _arg0 = (long int) (arg0);				\
 									\
 	{								\
 	register long int __a7 asm ("a7") = number;			\
-	register long int __a0 asm ("a0") = (long int) (arg0);		\
+	register long int __a0 asm ("a0") = _arg0;			\
 	__asm__ volatile ( 						\
 	"scall\n\t" 							\
 	: "+r" (__a0)							\
@@ -193,11 +194,13 @@
 # define internal_syscall2(number, err, arg0, arg1)	    		\
 ({ 									\
 	long int _sys_result;						\
+	long int _arg0 = (long int) (arg0);				\
+	long int _arg1 = (long int) (arg1);				\
 									\
 	{								\
 	register long int __a7 asm ("a7") = number;			\
-	register long int __a0 asm ("a0") = (long int) (arg0);		\
-	register long int __a1 asm ("a1") = (long int) (arg1);		\
+	register long int __a0 asm ("a0") = _arg0;			\
+	register long int __a1 asm ("a1") = _arg1;			\
 	__asm__ volatile ( 						\
 	"scall\n\t" 							\
 	: "+r" (__a0)							\
@@ -211,12 +214,15 @@
 # define internal_syscall3(number, err, arg0, arg1, arg2)      		\
 ({ 									\
 	long int _sys_result;						\
+	long int _arg0 = (long int) (arg0);				\
+	long int _arg1 = (long int) (arg1);				\
+	long int _arg2 = (long int) (arg2);				\
 									\
 	{								\
 	register long int __a7 asm ("a7") = number;			\
-	register long int __a0 asm ("a0") = (long int) (arg0);		\
-	register long int __a1 asm ("a1") = (long int) (arg1);		\
-	register long int __a2 asm ("a2") = (long int) (arg2);		\
+	register long int __a0 asm ("a0") = _arg0;			\
+	register long int __a1 asm ("a1") = _arg1;			\
+	register long int __a2 asm ("a2") = _arg2;			\
 	__asm__ volatile ( 						\
 	"scall\n\t" 							\
 	: "+r" (__a0)							\
@@ -230,13 +236,17 @@
 # define internal_syscall4(number, err, arg0, arg1, arg2, arg3)	  \
 ({ 									\
 	long int _sys_result;						\
+	long int _arg0 = (long int) (arg0);				\
+	long int _arg1 = (long int) (arg1);				\
+	long int _arg2 = (long int) (arg2);				\
+	long int _arg3 = (long int) (arg3);				\
 									\
 	{								\
 	register long int __a7 asm ("a7") = number;			\
-	register long int __a0 asm ("a0") = (long int) (arg0);		\
-	register long int __a1 asm ("a1") = (long int) (arg1);		\
-	register long int __a2 asm ("a2") = (long int) (arg2);		\
-	register long int __a3 asm ("a3") = (long int) (arg3);		\
+	register long int __a0 asm ("a0") = _arg0;			\
+	register long int __a1 asm ("a1") = _arg1;			\
+	register long int __a2 asm ("a2") = _arg2;			\
+	register long int __a3 asm ("a3") = _arg3;			\
 	__asm__ volatile ( 						\
 	"scall\n\t" 							\
 	: "+r" (__a0)							\
@@ -250,14 +260,19 @@
 # define internal_syscall5(number, err, arg0, arg1, arg2, arg3, arg4)   \
 ({ 									\
 	long int _sys_result;						\
+	long int _arg0 = (long int) (arg0);				\
+	long int _arg1 = (long int) (arg1);				\
+	long int _arg2 = (long int) (arg2);				\
+	long int _arg3 = (long int) (arg3);				\
+	long int _arg4 = (long int) (arg4);				\
 									\
 	{								\
 	register long int __a7 asm ("a7") = number;			\
-	register long int __a0 asm ("a0") = (long int) (arg0);		\
-	register long int __a1 asm ("a1") = (long int) (arg1);		\
-	register long int __a2 asm ("a2") = (long int) (arg2);		\
-	register long int __a3 asm ("a3") = (long int) (arg3);		\
-	register long int __a4 asm ("a4") = (long int) (arg4);		\
+	register long int __a0 asm ("a0") = _arg0;			\
+	register long int __a1 asm ("a1") = _arg1;			\
+	register long int __a2 asm ("a2") = _arg2;			\
+	register long int __a3 asm ("a3") = _arg3;			\
+	register long int __a4 asm ("a4") = _arg4;			\
 	__asm__ volatile ( 						\
 	"scall\n\t" 							\
 	: "+r" (__a0)							\
@@ -271,15 +286,21 @@
 # define internal_syscall6(number, err, arg0, arg1, arg2, arg3, arg4, arg5) \
 ({ 									\
 	long int _sys_result;						\
+	long int _arg0 = (long int) (arg0);				\
+	long int _arg1 = (long int) (arg1);				\
+	long int _arg2 = (long int) (arg2);				\
+	long int _arg3 = (long int) (arg3);				\
+	long int _arg4 = (long int) (arg4);				\
+	long int _arg5 = (long int) (arg5);				\
 									\
 	{								\
 	register long int __a7 asm ("a7") = number;			\
-	register long int __a0 asm ("a0") = (long int) (arg0);		\
-	register long int __a1 asm ("a1") = (long int) (arg1);		\
-	register long int __a2 asm ("a2") = (long int) (arg2);		\
-	register long int __a3 asm ("a3") = (long int) (arg3);		\
-	register long int __a4 asm ("a4") = (long int) (arg4);		\
-	register long int __a5 asm ("a5") = (long int) (arg5);		\
+	register long int __a0 asm ("a0") = _arg0;			\
+	register long int __a1 asm ("a1") = _arg1;			\
+	register long int __a2 asm ("a2") = _arg2;			\
+	register long int __a3 asm ("a3") = _arg3;			\
+	register long int __a4 asm ("a4") = _arg4;			\
+	register long int __a5 asm ("a5") = _arg5;			\
 	__asm__ volatile ( 						\
 	"scall\n\t" 							\
 	: "+r" (__a0)							\
@@ -294,16 +315,23 @@
 # define internal_syscall7(number, err, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
 ({ 									\
 	long int _sys_result;						\
+	long int _arg0 = (long int) (arg0);				\
+	long int _arg1 = (long int) (arg1);				\
+	long int _arg2 = (long int) (arg2);				\
+	long int _arg3 = (long int) (arg3);				\
+	long int _arg4 = (long int) (arg4);				\
+	long int _arg5 = (long int) (arg5);				\
+	long int _arg6 = (long int) (arg6);				\
 									\
 	{								\
 	register long int __a7 asm ("a7") = number;			\
-	register long int __a0 asm ("a0") = (long int) (arg0);		\
-	register long int __a1 asm ("a1") = (long int) (arg1);		\
-	register long int __a2 asm ("a2") = (long int) (arg2);		\
-	register long int __a3 asm ("a3") = (long int) (arg3);		\
-	register long int __a4 asm ("a4") = (long int) (arg4);		\
-	register long int __a5 asm ("a5") = (long int) (arg5);		\
-	register long int __a6 asm ("a6") = (long int) (arg6);		\
+	register long int __a0 asm ("a0") = _arg0;			\
+	register long int __a1 asm ("a1") = _arg1;			\
+	register long int __a2 asm ("a2") = _arg2;			\
+	register long int __a3 asm ("a3") = _arg3;			\
+	register long int __a4 asm ("a4") = _arg4;			\
+	register long int __a5 asm ("a5") = _arg5;			\
+	register long int __a6 asm ("a6") = _arg6;			\
 	__asm__ volatile ( 						\
 	"scall\n\t" 							\
 	: "+r" (__a0)							\
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 11/15] s390: Consolidate Linux syscall definition
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (8 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 10/15] riscv: " Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-10 19:20 ` [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall Adhemerval Zanella
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

The {INTERNAL,INLINE}_SYSCALL are defined only on s390 sysdep.h.

Checked on s390x-linux-gnu and s390-linux-gnu.
---
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h |  95 ----------------
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h |  97 -----------------
 sysdeps/unix/sysv/linux/s390/sysdep.h         | 102 ++++++++++++++++++
 3 files changed, 102 insertions(+), 192 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index f52b8b8735..520c9356c6 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -38,9 +38,6 @@
 /* in newer 2.1 kernels __NR_syscall is missing so we define it here */
 #define __NR_syscall 0
 
-#undef SYS_ify
-#define SYS_ify(syscall_name)	__NR_##syscall_name
-
 #ifdef __ASSEMBLER__
 
 /* Linux uses a negative return value to indicate syscall errors, unlike
@@ -180,98 +177,6 @@
 
 #endif /* __ASSEMBLER__ */
 
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				      \
-  ({									      \
-    unsigned int _ret = INTERNAL_SYSCALL (name, , nr, args);		      \
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, )))		      \
-     {									      \
-       __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, ));			      \
-       _ret = 0xffffffff;						      \
-     }									      \
-    (int) _ret; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_DIRECT
-#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...)			      \
-  ({									      \
-    DECLARGS_##nr(args)							      \
-    register int _ret __asm__("2");					      \
-    __asm__ __volatile__ (						      \
-			  "svc    %b1\n\t"				      \
-			  : "=d" (_ret)					      \
-			  : "i" (__NR_##name) ASMFMT_##nr		      \
-			  : "memory" );					      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL_SVC0
-#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...)			      \
-  ({									      \
-    DECLARGS_##nr(args)							      \
-    register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name);   \
-    register int _ret __asm__("2");					      \
-    __asm__ __volatile__ (						      \
-			  "svc    0\n\t"				      \
-			  : "=d" (_ret)					      \
-			  : "d" (_nr) ASMFMT_##nr			      \
-			  : "memory" );					      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(no, err, nr, args...)			      \
-  ({									      \
-    DECLARGS_##nr(args)							      \
-    register unsigned long _nr __asm__("1") = (unsigned long)(no);	      \
-    register int _ret __asm__("2");					      \
-    __asm__ __volatile__ (						      \
-			  "svc    0\n\t"				      \
-			  : "=d" (_ret)					      \
-			  : "d" (_nr) ASMFMT_##nr			      \
-			  : "memory" );					      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)			      \
-  (((__NR_##name) < 256)						      \
-   ? INTERNAL_SYSCALL_DIRECT(name, err, nr, args)			      \
-   : INTERNAL_SYSCALL_SVC0(name, err,nr, args))
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)				      \
-  ((unsigned int) (val) >= 0xfffff001u)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
-#define DECLARGS_0()
-#define DECLARGS_1(arg1) \
-	register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
-#define DECLARGS_2(arg1, arg2) \
-	DECLARGS_1(arg1) \
-	register unsigned long gpr3 __asm__ ("3") = (unsigned long)(arg2);
-#define DECLARGS_3(arg1, arg2, arg3) \
-	DECLARGS_2(arg1, arg2) \
-	register unsigned long gpr4 __asm__ ("4") = (unsigned long)(arg3);
-#define DECLARGS_4(arg1, arg2, arg3, arg4) \
-	DECLARGS_3(arg1, arg2, arg3) \
-	register unsigned long gpr5 __asm__ ("5") = (unsigned long)(arg4);
-#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
-	DECLARGS_4(arg1, arg2, arg3, arg4) \
-	register unsigned long gpr6 __asm__ ("6") = (unsigned long)(arg5);
-#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
-	DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
-	register unsigned long gpr7 __asm__ ("7") = (unsigned long)(arg6);
-
-#define ASMFMT_0
-#define ASMFMT_1 , "0" (gpr2)
-#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
-#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
-#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
-#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
-#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
-
 /* Pointer mangling support.  */
 #if IS_IN (rtld)
 /* We cannot use the thread descriptor because in ld.so we use setjmp
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 9ff4479dc3..623059135e 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -50,9 +50,6 @@
 # define __NR_pwrite __NR_pwrite64
 #endif
 
-#undef SYS_ify
-#define SYS_ify(syscall_name)	__NR_##syscall_name
-
 #ifdef __ASSEMBLER__
 
 /* Linux uses a negative return value to indicate syscall errors, unlike
@@ -186,100 +183,6 @@
 
 #endif /* __ASSEMBLER__ */
 
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				      \
-  ({									      \
-    long _ret = INTERNAL_SYSCALL (name, , nr, args);			      \
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, )))		      \
-     {									      \
-       __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, ));			      \
-       _ret = -1;							      \
-     }									      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_DIRECT
-#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...)			      \
-  ({									      \
-    DECLARGS_##nr(args)							      \
-    register long _ret __asm__("2");					      \
-    __asm__ __volatile__ (						      \
-			  "svc    %b1\n\t"				      \
-			  : "=d" (_ret)					      \
-			  : "i" (__NR_##name) ASMFMT_##nr		      \
-			  : "memory" );					      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL_SVC0
-#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...)			      \
-  ({									      \
-    DECLARGS_##nr(args)							      \
-    register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name);   \
-    register long _ret __asm__("2");					      \
-    __asm__ __volatile__ (						      \
-			  "svc    0\n\t"				      \
-			  : "=d" (_ret)					      \
-			  : "d" (_nr) ASMFMT_##nr			      \
-			  : "memory" );					      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(no, err, nr, args...)			      \
-  ({									      \
-    DECLARGS_##nr(args)							      \
-    register unsigned long _nr __asm__("1") = (unsigned long)(no);	      \
-    register long _ret __asm__("2");					      \
-    __asm__ __volatile__ (						      \
-			  "svc    0\n\t"				      \
-			  : "=d" (_ret)					      \
-			  : "d" (_nr) ASMFMT_##nr			      \
-			  : "memory" );					      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)			      \
-  (((__NR_##name) < 256)						      \
-   ? INTERNAL_SYSCALL_DIRECT(name, err, nr, args)			      \
-   : INTERNAL_SYSCALL_SVC0(name, err,nr, args))
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)				      \
-  ((unsigned long) (val) >= -4095UL)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
-#define DECLARGS_0()
-#define DECLARGS_1(arg1) \
-	register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
-#define DECLARGS_2(arg1, arg2) \
-	DECLARGS_1(arg1) \
-	register unsigned long gpr3 __asm__ ("3") = (unsigned long)(arg2);
-#define DECLARGS_3(arg1, arg2, arg3) \
-	DECLARGS_2(arg1, arg2) \
-	register unsigned long gpr4 __asm__ ("4") = (unsigned long)(arg3);
-#define DECLARGS_4(arg1, arg2, arg3, arg4) \
-	DECLARGS_3(arg1, arg2, arg3) \
-	register unsigned long gpr5 __asm__ ("5") = (unsigned long)(arg4);
-#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
-	DECLARGS_4(arg1, arg2, arg3, arg4) \
-	register unsigned long gpr6 __asm__ ("6") = (unsigned long)(arg5);
-#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
-	DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
-	register unsigned long gpr7 __asm__ ("7") = (unsigned long)(arg6);
-
-#define ASMFMT_0
-#define ASMFMT_1 , "0" (gpr2)
-#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
-#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
-#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
-#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
-#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
-
-#define SINGLE_THREAD_BY_GLOBAL		1
-
 /* Pointer mangling support.  */
 #if IS_IN (rtld)
 /* We cannot use the thread descriptor because in ld.so we use setjmp
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
index 33ed86f252..1df0462cc4 100644
--- a/sysdeps/unix/sysv/linux/s390/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -16,6 +16,106 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef __ASSEMBLY__
+
+#undef SYS_ify
+#define SYS_ify(syscall_name)	__NR_##syscall_name
+
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...)				      \
+  ({									      \
+    long _ret = INTERNAL_SYSCALL (name, , nr, args);			      \
+    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, )))		      \
+     {									      \
+       __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, ));			      \
+       _ret = -1;							      \
+     }									      \
+    _ret; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+#undef INTERNAL_SYSCALL_DIRECT
+#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...)			      \
+  ({									      \
+    DECLARGS_##nr(args)							      \
+    register long _ret __asm__("2");					      \
+    __asm__ __volatile__ (						      \
+			  "svc    %b1\n\t"				      \
+			  : "=d" (_ret)					      \
+			  : "i" (__NR_##name) ASMFMT_##nr		      \
+			  : "memory" );					      \
+    _ret; })
+
+#undef INTERNAL_SYSCALL_SVC0
+#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...)			      \
+  ({									      \
+    DECLARGS_##nr(args)							      \
+    register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name);   \
+    register long _ret __asm__("2");					      \
+    __asm__ __volatile__ (						      \
+			  "svc    0\n\t"				      \
+			  : "=d" (_ret)					      \
+			  : "d" (_nr) ASMFMT_##nr			      \
+			  : "memory" );					      \
+    _ret; })
+
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(no, err, nr, args...)			      \
+  ({									      \
+    DECLARGS_##nr(args)							      \
+    register unsigned long _nr __asm__("1") = (unsigned long)(no);	      \
+    register long _ret __asm__("2");					      \
+    __asm__ __volatile__ (						      \
+			  "svc    0\n\t"				      \
+			  : "=d" (_ret)					      \
+			  : "d" (_nr) ASMFMT_##nr			      \
+			  : "memory" );					      \
+    _ret; })
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, nr, args...)				      \
+  (((__NR_##name) < 256)						      \
+   ? INTERNAL_SYSCALL_DIRECT(name, nr, args)				      \
+   : INTERNAL_SYSCALL_SVC0(name, nr, args))
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err)                                    \
+  ((unsigned long) (val) >= -4095UL)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err)        (-(val))
+
+#define DECLARGS_0()
+#define DECLARGS_1(arg1) \
+	register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
+#define DECLARGS_2(arg1, arg2) \
+	DECLARGS_1(arg1) \
+	register unsigned long gpr3 __asm__ ("3") = (unsigned long)(arg2);
+#define DECLARGS_3(arg1, arg2, arg3) \
+	DECLARGS_2(arg1, arg2) \
+	register unsigned long gpr4 __asm__ ("4") = (unsigned long)(arg3);
+#define DECLARGS_4(arg1, arg2, arg3, arg4) \
+	DECLARGS_3(arg1, arg2, arg3) \
+	register unsigned long gpr5 __asm__ ("5") = (unsigned long)(arg4);
+#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
+	DECLARGS_4(arg1, arg2, arg3, arg4) \
+	register unsigned long gpr6 __asm__ ("6") = (unsigned long)(arg5);
+#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+	DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
+	register unsigned long gpr7 __asm__ ("7") = (unsigned long)(arg6);
+
+#define ASMFMT_0
+#define ASMFMT_1 , "0" (gpr2)
+#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
+#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
+#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
+#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
+#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
+
+#define SINGLE_THREAD_BY_GLOBAL		1
+
+
 #define VDSO_NAME  "LINUX_2.6.29"
 #define VDSO_HASH  123718585
 
@@ -29,3 +129,5 @@
 #endif
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
+
+#endif
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (9 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 11/15] s390: Consolidate Linux syscall definition Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 11:22   ` Florian Weimer
  2020-02-10 19:20 ` [PATCH 13/15] linux: Consolidate INLINE_SYSCALL Adhemerval Zanella
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

The sparc INTERNAL_SYSCALL macro might clobber the register
parameter if the argument itself might clobber any register (a function
call for instance).

This patch fixes it by using temporary variables for the expressions
between the register assignments (as indicated by GCC documentation,
6.47.5.2 Specifying Registers for Local Variables).

It is similar to the fix done for MIPS (BZ#25523).

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
---
 sysdeps/unix/sysv/linux/sparc/sysdep.h | 78 +++++++++++++++++---------
 1 file changed, 52 insertions(+), 26 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 67efa6f029..e2a12349a1 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -87,8 +87,9 @@
 
 #define internal_syscall1(string,err,name,arg1)				\
 ({									\
+	long _arg1 = (long) (arg1);					\
 	register long __err __asm__("g1") = (name);			\
-	register long __o0 __asm__ ("o0") = (long)(arg1);		\
+	register long __o0 __asm__ ("o0") = _arg1;			\
 	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
 			  "0" (__err), "1" (__o0) :			\
 			  __SYSCALL_CLOBBERS);				\
@@ -97,9 +98,11 @@
 
 #define internal_syscall2(string,err,name,arg1,arg2)			\
 ({									\
+	long _arg1 = (long) (arg1);					\
+	long _arg2 = (long) (arg2);					\
 	register long __err __asm__("g1") = (name);			\
-	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	register long __o1 __asm__ ("o1") = (long)(arg2);		\
+	register long __o0 __asm__ ("o0") = _arg1;			\
+	register long __o1 __asm__ ("o1") = _arg2;			\
 	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
 			  "0" (__err), "1" (__o0), "r" (__o1) :		\
 			  __SYSCALL_CLOBBERS);				\
@@ -108,10 +111,13 @@
 
 #define internal_syscall3(string,err,name,arg1,arg2,arg3)		\
 ({									\
+	long _arg1 = (long) (arg1);					\
+	long _arg2 = (long) (arg2);					\
+	long _arg3 = (long) (arg3);					\
 	register long __err __asm__("g1") = (name);			\
-	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	register long __o2 __asm__ ("o2") = (long)(arg3);		\
+	register long __o0 __asm__ ("o0") = _arg1;			\
+	register long __o1 __asm__ ("o1") = _arg2;			\
+	register long __o2 __asm__ ("o2") = _arg3;			\
 	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
 			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2) :					\
@@ -121,11 +127,15 @@
 
 #define internal_syscall4(string,err,name,arg1,arg2,arg3,arg4)		\
 ({									\
+	long _arg1 = (long) (arg1);					\
+	long _arg2 = (long) (arg2);					\
+	long _arg3 = (long) (arg3);					\
+	long _arg4 = (long) (arg4);					\
 	register long __err __asm__("g1") = (name);			\
-	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	register long __o2 __asm__ ("o2") = (long)(arg3);		\
-	register long __o3 __asm__ ("o3") = (long)(arg4);		\
+	register long __o0 __asm__ ("o0") = _arg1;			\
+	register long __o1 __asm__ ("o1") = _arg2;			\
+	register long __o2 __asm__ ("o2") = _arg3;			\
+	register long __o3 __asm__ ("o3") = _arg4;			\
 	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
 			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3) :			\
@@ -135,12 +145,17 @@
 
 #define internal_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5)	\
 ({									\
+	long _arg1 = (long) (arg1);					\
+	long _arg2 = (long) (arg2);					\
+	long _arg3 = (long) (arg3);					\
+	long _arg4 = (long) (arg4);					\
+	long _arg5 = (long) (arg5);					\
 	register long __err __asm__("g1") = (name);			\
-	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	register long __o2 __asm__ ("o2") = (long)(arg3);		\
-	register long __o3 __asm__ ("o3") = (long)(arg4);		\
-	register long __o4 __asm__ ("o4") = (long)(arg5);		\
+	register long __o0 __asm__ ("o0") = _arg1;			\
+	register long __o1 __asm__ ("o1") = _arg2;			\
+	register long __o2 __asm__ ("o2") = _arg3;			\
+	register long __o3 __asm__ ("o3") = _arg4;			\
+	register long __o4 __asm__ ("o4") = _arg5;			\
 	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
 			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
@@ -150,13 +165,19 @@
 
 #define internal_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)\
 ({									\
+	long _arg1 = (long) (arg1);					\
+	long _arg2 = (long) (arg2);					\
+	long _arg3 = (long) (arg3);					\
+	long _arg4 = (long) (arg4);					\
+	long _arg5 = (long) (arg5);					\
+	long _arg6 = (long) (arg6);					\
 	register long __err __asm__("g1") = (name);			\
-	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	register long __o2 __asm__ ("o2") = (long)(arg3);		\
-	register long __o3 __asm__ ("o3") = (long)(arg4);		\
-	register long __o4 __asm__ ("o4") = (long)(arg5);		\
-	register long __o5 __asm__ ("o5") = (long)(arg6);		\
+	register long __o0 __asm__ ("o0") = _arg1;			\
+	register long __o1 __asm__ ("o1") = _arg2;			\
+	register long __o2 __asm__ ("o2") = _arg3;			\
+	register long __o3 __asm__ ("o3") = _arg4;			\
+	register long __o4 __asm__ ("o4") = _arg5;			\
+	register long __o5 __asm__ ("o5") = _arg6;			\
 	__asm __volatile (string : "=r" (__err), "=r" (__o0) :		\
 			  "0" (__err), "1" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4),		\
@@ -167,11 +188,16 @@
 
 #define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5)			\
 ({									\
-	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	register long __o2 __asm__ ("o2") = (long)(arg3);		\
-	register long __o3 __asm__ ("o3") = (long)(arg4);		\
-	register long __o4 __asm__ ("o4") = (long)(arg5);		\
+	long _arg1 = (long) (arg1);					\
+	long _arg2 = (long) (arg2);					\
+	long _arg3 = (long) (arg3);					\
+	long _arg4 = (long) (arg4);					\
+	long _arg5 = (long) (arg5);					\
+	register long __o0 __asm__ ("o0") = _arg1;			\
+	register long __o1 __asm__ ("o1") = _arg2;			\
+	register long __o2 __asm__ ("o2") = _arg3;			\
+	register long __o3 __asm__ ("o3") = _arg4;			\
+	register long __o4 __asm__ ("o4") = _arg5;			\
 	register long __g1 __asm__ ("g1") = __NR_clone;			\
 	__asm __volatile (__SYSCALL_STRING :				\
 			  "=r" (__g1), "=r" (__o0), "=r" (__o1)	:	\
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 13/15] linux: Consolidate INLINE_SYSCALL
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (10 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 12:03   ` Florian Weimer
  2020-02-10 19:20 ` [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule Adhemerval Zanella
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

With all Linux ABIs using the expected Linux kABI to indicate
syscalls errors, there is no need to replicate the INLINE_SYSCALL.

The generic Linux sysdep.h includes errno.h even for !__ASSEMBLER__,
which is ok now and it allows cleanup some archaic code that assume
otherwise.

Checked with a build against all affected ABIs.
---
 sysdeps/i386/pthread_spin_trylock.S           |  2 +-
 sysdeps/mips/nptl/tls.h                       |  2 +-
 sysdeps/sh/nptl/pthread_spin_trylock.S        |  2 +-
 sysdeps/sparc/sparc32/pthread_spin_trylock.S  |  2 +-
 sysdeps/sparc/sparc64/pthread_spin_trylock.S  |  2 +-
 sysdeps/unix/arm/sysdep.S                     |  3 +-
 sysdeps/unix/mips/sysdep.S                    |  3 +-
 sysdeps/unix/sh/sysdep.S                      |  3 +-
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      | 22 ----------
 sysdeps/unix/sysv/linux/alpha/brk.S           |  3 +-
 sysdeps/unix/sysv/linux/alpha/sysdep.h        | 24 -----------
 sysdeps/unix/sysv/linux/arm/sysdep.h          | 27 -------------
 sysdeps/unix/sysv/linux/csky/sysdep.h         | 22 ----------
 sysdeps/unix/sysv/linux/hppa/sysdep.h         | 30 --------------
 sysdeps/unix/sysv/linux/i386/sysdep.h         | 40 +------------------
 sysdeps/unix/sysv/linux/ia64/sysdep.h         | 20 ----------
 sysdeps/unix/sysv/linux/m68k/sysdep.h         | 22 ----------
 sysdeps/unix/sysv/linux/microblaze/sysdep.h   | 24 -----------
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h  | 28 -------------
 sysdeps/unix/sysv/linux/mips/mips64/sysdep.h  | 28 -------------
 sysdeps/unix/sysv/linux/nios2/sysdep.h        | 24 +----------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 30 --------------
 sysdeps/unix/sysv/linux/riscv/sysdep.h        | 20 ----------
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h |  5 ---
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h |  5 ---
 sysdeps/unix/sysv/linux/s390/sysdep.h         | 21 ----------
 sysdeps/unix/sysv/linux/sh/sysdep.h           | 21 ----------
 sysdeps/unix/sysv/linux/sparc/sparc64/brk.S   |  3 +-
 sysdeps/unix/sysv/linux/sparc/sysdep.h        | 22 ----------
 sysdeps/unix/sysv/linux/sysdep.h              | 40 +++++++++++++++++++
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       | 35 ----------------
 sysdeps/unix/x86_64/sysdep.S                  |  3 +-
 sysdeps/x86_64/nptl/pthread_spin_trylock.S    |  2 +-
 33 files changed, 54 insertions(+), 486 deletions(-)

diff --git a/sysdeps/i386/pthread_spin_trylock.S b/sysdeps/i386/pthread_spin_trylock.S
index 949879c603..8edb676381 100644
--- a/sysdeps/i386/pthread_spin_trylock.S
+++ b/sysdeps/i386/pthread_spin_trylock.S
@@ -17,7 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <pthread-errnos.h>
+#include <errno.h>
 
 
 #ifdef UP
diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h
index ba0efe8af6..ae85984f95 100644
--- a/sysdeps/mips/nptl/tls.h
+++ b/sysdeps/mips/nptl/tls.h
@@ -35,7 +35,7 @@
 # define READ_THREAD_POINTER() (__builtin_thread_pointer ())
 #else
 /* Note: rd must be $v1 to be ABI-conformant.  */
-# if __mips_isa_rev >= 2
+# if defined (__mips_isa_rev) &&  __mips_isa_rev >= 2
 #  define READ_THREAD_POINTER() \
      ({ void *__result;							      \
         asm volatile ("rdhwr\t%0, $29" : "=v" (__result));	      	      \
diff --git a/sysdeps/sh/nptl/pthread_spin_trylock.S b/sysdeps/sh/nptl/pthread_spin_trylock.S
index c8c453ca9f..142908cf32 100644
--- a/sysdeps/sh/nptl/pthread_spin_trylock.S
+++ b/sysdeps/sh/nptl/pthread_spin_trylock.S
@@ -15,7 +15,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <pthread-errnos.h>
+#include <errno.h>
 
 	.globl	pthread_spin_trylock
 	.type	pthread_spin_trylock,@function
diff --git a/sysdeps/sparc/sparc32/pthread_spin_trylock.S b/sysdeps/sparc/sparc32/pthread_spin_trylock.S
index bd31fad711..4b992e78bf 100644
--- a/sysdeps/sparc/sparc32/pthread_spin_trylock.S
+++ b/sysdeps/sparc/sparc32/pthread_spin_trylock.S
@@ -16,7 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <pthread-errnos.h>
+#include <errno.h>
 
 	.text
 ENTRY(pthread_spin_trylock)
diff --git a/sysdeps/sparc/sparc64/pthread_spin_trylock.S b/sysdeps/sparc/sparc64/pthread_spin_trylock.S
index fd33946aec..b6cfa52b51 100644
--- a/sysdeps/sparc/sparc64/pthread_spin_trylock.S
+++ b/sysdeps/sparc/sparc64/pthread_spin_trylock.S
@@ -16,7 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <pthread-errnos.h>
+#include <errno.h>
 
 	.text
 ENTRY(pthread_spin_trylock)
diff --git a/sysdeps/unix/arm/sysdep.S b/sysdeps/unix/arm/sysdep.S
index 514937bd4b..5c9022a869 100644
--- a/sysdeps/unix/arm/sysdep.S
+++ b/sysdeps/unix/arm/sysdep.S
@@ -16,8 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#define _ERRNO_H
-#include <bits/errno.h>
+#include <errno.h>
 
 #if IS_IN (rtld)
 # include <dl-sysdep.h>			/* Defines RTLD_PRIVATE_ERRNO.  */
diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S
index fca1091cda..744d1620b3 100644
--- a/sysdeps/unix/mips/sysdep.S
+++ b/sysdeps/unix/mips/sysdep.S
@@ -17,8 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#define _ERRNO_H
-#include <bits/errno.h>
+#include <errno.h>
 #include <sys/asm.h>
 
 	.set	nomips16
diff --git a/sysdeps/unix/sh/sysdep.S b/sysdeps/unix/sh/sysdep.S
index 7facc028d6..dc9a230ee0 100644
--- a/sysdeps/unix/sh/sysdep.S
+++ b/sysdeps/unix/sh/sysdep.S
@@ -16,8 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#define _ERRNO_H
-#include <bits/errno.h>
+#include <errno.h>
 
 ENTRY(__syscall_error)
 #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index 00b8e241c8..79fa0bda27 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -170,21 +170,6 @@
 
 # define SINGLE_THREAD_BY_GLOBAL		1
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...)				\
-  ({ unsigned long _sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
-     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, ));		\
-	 _sys_result = (unsigned long) -1;				\
-       }								\
-     (long) _sys_result; })
-
-# undef INTERNAL_SYSCALL_DECL
-# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 # undef INTERNAL_SYSCALL_RAW
 # define INTERNAL_SYSCALL_RAW(name, err, nr, args...)		\
   ({ long _sys_result;						\
@@ -205,13 +190,6 @@
 # define INTERNAL_SYSCALL_AARCH64(name, err, nr, args...)	\
 	INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args)
 
-# undef INTERNAL_SYSCALL_ERROR_P
-# define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= (unsigned long) -4095)
-
-# undef INTERNAL_SYSCALL_ERRNO
-# define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
 # define LOAD_ARGS_0()				\
   register long _x0 asm ("x0");
 # define LOAD_ARGS_1(x0)			\
diff --git a/sysdeps/unix/sysv/linux/alpha/brk.S b/sysdeps/unix/sysv/linux/alpha/brk.S
index 45ecbbea1b..5596b346d8 100644
--- a/sysdeps/unix/sysv/linux/alpha/brk.S
+++ b/sysdeps/unix/sysv/linux/alpha/brk.S
@@ -21,8 +21,7 @@
    break value (instead of the new, requested one).  */
 
 #include <sysdep.h>
-#define _ERRNO_H
-#include <bits/errno.h>
+#include <errno.h>
 
 #ifdef PIC
 .section .bss
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h
index ca0b4e475c..679d6169de 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h
@@ -169,42 +169,18 @@ __LABEL(name)						\
 
 #else /* !ASSEMBLER */
 
-/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
-#include <errno.h>
-
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-({									\
-	INTERNAL_SYSCALL_DECL (_sc_err);				\
-	long int _sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
-	if (INTERNAL_SYSCALL_ERROR_P (_sc_ret, _sc_err))		\
-	  {								\
-	    __set_errno (INTERNAL_SYSCALL_ERRNO (_sc_ret, _sc_err));	\
-	    _sc_ret = -1L;						\
-	  }								\
-	_sc_ret;							\
-})
-
 #define INTERNAL_SYSCALL(name, err_out, nr, args...) \
 	internal_syscall##nr(__NR_##name, args)
 
 #define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
 	internal_syscall##nr(name, args)
 
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 /* The normal Alpha calling convention sign-extends 32-bit quantties
    no matter what the "real" sign of the 32-bit type.  We want to
    preserve that when filling in values for the kernel.  */
 #define syscall_promote(arg) \
   (sizeof (arg) == 4 ? (long)(int)(long)(arg) : (long)(arg))
 
-/* Make sure and "use" the variable that we're not returning,
-   in order to suppress unused variable warnings.  */
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-	((unsigned long) (val) >= (unsigned long) -4095)
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
 #define internal_syscall_clobbers				\
 	"$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",	\
 	"$22", "$23", "$24", "$25", "$27", "$28", "memory"
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index 0c5f498583..f6e6b63959 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -29,11 +29,6 @@
 
 #include <tls.h>
 
-/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
-#ifndef __ASSEMBLER__
-#include <errno.h>
-#endif
-
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
@@ -317,21 +312,6 @@ __local_syscall_error:						\
 
 #else /* not __ASSEMBLER__ */
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-  ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
-     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))	\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, ));		\
-	 _sys_result = (unsigned int) -1;				\
-       }								\
-     (int) _sys_result; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 #if defined(__thumb__)
 /* We can not expose the use of r7 to the compiler.  GCC (as
    of 4.5) uses r7 as the hard frame pointer for Thumb - although
@@ -377,13 +357,6 @@ __local_syscall_error:						\
 #define INTERNAL_SYSCALL(name, err, nr, args...)		\
 	INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
 
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned int) (val) >= 0xfffff001u)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
 #define VDSO_NAME  "LINUX_2.6"
 #define VDSO_HASH  61765110
 
diff --git a/sysdeps/unix/sysv/linux/csky/sysdep.h b/sysdeps/unix/sysv/linux/csky/sysdep.h
index fa1dbd6614..7ebb19dce8 100644
--- a/sysdeps/unix/sysv/linux/csky/sysdep.h
+++ b/sysdeps/unix/sysv/linux/csky/sysdep.h
@@ -293,28 +293,6 @@ __local_syscall_error:				\
 
 #else /* not __ASSEMBLER__ */
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...)				\
-  ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
-     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result,), 0))	\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, ));		\
-	 _sys_result = (unsigned int) -1;				\
-       }								\
-     (int) _sys_result; })
-
-# undef INTERNAL_SYSCALL_DECL
-# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-# undef INTERNAL_SYSCALL_ERROR_P
-# define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned int) (val) >= 0xffffff01u)
-
-# undef INTERNAL_SYSCALL_ERRNO
-# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
-
 # undef INTERNAL_SYSCALL_RAW
 #  define INTERNAL_SYSCALL_RAW0(name, err, dummy...)			\
   ({unsigned int __sys_result;						\
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h
index 6c34189eca..88e368db4d 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep.h
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h
@@ -360,36 +360,6 @@ L(pre_end):					ASM_LINE_SEP	\
 #define CALL_CLOB_REGS	"%r1", "%r2", CLOB_TREG \
 			"%r20", "%r29", "%r31"
 
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-({									\
-    long __sys_res = INTERNAL_SYSCALL (name, , nr, args);		\
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__sys_res, )))	\
-      {									\
-	__set_errno (INTERNAL_SYSCALL_ERRNO (__sys_res, ));		\
-	__sys_res = -1;							\
-      }									\
-    __sys_res;								\
-})
-
-/* INTERNAL_SYSCALL_DECL - Allows us to setup some function static
-   value to use within the context of the syscall
-   INTERNAL_SYSCALL_ERROR_P - Returns 0 if it wasn't an error, 1 otherwise
-   You are allowed to use the syscall result (val) and the DECL error
-   variable to determine what went wrong.
-   INTERLAL_SYSCALL_ERRNO - Munges the val/err pair into the error number.
-   In our case we just flip the sign. */
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-	((val < 0) && (val > -4095))
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
-
 /* Similar to INLINE_SYSCALL but we don't set errno */
 #undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL(name, err, nr, args...)			\
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 4aa7bb496a..d975683749 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -67,6 +67,7 @@
 
 /* We don't want the label for the error handle to be global when we define
    it here.  */
+#undef SYSCALL_ERROR_LABEL
 #define SYSCALL_ERROR_LABEL __syscall_error
 
 #undef	PSEUDO
@@ -280,35 +281,6 @@ struct libc_do_syscall_args
 };
 #endif
 
-/* Define a macro which expands inline into the wrapper code for a system
-   call.  */
-#undef INLINE_SYSCALL
-#if IS_IN (libc)
-# define INLINE_SYSCALL(name, nr, args...) \
-  ({									      \
-    unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args);	      \
-    __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))		      \
-    ? __syscall_error (-INTERNAL_SYSCALL_ERRNO (resultvar, ))		      \
-    : (int) resultvar; })
-#else
-# define INLINE_SYSCALL(name, nr, args...) \
-  ({									      \
-    unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args);	      \
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, )))	      \
-      {									      \
-	__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, ));		      \
-	resultvar = 0xffffffff;						      \
-      }									      \
-    (int) resultvar; })
-#endif
-
-/* Set error number and return -1.  Return the internal function,
-   __syscall_error, which sets errno from the negative error number
-   and returns -1, to avoid PIC.  */
-#undef INLINE_SYSCALL_ERROR_RETURN_VALUE
-#define INLINE_SYSCALL_ERROR_RETURN_VALUE(resultvar) \
-  __syscall_error (-(resultvar))
-
 # define VDSO_NAME  "LINUX_2.6"
 # define VDSO_HASH  61765110
 
@@ -490,16 +462,6 @@ struct libc_do_syscall_args
 # endif /* GCC 5  */
 #endif
 
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned int) (val) >= 0xfffff001u)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
 #define LOADARGS_0
 #ifdef __PIC__
 # if I386_USE_SYSENTER && defined PIC
diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.h b/sysdeps/unix/sysv/linux/ia64/sysdep.h
index 729bfadad0..fab8ca2359 100644
--- a/sysdeps/unix/sysv/linux/ia64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/ia64/sysdep.h
@@ -231,29 +231,9 @@
 
 #endif /* !IA64_USE_NEW_STUB */
 
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...)				\
-  ({ unsigned long _sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
-     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, ));		\
-	 _sys_result = (unsigned long) -1;				\
-       }								\
-     (long) _sys_result; })
-
-# undef INTERNAL_SYSCALL_DECL
-# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 #define INTERNAL_SYSCALL(name, err, nr, args...)	\
   INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
 
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= (unsigned long) -4095)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
 #define LOAD_ARGS_0()
 #define LOAD_REGS_0
 #define LOAD_ARGS_1(a1)					\
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h
index 5cd35fffcf..f6793d34fa 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -221,21 +221,6 @@ SYSCALL_ERROR_LABEL:							      \
 
 #else /* not __ASSEMBLER__ */
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-  ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args);	\
-     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, ));		\
-	 _sys_result = (unsigned int) -1;				\
-       }								\
-     (int) _sys_result; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 /* Define a macro which expands inline into the wrapper code for a system
    call.  This use is for internal calls that do not need to handle errors
    normally.  It will never touch errno.  This returns just what the kernel
@@ -260,13 +245,6 @@ SYSCALL_ERROR_LABEL:							      \
 #define INTERNAL_SYSCALL(name, err, nr, args...)	\
   INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
 
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)		\
-  ((unsigned int) (val) >= -4095U)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
 #define LOAD_ARGS_0()
 #define LOAD_REGS_0
 #define ASM_ARGS_0
diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
index b4a6ee89f1..6eeae33df5 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
@@ -163,23 +163,6 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 
 #else /* not __ASSEMBLER__ */
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...)                           \
-({  INTERNAL_SYSCALL_DECL(err);                                      \
-    unsigned long resultvar = INTERNAL_SYSCALL(name, err, nr, args); \
-    if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))                   \
-       {                                                             \
-        __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err));       \
-        resultvar = (unsigned long) -1;                              \
-       }                                                             \
-    (long) resultvar;                                                \
-})
-
-# undef INTERNAL_SYSCALL_DECL
-# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 /* Define a macro which expands inline into the wrapper code for a system
    call.  This use is for internal calls that do not need to handle errors
    normally.  It will never touch errno.  This returns just what the kernel
@@ -192,13 +175,6 @@ SYSCALL_ERROR_LABEL_DCL:                            \
 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...)                \
   inline_syscall##nr(name, args)
 
-# undef INTERNAL_SYSCALL_ERROR_P
-# define INTERNAL_SYSCALL_ERROR_P(val, err)                          \
-  ((unsigned int) (val) >= -4095U)
-
-# undef INTERNAL_SYSCALL_ERRNO
-# define INTERNAL_SYSCALL_ERRNO(val, err)    (-(val))
-
 # define SYSCALL_CLOBBERS_6 "r11", "r4", "memory"
 # define SYSCALL_CLOBBERS_5 "r10", SYSCALL_CLOBBERS_6
 # define SYSCALL_CLOBBERS_4 "r9", SYSCALL_CLOBBERS_5
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index 6842ff5211..75d483c59b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -25,11 +25,6 @@
 
 #include <tls.h>
 
-/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
-#ifndef __ASSEMBLER__
-#include <errno.h>
-#endif
-
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
@@ -47,29 +42,6 @@
 
 #else   /* ! __ASSEMBLER__ */
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)                               \
-  ({ INTERNAL_SYSCALL_DECL (_sc_err);					\
-     long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args);	\
-     if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) )		\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err));	\
-	 result_var = -1L;						\
-       }								\
-     result_var; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= (unsigned long) -4095)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
-
 /* Note that the original Linux syscall restart convention required the
    instruction immediately preceding SYSCALL to initialize $v0 with the
    syscall number.  Then if a restart triggered, $v0 would have been
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
index 072016f07e..03873ce2c2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
@@ -25,11 +25,6 @@
 
 #include <tls.h>
 
-/* In order to get __set_errno() definition in INLINE_SYSCALL.  */
-#ifndef __ASSEMBLER__
-#include <errno.h>
-#endif
-
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
@@ -55,29 +50,6 @@ typedef long long int __syscall_arg_t;
 typedef long int __syscall_arg_t;
 #endif
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-  ({ INTERNAL_SYSCALL_DECL (_sc_err);					\
-     long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args);	\
-     if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) )		\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err));	\
-	 result_var = -1L;						\
-       }								\
-     result_var; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= (unsigned long) -4095)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
-
 /* Note that the original Linux syscall restart convention required the
    instruction immediately preceding SYSCALL to initialize $v0 with the
    syscall number.  Then if a restart triggered, $v0 would have been
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
index eab888df32..45ef817ab5 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
@@ -37,6 +37,7 @@
 
 #ifdef __ASSEMBLER__
 
+#undef SYSCALL_ERROR_LABEL
 #define SYSCALL_ERROR_LABEL __local_syscall_error
 
 #undef PSEUDO
@@ -143,29 +144,6 @@
    which lead in a non existent __send symbol in libc.so.  */
 # undef HAVE_INTERNAL_SEND_SYMBOL
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)                               \
-  ({ INTERNAL_SYSCALL_DECL(err);					\
-     unsigned int result_var = INTERNAL_SYSCALL (name, err, nr, args);	\
-     if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) )			\
-       {								\
-	 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err));	\
-	 result_var = -1L;						\
-       }								\
-     (int) result_var; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= (unsigned long) -4095)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
-
 #undef INTERNAL_SYSCALL_RAW
 #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)            \
   ({ unsigned int _sys_result;                                  \
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index abdcfd4a63..92503ee20f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -67,26 +67,6 @@
 #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
   INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
 
-/* This version is for kernels that implement system calls that
-   behave like function calls as far as register saving.  */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				\
-  ({									\
-    INTERNAL_SYSCALL_DECL (sc_err);					\
-    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
-    if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			\
-      {									\
-        __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));		\
-        sc_ret = -1L;							\
-      }									\
-    sc_ret;								\
-  })
-
-/* Define a macro which expands inline into the wrapper code for a system
-   call. This use is for internal calls that do not need to handle errors
-   normally. It will never touch errno. This returns just what the kernel
-   gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
-   the negation of the return value in the kernel gets reverted.  */
 
 #undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
@@ -114,16 +94,6 @@
 #define INTERNAL_SYSCALL(name, err, nr, args...)			\
   INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
 
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= (unsigned long) -4095)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
-
 #if defined(__PPC64__) || defined(__powerpc64__)
 # define SYSCALL_ARG_SIZE 8
 #else
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 2bd9b16f32..e46160f3f6 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -130,26 +130,6 @@
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
-/* Define a macro which expands into the inline wrapper code for a system
-   call.  */
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...)				\
-  ({ INTERNAL_SYSCALL_DECL (err);					\
-     long int __sys_result = INTERNAL_SYSCALL (name, err, nr, args);	\
-     if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__sys_result, )))  \
-       {								\
-         __set_errno (INTERNAL_SYSCALL_ERRNO (__sys_result, ));		\
-	 __sys_result = (unsigned long) -1;				\
-       }								\
-     __sys_result; })
-
-# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-# define INTERNAL_SYSCALL_ERROR_P(val, err) \
-        ((unsigned long int) (val) > -4096UL)
-
-# define INTERNAL_SYSCALL_ERRNO(val, err)     (-val)
-
 # define INTERNAL_SYSCALL(name, err, nr, args...) \
 	internal_syscall##nr (SYS_ify (name), err, args)
 
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index 520c9356c6..7d31abbb6f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -26,11 +26,6 @@
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
 
-/* Define __set_errno() for INLINE_SYSCALL macro below.  */
-#ifndef __ASSEMBLER__
-#include <errno.h>
-#endif
-
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 623059135e..aba3999315 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -27,11 +27,6 @@
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
 
-/* Define __set_errno() for INLINE_SYSCALL macro below.  */
-#ifndef __ASSEMBLER__
-#include <errno.h>
-#endif
-
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
index 1df0462cc4..3802e07277 100644
--- a/sysdeps/unix/sysv/linux/s390/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -21,20 +21,6 @@
 #undef SYS_ify
 #define SYS_ify(syscall_name)	__NR_##syscall_name
 
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...)				      \
-  ({									      \
-    long _ret = INTERNAL_SYSCALL (name, , nr, args);			      \
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, )))		      \
-     {									      \
-       __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, ));			      \
-       _ret = -1;							      \
-     }									      \
-    _ret; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 #undef INTERNAL_SYSCALL_DIRECT
 #define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...)			      \
   ({									      \
@@ -79,13 +65,6 @@
    ? INTERNAL_SYSCALL_DIRECT(name, nr, args)				      \
    : INTERNAL_SYSCALL_SVC0(name, nr, args))
 
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err)                                    \
-  ((unsigned long) (val) >= -4095UL)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)        (-(val))
-
 #define DECLARGS_0()
 #define DECLARGS_1(arg1) \
 	register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h
index 703b042f4f..c0e52af65a 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep.h
@@ -287,17 +287,6 @@
 	register long int r1 asm ("%r1") = (long int) (_arg6);		      \
 	register long int r2 asm ("%r2") = (long int) (_arg7)
 
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
-  ({                                                                          \
-    unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args);             \
-    if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0))         \
-      {                                                                       \
-	__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, ));                   \
-	resultvar = 0xffffffff;                                               \
-      }                                                                       \
-    (int) resultvar; })
-
 #undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
   ({									      \
@@ -326,16 +315,6 @@
 									      \
     (int) resultvar; })
 
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned int) (val) >= 0xfffff001u)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)        (-(val))
-
 #endif	/* __ASSEMBLER__ */
 
 /* Pointer mangling support.  */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/brk.S b/sysdeps/unix/sysv/linux/sparc/sparc64/brk.S
index 0bcd882532..471da3d268 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/brk.S
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/brk.S
@@ -21,8 +21,7 @@
    break value (instead of the new, requested one).  */
 
 #include <sysdep.h>
-#define _ERRNO_H
-#include <bits/errno.h>
+#include <errno.h>
 
 #ifdef PIC
 .section .bss
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index e2a12349a1..46f4e06844 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -45,21 +45,6 @@
 # endif
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) 				\
-({	INTERNAL_SYSCALL_DECL(err);  					\
-	unsigned long resultvar = INTERNAL_SYSCALL(name, err, nr, args);\
-	if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))			\
-	  {		     			       		   	\
-	    __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err));	\
-	    resultvar = (unsigned long) -1;				\
-	  } 	      							\
-	(long) resultvar;						\
-})
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 #undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
   internal_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
@@ -68,13 +53,6 @@
 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
   internal_syscall##nr(__SYSCALL_STRING, err, name, args)
 
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long) (val) >= (unsigned long) -4095)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
-
 #define internal_syscall0(string,err,name,dummy...)			\
 ({									\
 	register long __err __asm__("g1") = (name);			\
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index c7f3e54d37..389c94cfda 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -15,8 +15,44 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#ifndef _SYSDEP_LINUX_H
+#define _SYSDEP_LINUX_H
+
 #include <bits/wordsize.h>
 #include <kernel-features.h>
+#include <errno.h>
+
+#ifndef __ASSEMBLER__
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((unsigned long) (val) > -4096UL)
+
+#ifndef SYSCALL_ERROR_LABEL
+# define SYSCALL_ERROR_LABEL(sc_err)					\
+  ({									\
+    __set_errno (sc_err);						\
+    -1L;								\
+  })
+#endif
+
+/* This version is for kernels that implement system calls that
+   behave like function calls as far as register saving.  */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...)				\
+  ({									\
+    INTERNAL_SYSCALL_DECL (sc_err);					\
+    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
+    __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))	\
+    ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err))	\
+    : sc_ret;								\
+  })
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
 
 /* Set error number and return -1.  A target may choose to return the
    internal function, __syscall_error, which sets errno and returns -1.
@@ -66,3 +102,7 @@
 /* Exports the __send symbol on send.c linux implementation (some ABI have
    it missing due the usage of a old generic version without it).  */
 #define HAVE_INTERNAL_SEND_SYMBOL	1
+
+#endif /* __ASSEMBLER__  */
+
+#endif /* _SYSDEP_LINUX_H  */
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index c2eb37e575..d91e00572c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -177,35 +177,6 @@
 # define DOARGS_6 DOARGS_5
 
 #else	/* !__ASSEMBLER__ */
-/* Define a macro which expands inline into the wrapper code for a system
-   call.  */
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...) \
-  ({									      \
-    unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args);	      \
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, )))	      \
-      {									      \
-	__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, ));		      \
-	resultvar = (unsigned long int) -1;				      \
-      }									      \
-    (long int) resultvar; })
-
-/* Define a macro with explicit types for arguments, which expands inline
-   into the wrapper code for a system call.  It should be used when size
-   of any argument > size of long int.  */
-# undef INLINE_SYSCALL_TYPES
-# define INLINE_SYSCALL_TYPES(name, nr, args...) \
-  ({									      \
-    unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args);  \
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, )))	      \
-      {									      \
-	__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, ));		      \
-	resultvar = (unsigned long int) -1;				      \
-      }									      \
-    (long int) resultvar; })
-
-# undef INTERNAL_SYSCALL_DECL
-# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 /* Registers clobbered by syscall.  */
 # define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx"
@@ -353,12 +324,6 @@
     (long int) resultvar;						\
 })
 
-# undef INTERNAL_SYSCALL_ERROR_P
-# define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((unsigned long int) (long int) (val) >= -4095L)
-
-# undef INTERNAL_SYSCALL_ERRNO
-# define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
 # define VDSO_NAME  "LINUX_2.6"
 # define VDSO_HASH  61765110
diff --git a/sysdeps/unix/x86_64/sysdep.S b/sysdeps/unix/x86_64/sysdep.S
index f617627eb8..2278fce9e4 100644
--- a/sysdeps/unix/x86_64/sysdep.S
+++ b/sysdeps/unix/x86_64/sysdep.S
@@ -16,8 +16,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#define _ERRNO_H
-#include <bits/errno.h>
+#include <errno.h>
 #include <tls.h>
 
 #if IS_IN (rtld)
diff --git a/sysdeps/x86_64/nptl/pthread_spin_trylock.S b/sysdeps/x86_64/nptl/pthread_spin_trylock.S
index 24981fe717..c084577755 100644
--- a/sysdeps/x86_64/nptl/pthread_spin_trylock.S
+++ b/sysdeps/x86_64/nptl/pthread_spin_trylock.S
@@ -16,8 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <pthread-errnos.h>
 #include <sysdep.h>
+#include <errno.h>
 
 
 #ifdef UP
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (11 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 13/15] linux: Consolidate INLINE_SYSCALL Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 11:23   ` Florian Weimer
  2020-02-10 19:20 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
  2020-02-11 19:43 ` [PATCH 01/15] powerpc: Consolidate Linux syscall definition Florian Weimer
  14 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

---
 nptl/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/nptl/Makefile b/nptl/Makefile
index 6f210d60e3..fcdc72adfe 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -327,8 +327,7 @@ test-xfail-tst-once5 = yes
 # Files which must not be linked with libpthread.
 tests-nolibpthread = tst-unload
 
-gen-as-const-headers = pthread-errnos.sym \
-		       unwindbuf.sym \
+gen-as-const-headers = unwindbuf.sym \
 		       pthread-pi-defines.sym
 
 gen-py-const-headers := nptl_lock_constants.pysym
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (12 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule Adhemerval Zanella
@ 2020-02-10 19:20 ` Adhemerval Zanella
  2020-02-11 12:34   ` Florian Weimer
                     ` (3 more replies)
  2020-02-11 19:43 ` [PATCH 01/15] powerpc: Consolidate Linux syscall definition Florian Weimer
  14 siblings, 4 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 19:20 UTC (permalink / raw)
  To: libc-alpha

With all Linux ABIs using the expected Linux kABI to indicate
syscalls errors, the INTERNAL_SYSCALL_DECL is an empty declaration
on all ports.

This patch removes the 'err' argument on INTERNAL_SYSCALL* macro
and remove the INTERNAL_SYSCALL_DECL usage.

Checked with a build against all affected ABIs.
---
 nptl/allocatestack.c                          | 12 ++--
 nptl/nptl-init.c                              | 26 ++++-----
 nptl/pthread_cancel.c                         |  7 +--
 nptl/pthread_create.c                         |  8 +--
 nptl/pthread_mutex_trylock.c                  | 11 ++--
 nptl/pthread_sigmask.c                        | 13 ++---
 nptl/thrd_yield.c                             |  3 +-
 sysdeps/csky/nptl/tls.h                       |  7 +--
 sysdeps/i386/nptl/tls.h                       |  3 +-
 sysdeps/m68k/nptl/tls.h                       |  5 +-
 sysdeps/mips/nptl/tls.h                       |  7 +--
 sysdeps/nptl/lowlevellock-futex.h             |  9 ++-
 sysdeps/powerpc/nofpu/sfp-machine.h           |  5 +-
 sysdeps/unix/sysdep.h                         | 36 ++++++------
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      | 14 ++---
 sysdeps/unix/sysv/linux/aio_misc.h            |  8 +--
 sysdeps/unix/sysv/linux/alpha/fxstat.c        | 13 ++---
 sysdeps/unix/sysv/linux/alpha/fxstatat.c      |  7 +--
 sysdeps/unix/sysv/linux/alpha/lxstat.c        | 13 ++---
 sysdeps/unix/sysv/linux/alpha/sysdep.h        |  4 +-
 sysdeps/unix/sysv/linux/alpha/xstat.c         | 13 ++---
 sysdeps/unix/sysv/linux/arm/dl-machine.h      |  2 +-
 sysdeps/unix/sysv/linux/arm/sysdep.h          | 12 ++--
 sysdeps/unix/sysv/linux/arm/tls.h             |  7 +--
 sysdeps/unix/sysv/linux/clock_getcpuclockid.c |  9 ++-
 sysdeps/unix/sysv/linux/clock_nanosleep.c     | 22 ++++---
 sysdeps/unix/sysv/linux/createthread.c        | 19 +++---
 sysdeps/unix/sysv/linux/csky/sysdep.h         | 24 ++++----
 sysdeps/unix/sysv/linux/default-sched.h       |  6 +-
 sysdeps/unix/sysv/linux/dl-origin.c           |  7 +--
 sysdeps/unix/sysv/linux/dl-writev.h           |  3 +-
 sysdeps/unix/sysv/linux/exit-thread.h         |  3 +-
 sysdeps/unix/sysv/linux/fcntl_nocancel.c      |  7 +--
 sysdeps/unix/sysv/linux/fxstatat.c            |  9 +--
 sysdeps/unix/sysv/linux/fxstatat64.c          | 13 ++---
 .../unix/sysv/linux/generic/____longjmp_chk.c |  3 +-
 sysdeps/unix/sysv/linux/generic/brk.c         |  4 +-
 sysdeps/unix/sysv/linux/generic/dl-origin.c   |  7 +--
 .../unix/sysv/linux/hppa/____longjmp_chk.c    |  5 +-
 sysdeps/unix/sysv/linux/hppa/sysdep.h         |  4 +-
 sysdeps/unix/sysv/linux/i386/brk.c            |  3 +-
 sysdeps/unix/sysv/linux/i386/fxstat.c         |  8 +--
 sysdeps/unix/sysv/linux/i386/fxstatat.c       |  8 +--
 sysdeps/unix/sysv/linux/i386/lxstat.c         |  8 +--
 sysdeps/unix/sysv/linux/i386/sysdep.h         | 58 +++++++++----------
 sysdeps/unix/sysv/linux/i386/xstat.c          |  8 +--
 .../unix/sysv/linux/ia64/__sigstack_longjmp.c |  3 +-
 sysdeps/unix/sysv/linux/ia64/sysdep.h         |  8 +--
 sysdeps/unix/sysv/linux/ifaddrs.c             |  3 +-
 sysdeps/unix/sysv/linux/internal-signals.h    |  9 +--
 sysdeps/unix/sysv/linux/libc_fatal.c          |  7 +--
 .../unix/sysv/linux/m68k/____longjmp_chk.c    |  5 +-
 sysdeps/unix/sysv/linux/m68k/brk.c            |  3 +-
 .../sysv/linux/m68k/coldfire/atomic-machine.h |  2 +-
 sysdeps/unix/sysv/linux/m68k/getpagesize.c    |  5 +-
 sysdeps/unix/sysv/linux/m68k/m68k-helpers.c   |  3 +-
 sysdeps/unix/sysv/linux/m68k/sysdep.h         |  6 +-
 sysdeps/unix/sysv/linux/microblaze/brk.c      |  4 +-
 sysdeps/unix/sysv/linux/microblaze/sysdep.h   |  4 +-
 sysdeps/unix/sysv/linux/mips/brk.c            |  3 +-
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h  | 11 ++--
 .../unix/sysv/linux/mips/mips64/fxstatat64.c  |  7 +--
 sysdeps/unix/sysv/linux/mips/mips64/sysdep.h  | 30 +++++-----
 sysdeps/unix/sysv/linux/mq_unlink.c           |  7 +--
 sysdeps/unix/sysv/linux/nios2/sysdep.h        | 10 ++--
 sysdeps/unix/sysv/linux/not-cancel.h          |  3 +-
 sysdeps/unix/sysv/linux/not-errno.h           | 16 +++--
 sysdeps/unix/sysv/linux/nscd_setup_thread.c   |  7 +--
 sysdeps/unix/sysv/linux/personality.c         |  7 +--
 sysdeps/unix/sysv/linux/posix_fadvise.c       | 11 ++--
 sysdeps/unix/sysv/linux/posix_fadvise64.c     |  9 ++-
 sysdeps/unix/sysv/linux/posix_fallocate.c     |  9 ++-
 sysdeps/unix/sysv/linux/posix_fallocate64.c   | 15 ++---
 sysdeps/unix/sysv/linux/posix_madvise.c       |  5 +-
 .../sysv/linux/powerpc/get_timebase_freq.c    |  3 +-
 .../linux/powerpc/powerpc32/fpu/fe_mask.c     |  3 +-
 .../linux/powerpc/powerpc32/fpu/fe_nomask.c   |  3 +-
 .../linux/powerpc/powerpc64/fpu/fe_mask.c     |  3 +-
 .../linux/powerpc/powerpc64/fpu/fe_nomask.c   |  3 +-
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 12 ++--
 sysdeps/unix/sysv/linux/pthread-pids.h        |  3 +-
 sysdeps/unix/sysv/linux/pthread_getaffinity.c |  9 ++-
 sysdeps/unix/sysv/linux/pthread_kill.c        |  8 +--
 sysdeps/unix/sysv/linux/pthread_setaffinity.c | 11 ++--
 sysdeps/unix/sysv/linux/pthread_sigqueue.c    |  8 +--
 sysdeps/unix/sysv/linux/raise.c               |  7 +--
 sysdeps/unix/sysv/linux/riscv/syscall.c       |  5 +-
 sysdeps/unix/sysv/linux/riscv/sysdep.h        | 24 ++++----
 .../sysv/linux/s390/s390-32/____longjmp_chk.c |  5 +-
 .../sysv/linux/s390/s390-32/posix_fadvise64.c |  7 +--
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h |  4 ++
 .../sysv/linux/s390/s390-64/____longjmp_chk.c |  5 +-
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h |  4 ++
 sysdeps/unix/sysv/linux/s390/sysdep.h         |  6 +-
 sysdeps/unix/sysv/linux/safe-fatal.h          |  5 +-
 sysdeps/unix/sysv/linux/sh/sysdep.h           |  4 +-
 sysdeps/unix/sysv/linux/shmat.c               |  8 +--
 sysdeps/unix/sysv/linux/sparc/sysdep.h        | 22 +++----
 sysdeps/unix/sysv/linux/sysdep-vdso.h         | 15 +++--
 sysdeps/unix/sysv/linux/sysdep.h              | 14 ++---
 sysdeps/unix/sysv/linux/timer_create.c        |  9 ++-
 sysdeps/unix/sysv/linux/timer_routines.c      |  9 +--
 sysdeps/unix/sysv/linux/times.c               |  7 +--
 sysdeps/unix/sysv/linux/x86/cpu-features.c    |  4 +-
 sysdeps/unix/sysv/linux/x86/dl-cet.h          | 17 +++---
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       | 24 ++++----
 sysdeps/unix/sysv/linux/x86_64/x32/times.c    |  4 +-
 107 files changed, 426 insertions(+), 544 deletions(-)

diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 110ba18f5d..c94980c21c 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -1028,11 +1028,10 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
 
   int val;
   pid_t pid = __getpid ();
-  INTERNAL_SYSCALL_DECL (err);
-  val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, t->tid, SIGSETXID);
+  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, err))
+  if (!INTERNAL_SYSCALL_ERROR_P (val))
     {
       atomic_increment (&cmdp->cntr);
       return 1;
@@ -1158,13 +1157,12 @@ __nptl_setxid (struct xid_command *cmdp)
 
   /* This must be last, otherwise the current thread might not have
      permissions to send SIGSETXID syscall to the other threads.  */
-  INTERNAL_SYSCALL_DECL (err);
-  result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, err, 3,
+  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, err)))
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
     {
-      error = INTERNAL_SYSCALL_ERRNO (result, err);
+      error = INTERNAL_SYSCALL_ERRNO (result);
       __set_errno (error);
       result = -1;
     }
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 1877248014..6bc1e75f55 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -130,9 +130,8 @@ void
 __nptl_set_robust (struct pthread *self)
 {
 #ifdef __NR_set_robust_list
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (set_robust_list, err, 2, &self->robust_head,
-		    sizeof (struct robust_list_head));
+  INTERNAL_SYSCALL_CALL (set_robust_list, &self->robust_head,
+			 sizeof (struct robust_list_head));
 #endif
 }
 
@@ -203,12 +202,11 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
       || si->si_code != SI_TKILL)
     return;
 
-  INTERNAL_SYSCALL_DECL (err);
-  result = INTERNAL_SYSCALL_NCS (__xidcmd->syscall_no, err, 3, __xidcmd->id[0],
+  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, err)))
-    error = INTERNAL_SYSCALL_ERRNO (result, err);
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
+    error = INTERNAL_SYSCALL_ERRNO (result);
   __nptl_setxid_error (__xidcmd, error);
 
   /* Reset the SETXID flag.  */
@@ -258,10 +256,9 @@ __pthread_initialize_minimal_internal (void)
     pd->robust_head.futex_offset = (offsetof (pthread_mutex_t, __data.__lock)
 				    - offsetof (pthread_mutex_t,
 						__data.__list.__next));
-    INTERNAL_SYSCALL_DECL (err);
-    int res = INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
-				sizeof (struct robust_list_head));
-    if (INTERNAL_SYSCALL_ERROR_P (res, err))
+    int res = INTERNAL_SYSCALL_CALL (set_robust_list, &pd->robust_head,
+				     sizeof (struct robust_list_head));
+    if (INTERNAL_SYSCALL_ERROR_P (res))
 #endif
       set_robust_list_not_avail ();
   }
@@ -299,11 +296,8 @@ __pthread_initialize_minimal_internal (void)
      structure.  It is already cleared.  */
   __sigaddset (&sa.sa_mask, SIGCANCEL);
   __sigaddset (&sa.sa_mask, SIGSETXID);
-  {
-    INTERNAL_SYSCALL_DECL (err);
-    (void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &sa.sa_mask,
-			     NULL, _NSIG / 8);
-  }
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_UNBLOCK, &sa.sa_mask,
+			 NULL, _NSIG / 8);
 
   /* Get the size of the static and alignment requirements for the TLS
      block.  */
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 8e7be996e9..88c1ab8f6a 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -67,11 +67,10 @@ __pthread_cancel (pthread_t th)
 	     thread as canceled.  */
 	  pid_t pid = __getpid ();
 
-	  INTERNAL_SYSCALL_DECL (err);
-	  int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, pd->tid,
+	  int val = INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid,
 					   SIGCANCEL);
-	  if (INTERNAL_SYSCALL_ERROR_P (val, err))
-	    result = INTERNAL_SYSCALL_ERRNO (val, err);
+	  if (INTERNAL_SYSCALL_ERROR_P (val))
+	    result = INTERNAL_SYSCALL_ERRNO (val);
 
 	  break;
 	}
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index d3fd58730c..f8c7e73881 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -394,10 +394,9 @@ START_THREAD_DEFN
   if (__set_robust_list_avail >= 0)
 # endif
     {
-      INTERNAL_SYSCALL_DECL (err);
       /* This call should never fail because the initial call in init.c
 	 succeeded.  */
-      INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
+      INTERNAL_SYSCALL (set_robust_list, 2, &pd->robust_head,
 			sizeof (struct robust_list_head));
     }
 #endif
@@ -407,12 +406,11 @@ START_THREAD_DEFN
      cancellation signal mask.  */
   if (__glibc_unlikely (pd->parent_cancelhandling & CANCELING_BITMASK))
     {
-      INTERNAL_SYSCALL_DECL (err);
       sigset_t mask;
       __sigemptyset (&mask);
       __sigaddset (&mask, SIGCANCEL);
-      (void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &mask,
-			       NULL, _NSIG / 8);
+      INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_UNBLOCK, &mask,
+			     NULL, _NSIG / 8);
     }
 
   /* This is where the try/finally block should be created.  For
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index b9896f420e..2130f52529 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -297,13 +297,12 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	    int private = (robust
 			   ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
 			   : PTHREAD_MUTEX_PSHARED (mutex));
-	    INTERNAL_SYSCALL_DECL (__err);
-	    int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
-				      __lll_private_flag (FUTEX_TRYLOCK_PI,
-							  private), 0, 0);
+	    int e = INTERNAL_SYSCALL_CALL (futex, &mutex->__data.__lock,
+					   __lll_private_flag (FUTEX_TRYLOCK_PI,
+							       private), 0, 0);
 
-	    if (INTERNAL_SYSCALL_ERROR_P (e, __err)
-		&& INTERNAL_SYSCALL_ERRNO (e, __err) == EWOULDBLOCK)
+	    if (INTERNAL_SYSCALL_ERROR_P (e)
+		&& INTERNAL_SYSCALL_ERRNO (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_sigmask.c b/nptl/pthread_sigmask.c
index 84eb189c81..c7860e02a5 100644
--- a/nptl/pthread_sigmask.c
+++ b/nptl/pthread_sigmask.c
@@ -39,16 +39,11 @@ pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask)
       newmask = &local_newmask;
     }
 
-#ifdef INTERNAL_SYSCALL
   /* We know that realtime signals are available if NPTL is used.  */
-  INTERNAL_SYSCALL_DECL (err);
-  int result = INTERNAL_SYSCALL (rt_sigprocmask, err, 4, how, newmask,
-				 oldmask, _NSIG / 8);
+  int result = INTERNAL_SYSCALL_CALL (rt_sigprocmask, how, newmask,
+				      oldmask, _NSIG / 8);
 
-  return (INTERNAL_SYSCALL_ERROR_P (result, err)
-	  ? INTERNAL_SYSCALL_ERRNO (result, err)
+  return (INTERNAL_SYSCALL_ERROR_P (result)
+	  ? INTERNAL_SYSCALL_ERRNO (result)
 	  : 0);
-#else
-  return sigprocmask (how, newmask, oldmask) == -1 ? errno : 0;
-#endif
 }
diff --git a/nptl/thrd_yield.c b/nptl/thrd_yield.c
index 865f123d73..3e0fd46a27 100644
--- a/nptl/thrd_yield.c
+++ b/nptl/thrd_yield.c
@@ -21,6 +21,5 @@
 void
 thrd_yield (void)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL_CALL (sched_yield, err);
+  INTERNAL_SYSCALL_CALL (sched_yield);
 }
diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
index af8e2c4882..552bc4d429 100644
--- a/sysdeps/csky/nptl/tls.h
+++ b/sysdeps/csky/nptl/tls.h
@@ -96,11 +96,10 @@ 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_DECL (err);					\
-     long result_var;							\
-     result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,		\
+  ({ long result_var;							\
+     result_var = INTERNAL_SYSCALL_CALL (set_thread_area, 		\
                     (char *) (tcbp) + TLS_TCB_OFFSET);			\
-     INTERNAL_SYSCALL_ERROR_P (result_var, err)				\
+     INTERNAL_SYSCALL_ERROR_P (result_var)				\
        ? "unknown error" : NULL; })
 
 /* Return the address of the dtv for the current thread.  */
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
index d1bf90a503..ffead90857 100644
--- a/sysdeps/i386/nptl/tls.h
+++ b/sysdeps/i386/nptl/tls.h
@@ -202,8 +202,7 @@ tls_fill_user_desc (union user_desc_init *desc,
      tls_fill_user_desc (&_segdescr, -1, _thrdescr);			      \
 									      \
      /* Install the TLS.  */						      \
-     INTERNAL_SYSCALL_DECL (err);					      \
-     _result = INTERNAL_SYSCALL (set_thread_area, err, 1, &_segdescr.desc);   \
+     _result = INTERNAL_SYSCALL_CALL (set_thread_area, &_segdescr.desc);      \
 									      \
      if (_result == 0)							      \
        /* We know the index in the GDT, now load the segment register.	      \
diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h
index 27e01f6e80..68ea952e79 100644
--- a/sysdeps/m68k/nptl/tls.h
+++ b/sysdeps/m68k/nptl/tls.h
@@ -95,12 +95,11 @@ typedef struct
    operation can cause a failure 'errno' must not be touched.  */
 # define TLS_INIT_TP(tcbp)						\
   ({									\
-    INTERNAL_SYSCALL_DECL (err);					\
     int _sys_result;							\
 									\
-    _sys_result = INTERNAL_SYSCALL (set_thread_area, err, 1,		\
+    _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, 		\
 				    ((void *) (tcbp)) + TLS_TCB_OFFSET); \
-    INTERNAL_SYSCALL_ERROR_P (_sys_result, err) ? "unknown error" : NULL; })
+    INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "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 ae85984f95..c93c3496e1 100644
--- a/sysdeps/mips/nptl/tls.h
+++ b/sysdeps/mips/nptl/tls.h
@@ -120,11 +120,10 @@ 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_DECL (err);					\
-     long result_var;							\
-     result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,		\
+  ({ long result_var;							\
+     result_var = INTERNAL_SYSCALL_CALL (set_thread_area, 		\
 				    (char *) (tcbp) + TLS_TCB_OFFSET);	\
-     INTERNAL_SYSCALL_ERROR_P (result_var, err)				\
+     INTERNAL_SYSCALL_ERROR_P (result_var)				\
        ? "unknown error" : NULL; })
 
 /* Value passed to 'clone' for initialization of the thread register.  */
diff --git a/sysdeps/nptl/lowlevellock-futex.h b/sysdeps/nptl/lowlevellock-futex.h
index 746f56f80c..2209ca76a1 100644
--- a/sysdeps/nptl/lowlevellock-futex.h
+++ b/sysdeps/nptl/lowlevellock-futex.h
@@ -65,13 +65,12 @@
   (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
 # endif
 
-# define lll_futex_syscall(nargs, futexp, op, ...)                       \
+# define lll_futex_syscall(nargs, futexp, op, ...)                      \
   ({                                                                    \
-    INTERNAL_SYSCALL_DECL (__err);                                      \
-    long int __ret = INTERNAL_SYSCALL (futex, __err, nargs, futexp, op, \
+    long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, 	\
 				       __VA_ARGS__);                    \
-    (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret, __err))         \
-     ? -INTERNAL_SYSCALL_ERRNO (__ret, __err) : 0);                     \
+    (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret))         	\
+     ? -INTERNAL_SYSCALL_ERRNO (__ret) : 0);                     	\
   })
 
 /* For most of these macros, the return value is never really used.
diff --git a/sysdeps/powerpc/nofpu/sfp-machine.h b/sysdeps/powerpc/nofpu/sfp-machine.h
index d92a90e3e2..8489c0f1c0 100644
--- a/sysdeps/powerpc/nofpu/sfp-machine.h
+++ b/sysdeps/powerpc/nofpu/sfp-machine.h
@@ -67,11 +67,10 @@ libc_hidden_proto (__feraiseexcept_soft)
   do									\
     {									\
       int _r;								\
-      INTERNAL_SYSCALL_DECL (_err);					\
 									\
       _spefscr = fegetenv_register ();					\
-      _r = INTERNAL_SYSCALL (prctl, _err, 2, PR_GET_FPEXC, &_ftrapex);	\
-      if (INTERNAL_SYSCALL_ERROR_P (_r, _err))				\
+      _r = INTERNAL_SYSCALL_CALL (prctl, PR_GET_FPEXC, &_ftrapex);	\
+      if (INTERNAL_SYSCALL_ERROR_P (_r))				\
 	_ftrapex = 0;							\
     }									\
   while (0)
diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h
index c2f1bd3c63..3c687a717a 100644
--- a/sysdeps/unix/sysdep.h
+++ b/sysdeps/unix/sysdep.h
@@ -28,24 +28,24 @@
 #define __SYSCALL_CONCAT(a,b)       __SYSCALL_CONCAT_X (a, b)
 
 
-#define __INTERNAL_SYSCALL0(name, err) \
-  INTERNAL_SYSCALL (name, err, 0)
-#define __INTERNAL_SYSCALL1(name, err, a1) \
-  INTERNAL_SYSCALL (name, err, 1, a1)
-#define __INTERNAL_SYSCALL2(name, err, a1, a2) \
-  INTERNAL_SYSCALL (name, err, 2, a1, a2)
-#define __INTERNAL_SYSCALL3(name, err, a1, a2, a3) \
-  INTERNAL_SYSCALL (name, err, 3, a1, a2, a3)
-#define __INTERNAL_SYSCALL4(name, err, a1, a2, a3, a4) \
-  INTERNAL_SYSCALL (name, err, 4, a1, a2, a3, a4)
-#define __INTERNAL_SYSCALL5(name, err, a1, a2, a3, a4, a5) \
-  INTERNAL_SYSCALL (name, err, 5, a1, a2, a3, a4, a5)
-#define __INTERNAL_SYSCALL6(name, err, a1, a2, a3, a4, a5, a6) \
-  INTERNAL_SYSCALL (name, err, 6, a1, a2, a3, a4, a5, a6)
-#define __INTERNAL_SYSCALL7(name, err, a1, a2, a3, a4, a5, a6, a7) \
-  INTERNAL_SYSCALL (name, err, 7, a1, a2, a3, a4, a5, a6, a7)
-
-#define __INTERNAL_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,o,...) o
+#define __INTERNAL_SYSCALL0(name) \
+  INTERNAL_SYSCALL (name, 0)
+#define __INTERNAL_SYSCALL1(name, a1) \
+  INTERNAL_SYSCALL (name, 1, a1)
+#define __INTERNAL_SYSCALL2(name, a1, a2) \
+  INTERNAL_SYSCALL (name, 2, a1, a2)
+#define __INTERNAL_SYSCALL3(name, a1, a2, a3) \
+  INTERNAL_SYSCALL (name, 3, a1, a2, a3)
+#define __INTERNAL_SYSCALL4(name, a1, a2, a3, a4) \
+  INTERNAL_SYSCALL (name, 4, a1, a2, a3, a4)
+#define __INTERNAL_SYSCALL5(name, a1, a2, a3, a4, a5) \
+  INTERNAL_SYSCALL (name, 5, a1, a2, a3, a4, a5)
+#define __INTERNAL_SYSCALL6(name, a1, a2, a3, a4, a5, a6) \
+  INTERNAL_SYSCALL (name, 6, a1, a2, a3, a4, a5, a6)
+#define __INTERNAL_SYSCALL7(name, a1, a2, a3, a4, a5, a6, a7) \
+  INTERNAL_SYSCALL (name, 7, a1, a2, a3, a4, a5, a6, a7)
+
+#define __INTERNAL_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
 #define __INTERNAL_SYSCALL_NARGS(...) \
   __INTERNAL_SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
 #define __INTERNAL_SYSCALL_DISP(b,...) \
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index 79fa0bda27..319a7c7ac5 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -171,7 +171,7 @@
 # define SINGLE_THREAD_BY_GLOBAL		1
 
 # undef INTERNAL_SYSCALL_RAW
-# define INTERNAL_SYSCALL_RAW(name, err, nr, args...)		\
+# define INTERNAL_SYSCALL_RAW(name, nr, args...)		\
   ({ long _sys_result;						\
      {								\
        LOAD_ARGS_##nr (args)					\
@@ -183,12 +183,12 @@
      _sys_result; })
 
 # undef INTERNAL_SYSCALL
-# define INTERNAL_SYSCALL(name, err, nr, args...)		\
-	INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
+# define INTERNAL_SYSCALL(name, nr, args...)			\
+	INTERNAL_SYSCALL_RAW(SYS_ify(name), nr, args)
 
 # undef INTERNAL_SYSCALL_AARCH64
-# define INTERNAL_SYSCALL_AARCH64(name, err, nr, args...)	\
-	INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args)
+# define INTERNAL_SYSCALL_AARCH64(name, nr, args...)		\
+	INTERNAL_SYSCALL_RAW(__ARM_NR_##name, nr, args)
 
 # define LOAD_ARGS_0()				\
   register long _x0 asm ("x0");
@@ -231,8 +231,8 @@
 # define ASM_ARGS_7	ASM_ARGS_6, "r" (_x6)
 
 # undef INTERNAL_SYSCALL_NCS
-# define INTERNAL_SYSCALL_NCS(number, err, nr, args...)	\
-	INTERNAL_SYSCALL_RAW (number, err, nr, args)
+# define INTERNAL_SYSCALL_NCS(number, nr, args...)	\
+	INTERNAL_SYSCALL_RAW (number, nr, args)
 
 #endif	/* __ASSEMBLER__ */
 
diff --git a/sysdeps/unix/sysv/linux/aio_misc.h b/sysdeps/unix/sysv/linux/aio_misc.h
index 42849ab74c..7c8f6144a6 100644
--- a/sysdeps/unix/sysv/linux/aio_misc.h
+++ b/sysdeps/unix/sysv/linux/aio_misc.h
@@ -31,8 +31,7 @@ __aio_start_notify_thread (void)
 {
   sigset_t ss;
   sigemptyset (&ss);
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, &ss, NULL, _NSIG / 8);
 }
 
 extern inline int
@@ -53,13 +52,12 @@ __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
   sigset_t ss;
   sigset_t oss;
   sigfillset (&ss);
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
+  INTERNAL_SYSCALL (rt_sigprocmask, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
 
   int ret = pthread_create (threadp, &attr, tf, arg);
 
   /* Restore the signal mask.  */
-  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL,
+  INTERNAL_SYSCALL (rt_sigprocmask, 4, SIG_SETMASK, &oss, NULL,
 		    _NSIG / 8);
 
   (void) pthread_attr_destroy (&attr);
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat.c b/sysdeps/unix/sysv/linux/alpha/fxstat.c
index d10e0ac2de..0978610bf0 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstat.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstat.c
@@ -33,23 +33,22 @@
 int
 __fxstat (int vers, int fd, struct stat *buf)
 {
-  INTERNAL_SYSCALL_DECL (err);
   int result;
   struct kernel_stat kbuf;
 
   if (vers == _STAT_VER_KERNEL64)
     {
-      result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
-      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+      result = INTERNAL_SYSCALL_CALL (fstat64, fd, buf);
+      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
 	return result;
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
       return -1;
     }
 
-  result = INTERNAL_SYSCALL (fstat, err, 2, fd, &kbuf);
-  if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  result = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
+  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
     return __xstat_conv (vers, &kbuf, buf);
-  __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
   return -1;
 }
 hidden_def (__fxstat)
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat.c b/sysdeps/unix/sysv/linux/alpha/fxstatat.c
index 4d2815ade0..c5953d250a 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstatat.c
@@ -33,7 +33,6 @@
 int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
-  INTERNAL_SYSCALL_DECL (err);
   int result, errno_out;
 
   /* ??? The __fxstatat entry point is new enough that it must be using
@@ -41,10 +40,10 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
      cannot actually check this, lest the compiler not optimize the rest
      of the function away.  */
 
-  result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, st, flag);
-  if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
     return result;
-  errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+  errno_out = INTERNAL_SYSCALL_ERRNO (result);
   __set_errno (errno_out);
   return -1;
 }
diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat.c b/sysdeps/unix/sysv/linux/alpha/lxstat.c
index bb2baf0ad9..eb03a5fbfe 100644
--- a/sysdeps/unix/sysv/linux/alpha/lxstat.c
+++ b/sysdeps/unix/sysv/linux/alpha/lxstat.c
@@ -33,23 +33,22 @@
 int
 __lxstat (int vers, const char *name, struct stat *buf)
 {
-  INTERNAL_SYSCALL_DECL (err);
   int result;
   struct kernel_stat kbuf;
 
   if (vers == _STAT_VER_KERNEL64)
     {
-      result = INTERNAL_SYSCALL (lstat64, err, 2, name, buf);
-      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+      result = INTERNAL_SYSCALL_CALL (lstat64, name, buf);
+      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
 	return result;
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
       return -1;
     }
 
-  result = INTERNAL_SYSCALL (lstat, err, 2, name, &kbuf);
-  if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  result = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
+  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
     return __xstat_conv (vers, &kbuf, buf);
-  __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
   return -1;
 }
 hidden_def (__lxstat)
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h
index 679d6169de..5ec73084c1 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h
@@ -169,10 +169,10 @@ __LABEL(name)						\
 
 #else /* !ASSEMBLER */
 
-#define INTERNAL_SYSCALL(name, err_out, nr, args...) \
+#define INTERNAL_SYSCALL(name, nr, args...) \
 	internal_syscall##nr(__NR_##name, args)
 
-#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
 	internal_syscall##nr(name, args)
 
 /* The normal Alpha calling convention sign-extends 32-bit quantties
diff --git a/sysdeps/unix/sysv/linux/alpha/xstat.c b/sysdeps/unix/sysv/linux/alpha/xstat.c
index aa45c7df69..3ba1ae1811 100644
--- a/sysdeps/unix/sysv/linux/alpha/xstat.c
+++ b/sysdeps/unix/sysv/linux/alpha/xstat.c
@@ -33,23 +33,22 @@
 int
 __xstat (int vers, const char *name, struct stat *buf)
 {
-  INTERNAL_SYSCALL_DECL (err);
   int result;
   struct kernel_stat kbuf;
 
   if (vers == _STAT_VER_KERNEL64)
     {
-      result = INTERNAL_SYSCALL (stat64, err, 2, name, buf);
-      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+      result = INTERNAL_SYSCALL_CALL (stat64, name, buf);
+      if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
 	return result;
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
       return -1;
     }
 
-  result = INTERNAL_SYSCALL (stat, err, 2, name, &kbuf);
-  if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  result = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
+  if (__glibc_likely (!INTERNAL_SYSCALL_ERROR_P (result)))
     return __xstat_conv (vers, &kbuf, buf);
-  __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+  __set_errno (INTERNAL_SYSCALL_ERRNO (result));
   return -1;
 }
 hidden_def (__xstat)
diff --git a/sysdeps/unix/sysv/linux/arm/dl-machine.h b/sysdeps/unix/sysv/linux/arm/dl-machine.h
index 5fc685fdaf..a307326e9c 100644
--- a/sysdeps/unix/sysv/linux/arm/dl-machine.h
+++ b/sysdeps/unix/sysv/linux/arm/dl-machine.h
@@ -20,7 +20,7 @@
 
 /* This definition is Linux-specific.  */
 #define CLEAR_CACHE(BEG,END)                                            \
-  INTERNAL_SYSCALL (cacheflush, , 3, (BEG), (END), 0)
+  INTERNAL_SYSCALL_CALL (cacheflush, (BEG), (END), 0)
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index f6e6b63959..e2985cffd7 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -328,7 +328,7 @@ __local_syscall_error:						\
    then unwinding will fail higher up the stack.  So we move the
    syscall out of line and provide its own unwind information.  */
 # undef INTERNAL_SYSCALL_RAW
-# define INTERNAL_SYSCALL_RAW(name, err, nr, args...)		\
+# define INTERNAL_SYSCALL_RAW(name, nr, args...)		\
   ({								\
       register int _a1 asm ("a1");				\
       int _nametmp = name;					\
@@ -341,7 +341,7 @@ __local_syscall_error:						\
       _a1; })
 #else /* ARM */
 # undef INTERNAL_SYSCALL_RAW
-# define INTERNAL_SYSCALL_RAW(name, err, nr, args...)		\
+# define INTERNAL_SYSCALL_RAW(name, nr, args...)		\
   ({								\
        register int _a1 asm ("r0"), _nr asm ("r7");		\
        LOAD_ARGS_##nr (args)					\
@@ -354,8 +354,8 @@ __local_syscall_error:						\
 #endif
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)		\
-	INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
+#define INTERNAL_SYSCALL(name, nr, args...)			\
+	INTERNAL_SYSCALL_RAW(SYS_ify(name), nr, args)
 
 #define VDSO_NAME  "LINUX_2.6"
 #define VDSO_HASH  61765110
@@ -407,8 +407,8 @@ __local_syscall_error:						\
 
 /* For EABI, non-constant syscalls are actually pretty easy...  */
 #undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(number, err, nr, args...)          \
-  INTERNAL_SYSCALL_RAW (number, err, nr, args)
+#define INTERNAL_SYSCALL_NCS(number, nr, args...)              \
+  INTERNAL_SYSCALL_RAW (number, nr, args)
 
 #define SINGLE_THREAD_BY_GLOBAL	1
 
diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h
index 18afe244d7..1b520c6802 100644
--- a/sysdeps/unix/sysv/linux/arm/tls.h
+++ b/sysdeps/unix/sysv/linux/arm/tls.h
@@ -31,10 +31,9 @@
    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_DECL (err);					\
-     long int result_var;						\
-     result_var = INTERNAL_SYSCALL (set_tls, err, 1, (tcbp));		\
-     INTERNAL_SYSCALL_ERROR_P (result_var, err)				\
+  ({ long int result_var;						\
+     result_var = INTERNAL_SYSCALL_CALL (set_tls, 1, (tcbp));		\
+     INTERNAL_SYSCALL_ERROR_P (result_var)				\
        ? "unknown error" : NULL; })
 
 #endif /* __ASSEMBLER__ */
diff --git a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c
index 97fa9cc496..be1f477187 100644
--- a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c
+++ b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c
@@ -30,21 +30,20 @@ __clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
 
   const clockid_t pidclock = MAKE_PROCESS_CPUCLOCK (pid, CPUCLOCK_SCHED);
 
-  INTERNAL_SYSCALL_DECL (err);
-  int r = INTERNAL_SYSCALL (clock_getres, err, 2, pidclock, NULL);
-  if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+  int r = INTERNAL_SYSCALL_CALL (clock_getres, pidclock, NULL);
+  if (!INTERNAL_SYSCALL_ERROR_P (r))
     {
       *clock_id = pidclock;
       return 0;
     }
 
-  if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
+  if (INTERNAL_SYSCALL_ERRNO (r) == EINVAL)
     {
       /* The clock_getres system call checked the PID for us.  */
       return ESRCH;
     }
   else
-    return INTERNAL_SYSCALL_ERRNO (r, err);
+    return INTERNAL_SYSCALL_ERRNO (r);
 }
 
 versioned_symbol (libc, __clock_getcpuclockid, clock_getcpuclockid, GLIBC_2_17);
diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 728137aa56..48175ef1da 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -39,23 +39,21 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
 
   /* If the call is interrupted by a signal handler or encounters an error,
      it returns a positive value similar to errno.  */
-  INTERNAL_SYSCALL_DECL (err);
-
 #ifdef __ASSUME_TIME64_SYSCALLS
 # ifndef __NR_clock_nanosleep_time64
 #  define __NR_clock_nanosleep_time64 __NR_clock_nanosleep
 # endif
-  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, err, clock_id,
+  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id,
                                flags, req, rem);
 #else
 # ifdef __NR_clock_nanosleep_time64
-  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, err, clock_id,
+  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id,
                                flags, req, rem);
 
-  if (! INTERNAL_SYSCALL_ERROR_P (r, err))
+  if (! INTERNAL_SYSCALL_ERROR_P (r))
     return 0;
-  if (INTERNAL_SYSCALL_ERRNO (r, err) != ENOSYS)
-    return INTERNAL_SYSCALL_ERRNO (r, err);
+  if (INTERNAL_SYSCALL_ERRNO (r) != ENOSYS)
+    return INTERNAL_SYSCALL_ERRNO (r);
 # endif /* __NR_clock_nanosleep_time64 */
 
   if (! in_time_t_range (req->tv_sec))
@@ -66,18 +64,18 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
 
   struct timespec tr32;
   struct timespec ts32 = valid_timespec64_to_timespec (*req);
-  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags,
+  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, clock_id, flags,
                                &ts32, &tr32);
-  if (INTERNAL_SYSCALL_ERROR_P (r, err))
+  if (INTERNAL_SYSCALL_ERROR_P (r))
     {
-      if (INTERNAL_SYSCALL_ERRNO (r, err) == EINTR && rem != NULL
+      if (INTERNAL_SYSCALL_ERRNO (r) == EINTR && rem != NULL
 	  && (flags & TIMER_ABSTIME) == 0)
 	*rem = valid_timespec_to_timespec64 (tr32);
     }
 #endif /* __ASSUME_TIME64_SYSCALLS */
 
-  return (INTERNAL_SYSCALL_ERROR_P (r, err)
-	  ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
+  return (INTERNAL_SYSCALL_ERROR_P (r)
+	  ? INTERNAL_SYSCALL_ERRNO (r) : 0);
 }
 
 #if __TIMESIZE != 64
diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c
index 33e5f5dbbb..21f9d24f2d 100644
--- a/sysdeps/unix/sysv/linux/createthread.c
+++ b/sysdeps/unix/sysv/linux/createthread.c
@@ -110,7 +110,6 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
   /* Now we have the possibility to set scheduling parameters etc.  */
   if (attr != NULL)
     {
-      INTERNAL_SYSCALL_DECL (err);
       int res;
 
       /* Set the affinity mask if necessary.  */
@@ -118,21 +117,19 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
 	{
 	  assert (*stopped_start);
 
-	  res = INTERNAL_SYSCALL (sched_setaffinity, err, 3, pd->tid,
-				  attr->cpusetsize, attr->cpuset);
+	  res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid,
+				       attr->cpusetsize, attr->cpuset);
 
-	  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err)))
+	  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res)))
 	  err_out:
 	    {
 	      /* The operation failed.  We have to kill the thread.
 		 We let the normal cancellation mechanism do the work.  */
 
 	      pid_t pid = __getpid ();
-	      INTERNAL_SYSCALL_DECL (err2);
-	      (void) INTERNAL_SYSCALL_CALL (tgkill, err2, pid, pd->tid,
-					    SIGCANCEL);
+	      INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid, SIGCANCEL);
 
-	      return INTERNAL_SYSCALL_ERRNO (res, err);
+	      return INTERNAL_SYSCALL_ERRNO (res);
 	    }
 	}
 
@@ -141,10 +138,10 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
 	{
 	  assert (*stopped_start);
 
-	  res = INTERNAL_SYSCALL (sched_setscheduler, err, 3, pd->tid,
-				  pd->schedpolicy, &pd->schedparam);
+	  res = INTERNAL_SYSCALL_CALL (sched_setscheduler, pd->tid,
+				       pd->schedpolicy, &pd->schedparam);
 
-	  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err)))
+	  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res)))
 	    goto err_out;
 	}
     }
diff --git a/sysdeps/unix/sysv/linux/csky/sysdep.h b/sysdeps/unix/sysv/linux/csky/sysdep.h
index 7ebb19dce8..7e8e89dd42 100644
--- a/sysdeps/unix/sysv/linux/csky/sysdep.h
+++ b/sysdeps/unix/sysv/linux/csky/sysdep.h
@@ -294,7 +294,7 @@ __local_syscall_error:				\
 #else /* not __ASSEMBLER__ */
 
 # undef INTERNAL_SYSCALL_RAW
-#  define INTERNAL_SYSCALL_RAW0(name, err, dummy...)			\
+#  define INTERNAL_SYSCALL_RAW0(name, dummy...)				\
   ({unsigned int __sys_result;						\
      {									\
        register int _a1 __asm__ ("a0"), _nr __asm__ ("r7");		\
@@ -307,7 +307,7 @@ __local_syscall_error:				\
      }									\
      (int) __sys_result; })
 
-#  define INTERNAL_SYSCALL_RAW1(name, err, arg1)			\
+#  define INTERNAL_SYSCALL_RAW1(name, arg1)				\
   ({unsigned int __sys_result;						\
     register int _tmp_arg1 = (int)(arg1);				\
      {									\
@@ -322,7 +322,7 @@ __local_syscall_error:				\
      }									\
      (int) __sys_result; })
 
-#  define INTERNAL_SYSCALL_RAW2(name, err, arg1, arg2)			\
+#  define INTERNAL_SYSCALL_RAW2(name, arg1, arg2)			\
   ({unsigned int __sys_result;						\
     register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2);	\
      {									\
@@ -338,7 +338,7 @@ __local_syscall_error:				\
      }									\
      (int) __sys_result; })
 
-#  define INTERNAL_SYSCALL_RAW3(name, err, arg1, arg2, arg3)		\
+#  define INTERNAL_SYSCALL_RAW3(name, arg1, arg2, arg3)			\
   ({unsigned int __sys_result;						\
     register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2);	\
     register int _tmp_arg3 = (int)(arg3);				\
@@ -359,7 +359,7 @@ __local_syscall_error:				\
      }									\
      (int) __sys_result; })
 
-#  define INTERNAL_SYSCALL_RAW4(name, err, arg1, arg2, arg3, arg4)	\
+#  define INTERNAL_SYSCALL_RAW4(name, arg1, arg2, arg3, arg4)		\
   ({unsigned int __sys_result;						\
     register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2);	\
     register int _tmp_arg3 = (int)(arg3), _tmp_arg4 = (int)(arg4);	\
@@ -379,7 +379,7 @@ __local_syscall_error:				\
      }									\
      (int) __sys_result; })
 
-#  define INTERNAL_SYSCALL_RAW5(name, err, arg1, arg2, arg3, arg4,	\
+#  define INTERNAL_SYSCALL_RAW5(name, arg1, arg2, arg3, arg4,		\
 			      arg5)					\
   ({unsigned int __sys_result;						\
     register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2);	\
@@ -402,7 +402,7 @@ __local_syscall_error:				\
      }									\
      (int) __sys_result; })
 
-#  define INTERNAL_SYSCALL_RAW6(name, err, arg1, arg2, arg3, arg4,	\
+#  define INTERNAL_SYSCALL_RAW6(name, arg1, arg2, arg3, arg4,		\
 			      arg5, arg6)				\
   ({unsigned int __sys_result;						\
     register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2);	\
@@ -426,7 +426,7 @@ __local_syscall_error:				\
      }									\
      (int) __sys_result; })
 
-#  define INTERNAL_SYSCALL_RAW7(name, err, arg1, arg2, arg3, arg4,	\
+#  define INTERNAL_SYSCALL_RAW7(name, arg1, arg2, arg3, arg4,		\
 			      arg5, arg6, arg7)				\
   ({unsigned int __sys_result;						\
     register int _tmp_arg1 = (int)(arg1), _tmp_arg2 = (int)(arg2);	\
@@ -454,12 +454,12 @@ __local_syscall_error:				\
      (int) __sys_result; })
 
 # undef INTERNAL_SYSCALL
-# define INTERNAL_SYSCALL(name, err, nr, args...)		\
-  INTERNAL_SYSCALL_RAW##nr(SYS_ify(name), err, args)
+# define INTERNAL_SYSCALL(name, nr, args...)			\
+  INTERNAL_SYSCALL_RAW##nr(SYS_ify(name), args)
 
 # undef INTERNAL_SYSCALL_NCS
-# define INTERNAL_SYSCALL_NCS(number, err, nr, args...)		\
-  INTERNAL_SYSCALL_RAW##nr (number, err, args)
+# define INTERNAL_SYSCALL_NCS(number, nr, args...)		\
+  INTERNAL_SYSCALL_RAW##nr (number, args)
 
 #endif /* __ASSEMBLER__ */
 
diff --git a/sysdeps/unix/sysv/linux/default-sched.h b/sysdeps/unix/sysv/linux/default-sched.h
index 26fe9ec6e6..6db3e3ba46 100644
--- a/sysdeps/unix/sysv/linux/default-sched.h
+++ b/sysdeps/unix/sysv/linux/default-sched.h
@@ -26,17 +26,15 @@
 static void
 collect_default_sched (struct pthread *pd)
 {
-  INTERNAL_SYSCALL_DECL (scerr);
-
   if ((pd->flags & ATTR_FLAG_POLICY_SET) == 0)
     {
-      pd->schedpolicy = INTERNAL_SYSCALL (sched_getscheduler, scerr, 1, 0);
+      pd->schedpolicy = INTERNAL_SYSCALL_CALL (sched_getscheduler, 0);
       pd->flags |= ATTR_FLAG_POLICY_SET;
     }
 
   if ((pd->flags & ATTR_FLAG_SCHED_SET) == 0)
     {
-      INTERNAL_SYSCALL (sched_getparam, scerr, 2, 0, &pd->schedparam);
+      INTERNAL_SYSCALL_CALL (sched_getparam, 0, &pd->schedparam);
       pd->flags |= ATTR_FLAG_SCHED_SET;
     }
 }
diff --git a/sysdeps/unix/sysv/linux/dl-origin.c b/sysdeps/unix/sysv/linux/dl-origin.c
index 74c8ff142b..515ed6fc8c 100644
--- a/sysdeps/unix/sysv/linux/dl-origin.c
+++ b/sysdeps/unix/sysv/linux/dl-origin.c
@@ -37,11 +37,10 @@ _dl_get_origin (void)
   char linkval[PATH_MAX];
   char *result;
   int len;
-  INTERNAL_SYSCALL_DECL (err);
 
-  len = INTERNAL_SYSCALL (readlink, err, 3, "/proc/self/exe", linkval,
-			  sizeof (linkval));
-  if (! INTERNAL_SYSCALL_ERROR_P (len, err) && len > 0 && linkval[0] != '[')
+  len = INTERNAL_SYSCALL_CALL (readlink, "/proc/self/exe", linkval,
+			       sizeof (linkval));
+  if (! INTERNAL_SYSCALL_ERROR_P (len) && len > 0 && linkval[0] != '[')
     {
       /* We can use this value.  */
       assert (linkval[0] == '/');
diff --git a/sysdeps/unix/sysv/linux/dl-writev.h b/sysdeps/unix/sysv/linux/dl-writev.h
index c04d1a74a8..3dd8376385 100644
--- a/sysdeps/unix/sysv/linux/dl-writev.h
+++ b/sysdeps/unix/sysv/linux/dl-writev.h
@@ -33,6 +33,5 @@
 static inline void
 _dl_writev (int fd, const struct iovec *iov, size_t niov)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (writev, err, 3, fd, iov, niov);
+  INTERNAL_SYSCALL_CALL (writev, fd, iov, niov);
 }
diff --git a/sysdeps/unix/sysv/linux/exit-thread.h b/sysdeps/unix/sysv/linux/exit-thread.h
index 083e4620d9..d617594bfd 100644
--- a/sysdeps/unix/sysv/linux/exit-thread.h
+++ b/sysdeps/unix/sysv/linux/exit-thread.h
@@ -32,7 +32,6 @@ __exit_thread (void)
      of the caller and doing unexpectedly strange things.  */
   while (1)
     {
-      INTERNAL_SYSCALL_DECL (err);
-      INTERNAL_SYSCALL (exit, err, 1, 0);
+      INTERNAL_SYSCALL_CALL (exit, 0);
     }
 }
diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
index bafc1cff5f..ed9211001f 100644
--- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c
+++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c
@@ -51,14 +51,13 @@ __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg)
 {
   if (cmd == F_GETOWN)
     {
-      INTERNAL_SYSCALL_DECL (err);
       struct f_owner_ex fex;
-      int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex);
-      if (!INTERNAL_SYSCALL_ERROR_P (res, err))
+      int res = INTERNAL_SYSCALL_CALL (fcntl64, fd, F_GETOWN_EX, &fex);
+      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, err));
+        (INTERNAL_SYSCALL_ERRNO (res));
     }
 
   return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg);
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index 524d5a6df6..3eb898e322 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -37,15 +37,14 @@ int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
   int result;
-  INTERNAL_SYSCALL_DECL (err);
 #ifdef STAT_IS_KERNEL_STAT
 # define kst (*st)
 #else
   struct kernel_stat kst;
 #endif
 
-  result = INTERNAL_SYSCALL (newfstatat, err, 4, fd, file, &kst, flag);
-  if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  result = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
     {
 #ifdef STAT_IS_KERNEL_STAT
       return 0;
@@ -53,9 +52,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       return __xstat_conv (vers, &kst, st);
 #endif
     }
-  else
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
-								      err));
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
 }
 libc_hidden_def (__fxstatat)
 #if XSTAT_IS_XSTAT64
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index c0f1035652..e24b456604 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -37,22 +37,19 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
   int result;
-  INTERNAL_SYSCALL_DECL (err);
 
 #ifdef __NR_fstatat64
-  result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, st, flag);
+  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, st, flag);
 #else
   struct statx tmp;
 
-  result = INTERNAL_SYSCALL (statx, err, 5, fd, file, AT_NO_AUTOMOUNT | flag,
-                             STATX_BASIC_STATS, &tmp);
+  result = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag,
+				  STATX_BASIC_STATS, &tmp);
   if (result == 0)
     __cp_stat64_statx (st, &tmp);
 #endif
-  if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  if (!__glibc_likely (INTERNAL_SYSCALL_ERROR_P (result)))
     return 0;
-  else
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
-								      err));
+  return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
 }
 libc_hidden_def (__fxstatat64)
diff --git a/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c b/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c
index 634101a1cd..9be49ad91c 100644
--- a/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/generic/____longjmp_chk.c
@@ -36,7 +36,6 @@ void ____longjmp_chk (__jmp_buf env, int val)
 {
   void *this_frame = __builtin_frame_address (0);
   void *saved_frame = JB_FRAME_ADDRESS (env);
-  INTERNAL_SYSCALL_DECL (err);
   stack_t ss;
 
   /* If "env" is from a frame that called us, we're all set.  */
@@ -44,7 +43,7 @@ void ____longjmp_chk (__jmp_buf env, int val)
     __longjmp (env, val);
 
   /* If we can't get the current stack state, give up and do the longjmp. */
-  if (INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &ss) != 0)
+  if (INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &ss) != 0)
     __longjmp (env, val);
 
   /* If we we are executing on the alternate stack and within the
diff --git a/sysdeps/unix/sysv/linux/generic/brk.c b/sysdeps/unix/sysv/linux/generic/brk.c
index 2bfe5f2e39..40a80ab970 100644
--- a/sysdeps/unix/sysv/linux/generic/brk.c
+++ b/sysdeps/unix/sysv/linux/generic/brk.c
@@ -31,9 +31,7 @@ weak_alias (__curbrk, ___brk_addr)
 int
 __brk (void *addr)
 {
-  INTERNAL_SYSCALL_DECL (err);
-
-  __curbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
+  __curbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);
   if (__curbrk < addr)
     {
       __set_errno (ENOMEM);
diff --git a/sysdeps/unix/sysv/linux/generic/dl-origin.c b/sysdeps/unix/sysv/linux/generic/dl-origin.c
index 9d3c639a7c..1ab02bbf10 100644
--- a/sysdeps/unix/sysv/linux/generic/dl-origin.c
+++ b/sysdeps/unix/sysv/linux/generic/dl-origin.c
@@ -38,11 +38,10 @@ _dl_get_origin (void)
   char linkval[PATH_MAX];
   char *result;
   int len;
-  INTERNAL_SYSCALL_DECL (err);
 
-  len = INTERNAL_SYSCALL (readlinkat, err, 4, AT_FDCWD, "/proc/self/exe",
-                          linkval, sizeof (linkval));
-  if (! INTERNAL_SYSCALL_ERROR_P (len, err) && len > 0 && linkval[0] != '[')
+  len = INTERNAL_SYSCALL_CALL (readlinkat, AT_FDCWD, "/proc/self/exe",
+			       linkval, sizeof (linkval));
+  if (! INTERNAL_SYSCALL_ERROR_P (len) && 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 d77db64a54..eae0a7fe31 100644
--- a/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
@@ -28,15 +28,14 @@
     if ((unsigned long) (sp) > this_sp)					\
       {									\
         stack_t oss;							\
-        INTERNAL_SYSCALL_DECL (err);					\
-        int result = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss);\
+        int result = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss);\
 	/* If we aren't using an alternate stack then we have already	\
 	   shown that we are jumping to a frame that doesn't exist so	\
 	   error out. If we are using an alternate stack we must prove	\
 	   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, err)			\
+        if (!INTERNAL_SYSCALL_ERROR_P (result)				\
             && ((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/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h
index 88e368db4d..7f8da30d23 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep.h
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h
@@ -362,7 +362,7 @@ L(pre_end):					ASM_LINE_SEP	\
 
 /* Similar to INLINE_SYSCALL but we don't set errno */
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)			\
+#define INTERNAL_SYSCALL(name, nr, args...)				\
 ({									\
 	long __sys_res;							\
 	{								\
@@ -388,7 +388,7 @@ L(pre_end):					ASM_LINE_SEP	\
 
 /* The _NCS variant allows non-constant syscall numbers.  */
 #undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...)			\
+#define INTERNAL_SYSCALL_NCS(name, nr, args...)				\
 ({									\
 	long __sys_res;							\
 	{								\
diff --git a/sysdeps/unix/sysv/linux/i386/brk.c b/sysdeps/unix/sysv/linux/i386/brk.c
index b0e5b0f85c..021b6d37a0 100644
--- a/sysdeps/unix/sysv/linux/i386/brk.c
+++ b/sysdeps/unix/sysv/linux/i386/brk.c
@@ -36,8 +36,7 @@ weak_alias (__curbrk, ___brk_addr)
 int
 __brk (void *addr)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  void *newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
+  void *newbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);
   __curbrk = newbrk;
   if (newbrk < addr)
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOMEM);
diff --git a/sysdeps/unix/sysv/linux/i386/fxstat.c b/sysdeps/unix/sysv/linux/i386/fxstat.c
index 8eda42f2e6..db59baa71b 100644
--- a/sysdeps/unix/sysv/linux/i386/fxstat.c
+++ b/sysdeps/unix/sysv/linux/i386/fxstat.c
@@ -42,11 +42,9 @@ __fxstat (int vers, int fd, struct stat *buf)
   {
     struct stat64 buf64;
 
-    INTERNAL_SYSCALL_DECL (err);
-    result = INTERNAL_SYSCALL (fstat64, err, 2, fd, &buf64);
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
-      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
-									err));
+    result = INTERNAL_SYSCALL_CALL (fstat64, fd, &buf64);
+    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
+      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
     else
       return __xstat32_conv (vers, &buf64, buf);
   }
diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c b/sysdeps/unix/sysv/linux/i386/fxstatat.c
index d510d7463d..f720f6e429 100644
--- a/sysdeps/unix/sysv/linux/i386/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/i386/fxstatat.c
@@ -38,13 +38,11 @@ int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
   int result;
-  INTERNAL_SYSCALL_DECL (err);
   struct stat64 st64;
 
-  result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, &st64, flag);
-  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
-								      err));
+  result = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, &st64, flag);
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
   else
     return __xstat32_conv (vers, &st64, st);
 }
diff --git a/sysdeps/unix/sysv/linux/i386/lxstat.c b/sysdeps/unix/sysv/linux/i386/lxstat.c
index e6f8e0fbca..e960077893 100644
--- a/sysdeps/unix/sysv/linux/i386/lxstat.c
+++ b/sysdeps/unix/sysv/linux/i386/lxstat.c
@@ -43,11 +43,9 @@ __lxstat (int vers, const char *name, struct stat *buf)
   {
     struct stat64 buf64;
 
-    INTERNAL_SYSCALL_DECL (err);
-    result = INTERNAL_SYSCALL (lstat64, err, 2, name, &buf64);
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
-      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
-									err));
+    result = INTERNAL_SYSCALL_CALL (lstat64, name, &buf64);
+    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
+      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
     else
       return __xstat32_conv (vers, &buf64, buf);
   }
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index d975683749..62d9119e64 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -299,25 +299,25 @@ struct libc_do_syscall_args
    The _NCS variant allows non-constant syscall numbers but it is not
    possible to use more than four parameters.  */
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL_MAIN_0(name, err, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, err, 0, args)
-#define INTERNAL_SYSCALL_MAIN_1(name, err, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, err, 1, args)
-#define INTERNAL_SYSCALL_MAIN_2(name, err, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, err, 2, args)
-#define INTERNAL_SYSCALL_MAIN_3(name, err, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, err, 3, args)
-#define INTERNAL_SYSCALL_MAIN_4(name, err, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, err, 4, args)
-#define INTERNAL_SYSCALL_MAIN_5(name, err, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
+#define INTERNAL_SYSCALL_MAIN_0(name, args...) \
+    INTERNAL_SYSCALL_MAIN_INLINE(name, 0, args)
+#define INTERNAL_SYSCALL_MAIN_1(name, args...) \
+    INTERNAL_SYSCALL_MAIN_INLINE(name, 1, args)
+#define INTERNAL_SYSCALL_MAIN_2(name, args...) \
+    INTERNAL_SYSCALL_MAIN_INLINE(name, 2, args)
+#define INTERNAL_SYSCALL_MAIN_3(name, args...) \
+    INTERNAL_SYSCALL_MAIN_INLINE(name, 3, args)
+#define INTERNAL_SYSCALL_MAIN_4(name, args...) \
+    INTERNAL_SYSCALL_MAIN_INLINE(name, 4, args)
+#define INTERNAL_SYSCALL_MAIN_5(name, args...) \
+    INTERNAL_SYSCALL_MAIN_INLINE(name, 5, args)
 /* Each object using 6-argument inline syscalls must include a
    definition of __libc_do_syscall.  */
 #ifdef OPTIMIZE_FOR_GCC_5
-# define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
-    INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args)
+# define INTERNAL_SYSCALL_MAIN_6(name, args...) \
+    INTERNAL_SYSCALL_MAIN_INLINE(name, 6, args)
 #else /* GCC 5  */
-# define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3,		\
+# define INTERNAL_SYSCALL_MAIN_6(name, arg1, arg2, arg3,		\
 				 arg4, arg5, arg6)			\
   struct libc_do_syscall_args _xv =					\
     {									\
@@ -332,22 +332,22 @@ struct libc_do_syscall_args
     : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
     : "memory", "cc")
 #endif /* GCC 5  */
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL(name, nr, args...) \
   ({									      \
     register unsigned int resultvar;					      \
-    INTERNAL_SYSCALL_MAIN_##nr (name, err, args);			      \
+    INTERNAL_SYSCALL_MAIN_##nr (name, args);			      	      \
     (int) resultvar; })
 #if I386_USE_SYSENTER
 # ifdef OPTIMIZE_FOR_GCC_5
 #  ifdef PIC
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *%%gs:%P2"							\
     : "=a" (resultvar)							\
     : "a" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo))		\
       ASMARGS_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									\
     register unsigned int resultvar;					\
     LOADREGS_##nr(args)							\
@@ -358,13 +358,13 @@ struct libc_do_syscall_args
       ASMARGS_##nr(args) : "memory", "cc");				\
     (int) resultvar; })
 #  else
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "call *_dl_sysinfo"							\
     : "=a" (resultvar)							\
     : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									\
     register unsigned int resultvar;					\
     LOADREGS_##nr(args)							\
@@ -376,7 +376,7 @@ struct libc_do_syscall_args
 #  endif
 # else /* GCC 5  */
 #  ifdef PIC
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     EXTRAVAR_##nr							      \
     asm volatile (							      \
     LOADARGS_##nr							      \
@@ -386,7 +386,7 @@ struct libc_do_syscall_args
     : "=a" (resultvar)							      \
     : "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo))		      \
       ASMFMT_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									      \
     register unsigned int resultvar;					      \
     EXTRAVAR_##nr							      \
@@ -399,7 +399,7 @@ struct libc_do_syscall_args
       ASMFMT_##nr(args) : "memory", "cc");				      \
     (int) resultvar; })
 #  else
-#   define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     EXTRAVAR_##nr							      \
     asm volatile (							      \
     LOADARGS_##nr							      \
@@ -408,7 +408,7 @@ struct libc_do_syscall_args
     RESTOREARGS_##nr							      \
     : "=a" (resultvar)							      \
     : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-#   define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#   define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									      \
     register unsigned int resultvar;					      \
     EXTRAVAR_##nr							      \
@@ -423,13 +423,13 @@ struct libc_do_syscall_args
 # endif /* GCC 5  */
 #else
 # ifdef OPTIMIZE_FOR_GCC_5
-#  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+#  define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     LOADREGS_##nr(args)							\
     asm volatile (							\
     "int $0x80"								\
     : "=a" (resultvar)							\
     : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
-#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#  define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									\
     register unsigned int resultvar;					\
     LOADREGS_##nr(args)							\
@@ -439,7 +439,7 @@ struct libc_do_syscall_args
     : "a" (name) ASMARGS_##nr(args) : "memory", "cc");			\
     (int) resultvar; })
 # else /* GCC 5  */
-#  define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+#  define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
     EXTRAVAR_##nr							      \
     asm volatile (							      \
     LOADARGS_##nr							      \
@@ -448,7 +448,7 @@ struct libc_do_syscall_args
     RESTOREARGS_##nr							      \
     : "=a" (resultvar)							      \
     : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#  define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									      \
     register unsigned int resultvar;					      \
     EXTRAVAR_##nr							      \
diff --git a/sysdeps/unix/sysv/linux/i386/xstat.c b/sysdeps/unix/sysv/linux/i386/xstat.c
index 3557a91394..96f67168ac 100644
--- a/sysdeps/unix/sysv/linux/i386/xstat.c
+++ b/sysdeps/unix/sysv/linux/i386/xstat.c
@@ -43,11 +43,9 @@ __xstat (int vers, const char *name, struct stat *buf)
   {
     struct stat64 buf64;
 
-    INTERNAL_SYSCALL_DECL (err);
-    result = INTERNAL_SYSCALL (stat64, err, 2, name, &buf64);
-    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
-      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
-									err));
+    result = INTERNAL_SYSCALL_CALL (stat64, name, &buf64);
+    if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
+      return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result));
     else
       return __xstat32_conv (vers, &buf64, buf);
   }
diff --git a/sysdeps/unix/sysv/linux/ia64/__sigstack_longjmp.c b/sysdeps/unix/sysv/linux/ia64/__sigstack_longjmp.c
index 85a8714c4d..6e16651fd0 100644
--- a/sysdeps/unix/sysv/linux/ia64/__sigstack_longjmp.c
+++ b/sysdeps/unix/sysv/linux/ia64/__sigstack_longjmp.c
@@ -112,8 +112,7 @@ __sigstack_longjmp (__jmp_buf buf, int val)
   jb_sp  = ((unsigned long *)  buf)[JB_SP];
   jb_bsp = ((unsigned long **) buf)[JB_BSP];
 
-  INTERNAL_SYSCALL_DECL (err);
-  (void) INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &stk);
+  INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &stk);
 
   ss_sp = (unsigned long) stk.ss_sp;
   jb_rnat_addr = ia64_rse_rnat_addr (jb_bsp);
diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.h b/sysdeps/unix/sysv/linux/ia64/sysdep.h
index fab8ca2359..3d79b8ce82 100644
--- a/sysdeps/unix/sysv/linux/ia64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/ia64/sysdep.h
@@ -191,7 +191,7 @@
 
 #ifdef IA64_USE_NEW_STUB
 
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...)			      \
+# define INTERNAL_SYSCALL_NCS(name, nr, args...)			      \
 ({									      \
     LOAD_ARGS_##nr (args)						      \
     register long _r8 __asm ("r8");					      \
@@ -214,7 +214,7 @@
 
 #else /* !IA64_USE_NEW_STUB */
 
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...)		\
+# define INTERNAL_SYSCALL_NCS(name, nr, args...)		\
 ({								\
     LOAD_ARGS_##nr (args)					\
     register long _r8 asm ("r8");				\
@@ -231,8 +231,8 @@
 
 #endif /* !IA64_USE_NEW_STUB */
 
-#define INTERNAL_SYSCALL(name, err, nr, args...)	\
-  INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
+#define INTERNAL_SYSCALL(name, nr, args...)	\
+  INTERNAL_SYSCALL_NCS (__NR_##name, nr, ##args)
 
 #define LOAD_ARGS_0()
 #define LOAD_REGS_0
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index ccacbfdb16..8ab73a7422 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -244,8 +244,7 @@ void
 __netlink_close (struct netlink_handle *h)
 {
   /* Don't modify errno.  */
-  INTERNAL_SYSCALL_DECL (err);
-  (void) INTERNAL_SYSCALL (close, err, 1, h->fd);
+  INTERNAL_SYSCALL_CALL (close, h->fd);
 }
 
 
diff --git a/sysdeps/unix/sysv/linux/internal-signals.h b/sysdeps/unix/sysv/linux/internal-signals.h
index bc2f23aea4..e958522a07 100644
--- a/sysdeps/unix/sysv/linux/internal-signals.h
+++ b/sysdeps/unix/sysv/linux/internal-signals.h
@@ -62,8 +62,7 @@ static const sigset_t sigall_set = {
 static inline void
 __libc_signal_block_all (sigset_t *set)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL_CALL (rt_sigprocmask, err, SIG_BLOCK, &sigall_set, set,
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_BLOCK, &sigall_set, set,
 			 _NSIG / 8);
 }
 
@@ -73,8 +72,7 @@ __libc_signal_block_app (sigset_t *set)
 {
   sigset_t allset = sigall_set;
   __clear_internal_signals (&allset);
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL_CALL (rt_sigprocmask, err, SIG_BLOCK, &allset, set,
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_BLOCK, &allset, set,
 			 _NSIG / 8);
 }
 
@@ -82,8 +80,7 @@ __libc_signal_block_app (sigset_t *set)
 static inline void
 __libc_signal_restore_set (const sigset_t *set)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL_CALL (rt_sigprocmask, err, SIG_SETMASK, set, NULL,
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, set, NULL,
 			 _NSIG / 8);
 }
 
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index 5097f41dc8..7e22c0fc32 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -22,12 +22,11 @@
 static bool
 writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total)
 {
-  INTERNAL_SYSCALL_DECL (err);
   ssize_t cnt;
   do
-    cnt = INTERNAL_SYSCALL (writev, err, 3, fd, iov, niov);
-  while (INTERNAL_SYSCALL_ERROR_P (cnt, err)
-         && INTERNAL_SYSCALL_ERRNO (cnt, err) == EINTR);
+    cnt = INTERNAL_SYSCALL_CALL (writev, fd, iov, niov);
+  while (INTERNAL_SYSCALL_ERROR_P (cnt)
+         && INTERNAL_SYSCALL_ERRNO (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 28b0ee08c1..1e9c5259ab 100644
--- a/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c
@@ -25,9 +25,8 @@
     if ((unsigned long) (sp) < this_sp)					      \
       {									      \
 	stack_t oss;							      \
-	INTERNAL_SYSCALL_DECL (err);					      \
-	int result = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss);      \
-	if (!INTERNAL_SYSCALL_ERROR_P (result, err)			      \
+	int result = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss);         \
+	if (!INTERNAL_SYSCALL_ERROR_P (result)				      \
 	    && ((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/brk.c b/sysdeps/unix/sysv/linux/m68k/brk.c
index 6ce2f2553c..ee88acbdc4 100644
--- a/sysdeps/unix/sysv/linux/m68k/brk.c
+++ b/sysdeps/unix/sysv/linux/m68k/brk.c
@@ -32,8 +32,7 @@ __brk (void *addr)
 {
   void *newbrk;
 
-  INTERNAL_SYSCALL_DECL (err);
-  newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
+  newbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);
   __curbrk = newbrk;
 
   if (newbrk < addr)
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
index 53c30be802..ea05b00357 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
@@ -61,6 +61,6 @@ typedef uintmax_t uatomic_max_t;
   })
 
 # define atomic_full_barrier()				\
-  (INTERNAL_SYSCALL (atomic_barrier, , 0), (void) 0)
+  (INTERNAL_SYSCALL_CALL (atomic_barrier), (void) 0)
 
 #endif
diff --git a/sysdeps/unix/sysv/linux/m68k/getpagesize.c b/sysdeps/unix/sysv/linux/m68k/getpagesize.c
index ad6559320e..b57a03f7d3 100644
--- a/sysdeps/unix/sysv/linux/m68k/getpagesize.c
+++ b/sysdeps/unix/sysv/linux/m68k/getpagesize.c
@@ -36,10 +36,9 @@ __getpagesize (void)
     return GLRO(dl_pagesize);
 
 #ifdef __NR_getpagesize
-  INTERNAL_SYSCALL_DECL (err);
-  result = INTERNAL_SYSCALL (getpagesize, err, 0);
+  result = INTERNAL_SYSCALL_CALL (getpagesize);
   /* The only possible error is ENOSYS.  */
-  if (!INTERNAL_SYSCALL_ERROR_P (result, err))
+  if (!INTERNAL_SYSCALL_ERROR_P (result))
     return result;
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c b/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c
index f3bb727d02..62809e3f5a 100644
--- a/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c
+++ b/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c
@@ -21,6 +21,5 @@
 void *
 __m68k_read_tp (void)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  return (void*) INTERNAL_SYSCALL_CALL (get_thread_area, err);
+  return (void*) INTERNAL_SYSCALL_CALL (get_thread_area);
 }
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h
index f6793d34fa..a1316d6da7 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -226,7 +226,7 @@ SYSCALL_ERROR_LABEL:							      \
    normally.  It will never touch errno.  This returns just what the kernel
    gave back.  */
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...)	\
+#define INTERNAL_SYSCALL_NCS(name, nr, args...)	\
   ({ unsigned int _sys_result;				\
      {							\
        /* Load argument values in temporary variables
@@ -242,8 +242,8 @@ SYSCALL_ERROR_LABEL:							      \
        _sys_result = _d0;				\
      }							\
      (int) _sys_result; })
-#define INTERNAL_SYSCALL(name, err, nr, args...)	\
-  INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
+#define INTERNAL_SYSCALL(name, nr, args...)	\
+  INTERNAL_SYSCALL_NCS (__NR_##name, nr, ##args)
 
 #define LOAD_ARGS_0()
 #define LOAD_REGS_0
diff --git a/sysdeps/unix/sysv/linux/microblaze/brk.c b/sysdeps/unix/sysv/linux/microblaze/brk.c
index 4dd5b76079..20c3e625e4 100644
--- a/sysdeps/unix/sysv/linux/microblaze/brk.c
+++ b/sysdeps/unix/sysv/linux/microblaze/brk.c
@@ -30,9 +30,7 @@ weak_alias (__curbrk, ___brk_addr)
 int
 __brk (void *addr)
 {
-  INTERNAL_SYSCALL_DECL (err);
-
-  __curbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
+  __curbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);
   if (__curbrk < addr)
     {
       __set_errno (ENOMEM);
diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
index 6eeae33df5..6b0132398d 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
@@ -168,11 +168,11 @@ SYSCALL_ERROR_LABEL_DCL:                            \
    normally.  It will never touch errno.  This returns just what the kernel
    gave back.  */
 # undef INTERNAL_SYSCALL
-# define INTERNAL_SYSCALL(name, err, nr, args...)                    \
+# define INTERNAL_SYSCALL(name, nr, args...)                    \
   inline_syscall##nr(SYS_ify(name), args)
 
 # undef INTERNAL_SYSCALL_NCS
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...)                \
+# define INTERNAL_SYSCALL_NCS(name, nr, args...)                \
   inline_syscall##nr(name, args)
 
 # define SYSCALL_CLOBBERS_6 "r11", "r4", "memory"
diff --git a/sysdeps/unix/sysv/linux/mips/brk.c b/sysdeps/unix/sysv/linux/mips/brk.c
index 4ec2a43bc8..0335837948 100644
--- a/sysdeps/unix/sysv/linux/mips/brk.c
+++ b/sysdeps/unix/sysv/linux/mips/brk.c
@@ -30,10 +30,9 @@ weak_alias (__curbrk, ___brk_addr)
 int
 __brk (void *addr)
 {
-  INTERNAL_SYSCALL_DECL (err);
   void *newbrk;
 
-  newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
+  newbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);
   __curbrk = newbrk;
 
   if (newbrk < addr)
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index 75d483c59b..8e9cb187d2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -37,6 +37,7 @@
 /* We don't want the label for the error handler to be visible in the symbol
    table when we define it here.  */
 #ifdef __PIC__
+# undef SYSCALL_ERROR_LABEL
 # define SYSCALL_ERROR_LABEL 99b
 #endif
 
@@ -94,10 +95,10 @@ union __mips_syscall_return
 
 # include <mips16-syscall.h>
 
-# define INTERNAL_SYSCALL(name, err, nr, args...)			\
-	INTERNAL_SYSCALL_NCS (SYS_ify (name), err, nr, args)
+# define INTERNAL_SYSCALL(name, nr, args...)				\
+	INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
 
-# define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
+# define INTERNAL_SYSCALL_NCS(number, nr, args...)			\
 ({									\
 	union __mips_syscall_return _sc_ret;				\
 	_sc_ret.val = __mips16_syscall##nr (args, number);		\
@@ -110,12 +111,12 @@ union __mips_syscall_return
 			      number, err, args)
 
 #else /* !__mips16 */
-# define INTERNAL_SYSCALL(name, err, nr, args...)			\
+# define INTERNAL_SYSCALL(name, nr, args...)				\
 	internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t",	\
 			      "IK" (SYS_ify (name)),			\
 			      SYS_ify (name), err, args)
 
-# define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
+# define INTERNAL_SYSCALL_NCS(number, nr, args...)			\
 	internal_syscall##nr (MOVE32 "\t%0, %2\n\t",			\
 			      "r" (__s0),				\
 			      number, err, args)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
index 6d36adab05..cd495a3337 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c
@@ -40,15 +40,14 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
     }
 
   int result;
-  INTERNAL_SYSCALL_DECL (err);
   struct kernel_stat kst;
 
-  result = INTERNAL_SYSCALL (newfstatat, err, 4, fd, file, &kst, flag);
-  if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  result = INTERNAL_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result)))
     return __xstat64_conv (vers, &kst, st);
   else
     {
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result));
       return -1;
     }
 }
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
index 03873ce2c2..fad4c14fa0 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h
@@ -36,6 +36,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
 # define SYSCALL_ERROR_LABEL 99b
 
 #else   /* ! __ASSEMBLER__ */
@@ -78,18 +79,18 @@ typedef long int __syscall_arg_t;
 #endif
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)			\
+#define INTERNAL_SYSCALL(name, nr, args...)			\
 	internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t",	\
 			      "IK" (SYS_ify (name)),			\
-			      0, err, args)
+			      0, args)
 
 #undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
+#define INTERNAL_SYSCALL_NCS(number, nr, args...)			\
 	internal_syscall##nr (MOVE32 "\t%0, %2\n\t",			\
 			      "r" (__s0),				\
-			      number, err, args)
+			      number, args)
 
-#define internal_syscall0(v0_init, input, number, err, dummy...)	\
+#define internal_syscall0(v0_init, input, number, dummy...)	\
 ({									\
 	long _sys_result;						\
 									\
@@ -111,7 +112,7 @@ typedef long int __syscall_arg_t;
 	_sys_result;							\
 })
 
-#define internal_syscall1(v0_init, input, number, err, arg1)		\
+#define internal_syscall1(v0_init, input, number, arg1)		\
 ({									\
 	long _sys_result;						\
 									\
@@ -134,7 +135,7 @@ typedef long int __syscall_arg_t;
 	_sys_result;							\
 })
 
-#define internal_syscall2(v0_init, input, number, err, arg1, arg2)	\
+#define internal_syscall2(v0_init, input, number, arg1, arg2)	\
 ({									\
 	long _sys_result;						\
 									\
@@ -158,8 +159,7 @@ typedef long int __syscall_arg_t;
 	_sys_result;							\
 })
 
-#define internal_syscall3(v0_init, input, number, err,			\
-			  arg1, arg2, arg3)				\
+#define internal_syscall3(v0_init, input, number, arg1, arg2, arg3)	\
 ({									\
 	long _sys_result;						\
 									\
@@ -184,8 +184,8 @@ typedef long int __syscall_arg_t;
 	_sys_result;							\
 })
 
-#define internal_syscall4(v0_init, input, number, err,			\
-			  arg1, arg2, arg3, arg4)			\
+#define internal_syscall4(v0_init, input, number, arg1, arg2, arg3, 	\
+			  arg4)						\
 ({									\
 	long _sys_result;						\
 									\
@@ -210,8 +210,8 @@ typedef long int __syscall_arg_t;
 	_sys_result;							\
 })
 
-#define internal_syscall5(v0_init, input, number, err,			\
-			  arg1, arg2, arg3, arg4, arg5)			\
+#define internal_syscall5(v0_init, input, number, arg1, arg2, arg3, 	\
+			  arg4, arg5)					\
 ({									\
 	long _sys_result;						\
 									\
@@ -237,8 +237,8 @@ typedef long int __syscall_arg_t;
 	_sys_result;							\
 })
 
-#define internal_syscall6(v0_init, input, number, err,			\
-			  arg1, arg2, arg3, arg4, arg5, arg6)		\
+#define internal_syscall6(v0_init, input, number, arg1, arg2, arg3, 	\
+			  arg4, arg5, arg6)				\
 ({									\
 	long _sys_result;						\
 									\
diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c
index a0c3348744..4ea882da86 100644
--- a/sysdeps/unix/sysv/linux/mq_unlink.c
+++ b/sysdeps/unix/sysv/linux/mq_unlink.c
@@ -28,14 +28,13 @@ mq_unlink (const char *name)
   if (name[0] != '/')
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
-  INTERNAL_SYSCALL_DECL (err);
-  int ret = INTERNAL_SYSCALL (mq_unlink, err, 1, name + 1);
+  int ret = INTERNAL_SYSCALL_CALL (mq_unlink, name + 1);
 
   /* While unlink can return either EPERM or EACCES, mq_unlink should
      return just EACCES.  */
-  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret, err)))
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
     {
-      ret = INTERNAL_SYSCALL_ERRNO (ret, err);
+      ret = INTERNAL_SYSCALL_ERRNO (ret);
       if (ret == EPERM)
 	ret = EACCES;
       return INLINE_SYSCALL_ERROR_RETURN_VALUE (ret);
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
index 45ef817ab5..dbd23b814a 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
@@ -145,7 +145,7 @@
 # undef HAVE_INTERNAL_SEND_SYMBOL
 
 #undef INTERNAL_SYSCALL_RAW
-#define INTERNAL_SYSCALL_RAW(name, err, nr, args...)            \
+#define INTERNAL_SYSCALL_RAW(name, nr, args...)                 \
   ({ unsigned int _sys_result;                                  \
      {                                                          \
        /* Load argument values in temporary variables
@@ -164,12 +164,12 @@
      (int) _sys_result; })
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
-	INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
+#define INTERNAL_SYSCALL(name, nr, args...) \
+	INTERNAL_SYSCALL_RAW(SYS_ify(name), nr, args)
 
 #undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
-	INTERNAL_SYSCALL_RAW(number, err, nr, args)
+#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
+	INTERNAL_SYSCALL_RAW(number, nr, args)
 
 #define LOAD_ARGS_0()
 #define LOAD_REGS_0
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index df6023a1de..bf09a3d6b8 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -65,8 +65,7 @@ __close_nocancel_nostatus (int fd)
 static inline void
 __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt);
+  INTERNAL_SYSCALL_CALL (writev, fd, iov, iovcnt);
 }
 
 /* Uncancelable fcntl.  */
diff --git a/sysdeps/unix/sysv/linux/not-errno.h b/sysdeps/unix/sysv/linux/not-errno.h
index cdc9d9b492..394dabeb93 100644
--- a/sysdeps/unix/sysv/linux/not-errno.h
+++ b/sysdeps/unix/sysv/linux/not-errno.h
@@ -26,14 +26,13 @@ static inline int
 __access_noerrno (const char *pathname, int mode)
 {
   int res;
-  INTERNAL_SYSCALL_DECL (err);
 #ifdef __NR_access
-  res = INTERNAL_SYSCALL_CALL (access, err, pathname, mode);
+  res = INTERNAL_SYSCALL_CALL (access, pathname, mode);
 #else
-  res = INTERNAL_SYSCALL_CALL (faccessat, err, AT_FDCWD, pathname, mode);
+  res = INTERNAL_SYSCALL_CALL (faccessat, AT_FDCWD, pathname, mode);
 #endif
-  if (INTERNAL_SYSCALL_ERROR_P (res, err))
-    return INTERNAL_SYSCALL_ERRNO (res, err);
+  if (INTERNAL_SYSCALL_ERROR_P (res))
+    return INTERNAL_SYSCALL_ERRNO (res);
   return 0;
 }
 
@@ -41,9 +40,8 @@ static inline int
 __kill_noerrno (pid_t pid, int sig)
 {
   int res;
-  INTERNAL_SYSCALL_DECL (err);
-  res = INTERNAL_SYSCALL_CALL (kill, err, pid, sig);
-  if (INTERNAL_SYSCALL_ERROR_P (res, err))
-    return INTERNAL_SYSCALL_ERRNO (res, err);
+  res = INTERNAL_SYSCALL_CALL (kill, pid, sig);
+  if (INTERNAL_SYSCALL_ERROR_P (res))
+    return INTERNAL_SYSCALL_ERRNO (res);
   return 0;
 }
diff --git a/sysdeps/unix/sysv/linux/nscd_setup_thread.c b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
index 6e14918be0..fe77704d1f 100644
--- a/sysdeps/unix/sysv/linux/nscd_setup_thread.c
+++ b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
@@ -35,10 +35,9 @@ setup_thread (struct database_dyn *db)
   /* Do not try this at home, kids.  We play with the SETTID address
      even thought the process is multi-threaded.  This can only work
      since none of the threads ever terminates.  */
-  INTERNAL_SYSCALL_DECL (err);
-  int r = INTERNAL_SYSCALL (set_tid_address, err, 1,
-			    &db->head->nscd_certainly_running);
-  if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+  int r = INTERNAL_SYSCALL_CALL (set_tid_address,
+				 &db->head->nscd_certainly_running);
+  if (!INTERNAL_SYSCALL_ERROR_P (r))
     /* 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/personality.c b/sysdeps/unix/sysv/linux/personality.c
index 970bd7becd..d0c597b6a0 100644
--- a/sysdeps/unix/sysv/linux/personality.c
+++ b/sysdeps/unix/sysv/linux/personality.c
@@ -35,15 +35,14 @@ __personality (unsigned long persona)
   persona = (unsigned int) persona;
 #endif
 
-  INTERNAL_SYSCALL_DECL (err);
-  long ret = INTERNAL_SYSCALL (personality, err, 1, persona);
+  long 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, err)))
-    ret = -INTERNAL_SYSCALL_ERRNO (ret, err);
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
+    ret = -INTERNAL_SYSCALL_ERRNO (ret);
   return ret;
 }
 weak_alias (__personality, personality)
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c
index 63965dddbd..bada96b697 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise.c
@@ -41,14 +41,13 @@
 int
 posix_fadvise (int fd, off_t offset, off_t len, int advise)
 {
-  INTERNAL_SYSCALL_DECL (err);
 # if defined (__NR_fadvise64) && !defined (__ASSUME_FADVISE64_AS_64_64)
-  int ret = INTERNAL_SYSCALL_CALL (fadvise64, err, fd,
+  int ret = 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, err, fd, advise,
+  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise,
 				   SYSCALL_LL (offset), SYSCALL_LL (len));
 #  else
 
@@ -56,13 +55,13 @@ posix_fadvise (int fd, off_t offset, off_t len, int advise)
 #    define __NR_fadvise64_64 __NR_fadvise64
 #   endif
 
-  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd,
+  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd,
 				   __ALIGNMENT_ARG SYSCALL_LL (offset),
 				   SYSCALL_LL (len), advise);
 #  endif
 # endif
-  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
-    return INTERNAL_SYSCALL_ERRNO (ret, err);
+  if (INTERNAL_SYSCALL_ERROR_P (ret))
+    return INTERNAL_SYSCALL_ERRNO (ret);
   return 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 c0fa6e3391..9787ab4c7c 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c
@@ -40,18 +40,17 @@ libc_hidden_proto (__posix_fadvise64_l64)
 int
 __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
 {
-  INTERNAL_SYSCALL_DECL (err);
 #ifdef __ASSUME_FADVISE64_64_6ARG
-  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd, advise,
+  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise,
 				   SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
 #else
-  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd,
+  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd,
 				   __ALIGNMENT_ARG SYSCALL_LL64 (offset),
 				   SYSCALL_LL64 (len), advise);
 #endif
-  if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
+  if (!INTERNAL_SYSCALL_ERROR_P (ret))
     return 0;
-  return INTERNAL_SYSCALL_ERRNO (ret, err);
+  return INTERNAL_SYSCALL_ERRNO (ret);
 }
 
 /* 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 7af973be9e..7238b00038 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate.c
@@ -26,12 +26,11 @@
 int
 posix_fallocate (int fd, __off_t offset, __off_t len)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  int res = INTERNAL_SYSCALL_CALL (fallocate, err, fd, 0,
+  int res = INTERNAL_SYSCALL_CALL (fallocate, fd, 0,
 				   SYSCALL_LL (offset), SYSCALL_LL (len));
-  if (! INTERNAL_SYSCALL_ERROR_P (res, err))
+  if (! INTERNAL_SYSCALL_ERROR_P (res))
     return 0;
-  if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP)
-    return INTERNAL_SYSCALL_ERRNO (res, err);
+  if (INTERNAL_SYSCALL_ERRNO (res) != EOPNOTSUPP)
+    return INTERNAL_SYSCALL_ERRNO (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 ce8de713d5..2de63ac277 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate64.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c
@@ -28,19 +28,12 @@ libc_hidden_proto (__posix_fallocate64_l64)
 int
 __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
 {
-  INTERNAL_SYSCALL_DECL (err);
-#ifdef INTERNAL_SYSCALL_TYPES
-  int res = INTERNAL_SYSCALL_TYPES (fallocate, err, 4, int, fd,
-                                    int, 0, off_t, offset,
-                                    off_t, len);
-#else
-  int res = INTERNAL_SYSCALL_CALL (fallocate, err, fd, 0,
+  int res = INTERNAL_SYSCALL_CALL (fallocate, fd, 0,
 				   SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
-#endif
-  if (! INTERNAL_SYSCALL_ERROR_P (res, err))
+  if (! INTERNAL_SYSCALL_ERROR_P (res))
     return 0;
-  if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP)
-    return INTERNAL_SYSCALL_ERRNO (res, err);
+  if (INTERNAL_SYSCALL_ERRNO (res) != EOPNOTSUPP)
+    return INTERNAL_SYSCALL_ERRNO (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 daff027aac..0e49f3b7ac 100644
--- a/sysdeps/unix/sysv/linux/posix_madvise.c
+++ b/sysdeps/unix/sysv/linux/posix_madvise.c
@@ -31,7 +31,6 @@ posix_madvise (void *addr, size_t len, int advice)
   if (advice == POSIX_MADV_DONTNEED)
     return 0;
 
-  INTERNAL_SYSCALL_DECL (err);
-  int result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice);
-  return INTERNAL_SYSCALL_ERRNO (result, err);
+  int result = INTERNAL_SYSCALL_CALL (madvise, addr, len, advice);
+  return INTERNAL_SYSCALL_ERRNO (result);
 }
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index 81f7c73f38..279b86e0da 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -105,7 +105,6 @@ __get_timebase_freq (void)
   if (vdsop == NULL)
     return get_timebase_freq_fallback ();
 
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, uint64_t, 0);
+  return INTERNAL_VSYSCALL_CALL_TYPE (vdsop, uint64_t, 0);
 }
 weak_alias (__get_timebase_freq, __ppc_get_timebase_freq)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_mask.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_mask.c
index 61164f21df..1a047fb7ff 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_mask.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_mask.c
@@ -26,8 +26,7 @@
 const fenv_t *
 __fe_mask_env (void)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (prctl, err, 2, PR_SET_FPEXC, PR_FP_EXC_DISABLED);
+  INTERNAL_SYSCALL_CALL (prctl, PR_SET_FPEXC, PR_FP_EXC_DISABLED);
 
   return FE_DFL_ENV;
 }
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c
index 6ee75f6324..1c40cd36d6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/fe_nomask.c
@@ -27,8 +27,7 @@
 const fenv_t *
 __fe_nomask_env_priv (void)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (prctl, err, 2, PR_SET_FPEXC, PR_FP_EXC_PRECISE);
+  INTERNAL_SYSCALL_CALL (prctl, PR_SET_FPEXC, PR_FP_EXC_PRECISE);
 
   return FE_ENABLED_ENV;
 }
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_mask.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_mask.c
index 61fd3b0181..02ed0a66ae 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_mask.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_mask.c
@@ -26,8 +26,7 @@ const fenv_t *
 __fe_mask_env (void)
 {
 #if defined PR_SET_FPEXC && defined PR_FP_EXC_DISABLED
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (prctl, err, 2, PR_SET_FPEXC, PR_FP_EXC_DISABLED);
+  INTERNAL_SYSCALL_CALL (prctl, PR_SET_FPEXC, PR_FP_EXC_DISABLED);
 #else
   __set_errno (ENOSYS);
 #endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c
index f4febe7603..33a36e2673 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/fe_nomask.c
@@ -27,8 +27,7 @@ const fenv_t *
 __fe_nomask_env_priv (void)
 {
 #if defined PR_SET_FPEXC && defined PR_FP_EXC_PRECISE
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (prctl, err, 2, PR_SET_FPEXC, PR_FP_EXC_PRECISE);
+  INTERNAL_SYSCALL_CALL (prctl, PR_SET_FPEXC, PR_FP_EXC_PRECISE);
 #else
   __set_errno (ENOSYS);
 #endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 92503ee20f..b5ef255156 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -41,7 +41,7 @@
    gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
    the negation of the return value in the kernel gets reverted.  */
 
-#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...)    \
+#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, type, nr, args...)         \
   ({									\
     register void *r0  __asm__ ("r0");					\
     register long int r3  __asm__ ("r3");				\
@@ -64,12 +64,12 @@
     (long int) r0 & (1 << 28) ? -rval : rval;				\
   })
 
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
+#define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...)			\
+  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, long int, nr, args)
 
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									\
     register long int r0  __asm__ ("r0");				\
     register long int r3  __asm__ ("r3");				\
@@ -91,8 +91,8 @@
          "cr0", "ctr", "memory");					\
     r0 & (1 << 28) ? -r3 : r3;						\
   })
-#define INTERNAL_SYSCALL(name, err, nr, args...)			\
-  INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
+#define INTERNAL_SYSCALL(name, nr, args...)				\
+  INTERNAL_SYSCALL_NCS (__NR_##name, nr, args)
 
 #if defined(__PPC64__) || defined(__powerpc64__)
 # define SYSCALL_ARG_SIZE 8
diff --git a/sysdeps/unix/sysv/linux/pthread-pids.h b/sysdeps/unix/sysv/linux/pthread-pids.h
index 50c022ead2..0b8ca4ec06 100644
--- a/sysdeps/unix/sysv/linux/pthread-pids.h
+++ b/sysdeps/unix/sysv/linux/pthread-pids.h
@@ -25,6 +25,5 @@
 static inline void
 __pthread_initialize_pids (struct pthread *pd)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  pd->tid = INTERNAL_SYSCALL_CALL (set_tid_address, err, &pd->tid);
+  pd->tid = INTERNAL_SYSCALL_CALL (set_tid_address, &pd->tid);
 }
diff --git a/sysdeps/unix/sysv/linux/pthread_getaffinity.c b/sysdeps/unix/sysv/linux/pthread_getaffinity.c
index a3d5856763..cf6ecfe01f 100644
--- a/sysdeps/unix/sysv/linux/pthread_getaffinity.c
+++ b/sysdeps/unix/sysv/linux/pthread_getaffinity.c
@@ -31,11 +31,10 @@ __pthread_getaffinity_new (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)
 {
   const struct pthread *pd = (const struct pthread *) th;
 
-  INTERNAL_SYSCALL_DECL (err);
-  int res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, pd->tid,
-			      MIN (INT_MAX, cpusetsize), cpuset);
-  if (INTERNAL_SYSCALL_ERROR_P (res, err))
-    return INTERNAL_SYSCALL_ERRNO (res, err);
+  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);
 
   /* Clean the rest of the memory the kernel didn't do.  */
   memset ((char *) cpuset + res, '\0', cpusetsize - res);
diff --git a/sysdeps/unix/sysv/linux/pthread_kill.c b/sysdeps/unix/sysv/linux/pthread_kill.c
index 1d63100b33..4dfe08ffcd 100644
--- a/sysdeps/unix/sysv/linux/pthread_kill.c
+++ b/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -48,12 +48,10 @@ __pthread_kill (pthread_t threadid, int signo)
     return EINVAL;
 
   /* We have a special syscall to do the work.  */
-  INTERNAL_SYSCALL_DECL (err);
-
   pid_t pid = __getpid ();
 
-  int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, tid, signo);
-  return (INTERNAL_SYSCALL_ERROR_P (val, err)
-	  ? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
+  int val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo);
+  return (INTERNAL_SYSCALL_ERROR_P (val)
+	  ? INTERNAL_SYSCALL_ERRNO (val) : 0);
 }
 strong_alias (__pthread_kill, pthread_kill)
diff --git a/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/sysdeps/unix/sysv/linux/pthread_setaffinity.c
index 746824c79f..264d677c29 100644
--- a/sysdeps/unix/sysv/linux/pthread_setaffinity.c
+++ b/sysdeps/unix/sysv/linux/pthread_setaffinity.c
@@ -28,19 +28,18 @@ __pthread_setaffinity_new (pthread_t th, size_t cpusetsize,
 			   const cpu_set_t *cpuset)
 {
   const struct pthread *pd = (const struct pthread *) th;
-  INTERNAL_SYSCALL_DECL (err);
   int res;
 
-  res = INTERNAL_SYSCALL (sched_setaffinity, err, 3, pd->tid, cpusetsize,
-			  cpuset);
+  res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize,
+			       cpuset);
 
 #ifdef RESET_VGETCPU_CACHE
-  if (!INTERNAL_SYSCALL_ERROR_P (res, err))
+  if (!INTERNAL_SYSCALL_ERROR_P (res))
     RESET_VGETCPU_CACHE ();
 #endif
 
-  return (INTERNAL_SYSCALL_ERROR_P (res, err)
-	  ? INTERNAL_SYSCALL_ERRNO (res, err)
+  return (INTERNAL_SYSCALL_ERROR_P (res)
+	  ? INTERNAL_SYSCALL_ERRNO (res)
 	  : 0);
 }
 versioned_symbol (libpthread, __pthread_setaffinity_new,
diff --git a/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
index 52d815a399..4b32be2d64 100644
--- a/sysdeps/unix/sysv/linux/pthread_sigqueue.c
+++ b/sysdeps/unix/sysv/linux/pthread_sigqueue.c
@@ -61,12 +61,10 @@ pthread_sigqueue (pthread_t threadid, int signo, const union sigval value)
   info.si_value = value;
 
   /* We have a special syscall to do the work.  */
-  INTERNAL_SYSCALL_DECL (err);
-
-  int val = INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, err, pid, tid, signo,
+  int val = INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, pid, tid, signo,
 				   &info);
-  return (INTERNAL_SYSCALL_ERROR_P (val, err)
-	  ? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
+  return (INTERNAL_SYSCALL_ERROR_P (val)
+	  ? INTERNAL_SYSCALL_ERRNO (val) : 0);
 #else
   return ENOSYS;
 #endif
diff --git a/sysdeps/unix/sysv/linux/raise.c b/sysdeps/unix/sysv/linux/raise.c
index 4c9f3fad8b..3b90ae1d55 100644
--- a/sysdeps/unix/sysv/linux/raise.c
+++ b/sysdeps/unix/sysv/linux/raise.c
@@ -39,11 +39,10 @@ raise (int sig)
   sigset_t set;
   __libc_signal_block_app (&set);
 
-  INTERNAL_SYSCALL_DECL (err);
-  pid_t pid = INTERNAL_SYSCALL (getpid, err, 0);
-  pid_t tid = INTERNAL_SYSCALL (gettid, err, 0);
+  pid_t pid = INTERNAL_SYSCALL_CALL (getpid);
+  pid_t tid = INTERNAL_SYSCALL_CALL (gettid);
 
-  int ret = INLINE_SYSCALL (tgkill, 3, pid, tid, sig);
+  int ret = INLINE_SYSCALL_CALL (tgkill, pid, tid, sig);
 
   __libc_signal_restore_set (&set);
 
diff --git a/sysdeps/unix/sysv/linux/riscv/syscall.c b/sysdeps/unix/sysv/linux/riscv/syscall.c
index 9d0e4175dd..a99375c054 100644
--- a/sysdeps/unix/sysv/linux/riscv/syscall.c
+++ b/sysdeps/unix/sysv/linux/riscv/syscall.c
@@ -23,12 +23,11 @@ syscall (long int syscall_number, long int arg1, long int arg2, long int arg3,
 	 long int arg4, long int arg5, long int arg6, long int arg7)
 {
   long int ret;
-  INTERNAL_SYSCALL_DECL (err);
 
-  ret = INTERNAL_SYSCALL_NCS (syscall_number, err, 7, arg1, arg2, arg3, arg4,
+  ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4,
 			      arg5, arg6, arg7);
 
-  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+  if (INTERNAL_SYSCALL_ERROR_P (ret))
     return __syscall_error (ret);
 
   return ret;
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index e46160f3f6..83e4adf6a2 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -130,13 +130,13 @@
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
-# define INTERNAL_SYSCALL(name, err, nr, args...) \
-	internal_syscall##nr (SYS_ify (name), err, args)
+# define INTERNAL_SYSCALL(name, nr, args...) \
+	internal_syscall##nr (SYS_ify (name), args)
 
-# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
-	internal_syscall##nr (number, err, args)
+# define INTERNAL_SYSCALL_NCS(number, nr, args...) \
+	internal_syscall##nr (number, args)
 
-# define internal_syscall0(number, err, dummy...)			\
+# define internal_syscall0(number, dummy...)			\
 ({ 									\
 	long int _sys_result;						\
 									\
@@ -153,7 +153,7 @@
 	_sys_result;							\
 })
 
-# define internal_syscall1(number, err, arg0)				\
+# define internal_syscall1(number, arg0)				\
 ({ 									\
 	long int _sys_result;						\
 	long int _arg0 = (long int) (arg0);				\
@@ -171,7 +171,7 @@
 	_sys_result;							\
 })
 
-# define internal_syscall2(number, err, arg0, arg1)	    		\
+# define internal_syscall2(number, arg0, arg1)	    		\
 ({ 									\
 	long int _sys_result;						\
 	long int _arg0 = (long int) (arg0);				\
@@ -191,7 +191,7 @@
 	_sys_result;							\
 })
 
-# define internal_syscall3(number, err, arg0, arg1, arg2)      		\
+# define internal_syscall3(number, arg0, arg1, arg2)      		\
 ({ 									\
 	long int _sys_result;						\
 	long int _arg0 = (long int) (arg0);				\
@@ -213,7 +213,7 @@
 	_sys_result;							\
 })
 
-# define internal_syscall4(number, err, arg0, arg1, arg2, arg3)	  \
+# define internal_syscall4(number, arg0, arg1, arg2, arg3)	  \
 ({ 									\
 	long int _sys_result;						\
 	long int _arg0 = (long int) (arg0);				\
@@ -237,7 +237,7 @@
 	_sys_result;							\
 })
 
-# define internal_syscall5(number, err, arg0, arg1, arg2, arg3, arg4)   \
+# define internal_syscall5(number, arg0, arg1, arg2, arg3, arg4)   \
 ({ 									\
 	long int _sys_result;						\
 	long int _arg0 = (long int) (arg0);				\
@@ -263,7 +263,7 @@
 	_sys_result;							\
 })
 
-# define internal_syscall6(number, err, arg0, arg1, arg2, arg3, arg4, arg5) \
+# define internal_syscall6(number, arg0, arg1, arg2, arg3, arg4, arg5) \
 ({ 									\
 	long int _sys_result;						\
 	long int _arg0 = (long int) (arg0);				\
@@ -292,7 +292,7 @@
 	_sys_result;							\
 })
 
-# define internal_syscall7(number, err, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
+# define internal_syscall7(number, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
 ({ 									\
 	long int _sys_result;						\
 	long int _arg0 = (long int) (arg0);				\
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 28fa16fe4e..1f214173fe 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c
@@ -39,9 +39,8 @@
       if (new_sp < cur_sp)						\
 	{								\
 	  stack_t oss;							\
-	  INTERNAL_SYSCALL_DECL (err);					\
-	  int res = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss);	\
-	  if (!INTERNAL_SYSCALL_ERROR_P (res, err))			\
+	  int res = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss);	\
+	  if (!INTERNAL_SYSCALL_ERROR_P (res))				\
 	    {								\
 	      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 c9847796f4..b556a6caae 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
@@ -37,16 +37,15 @@ int
 __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
 {
   struct fadvise64_64_layout parameters;
-  INTERNAL_SYSCALL_DECL (err);
 
   parameters.fd = fd;
   parameters.offset = offset;
   parameters.len = len;
   parameters.advise = advise;
-  int ret = INTERNAL_SYSCALL (fadvise64_64, err, 1, &parameters);
-  if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
+  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, &parameters);
+  if (!INTERNAL_SYSCALL_ERROR_P (ret))
     return 0;
-  return INTERNAL_SYSCALL_ERRNO (ret, err);
+  return INTERNAL_SYSCALL_ERRNO (ret);
 }
 
 #include <shlib-compat.h>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index 7d31abbb6f..73c42c6b5b 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -81,6 +81,7 @@
   END (name)
 
 #ifndef PIC
+# undef SYSCALL_ERROR_LABEL
 # define SYSCALL_ERROR_LABEL 0f
 # define SYSCALL_ERROR_HANDLER \
 0:  basr  %r1,0;							      \
@@ -89,6 +90,7 @@
 2:  .long syscall_error
 #else
 # if RTLD_PRIVATE_ERRNO
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL 0f
 #  define SYSCALL_ERROR_HANDLER \
 0:  basr  %r1,0;							      \
@@ -104,6 +106,7 @@
 #  else
 #   define SYSCALL_ERROR_ERRNO errno
 #  endif
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL 0f
 #  define SYSCALL_ERROR_HANDLER \
 0:  lcr   %r0,%r2;							      \
@@ -116,6 +119,7 @@
     br    %r14;								      \
 2:  .long _GLOBAL_OFFSET_TABLE_-1b
 # else
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL 0f
 #  define SYSCALL_ERROR_HANDLER \
 0:  basr  %r1,0;							      \
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 1305c81421..bc74408135 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c
@@ -39,9 +39,8 @@
       if (new_sp < cur_sp)						\
 	{								\
 	  stack_t oss;							\
-	  INTERNAL_SYSCALL_DECL (err);					\
-	  int res = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss);	\
-	  if (!INTERNAL_SYSCALL_ERROR_P (res, err))			\
+	  int res = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss);	\
+	  if (!INTERNAL_SYSCALL_ERROR_P (res))				\
 	    {								\
 	      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-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index aba3999315..8049fb4e1b 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -95,10 +95,12 @@
   END (name)
 
 #ifndef PIC
+# undef SYSCALL_ERROR_LABEL
 # define SYSCALL_ERROR_LABEL syscall_error
 # define SYSCALL_ERROR_HANDLER
 #else
 # if RTLD_PRIVATE_ERRNO
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL 0f
 #  define SYSCALL_ERROR_HANDLER \
 0:  larl  %r1,rtld_errno;						      \
@@ -112,6 +114,7 @@
 #  else
 #   define SYSCALL_ERROR_ERRNO errno
 #  endif
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL 0f
 #  define SYSCALL_ERROR_HANDLER \
 0:  lcr   %r0,%r2;							      \
@@ -124,6 +127,7 @@
     lghi   %r2,-1;							      \
     br    %r14
 # else
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL 0f
 #  define SYSCALL_ERROR_HANDLER \
 0:  larl  %r1,_GLOBAL_OFFSET_TABLE_;					      \
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
index 3802e07277..b846c3c27e 100644
--- a/sysdeps/unix/sysv/linux/s390/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -22,7 +22,7 @@
 #define SYS_ify(syscall_name)	__NR_##syscall_name
 
 #undef INTERNAL_SYSCALL_DIRECT
-#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...)			      \
+#define INTERNAL_SYSCALL_DIRECT(name, nr, args...)			      \
   ({									      \
     DECLARGS_##nr(args)							      \
     register long _ret __asm__("2");					      \
@@ -34,7 +34,7 @@
     _ret; })
 
 #undef INTERNAL_SYSCALL_SVC0
-#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...)			      \
+#define INTERNAL_SYSCALL_SVC0(name, nr, args...)			      \
   ({									      \
     DECLARGS_##nr(args)							      \
     register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name);   \
@@ -47,7 +47,7 @@
     _ret; })
 
 #undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(no, err, nr, args...)			      \
+#define INTERNAL_SYSCALL_NCS(no, nr, args...)				      \
   ({									      \
     DECLARGS_##nr(args)							      \
     register unsigned long _nr __asm__("1") = (unsigned long)(no);	      \
diff --git a/sysdeps/unix/sysv/linux/safe-fatal.h b/sysdeps/unix/sysv/linux/safe-fatal.h
index 31432b5bf7..62126d1195 100644
--- a/sysdeps/unix/sysv/linux/safe-fatal.h
+++ b/sysdeps/unix/sysv/linux/safe-fatal.h
@@ -25,9 +25,8 @@
 static inline void
 __safe_fatal (void)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  pid_t self = INTERNAL_SYSCALL (getpid, err, 0);
-  INTERNAL_SYSCALL (kill, err, 2, self, SIGKILL);
+  pid_t self = INTERNAL_SYSCALL_CALL (getpid);
+  INTERNAL_SYSCALL_CALL (kill, self, SIGKILL);
 }
 
 #endif  /* safe-fatal.h */
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h
index c0e52af65a..60a5032ce4 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep.h
@@ -288,7 +288,7 @@
 	register long int r2 asm ("%r2") = (long int) (_arg7)
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL(name, nr, args...) \
   ({									      \
     unsigned long int resultvar;					      \
     register long int r3 asm ("%r3") = SYS_ify (name);			      \
@@ -302,7 +302,7 @@
     (int) resultvar; })
 
 /* The _NCS variant allows non-constant syscall numbers.  */
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
   ({									      \
     unsigned long int resultvar;					      \
     register long int r3 asm ("%r3") = (name);				      \
diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c
index c11811ae17..3bc791c05f 100644
--- a/sysdeps/unix/sysv/linux/shmat.c
+++ b/sysdeps/unix/sysv/linux/shmat.c
@@ -31,15 +31,13 @@ shmat (int shmid, const void *shmaddr, int shmflg)
 #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
   return (void*) INLINE_SYSCALL_CALL (shmat, shmid, shmaddr, shmflg);
 #else
-  INTERNAL_SYSCALL_DECL(err);
   unsigned long resultvar;
   void *raddr;
 
-  resultvar = INTERNAL_SYSCALL_CALL (ipc, err, IPCOP_shmat, shmid, shmflg,
+  resultvar = INTERNAL_SYSCALL_CALL (ipc, IPCOP_shmat, shmid, shmflg,
 				     &raddr, shmaddr);
-  if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))
-    return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (resultvar,
-									       err));
+  if (INTERNAL_SYSCALL_ERROR_P (resultvar))
+    return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (resultvar));
 
   return raddr;
 #endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 46f4e06844..babb82f4e2 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -46,14 +46,14 @@
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
-  internal_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
+#define INTERNAL_SYSCALL(name, nr, args...) \
+  internal_syscall##nr(__SYSCALL_STRING, __NR_##name, args)
 
 #undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  internal_syscall##nr(__SYSCALL_STRING, err, name, args)
+#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
+  internal_syscall##nr(__SYSCALL_STRING, name, args)
 
-#define internal_syscall0(string,err,name,dummy...)			\
+#define internal_syscall0(string,name,dummy...)			\
 ({									\
 	register long __err __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0");				\
@@ -63,7 +63,7 @@
 	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define internal_syscall1(string,err,name,arg1)				\
+#define internal_syscall1(string,name,arg1)				\
 ({									\
 	long _arg1 = (long) (arg1);					\
 	register long __err __asm__("g1") = (name);			\
@@ -74,7 +74,7 @@
 	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define internal_syscall2(string,err,name,arg1,arg2)			\
+#define internal_syscall2(string,name,arg1,arg2)			\
 ({									\
 	long _arg1 = (long) (arg1);					\
 	long _arg2 = (long) (arg2);					\
@@ -87,7 +87,7 @@
 	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define internal_syscall3(string,err,name,arg1,arg2,arg3)		\
+#define internal_syscall3(string,name,arg1,arg2,arg3)			\
 ({									\
 	long _arg1 = (long) (arg1);					\
 	long _arg2 = (long) (arg2);					\
@@ -103,7 +103,7 @@
 	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define internal_syscall4(string,err,name,arg1,arg2,arg3,arg4)		\
+#define internal_syscall4(string,name,arg1,arg2,arg3,arg4)		\
 ({									\
 	long _arg1 = (long) (arg1);					\
 	long _arg2 = (long) (arg2);					\
@@ -121,7 +121,7 @@
 	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define internal_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5)	\
+#define internal_syscall5(string,name,arg1,arg2,arg3,arg4,arg5)		\
 ({									\
 	long _arg1 = (long) (arg1);					\
 	long _arg2 = (long) (arg2);					\
@@ -141,7 +141,7 @@
 	__err == -1 ? -__o0 : __o0;					\
 })
 
-#define internal_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)\
+#define internal_syscall6(string,name,arg1,arg2,arg3,arg4,arg5,arg6)	\
 ({									\
 	long _arg1 = (long) (arg1);					\
 	long _arg2 = (long) (arg2);					\
diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index dc6eaddbbf..a9215494dc 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -22,7 +22,7 @@
 #include <ldsodefs.h>
 
 #ifndef INTERNAL_VSYSCALL_CALL
-# define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		      \
+# define INTERNAL_VSYSCALL_CALL(funcptr, nr, args...)		      	      \
      funcptr (args)
 #endif
 
@@ -30,24 +30,23 @@
   ({									      \
     __label__ out;							      \
     __label__ iserr;							      \
-    INTERNAL_SYSCALL_DECL (sc_err);					      \
     long int sc_ret;							      \
 									      \
     __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name);	      \
     if (vdsop != NULL)							      \
       {									      \
-	sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, sc_err, nr, ##args);	      \
-	if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			      \
+	sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args);	      	      \
+	if (!INTERNAL_SYSCALL_ERROR_P (sc_ret))			      	      \
 	  goto out;							      \
-	if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS)		      \
+	if (INTERNAL_SYSCALL_ERRNO (sc_ret) != ENOSYS)		      	      \
 	  goto iserr;							      \
       }									      \
 									      \
-    sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args);		      \
-    if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			      \
+    sc_ret = INTERNAL_SYSCALL_CALL (name, ##args);		      	      \
+    if (INTERNAL_SYSCALL_ERROR_P (sc_ret))			      	      \
       {									      \
       iserr:								      \
-        __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));		      \
+        __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret));		      	      \
         sc_ret = -1L;							      \
       }									      \
   out:									      \
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index 389c94cfda..5c94357394 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -24,11 +24,8 @@
 
 #ifndef __ASSEMBLER__
 
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+#define INTERNAL_SYSCALL_ERROR_P(val) \
   ((unsigned long) (val) > -4096UL)
 
 #ifndef SYSCALL_ERROR_LABEL
@@ -44,15 +41,14 @@
 #undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)				\
   ({									\
-    INTERNAL_SYSCALL_DECL (sc_err);					\
-    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
-    __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))	\
-    ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err))	\
+    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))		\
     : sc_ret;								\
   })
 
 #undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
+#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.
diff --git a/sysdeps/unix/sysv/linux/timer_create.c b/sysdeps/unix/sysv/linux/timer_create.c
index b850a7631e..64d68a6ade 100644
--- a/sysdeps/unix/sysv/linux/timer_create.c
+++ b/sysdeps/unix/sysv/linux/timer_create.c
@@ -148,11 +148,10 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
 	    ._sigev_un = { ._pad = { [0] = __helper_tid } } };
 
 	/* Create the timer.  */
-	INTERNAL_SYSCALL_DECL (err);
 	int res;
-	res = INTERNAL_SYSCALL (timer_create, err, 3,
-				syscall_clockid, &sev, &newp->ktimerid);
-	if (! INTERNAL_SYSCALL_ERROR_P (res, err))
+	res = INTERNAL_SYSCALL_CALL (timer_create, 
+				     syscall_clockid, &sev, &newp->ktimerid);
+	if (! INTERNAL_SYSCALL_ERROR_P (res))
 	  {
 	    /* Add to the queue of active timers with thread
 	       delivery.  */
@@ -168,7 +167,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
 	/* Free the resources.  */
 	free (newp);
 
-	__set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
+	__set_errno (INTERNAL_SYSCALL_ERRNO (res));
 
 	return -1;
       }
diff --git a/sysdeps/unix/sysv/linux/timer_routines.c b/sysdeps/unix/sysv/linux/timer_routines.c
index abafffdfd5..00b7e018ba 100644
--- a/sysdeps/unix/sysv/linux/timer_routines.c
+++ b/sysdeps/unix/sysv/linux/timer_routines.c
@@ -47,8 +47,7 @@ timer_sigev_thread (void *arg)
      signals.  */
   sigset_t ss;
   sigemptyset (&ss);
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, &ss, NULL, _NSIG / 8);
 
   struct thread_start_data *td = (struct thread_start_data *) arg;
 
@@ -168,8 +167,7 @@ __start_helper_thread (void)
   sigset_t oss;
   sigfillset (&ss);
   __sigaddset (&ss, SIGCANCEL);
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, &ss, &oss, _NSIG / 8);
 
   /* Create the helper thread for this timer.  */
   pthread_t th;
@@ -179,8 +177,7 @@ __start_helper_thread (void)
     __helper_tid = ((struct pthread *) th)->tid;
 
   /* Restore the signal mask.  */
-  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL,
-		    _NSIG / 8);
+  INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, &oss, NULL, _NSIG / 8);
 
   /* No need for the attribute anymore.  */
   (void) pthread_attr_destroy (&attr);
diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c
index fee7f7eee3..e3db9cb400 100644
--- a/sysdeps/unix/sysv/linux/times.c
+++ b/sysdeps/unix/sysv/linux/times.c
@@ -23,10 +23,9 @@
 clock_t
 __times (struct tms *buf)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf);
-  if (INTERNAL_SYSCALL_ERROR_P (ret, err)
-      && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0)
+  clock_t ret = INTERNAL_SYSCALL_CALL (times, buf);
+  if (INTERNAL_SYSCALL_ERROR_P (ret)
+      && __glibc_unlikely (INTERNAL_SYSCALL_ERRNO (ret) == EFAULT)
       && buf)
     {
       /* This might be an error or not.  For architectures which have no
diff --git a/sysdeps/unix/sysv/linux/x86/cpu-features.c b/sysdeps/unix/sysv/linux/x86/cpu-features.c
index fcba2c000d..d67b300595 100644
--- a/sysdeps/unix/sysv/linux/x86/cpu-features.c
+++ b/sysdeps/unix/sysv/linux/x86/cpu-features.c
@@ -24,9 +24,7 @@ static inline int __attribute__ ((always_inline))
 get_cet_status (void)
 {
   unsigned long long cet_status[3];
-  INTERNAL_SYSCALL_DECL (err);
-  if (INTERNAL_SYSCALL (arch_prctl, err, 2, ARCH_CET_STATUS,
-			cet_status) == 0)
+  if (INTERNAL_SYSCALL_CALL (arch_prctl, ARCH_CET_STATUS, cet_status) == 0)
     return cet_status[0];
   return 0;
 }
diff --git a/sysdeps/unix/sysv/linux/x86/dl-cet.h b/sysdeps/unix/sysv/linux/x86/dl-cet.h
index a5cd95f4c3..1410f0fb59 100644
--- a/sysdeps/unix/sysv/linux/x86/dl-cet.h
+++ b/sysdeps/unix/sysv/linux/x86/dl-cet.h
@@ -22,14 +22,13 @@ static inline int __attribute__ ((always_inline))
 dl_cet_allocate_legacy_bitmap (unsigned long *legacy_bitmap)
 {
   /* Allocate legacy bitmap.  */
-  INTERNAL_SYSCALL_DECL (err);
 #ifdef __LP64__
-  return (int) INTERNAL_SYSCALL (arch_prctl, err, 2,
-				 ARCH_CET_LEGACY_BITMAP, legacy_bitmap);
+  return (int) INTERNAL_SYSCALL_CALL (arch_prctl, 
+				      ARCH_CET_LEGACY_BITMAP, legacy_bitmap);
 #else
   unsigned long long legacy_bitmap_u64[2];
-  int res = INTERNAL_SYSCALL (arch_prctl, err, 2,
-			      ARCH_CET_LEGACY_BITMAP, legacy_bitmap_u64);
+  int res = INTERNAL_SYSCALL_CALL (arch_prctl, 
+				   ARCH_CET_LEGACY_BITMAP, legacy_bitmap_u64);
   if (res == 0)
     {
       legacy_bitmap[0] = legacy_bitmap_u64[0];
@@ -42,14 +41,12 @@ dl_cet_allocate_legacy_bitmap (unsigned long *legacy_bitmap)
 static inline int __attribute__ ((always_inline))
 dl_cet_disable_cet (unsigned int cet_feature)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  return (int) INTERNAL_SYSCALL (arch_prctl, err, 2, ARCH_CET_DISABLE,
-				 cet_feature);
+  return (int) INTERNAL_SYSCALL_CALL (arch_prctl, ARCH_CET_DISABLE,
+				      cet_feature);
 }
 
 static inline int __attribute__ ((always_inline))
 dl_cet_lock_cet (void)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  return (int) INTERNAL_SYSCALL (arch_prctl, err, 2, ARCH_CET_LOCK, 0);
+  return (int) INTERNAL_SYSCALL_CALL (arch_prctl, ARCH_CET_LOCK, 0);
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index d91e00572c..9897fbec78 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -56,8 +56,10 @@
 /* We don't want the label for the error handle to be global when we define
    it here.  */
 # ifdef PIC
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL 0f
 # else
+#  undef SYSCALL_ERROR_LABEL
 #  define SYSCALL_ERROR_LABEL syscall_error
 # endif
 
@@ -189,15 +191,15 @@
 #define ARGIFY(X) ((__typeof__ ((X) - (X))) (X))
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)			\
-	internal_syscall##nr (SYS_ify (name), err, args)
+#define INTERNAL_SYSCALL(name, nr, args...)				\
+	internal_syscall##nr (SYS_ify (name), args)
 
 #undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
-	internal_syscall##nr (number, err, args)
+#define INTERNAL_SYSCALL_NCS(number, nr, args...)			\
+	internal_syscall##nr (number, args)
 
 #undef internal_syscall0
-#define internal_syscall0(number, err, dummy...)			\
+#define internal_syscall0(number, dummy...)				\
 ({									\
     unsigned long int resultvar;					\
     asm volatile (							\
@@ -209,7 +211,7 @@
 })
 
 #undef internal_syscall1
-#define internal_syscall1(number, err, arg1)				\
+#define internal_syscall1(number, arg1)					\
 ({									\
     unsigned long int resultvar;					\
     TYPEFY (arg1, __arg1) = ARGIFY (arg1);			 	\
@@ -223,7 +225,7 @@
 })
 
 #undef internal_syscall2
-#define internal_syscall2(number, err, arg1, arg2)			\
+#define internal_syscall2(number, arg1, arg2)				\
 ({									\
     unsigned long int resultvar;					\
     TYPEFY (arg2, __arg2) = ARGIFY (arg2);			 	\
@@ -239,7 +241,7 @@
 })
 
 #undef internal_syscall3
-#define internal_syscall3(number, err, arg1, arg2, arg3)		\
+#define internal_syscall3(number, arg1, arg2, arg3)			\
 ({									\
     unsigned long int resultvar;					\
     TYPEFY (arg3, __arg3) = ARGIFY (arg3);			 	\
@@ -257,7 +259,7 @@
 })
 
 #undef internal_syscall4
-#define internal_syscall4(number, err, arg1, arg2, arg3, arg4)		\
+#define internal_syscall4(number, arg1, arg2, arg3, arg4)		\
 ({									\
     unsigned long int resultvar;					\
     TYPEFY (arg4, __arg4) = ARGIFY (arg4);			 	\
@@ -277,7 +279,7 @@
 })
 
 #undef internal_syscall5
-#define internal_syscall5(number, err, arg1, arg2, arg3, arg4, arg5)	\
+#define internal_syscall5(number, arg1, arg2, arg3, arg4, arg5)	\
 ({									\
     unsigned long int resultvar;					\
     TYPEFY (arg5, __arg5) = ARGIFY (arg5);			 	\
@@ -300,7 +302,7 @@
 })
 
 #undef internal_syscall6
-#define internal_syscall6(number, err, arg1, arg2, arg3, arg4, arg5, arg6) \
+#define internal_syscall6(number, arg1, arg2, arg3, arg4, arg5, arg6) \
 ({									\
     unsigned long int resultvar;					\
     TYPEFY (arg6, __arg6) = ARGIFY (arg6);			 	\
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/times.c b/sysdeps/unix/sysv/linux/x86_64/x32/times.c
index fb93cb609c..864c123117 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/times.c
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/times.c
@@ -20,7 +20,7 @@
 
 /* Linux times system call returns 64-bit integer.  */
 #undef internal_syscall1
-#define internal_syscall1(number, err, arg1)				\
+#define internal_syscall1(number, arg1)				\
 ({									\
     unsigned long long int resultvar;					\
     TYPEFY (arg1, __arg1) = ARGIFY (arg1);			 	\
@@ -34,7 +34,7 @@
 })
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+#define INTERNAL_SYSCALL_ERROR_P(val) \
   ((unsigned long long int) (val) >= -4095LL)
 
 #include <sysdeps/unix/sysv/linux/times.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH 10/15] riscv: Avoid clobbering register parameters in syscall
  2020-02-10 19:20 ` [PATCH 10/15] riscv: " Adhemerval Zanella
@ 2020-02-10 19:51   ` DJ Delorie
  2020-02-10 21:27     ` Palmer Dabbelt
  0 siblings, 1 reply; 63+ messages in thread
From: DJ Delorie @ 2020-02-10 19:51 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha


Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>  	long int _sys_result;						\
> +	long int _arg0 = (long int) (arg0);				\
>  									\
>  	{								\
>  	register long int __a7 asm ("a7") = number;			\
> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
> +	register long int __a0 asm ("a0") = _arg0;			\

Ok

>  	long int _sys_result;						\
> +	long int _arg0 = (long int) (arg0);				\
> +	long int _arg1 = (long int) (arg1);				\
>  									\
>  	{								\
>  	register long int __a7 asm ("a7") = number;			\
> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
> +	register long int __a0 asm ("a0") = _arg0;			\
> +	register long int __a1 asm ("a1") = _arg1;			\

Ok.

>  	long int _sys_result;						\
> +	long int _arg0 = (long int) (arg0);				\
> +	long int _arg1 = (long int) (arg1);				\
> +	long int _arg2 = (long int) (arg2);				\
>  									\
>  	{								\
>  	register long int __a7 asm ("a7") = number;			\
> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
> +	register long int __a0 asm ("a0") = _arg0;			\
> +	register long int __a1 asm ("a1") = _arg1;			\
> +	register long int __a2 asm ("a2") = _arg2;			\

Ok.

>  	long int _sys_result;						\
> +	long int _arg0 = (long int) (arg0);				\
> +	long int _arg1 = (long int) (arg1);				\
> +	long int _arg2 = (long int) (arg2);				\
> +	long int _arg3 = (long int) (arg3);				\
>  									\
>  	{								\
>  	register long int __a7 asm ("a7") = number;			\
> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
> +	register long int __a0 asm ("a0") = _arg0;			\
> +	register long int __a1 asm ("a1") = _arg1;			\
> +	register long int __a2 asm ("a2") = _arg2;			\
> +	register long int __a3 asm ("a3") = _arg3;			\

Ok.

>  	long int _sys_result;						\
> +	long int _arg0 = (long int) (arg0);				\
> +	long int _arg1 = (long int) (arg1);				\
> +	long int _arg2 = (long int) (arg2);				\
> +	long int _arg3 = (long int) (arg3);				\
> +	long int _arg4 = (long int) (arg4);				\
>  									\
>  	{								\
>  	register long int __a7 asm ("a7") = number;			\
> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
> -	register long int __a4 asm ("a4") = (long int) (arg4);		\
> +	register long int __a0 asm ("a0") = _arg0;			\
> +	register long int __a1 asm ("a1") = _arg1;			\
> +	register long int __a2 asm ("a2") = _arg2;			\
> +	register long int __a3 asm ("a3") = _arg3;			\
> +	register long int __a4 asm ("a4") = _arg4;			\

Ok

>  ({ 									\
>  	long int _sys_result;						\
> +	long int _arg0 = (long int) (arg0);				\
> +	long int _arg1 = (long int) (arg1);				\
> +	long int _arg2 = (long int) (arg2);				\
> +	long int _arg3 = (long int) (arg3);				\
> +	long int _arg4 = (long int) (arg4);				\
> +	long int _arg5 = (long int) (arg5);				\
>  									\
>  	{								\
>  	register long int __a7 asm ("a7") = number;			\
> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
> -	register long int __a4 asm ("a4") = (long int) (arg4);		\
> -	register long int __a5 asm ("a5") = (long int) (arg5);		\
> +	register long int __a0 asm ("a0") = _arg0;			\
> +	register long int __a1 asm ("a1") = _arg1;			\
> +	register long int __a2 asm ("a2") = _arg2;			\
> +	register long int __a3 asm ("a3") = _arg3;			\
> +	register long int __a4 asm ("a4") = _arg4;			\
> +	register long int __a5 asm ("a5") = _arg5;			\

Ok.

>  	long int _sys_result;						\
> +	long int _arg0 = (long int) (arg0);				\
> +	long int _arg1 = (long int) (arg1);				\
> +	long int _arg2 = (long int) (arg2);				\
> +	long int _arg3 = (long int) (arg3);				\
> +	long int _arg4 = (long int) (arg4);				\
> +	long int _arg5 = (long int) (arg5);				\
> +	long int _arg6 = (long int) (arg6);				\
>  									\
>  	{								\
>  	register long int __a7 asm ("a7") = number;			\
> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
> -	register long int __a4 asm ("a4") = (long int) (arg4);		\
> -	register long int __a5 asm ("a5") = (long int) (arg5);		\
> -	register long int __a6 asm ("a6") = (long int) (arg6);		\
> +	register long int __a0 asm ("a0") = _arg0;			\
> +	register long int __a1 asm ("a1") = _arg1;			\
> +	register long int __a2 asm ("a2") = _arg2;			\
> +	register long int __a3 asm ("a3") = _arg3;			\
> +	register long int __a4 asm ("a4") = _arg4;			\
> +	register long int __a5 asm ("a5") = _arg5;			\
> +	register long int __a6 asm ("a6") = _arg6;			\

Ok.

Reviewed-by: DJ Delorie <dj@redhat.com>


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 10/15] riscv: Avoid clobbering register parameters in syscall
  2020-02-10 19:51   ` DJ Delorie
@ 2020-02-10 21:27     ` Palmer Dabbelt
  2020-02-10 21:55       ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Palmer Dabbelt @ 2020-02-10 21:27 UTC (permalink / raw)
  To: dj; +Cc: adhemerval.zanella, libc-alpha

On Mon, 10 Feb 2020 11:51:05 PST (-0800), dj@redhat.com wrote:
>
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>>  	long int _sys_result;						\
>> +	long int _arg0 = (long int) (arg0);				\
>>  									\
>>  	{								\
>>  	register long int __a7 asm ("a7") = number;			\
>> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
>> +	register long int __a0 asm ("a0") = _arg0;			\
>
> Ok

Ya, thanks -- I found this behavior super surprising.  I'm assuming you're
commiting this one (you is Adhemerval here)?

>
>>  	long int _sys_result;						\
>> +	long int _arg0 = (long int) (arg0);				\
>> +	long int _arg1 = (long int) (arg1);				\
>>  									\
>>  	{								\
>>  	register long int __a7 asm ("a7") = number;			\
>> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
>> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
>> +	register long int __a0 asm ("a0") = _arg0;			\
>> +	register long int __a1 asm ("a1") = _arg1;			\
>
> Ok.
>
>>  	long int _sys_result;						\
>> +	long int _arg0 = (long int) (arg0);				\
>> +	long int _arg1 = (long int) (arg1);				\
>> +	long int _arg2 = (long int) (arg2);				\
>>  									\
>>  	{								\
>>  	register long int __a7 asm ("a7") = number;			\
>> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
>> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
>> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
>> +	register long int __a0 asm ("a0") = _arg0;			\
>> +	register long int __a1 asm ("a1") = _arg1;			\
>> +	register long int __a2 asm ("a2") = _arg2;			\
>
> Ok.
>
>>  	long int _sys_result;						\
>> +	long int _arg0 = (long int) (arg0);				\
>> +	long int _arg1 = (long int) (arg1);				\
>> +	long int _arg2 = (long int) (arg2);				\
>> +	long int _arg3 = (long int) (arg3);				\
>>  									\
>>  	{								\
>>  	register long int __a7 asm ("a7") = number;			\
>> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
>> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
>> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
>> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
>> +	register long int __a0 asm ("a0") = _arg0;			\
>> +	register long int __a1 asm ("a1") = _arg1;			\
>> +	register long int __a2 asm ("a2") = _arg2;			\
>> +	register long int __a3 asm ("a3") = _arg3;			\
>
> Ok.
>
>>  	long int _sys_result;						\
>> +	long int _arg0 = (long int) (arg0);				\
>> +	long int _arg1 = (long int) (arg1);				\
>> +	long int _arg2 = (long int) (arg2);				\
>> +	long int _arg3 = (long int) (arg3);				\
>> +	long int _arg4 = (long int) (arg4);				\
>>  									\
>>  	{								\
>>  	register long int __a7 asm ("a7") = number;			\
>> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
>> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
>> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
>> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
>> -	register long int __a4 asm ("a4") = (long int) (arg4);		\
>> +	register long int __a0 asm ("a0") = _arg0;			\
>> +	register long int __a1 asm ("a1") = _arg1;			\
>> +	register long int __a2 asm ("a2") = _arg2;			\
>> +	register long int __a3 asm ("a3") = _arg3;			\
>> +	register long int __a4 asm ("a4") = _arg4;			\
>
> Ok
>
>>  ({ 									\
>>  	long int _sys_result;						\
>> +	long int _arg0 = (long int) (arg0);				\
>> +	long int _arg1 = (long int) (arg1);				\
>> +	long int _arg2 = (long int) (arg2);				\
>> +	long int _arg3 = (long int) (arg3);				\
>> +	long int _arg4 = (long int) (arg4);				\
>> +	long int _arg5 = (long int) (arg5);				\
>>  									\
>>  	{								\
>>  	register long int __a7 asm ("a7") = number;			\
>> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
>> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
>> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
>> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
>> -	register long int __a4 asm ("a4") = (long int) (arg4);		\
>> -	register long int __a5 asm ("a5") = (long int) (arg5);		\
>> +	register long int __a0 asm ("a0") = _arg0;			\
>> +	register long int __a1 asm ("a1") = _arg1;			\
>> +	register long int __a2 asm ("a2") = _arg2;			\
>> +	register long int __a3 asm ("a3") = _arg3;			\
>> +	register long int __a4 asm ("a4") = _arg4;			\
>> +	register long int __a5 asm ("a5") = _arg5;			\
>
> Ok.
>
>>  	long int _sys_result;						\
>> +	long int _arg0 = (long int) (arg0);				\
>> +	long int _arg1 = (long int) (arg1);				\
>> +	long int _arg2 = (long int) (arg2);				\
>> +	long int _arg3 = (long int) (arg3);				\
>> +	long int _arg4 = (long int) (arg4);				\
>> +	long int _arg5 = (long int) (arg5);				\
>> +	long int _arg6 = (long int) (arg6);				\
>>  									\
>>  	{								\
>>  	register long int __a7 asm ("a7") = number;			\
>> -	register long int __a0 asm ("a0") = (long int) (arg0);		\
>> -	register long int __a1 asm ("a1") = (long int) (arg1);		\
>> -	register long int __a2 asm ("a2") = (long int) (arg2);		\
>> -	register long int __a3 asm ("a3") = (long int) (arg3);		\
>> -	register long int __a4 asm ("a4") = (long int) (arg4);		\
>> -	register long int __a5 asm ("a5") = (long int) (arg5);		\
>> -	register long int __a6 asm ("a6") = (long int) (arg6);		\
>> +	register long int __a0 asm ("a0") = _arg0;			\
>> +	register long int __a1 asm ("a1") = _arg1;			\
>> +	register long int __a2 asm ("a2") = _arg2;			\
>> +	register long int __a3 asm ("a3") = _arg3;			\
>> +	register long int __a4 asm ("a4") = _arg4;			\
>> +	register long int __a5 asm ("a5") = _arg5;			\
>> +	register long int __a6 asm ("a6") = _arg6;			\
>
> Ok.
>
> Reviewed-by: DJ Delorie <dj@redhat.com>

Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>

Thanks!

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 10/15] riscv: Avoid clobbering register parameters in syscall
  2020-02-10 21:27     ` Palmer Dabbelt
@ 2020-02-10 21:55       ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-10 21:55 UTC (permalink / raw)
  To: Palmer Dabbelt, dj; +Cc: libc-alpha



On 10/02/2020 18:27, Palmer Dabbelt wrote:
> On Mon, 10 Feb 2020 11:51:05 PST (-0800), dj@redhat.com wrote:
>>
>> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>>>      long int _sys_result;                        \
>>> +    long int _arg0 = (long int) (arg0);                \
>>>                                      \
>>>      {                                \
>>>      register long int __a7 asm ("a7") = number;            \
>>> -    register long int __a0 asm ("a0") = (long int) (arg0);        \
>>> +    register long int __a0 asm ("a0") = _arg0;            \
>>
>> Ok
> 
> Ya, thanks -- I found this behavior super surprising.  I'm assuming you're
> commiting this one (you is Adhemerval here)?

Yes, this should be independent from the patchset.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 06/15] mips64: Consolidate Linux sysdep.h
  2020-02-10 19:20 ` [PATCH 06/15] mips64: Consolidate Linux sysdep.h Adhemerval Zanella
@ 2020-02-10 22:48   ` Joseph Myers
  2020-02-11 19:05     ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Joseph Myers @ 2020-02-10 22:48 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mon, 10 Feb 2020, Adhemerval Zanella wrote:

> The mips64 Linux syscall macros only differs argument type and
> the requirement of zero-extending values on n32.  The headers

It's sign-extension, not zero-extension (because that's the 
architecturally-defined rule for how 32-bit values must be represented in 
64-bit registers for 32-bit instructions to work correctly - though 
current Linux kernels ensure syscall arguments are properly extended 
before they reach any C functions in the kernel).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-10 19:20 ` [PATCH 03/15] sparc: " Adhemerval Zanella
@ 2020-02-11 11:15   ` Florian Weimer
  2020-02-11 18:55     ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 11:15 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> +	if (__glibc_unlikely (__g1 != 0)) 				\

This change is inconsistent with the other updates, which use __g1 ==
-1.  Is this deliberate?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-10 19:20 ` [PATCH 02/15] powerpc: Use Linux kABI for syscall return Adhemerval Zanella
@ 2020-02-11 11:18   ` Florian Weimer
  2020-02-11 12:14     ` Adhemerval Zanella
  2020-02-11 19:45   ` Florian Weimer
  1 sibling, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 11:18 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> index 01c26be24b..abdcfd4a63 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> @@ -60,9 +60,8 @@
>         : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
>           "+r" (r7), "+r" (r8)						\
>         : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
> -    err = (long int) r0;						\
>      __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
> -    rval;								\
> +    (long int) r0 & (1 << 28) ? -rval : rval;				\
>    })
>  
>  #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
> @@ -110,21 +109,20 @@
>         : ASM_INPUT_##nr							\
>         : "r9", "r10", "r11", "r12",					\
>           "cr0", "ctr", "memory");					\
> -	  err = r0;  \
> -    r3;  \
> +    r0 & (1 << 28) ? -r3 : r3;						\
>    })
>  #define INTERNAL_SYSCALL(name, err, nr, args...)			\
>    INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
>  
>  #undef INTERNAL_SYSCALL_DECL
> -#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>  
>  #undef INTERNAL_SYSCALL_ERROR_P
>  #define INTERNAL_SYSCALL_ERROR_P(val, err) \
> -  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
> +  ((unsigned long) (val) >= (unsigned long) -4095)
>  
>  #undef INTERNAL_SYSCALL_ERRNO
> -#define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
> +#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
>  
>  #if defined(__PPC64__) || defined(__powerpc64__)
>  # define SYSCALL_ARG_SIZE 8

What's the baseline for this patch?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-10 19:20 ` [PATCH 08/15] nios2: " Adhemerval Zanella
@ 2020-02-11 11:20   ` Florian Weimer
  2020-02-11 19:09     ` Adhemerval Zanella
  2020-02-11 11:50   ` Andreas Schwab
  2020-02-19 21:40   ` Vineet Gupta
  2 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 11:20 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
> +  ((unsigned long) (val) >= (unsigned long) -4095)

This should use unsigned long int.  Rest looks okay.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall
  2020-02-10 19:20 ` [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall Adhemerval Zanella
@ 2020-02-11 11:21   ` Florian Weimer
  2020-02-11 19:10     ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 11:21 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> The microblaze INTERNAL_SYSCALL macro might clobber the register
> parameter if the argument itself might clobber any register (a function
> call for instance).
>
> This patch fixes it by using temporary variables for the expressions
> between the register assignments (as indicated by GCC documentation,
> 6.47.5.2 Specifying Registers for Local Variables).
>
> It is similar to the fix done for MIPS (BZ#25523).

(bug 25523) for the bug reference, so that it will be recognized by the
commit hook.  Rest looks good.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall
  2020-02-10 19:20 ` [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall Adhemerval Zanella
@ 2020-02-11 11:22   ` Florian Weimer
  2020-02-11 19:17     ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 11:22 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> The sparc INTERNAL_SYSCALL macro might clobber the register
> parameter if the argument itself might clobber any register (a function
> call for instance).
>
> This patch fixes it by using temporary variables for the expressions
> between the register assignments (as indicated by GCC documentation,
> 6.47.5.2 Specifying Registers for Local Variables).
>
> It is similar to the fix done for MIPS (BZ#25523).

(bug 25523) for the bug reference.  You may also consider switching to
long int instead of long, given that you change most of the code anyway.
Otherwise looks good.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule
  2020-02-10 19:20 ` [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule Adhemerval Zanella
@ 2020-02-11 11:23   ` Florian Weimer
  2020-02-11 11:51     ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 11:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> ---
>  nptl/Makefile | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/nptl/Makefile b/nptl/Makefile
> index 6f210d60e3..fcdc72adfe 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -327,8 +327,7 @@ test-xfail-tst-once5 = yes
>  # Files which must not be linked with libpthread.
>  tests-nolibpthread = tst-unload
>  
> -gen-as-const-headers = pthread-errnos.sym \
> -		       unwindbuf.sym \
> +gen-as-const-headers = unwindbuf.sym \
>  		       pthread-pi-defines.sym
>  
>  gen-py-const-headers := nptl_lock_constants.pysym

I don't think this is unused?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-10 19:20 ` [PATCH 08/15] nios2: " Adhemerval Zanella
  2020-02-11 11:20   ` Florian Weimer
@ 2020-02-11 11:50   ` Andreas Schwab
  2020-02-19 21:40   ` Vineet Gupta
  2 siblings, 0 replies; 63+ messages in thread
From: Andreas Schwab @ 2020-02-11 11:50 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Feb 10 2020, Adhemerval Zanella wrote:

> diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
> index b02730bd23..eab888df32 100644
> --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
> @@ -157,13 +157,14 @@
>       (int) result_var; })
>  
>  #undef INTERNAL_SYSCALL_DECL
> -#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>  
>  #undef INTERNAL_SYSCALL_ERROR_P
> -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
> +  ((unsigned long) (val) >= (unsigned long) -4095)

Perhaps -4095UL instead?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule
  2020-02-11 11:23   ` Florian Weimer
@ 2020-02-11 11:51     ` Florian Weimer
  2020-02-11 21:01       ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 11:51 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Florian Weimer:

> * Adhemerval Zanella:
>
>> ---
>>  nptl/Makefile | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/nptl/Makefile b/nptl/Makefile
>> index 6f210d60e3..fcdc72adfe 100644
>> --- a/nptl/Makefile
>> +++ b/nptl/Makefile
>> @@ -327,8 +327,7 @@ test-xfail-tst-once5 = yes
>>  # Files which must not be linked with libpthread.
>>  tests-nolibpthread = tst-unload
>>  
>> -gen-as-const-headers = pthread-errnos.sym \
>> -		       unwindbuf.sym \
>> +gen-as-const-headers = unwindbuf.sym \
>>  		       pthread-pi-defines.sym
>>  
>>  gen-py-const-headers := nptl_lock_constants.pysym
>
> I don't think this is unused?

Sorry, I see the changes now.  But why doesn't this patch delete the
pthread-errnos.sym file as well?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 13/15] linux: Consolidate INLINE_SYSCALL
  2020-02-10 19:20 ` [PATCH 13/15] linux: Consolidate INLINE_SYSCALL Adhemerval Zanella
@ 2020-02-11 12:03   ` Florian Weimer
  2020-02-11 20:53     ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 12:03 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
> index c7f3e54d37..389c94cfda 100644
> --- a/sysdeps/unix/sysv/linux/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/sysdep.h
> @@ -15,8 +15,44 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> +#ifndef _SYSDEP_LINUX_H
> +#define _SYSDEP_LINUX_H
> +
>  #include <bits/wordsize.h>
>  #include <kernel-features.h>
> +#include <errno.h>
> +
> +#ifndef __ASSEMBLER__
> +
> +#undef INTERNAL_SYSCALL_DECL
> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)

I think these preprocessor directives should be indented (including most
of the rest of the file).

> +#undef INTERNAL_SYSCALL_ERROR_P
> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
> +  ((unsigned long) (val) > -4096UL)
> +
> +#ifndef SYSCALL_ERROR_LABEL
> +# define SYSCALL_ERROR_LABEL(sc_err)					\
> +  ({									\
> +    __set_errno (sc_err);						\
> +    -1L;								\
> +  })
> +#endif
> +
> +/* This version is for kernels that implement system calls that
> +   behave like function calls as far as register saving.  */
> +#undef INLINE_SYSCALL
> +#define INLINE_SYSCALL(name, nr, args...)				\
> +  ({									\
> +    INTERNAL_SYSCALL_DECL (sc_err);					\
> +    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
> +    __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))	\
> +    ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err))	\
> +    : sc_ret;								\
> +  })

The comment seems misleading to me.  Does “register saving” really
matter here?  I think it's about the -errno behavior.  I think the
comment should explain how this macro is to be used (i.e., it sets errno
on failure).

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-11 11:18   ` Florian Weimer
@ 2020-02-11 12:14     ` Adhemerval Zanella
  2020-02-11 12:31       ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 12:14 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 08:18, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>> index 01c26be24b..abdcfd4a63 100644
>> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>> @@ -60,9 +60,8 @@
>>         : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
>>           "+r" (r7), "+r" (r8)						\
>>         : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
>> -    err = (long int) r0;						\
>>      __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
>> -    rval;								\
>> +    (long int) r0 & (1 << 28) ? -rval : rval;				\
>>    })
>>  
>>  #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
>> @@ -110,21 +109,20 @@
>>         : ASM_INPUT_##nr							\
>>         : "r9", "r10", "r11", "r12",					\
>>           "cr0", "ctr", "memory");					\
>> -	  err = r0;  \
>> -    r3;  \
>> +    r0 & (1 << 28) ? -r3 : r3;						\
>>    })
>>  #define INTERNAL_SYSCALL(name, err, nr, args...)			\
>>    INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
>>  
>>  #undef INTERNAL_SYSCALL_DECL
>> -#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>>  
>>  #undef INTERNAL_SYSCALL_ERROR_P
>>  #define INTERNAL_SYSCALL_ERROR_P(val, err) \
>> -  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
>> +  ((unsigned long) (val) >= (unsigned long) -4095)
>>  
>>  #undef INTERNAL_SYSCALL_ERRNO
>> -#define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
>> +#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
>>  
>>  #if defined(__PPC64__) || defined(__powerpc64__)
>>  # define SYSCALL_ARG_SIZE 8
> 
> What's the baseline for this patch?

To simplify the Linux syscall handling on all architectures by using the
already set kABI interface (where returns values from
0xfffffffffffff000 to 0xffffffffffffffff indicates an error). The idea
is initially to consolidate the INLINE_SYSCALL macro and remove the
INTERNAL_SYSCALL_DECL macro.

This refactoring is an initial one, my long-term goal is twofold:

  1. Remove the assembly macros to define syscall and only use the
     C interface. It simplifies ports, requires less hackery to handle
     all its subtitles in C generations (static/pic/etc), and most likely
     would play nice on a possible LTO build.

  2. Rework the syscall interfaces to use static inline instead of
     macros. It will avoid the argument handling that led to the
     subtle BZ#25523 bug and it defines a proper kABI interface.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-11 12:14     ` Adhemerval Zanella
@ 2020-02-11 12:31       ` Florian Weimer
  2020-02-11 13:31         ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 12:31 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> On 11/02/2020 08:18, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>>> index 01c26be24b..abdcfd4a63 100644
>>> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>>> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>>> @@ -60,9 +60,8 @@
>>>         : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
>>>           "+r" (r7), "+r" (r8)						\
>>>         : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
>>> -    err = (long int) r0;						\
>>>      __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
>>> -    rval;								\
>>> +    (long int) r0 & (1 << 28) ? -rval : rval;				\
>>>    })
>>>  
>>>  #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
>>> @@ -110,21 +109,20 @@
>>>         : ASM_INPUT_##nr							\
>>>         : "r9", "r10", "r11", "r12",					\
>>>           "cr0", "ctr", "memory");					\
>>> -	  err = r0;  \
>>> -    r3;  \
>>> +    r0 & (1 << 28) ? -r3 : r3;						\
>>>    })
>>>  #define INTERNAL_SYSCALL(name, err, nr, args...)			\
>>>    INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
>>>  
>>>  #undef INTERNAL_SYSCALL_DECL
>>> -#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
>>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>>>  
>>>  #undef INTERNAL_SYSCALL_ERROR_P
>>>  #define INTERNAL_SYSCALL_ERROR_P(val, err) \
>>> -  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
>>> +  ((unsigned long) (val) >= (unsigned long) -4095)
>>>  
>>>  #undef INTERNAL_SYSCALL_ERRNO
>>> -#define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
>>> +#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
>>>  
>>>  #if defined(__PPC64__) || defined(__powerpc64__)
>>>  # define SYSCALL_ARG_SIZE 8
>> 
>> What's the baseline for this patch?
>
> To simplify the Linux syscall handling on all architectures by using the
> already set kABI interface (where returns values from
> 0xfffffffffffff000 to 0xffffffffffffffff indicates an error). The idea
> is initially to consolidate the INLINE_SYSCALL macro and remove the
> INTERNAL_SYSCALL_DECL macro.
>
> This refactoring is an initial one, my long-term goal is twofold:
>
>   1. Remove the assembly macros to define syscall and only use the
>      C interface. It simplifies ports, requires less hackery to handle
>      all its subtitles in C generations (static/pic/etc), and most likely
>      would play nice on a possible LTO build.
>
>   2. Rework the syscall interfaces to use static inline instead of
>      macros. It will avoid the argument handling that led to the
>      subtle BZ#25523 bug and it defines a proper kABI interface.

I meant that the patch doesn't seem to be against master.

I don't have the object 01c26be24b locally.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL
  2020-02-10 19:20 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
@ 2020-02-11 12:34   ` Florian Weimer
  2020-02-11 12:36   ` Florian Weimer
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 12:34 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> index 75d483c59b..8e9cb187d2 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> @@ -37,6 +37,7 @@
>  /* We don't want the label for the error handler to be visible in the symbol
>     table when we define it here.  */
>  #ifdef __PIC__
> +# undef SYSCALL_ERROR_LABEL
>  # define SYSCALL_ERROR_LABEL 99b
>  #endif

This change seems like it would fit more into patch 13?

(Also for mips64, s390, s390x, x86-64.)

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL
  2020-02-10 19:20 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
  2020-02-11 12:34   ` Florian Weimer
@ 2020-02-11 12:36   ` Florian Weimer
  2020-02-11 20:57     ` Adhemerval Zanella
  2020-02-11 12:48   ` Florian Weimer
  2020-02-15  7:51   ` Andreas Schwab
  3 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 12:36 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> diff --git a/sysdeps/unix/sysv/linux/personality.c b/sysdeps/unix/sysv/linux/personality.c
> index 970bd7becd..d0c597b6a0 100644
> --- a/sysdeps/unix/sysv/linux/personality.c
> +++ b/sysdeps/unix/sysv/linux/personality.c
> @@ -35,15 +35,14 @@ __personality (unsigned long persona)
>    persona = (unsigned int) persona;
>  #endif
>  
> -  INTERNAL_SYSCALL_DECL (err);
> -  long ret = INTERNAL_SYSCALL (personality, err, 1, persona);
> +  long 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, err)))
> -    ret = -INTERNAL_SYSCALL_ERRNO (ret, err);
> +  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
> +    ret = -INTERNAL_SYSCALL_ERRNO (ret);
>    return ret;
>  }
>  weak_alias (__personality, personality)

The comment is now outdated, I think, and the code should be simplified
in this change (maybe as a separate commit).  You could also use long
int instead of long here.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL
  2020-02-10 19:20 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
  2020-02-11 12:34   ` Florian Weimer
  2020-02-11 12:36   ` Florian Weimer
@ 2020-02-11 12:48   ` Florian Weimer
  2020-02-11 20:55     ` Adhemerval Zanella
  2020-02-15  7:51   ` Andreas Schwab
  3 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 12:48 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> With all Linux ABIs using the expected Linux kABI to indicate
> syscalls errors, the INTERNAL_SYSCALL_DECL is an empty declaration
> on all ports.
>
> This patch removes the 'err' argument on INTERNAL_SYSCALL* macro
> and remove the INTERNAL_SYSCALL_DECL usage.

I see some cases where you modify lines which contain INTERNAL_SYSCALL
without changing it to INTERNAL_SYSCALL_CALL.  Maybe you can fix those
as well?

Same for long vs long int.

Apart from the other quirks I mentioned, this patch looks okay to me.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-11 12:31       ` Florian Weimer
@ 2020-02-11 13:31         ` Adhemerval Zanella
  2020-02-11 19:45           ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 13:31 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 09:31, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 11/02/2020 08:18, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>>>> index 01c26be24b..abdcfd4a63 100644
>>>> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>>>> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>>>> @@ -60,9 +60,8 @@
>>>>         : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
>>>>           "+r" (r7), "+r" (r8)						\
>>>>         : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
>>>> -    err = (long int) r0;						\
>>>>      __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
>>>> -    rval;								\
>>>> +    (long int) r0 & (1 << 28) ? -rval : rval;				\
>>>>    })
>>>>  
>>>>  #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
>>>> @@ -110,21 +109,20 @@
>>>>         : ASM_INPUT_##nr							\
>>>>         : "r9", "r10", "r11", "r12",					\
>>>>           "cr0", "ctr", "memory");					\
>>>> -	  err = r0;  \
>>>> -    r3;  \
>>>> +    r0 & (1 << 28) ? -r3 : r3;						\
>>>>    })
>>>>  #define INTERNAL_SYSCALL(name, err, nr, args...)			\
>>>>    INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
>>>>  
>>>>  #undef INTERNAL_SYSCALL_DECL
>>>> -#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
>>>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>>>>  
>>>>  #undef INTERNAL_SYSCALL_ERROR_P
>>>>  #define INTERNAL_SYSCALL_ERROR_P(val, err) \
>>>> -  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
>>>> +  ((unsigned long) (val) >= (unsigned long) -4095)
>>>>  
>>>>  #undef INTERNAL_SYSCALL_ERRNO
>>>> -#define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
>>>> +#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
>>>>  
>>>>  #if defined(__PPC64__) || defined(__powerpc64__)
>>>>  # define SYSCALL_ARG_SIZE 8
>>>
>>> What's the baseline for this patch?
>>
>> To simplify the Linux syscall handling on all architectures by using the
>> already set kABI interface (where returns values from
>> 0xfffffffffffff000 to 0xffffffffffffffff indicates an error). The idea
>> is initially to consolidate the INLINE_SYSCALL macro and remove the
>> INTERNAL_SYSCALL_DECL macro.
>>
>> This refactoring is an initial one, my long-term goal is twofold:
>>
>>   1. Remove the assembly macros to define syscall and only use the
>>      C interface. It simplifies ports, requires less hackery to handle
>>      all its subtitles in C generations (static/pic/etc), and most likely
>>      would play nice on a possible LTO build.
>>
>>   2. Rework the syscall interfaces to use static inline instead of
>>      macros. It will avoid the argument handling that led to the
>>      subtle BZ#25523 bug and it defines a proper kABI interface.
> 
> I meant that the patch doesn't seem to be against master.

Hum I just rebase against master (eb948facd8) and it does apply.  Why
do you think it does not seem to be apply against master?

> 
> I don't have the object 01c26be24b locally.
> 
> Thanks,
> Florian
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-11 11:15   ` Florian Weimer
@ 2020-02-11 18:55     ` Adhemerval Zanella
  2020-02-11 19:24       ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 18:55 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 08:15, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> +	if (__glibc_unlikely (__g1 != 0)) 				\
> 
> This change is inconsistent with the other updates, which use __g1 ==
> -1.  Is this deliberate?
> 
> Thanks,
> Florian
> 

In fact __SYSCALL_STRING already sets the 'o0' to a negative value if
the 'xcc' condition is set (indicating that the syscall has failed).
The 'g1' check is superfluous, it will be always true since 'g1' will
be either 0 or 1. 

And both the set and check of 'g1' result is also superfluous, since 'o0' 
will already hold all the required information.

Below is an updated patch, checked on sparc64-linux-gnu and 
sparcv9-linux-gnu.

--

It changes the sparc internal_syscall* macros to return a negative
value instead the 'g1' register value on 'err' macro argument.
The __SYSCALL_STRING macro is also changed to no set the 'g1'
value, since 'o1' already holds all the required information
to check if syscall has failed.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.  The
redefinition of INTERNAL_VSYSCALL_CALL is also no longer
required.

Checked on sparc64-linux-gnu and sparcv9-linux-gnu. It fixes
the sporadic issues on sparc32 where clock_nanosleep does not
act as cancellation entrypoint.
---
 .../unix/sysv/linux/sparc/sparc32/sysdep.h    |  3 +-
 .../unix/sysv/linux/sparc/sparc64/sysdep.h    |  3 +-
 sysdeps/unix/sysv/linux/sparc/sysdep.h        | 80 +++++++++----------
 3 files changed, 38 insertions(+), 48 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
index 8461261674..2c3754770b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
@@ -110,9 +110,8 @@ ENTRY(name);					\
 #define __SYSCALL_STRING						\
 	"ta	0x10;"							\
 	"bcc	1f;"							\
-	" mov	0, %%g1;"						\
+	" nop;"								\
 	"sub	%%g0, %%o0, %%o0;"					\
-	"mov	1, %%g1;"						\
 	"1:"
 
 #define __SYSCALL_CLOBBERS						\
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
index b9a4c75cbd..2010faf50f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
@@ -109,9 +109,8 @@ ENTRY(name);					\
 #define __SYSCALL_STRING						\
 	"ta	0x6d;"							\
 	"bcc,pt	%%xcc, 1f;"						\
-	" mov	0, %%g1;"						\
+	" nop;"								\
 	"sub	%%g0, %%o0, %%o0;"					\
-	"mov	1, %%g1;"						\
 	"1:"
 
 #define __SYSCALL_CLOBBERS						\
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 0c32780d9c..a0dfdbe079 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -34,13 +34,6 @@
 
 #else	/* __ASSEMBLER__ */
 
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    _ret;								\
-  })
-
 # define VDSO_NAME  "LINUX_2.6"
 # define VDSO_HASH  61765110
 
@@ -65,108 +58,107 @@
 })
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) \
-	register long err __asm__("g1");
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 #undef INTERNAL_SYSCALL
 #define INTERNAL_SYSCALL(name, err, nr, args...) \
-  inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
+  internal_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
 
 #undef INTERNAL_SYSCALL_NCS
 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-  inline_syscall##nr(__SYSCALL_STRING, err, name, args)
+  internal_syscall##nr(__SYSCALL_STRING, err, name, args)
 
 #undef INTERNAL_SYSCALL_ERROR_P
 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  ((void) (val), __builtin_expect((err) != 0, 0))
+  ((unsigned long) (val) > -4096UL)
 
 #undef INTERNAL_SYSCALL_ERRNO
 #define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
-#define inline_syscall0(string,err,name,dummy...)			\
+#define internal_syscall0(string,err,name,dummy...)			\
 ({									\
+	register long int __g1 __asm__ ("g1") = (name);			\
 	register long __o0 __asm__ ("o0");				\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err) :					\
+	__asm __volatile (string : "=r" (__o0) :			\
+			  "0" (__g1) :					\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall1(string,err,name,arg1)				\
+#define internal_syscall1(string,err,name,arg1)				\
 ({									\
+	register long int __g1 __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0) :			\
+	__asm __volatile (string : "=r" (__o0) :			\
+			  "r" (__g1), "0" (__o0) :			\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall2(string,err,name,arg1,arg2)			\
+#define internal_syscall2(string,err,name,arg1,arg2)			\
 ({									\
+	register long int __g1 __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1) :		\
+	__asm __volatile (string : "=r" (__o0) :			\
+			  "r" (__g1), "0" (__o0), "r" (__o1) :		\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall3(string,err,name,arg1,arg2,arg3)			\
+#define internal_syscall3(string,err,name,arg1,arg2,arg3)		\
 ({									\
+	register long int __g1 __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__o0) :			\
+			  "r" (__g1), "0" (__o0), "r" (__o1),		\
 			  "r" (__o2) :					\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4)		\
+#define internal_syscall4(string,err,name,arg1,arg2,arg3,arg4)		\
 ({									\
+	register long int __g1 __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__o0) :			\
+			  "r" (__g1), "0" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3) :			\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5)	\
+#define internal_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5)	\
 ({									\
+	register long int __g1 __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__o0) :			\
+			  "r" (__g1), "0" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
 			  __SYSCALL_CLOBBERS);				\
 	__o0;								\
 })
 
-#define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)	\
+#define internal_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)\
 ({									\
+	register long int __g1 __asm__("g1") = (name);			\
 	register long __o0 __asm__ ("o0") = (long)(arg1);		\
 	register long __o1 __asm__ ("o1") = (long)(arg2);		\
 	register long __o2 __asm__ ("o2") = (long)(arg3);		\
 	register long __o3 __asm__ ("o3") = (long)(arg4);		\
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
 	register long __o5 __asm__ ("o5") = (long)(arg6);		\
-	err = name;							\
-	__asm __volatile (string : "=r" (err), "=r" (__o0) :		\
-			  "0" (err), "1" (__o0), "r" (__o1),		\
+	__asm __volatile (string : "=r" (__o0) :			\
+			  "r" (__g1), "0" (__o0), "r" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4),		\
 			  "r" (__o5) :					\
 			  __SYSCALL_CLOBBERS);				\
@@ -182,13 +174,13 @@
 	register long __o4 __asm__ ("o4") = (long)(arg5);		\
 	register long __g1 __asm__ ("g1") = __NR_clone;			\
 	__asm __volatile (__SYSCALL_STRING :				\
-			  "=r" (__g1), "=r" (__o0), "=r" (__o1)	:	\
-			  "0" (__g1), "1" (__o0), "2" (__o1),		\
+			  "=r" (__o0), "=r" (__o1) :			\
+			  "r" (__g1), "0" (__o0), "1" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
 			  __SYSCALL_CLOBBERS);				\
-	if (INTERNAL_SYSCALL_ERROR_P (__o0, __g1))			\
+	if (__glibc_unlikely ((unsigned long int) (__o0) > -4096UL))	\
 	  {		     			       		   	\
-	    __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1));		\
+	    __set_errno (-__o0);					\
 	    __o0 = -1L;			    				\
 	  } 	      							\
 	else								\

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH 06/15] mips64: Consolidate Linux sysdep.h
  2020-02-10 22:48   ` Joseph Myers
@ 2020-02-11 19:05     ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 19:05 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 10/02/2020 19:48, Joseph Myers wrote:
> On Mon, 10 Feb 2020, Adhemerval Zanella wrote:
> 
>> The mips64 Linux syscall macros only differs argument type and
>> the requirement of zero-extending values on n32.  The headers
> 
> It's sign-extension, not zero-extension (because that's the 
> architecturally-defined rule for how 32-bit values must be represented in 
> 64-bit registers for 32-bit instructions to work correctly - though 
> current Linux kernels ensure syscall arguments are properly extended 
> before they reach any C functions in the kernel).
> 

Thanks, I corrected the patch description.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-11 11:20   ` Florian Weimer
@ 2020-02-11 19:09     ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 19:09 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, Andreas Schwab



On 11/02/2020 08:20, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
>> +  ((unsigned long) (val) >= (unsigned long) -4095)
> 
> This should use unsigned long int.  Rest looks okay.
> 
> Thanks,
> Florian
> 

I didn't bother because this snippet will be removed by the
'linux: Consolidate INLINE_SYSCALL' patch in this set, but you
are correct.

I have changed to:
 
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
  ((unsigned long) (val) > -4096UL)

(which is the one I used on consolidation).

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall
  2020-02-11 11:21   ` Florian Weimer
@ 2020-02-11 19:10     ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 19:10 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 08:21, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> The microblaze INTERNAL_SYSCALL macro might clobber the register
>> parameter if the argument itself might clobber any register (a function
>> call for instance).
>>
>> This patch fixes it by using temporary variables for the expressions
>> between the register assignments (as indicated by GCC documentation,
>> 6.47.5.2 Specifying Registers for Local Variables).
>>
>> It is similar to the fix done for MIPS (BZ#25523).
> 
> (bug 25523) for the bug reference, so that it will be recognized by the
> commit hook.  Rest looks good.

Ack.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall
  2020-02-11 11:22   ` Florian Weimer
@ 2020-02-11 19:17     ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 19:17 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 08:22, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> The sparc INTERNAL_SYSCALL macro might clobber the register
>> parameter if the argument itself might clobber any register (a function
>> call for instance).
>>
>> This patch fixes it by using temporary variables for the expressions
>> between the register assignments (as indicated by GCC documentation,
>> 6.47.5.2 Specifying Registers for Local Variables).
>>
>> It is similar to the fix done for MIPS (BZ#25523).
> 
> (bug 25523) for the bug reference.  You may also consider switching to
> long int instead of long, given that you change most of the code anyway.
> Otherwise looks good.

Ack I have changed to long int on my local branch.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-11 18:55     ` Adhemerval Zanella
@ 2020-02-11 19:24       ` Florian Weimer
  2020-02-11 20:29         ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 19:24 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> On 11/02/2020 08:15, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>> +	if (__glibc_unlikely (__g1 != 0)) 				\
>> 
>> This change is inconsistent with the other updates, which use __g1 ==
>> -1.  Is this deliberate?
>> 
>> Thanks,
>> Florian
>> 
>
> In fact __SYSCALL_STRING already sets the 'o0' to a negative value if
> the 'xcc' condition is set (indicating that the syscall has failed).
> The 'g1' check is superfluous, it will be always true since 'g1' will
> be either 0 or 1. 
>
> And both the set and check of 'g1' result is also superfluous, since 'o0' 
> will already hold all the required information.
>
> Below is an updated patch, checked on sparc64-linux-gnu and 
> sparcv9-linux-gnu.

I see, nice additional cleanup.

> It changes the sparc internal_syscall* macros to return a negative
> value instead the 'g1' register value on 'err' macro argument.
               ^ of                     ^ in the?


> The __SYSCALL_STRING macro is also changed to no set the 'g1'
                                                ^ not
> value, since 'o1' already holds all the required information
> to check if syscall has failed.
>
> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.  The
                          ^ macro?                 ^ kABIs
                (or drop the “the“ on the preceding line)

> redefinition of INTERNAL_VSYSCALL_CALL is also no longer
> required.
>
> Checked on sparc64-linux-gnu and sparcv9-linux-gnu. It fixes
> the sporadic issues on sparc32 where clock_nanosleep does not
> act as cancellation entrypoint.

I double-checked this against the kernel sources, and entry.S has
this:

ret_sys_call:
        ld      [%curptr + TI_FLAGS], %l6
        cmp     %o0, -ERESTART_RESTARTBLOCK
        ld      [%sp + STACKFRAME_SZ + PT_PSR], %g3
        set     PSR_C, %g2
        bgeu    1f

But ERESTART_RESTARTBLOCK is not 4095, so glibc with this change will
now treat certain internal kernel error codes as errors, while they
were previously reported as success.  This looks like a kernel bug, in
that ERESTART_RESTARTBLOCK was not updated when more error codes were
added.  On the other hand, these error codes should never leak into
userspace.

To me, your patch looks good.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/15] powerpc: Consolidate Linux syscall definition
  2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
                   ` (13 preceding siblings ...)
  2020-02-10 19:20 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
@ 2020-02-11 19:43 ` Florian Weimer
  2020-02-12 13:19   ` Adhemerval Zanella
  14 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 19:43 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> +/* Define __set_errno() for INLINE_SYSCALL macro below.  */
> +#ifndef __ASSEMBLER__
> +#include <errno.h>
> +#endif

Missing indentation (but the existing files are not consistent about
that).

> +/* Pointer mangling support.  */
> +#if defined(__PPC64__) || defined(__powerpc64__)
> +# define LOAD  ld
> +# define TPREG r13
> +#else
> +# define LOAD  lwz
> +# define TPREG r2
> +#endif

Can you restrict those to #ifdef __ASSEMBLER__?  <sysdep.h> is a
fairly widely included header, and this has the potential of breaking
future changes that compile on other architectures.

Rest looks okay to me, but maybe a POWER maintainer wants to have a
look as well.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-10 19:20 ` [PATCH 02/15] powerpc: Use Linux kABI for syscall return Adhemerval Zanella
  2020-02-11 11:18   ` Florian Weimer
@ 2020-02-11 19:45   ` Florian Weimer
  2020-02-12 13:24     ` Adhemerval Zanella
  1 sibling, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 19:45 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> It changes the powerpc INTERNAL_VSYSCALL_CALL and INTERNAL_SYSCALL_NCS
> to return a negative value instead of returning the CR value on 'err'
> macro argument.

value on?  This part is unclear to me.

> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.

See my other comment about wording here.

The patch looks reasonable to me.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-11 13:31         ` Adhemerval Zanella
@ 2020-02-11 19:45           ` Florian Weimer
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 19:45 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> Hum I just rebase against master (eb948facd8) and it does apply.  Why
> do you think it does not seem to be apply against master?

Never mind, found it, looks like I have trouble reading email today.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-11 19:24       ` Florian Weimer
@ 2020-02-11 20:29         ` Adhemerval Zanella
  2020-02-11 21:15           ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 20:29 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 16:24, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> On 11/02/2020 08:15, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> +	if (__glibc_unlikely (__g1 != 0)) 				\
>>>
>>> This change is inconsistent with the other updates, which use __g1 ==
>>> -1.  Is this deliberate?
>>>
>>> Thanks,
>>> Florian
>>>
>>
>> In fact __SYSCALL_STRING already sets the 'o0' to a negative value if
>> the 'xcc' condition is set (indicating that the syscall has failed).
>> The 'g1' check is superfluous, it will be always true since 'g1' will
>> be either 0 or 1. 
>>
>> And both the set and check of 'g1' result is also superfluous, since 'o0' 
>> will already hold all the required information.
>>
>> Below is an updated patch, checked on sparc64-linux-gnu and 
>> sparcv9-linux-gnu.
> 
> I see, nice additional cleanup.
> 
>> It changes the sparc internal_syscall* macros to return a negative
>> value instead the 'g1' register value on 'err' macro argument.
>                ^ of                     ^ in the?
> 
> 

Ack.

>> The __SYSCALL_STRING macro is also changed to no set the 'g1'
>                                                 ^ not
>> value, since 'o1' already holds all the required information
>> to check if syscall has failed.
>>
>> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
>> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.  The
>                           ^ macro?                 ^ kABIs

Ack.

>                 (or drop the “the“ on the preceding line)
> 
>> redefinition of INTERNAL_VSYSCALL_CALL is also no longer
>> required.
>>
>> Checked on sparc64-linux-gnu and sparcv9-linux-gnu. It fixes
>> the sporadic issues on sparc32 where clock_nanosleep does not
>> act as cancellation entrypoint.
> 
> I double-checked this against the kernel sources, and entry.S has
> this:
> 
> ret_sys_call:
>         ld      [%curptr + TI_FLAGS], %l6
>         cmp     %o0, -ERESTART_RESTARTBLOCK
>         ld      [%sp + STACKFRAME_SZ + PT_PSR], %g3
>         set     PSR_C, %g2
>         bgeu    1f
> 
> But ERESTART_RESTARTBLOCK is not 4095, so glibc with this change will
> now treat certain internal kernel error codes as errors, while they
> were previously reported as success.  This looks like a kernel bug, in
> that ERESTART_RESTARTBLOCK was not updated when more error codes were
> added.  On the other hand, these error codes should never leak into
> userspace.

My understanding is such errors should not be visible by the application,
as indicated by include/linux/errno.h comment. And it seems to be the
case for sparc, at least on:

arch/sparc/kernel/signal_64.c
477 static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
[...]
514         restart_syscall = 0;
515         if (pt_regs_is_syscall(regs) &&
516             (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) {
517                 restart_syscall = 1; 
518                 orig_i0 = regs->u_regs[UREG_G6];
519         }
520
521         if (has_handler) {
522                 if (restart_syscall)
523                         syscall_restart(orig_i0, regs, &ksig.ka.sa);                               
524                 signal_setup_done(setup_rt_frame(&ksig, regs), &ksig, 0);                          
525         } else {
526                 if (restart_syscall) {                                                             
527                         switch (regs->u_regs[UREG_I0]) {                                           
528                         case ERESTARTNOHAND:
529                         case ERESTARTSYS:
530                         case ERESTARTNOINTR:                                                       
531                                 /* replay the system call when we are done */                      
532                                 regs->u_regs[UREG_I0] = orig_i0;                                   
533                                 regs->tpc -= 4;
534                                 regs->tnpc -= 4;                                                   
535                                 pt_regs_clear_syscall(regs);                                       
536                                 /* fall through */                                                 
537                         case ERESTART_RESTARTBLOCK:                                                
538                                 regs->u_regs[UREG_G1] = __NR_restart_syscall;                      
539                                 regs->tpc -= 4;                                                    
540                                 regs->tnpc -= 4;                                                   
541                                 pt_regs_clear_syscall(regs);                                       
542                         }
543                 }
544             

If signal has a handler, syscall_restart will either set EINTR or
previous 'o0' value.  Otherwise if syscall should be restarted,
either it will be trying again (line 538) or previous error code
would be set.

> 
> To me, your patch looks good.
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 13/15] linux: Consolidate INLINE_SYSCALL
  2020-02-11 12:03   ` Florian Weimer
@ 2020-02-11 20:53     ` Adhemerval Zanella
  2020-02-11 21:00       ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 20:53 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 09:03, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
>> index c7f3e54d37..389c94cfda 100644
>> --- a/sysdeps/unix/sysv/linux/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/sysdep.h
>> @@ -15,8 +15,44 @@
>>     License along with the GNU C Library; if not, see
>>     <https://www.gnu.org/licenses/>.  */
>>  
>> +#ifndef _SYSDEP_LINUX_H
>> +#define _SYSDEP_LINUX_H
>> +
>>  #include <bits/wordsize.h>
>>  #include <kernel-features.h>
>> +#include <errno.h>
>> +
>> +#ifndef __ASSEMBLER__
>> +
>> +#undef INTERNAL_SYSCALL_DECL
>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
> 
> I think these preprocessor directives should be indented (including most
> of the rest of the file).

I usually avoid such changes since it generated changes unrelated to the
patch itself.  The __ASSEMBLER__ is not really required, so I removed
it. Also, my idea is to refactor this code to use inline function, so
I add the indentation change once __ASSEMBLER__ closure is really
required.

> 
>> +#undef INTERNAL_SYSCALL_ERROR_P
>> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
>> +  ((unsigned long) (val) > -4096UL)
>> +
>> +#ifndef SYSCALL_ERROR_LABEL
>> +# define SYSCALL_ERROR_LABEL(sc_err)					\
>> +  ({									\
>> +    __set_errno (sc_err);						\
>> +    -1L;								\
>> +  })
>> +#endif
>> +
>> +/* This version is for kernels that implement system calls that
>> +   behave like function calls as far as register saving.  */
>> +#undef INLINE_SYSCALL
>> +#define INLINE_SYSCALL(name, nr, args...)				\
>> +  ({									\
>> +    INTERNAL_SYSCALL_DECL (sc_err);					\
>> +    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);	\
>> +    __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))	\
>> +    ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err))	\
>> +    : sc_ret;								\
>> +  })
> 
> The comment seems misleading to me.  Does “register saving” really
> matter here?  I think it's about the -errno behavior.  I think the
> comment should explain how this macro is to be used (i.e., it sets errno
> on failure).

Indeed, it is an artefact from powerpc version.   What about:

/* 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.  */

> 
> Thanks,
> Florian
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL
  2020-02-11 12:48   ` Florian Weimer
@ 2020-02-11 20:55     ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 20:55 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 09:48, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> With all Linux ABIs using the expected Linux kABI to indicate
>> syscalls errors, the INTERNAL_SYSCALL_DECL is an empty declaration
>> on all ports.
>>
>> This patch removes the 'err' argument on INTERNAL_SYSCALL* macro
>> and remove the INTERNAL_SYSCALL_DECL usage.
> 
> I see some cases where you modify lines which contain INTERNAL_SYSCALL
> without changing it to INTERNAL_SYSCALL_CALL.  Maybe you can fix those
> as well?

Ack, I will update the patch.

> 
> Same for long vs long int.

Ack.

> 
> Apart from the other quirks I mentioned, this patch looks okay to me.
> 
> Thanks,
> Florian
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL
  2020-02-11 12:36   ` Florian Weimer
@ 2020-02-11 20:57     ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 20:57 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 09:36, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> diff --git a/sysdeps/unix/sysv/linux/personality.c b/sysdeps/unix/sysv/linux/personality.c
>> index 970bd7becd..d0c597b6a0 100644
>> --- a/sysdeps/unix/sysv/linux/personality.c
>> +++ b/sysdeps/unix/sysv/linux/personality.c
>> @@ -35,15 +35,14 @@ __personality (unsigned long persona)
>>    persona = (unsigned int) persona;
>>  #endif
>>  
>> -  INTERNAL_SYSCALL_DECL (err);
>> -  long ret = INTERNAL_SYSCALL (personality, err, 1, persona);
>> +  long 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, err)))
>> -    ret = -INTERNAL_SYSCALL_ERRNO (ret, err);
>> +  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
>> +    ret = -INTERNAL_SYSCALL_ERRNO (ret);
>>    return ret;
>>  }
>>  weak_alias (__personality, personality)
> 
> The comment is now outdated, I think, and the code should be simplified
> in this change (maybe as a separate commit).  You could also use long
> int instead of long here.
> 

I will check which is current kernel behaviour and check if this comment
still holds.  I fixed the long use internally.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 13/15] linux: Consolidate INLINE_SYSCALL
  2020-02-11 20:53     ` Adhemerval Zanella
@ 2020-02-11 21:00       ` Florian Weimer
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 21:00 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

>> The comment seems misleading to me.  Does “register saving” really
>> matter here?  I think it's about the -errno behavior.  I think the
>> comment should explain how this macro is to be used (i.e., it sets errno
>> on failure).
>
> Indeed, it is an artefact from powerpc version.   What about:
>
> /* 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.  */

Looks good.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule
  2020-02-11 11:51     ` Florian Weimer
@ 2020-02-11 21:01       ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-11 21:01 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 08:51, Florian Weimer wrote:
> * Florian Weimer:
> 
>> * Adhemerval Zanella:
>>
>>> ---
>>>  nptl/Makefile | 3 +--
>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/nptl/Makefile b/nptl/Makefile
>>> index 6f210d60e3..fcdc72adfe 100644
>>> --- a/nptl/Makefile
>>> +++ b/nptl/Makefile
>>> @@ -327,8 +327,7 @@ test-xfail-tst-once5 = yes
>>>  # Files which must not be linked with libpthread.
>>>  tests-nolibpthread = tst-unload
>>>  
>>> -gen-as-const-headers = pthread-errnos.sym \
>>> -		       unwindbuf.sym \
>>> +gen-as-const-headers = unwindbuf.sym \
>>>  		       pthread-pi-defines.sym
>>>  
>>>  gen-py-const-headers := nptl_lock_constants.pysym
>>
>> I don't think this is unused?
> 
> Sorry, I see the changes now.  But why doesn't this patch delete the
> pthread-errnos.sym file as well?

I update the patch to delete it, thanks for catching it.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-11 20:29         ` Adhemerval Zanella
@ 2020-02-11 21:15           ` Florian Weimer
  2020-02-12 12:35             ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-11 21:15 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

>> But ERESTART_RESTARTBLOCK is not 4095, so glibc with this change will
>> now treat certain internal kernel error codes as errors, while they
>> were previously reported as success.  This looks like a kernel bug, in
>> that ERESTART_RESTARTBLOCK was not updated when more error codes were
>> added.  On the other hand, these error codes should never leak into
>> userspace.
>
> My understanding is such errors should not be visible by the application,
> as indicated by include/linux/errno.h comment. And it seems to be the
> case for sparc, at least on:

These error codes tend to leak from device drivers and other less
scrutinized parts of the kernel.  It's not actually about the
ERESTART_RESTARTBLOCK value as such, there are other values larger
than that:

#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
#define EPROBE_DEFER    517     /* Driver requests probe retry */
#define EOPENSTALE      518     /* open found a stale dentry */
#define ENOPARAM        519     /* Parameter not supported */

/* Defined for the NFSv3 protocol */
#define EBADHANDLE      521     /* Illegal NFS file handle */
#define ENOTSYNC        522     /* Update synchronization mismatch */
#define EBADCOOKIE      523     /* Cookie is stale */
#define ENOTSUPP        524     /* Operation is not supported */

And so on.

Like I said, it looks like someone forgot to update this code.  It
probably should use the 4095 boundary and not specific error codes
anyway.  (We had a similar problem in glibc itself in the s390
socketcall support.)

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-11 21:15           ` Florian Weimer
@ 2020-02-12 12:35             ` Adhemerval Zanella
  2020-02-12 12:38               ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-12 12:35 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 18:15, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>>> But ERESTART_RESTARTBLOCK is not 4095, so glibc with this change will
>>> now treat certain internal kernel error codes as errors, while they
>>> were previously reported as success.  This looks like a kernel bug, in
>>> that ERESTART_RESTARTBLOCK was not updated when more error codes were
>>> added.  On the other hand, these error codes should never leak into
>>> userspace.
>>
>> My understanding is such errors should not be visible by the application,
>> as indicated by include/linux/errno.h comment. And it seems to be the
>> case for sparc, at least on:
> 
> These error codes tend to leak from device drivers and other less
> scrutinized parts of the kernel.  It's not actually about the
> ERESTART_RESTARTBLOCK value as such, there are other values larger
> than that:
> 
> #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
> #define EPROBE_DEFER    517     /* Driver requests probe retry */
> #define EOPENSTALE      518     /* open found a stale dentry */
> #define ENOPARAM        519     /* Parameter not supported */
> 
> /* Defined for the NFSv3 protocol */
> #define EBADHANDLE      521     /* Illegal NFS file handle */
> #define ENOTSYNC        522     /* Update synchronization mismatch */
> #define EBADCOOKIE      523     /* Cookie is stale */
> #define ENOTSUPP        524     /* Operation is not supported */
> 
> And so on.
> 
> Like I said, it looks like someone forgot to update this code.  It
> probably should use the 4095 boundary and not specific error codes
> anyway.  (We had a similar problem in glibc itself in the s390
> socketcall support.)
This code seems to come from since initial git repository 
(Linux-2.6.12-rc2).

From a glibc standpoint, the error handling will be the same in fact,
since what indicates the syscall has failed is the carry condition code
value, not the syscall returned value ('o0' register).


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-12 12:35             ` Adhemerval Zanella
@ 2020-02-12 12:38               ` Florian Weimer
  2020-02-12 12:56                 ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Florian Weimer @ 2020-02-12 12:38 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> This code seems to come from since initial git repository 
> (Linux-2.6.12-rc2).
>
> From a glibc standpoint, the error handling will be the same in fact,
> since what indicates the syscall has failed is the carry condition code
> value, not the syscall returned value ('o0' register).

The kernel will not set the carry condition code for large errors due
to the faulty check.  I think before your changes, we would not treat
these cases as errors because the carry condition is not set and we
check the separate err value.  After your changes, the carry condition
code is still not set, but the return value looks like an error return
value if unchanged, so we now treat these leaked error codes as
errors.

But I don't think this should block your changes.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 03/15] sparc: Use Linux kABI for syscall return
  2020-02-12 12:38               ` Florian Weimer
@ 2020-02-12 12:56                 ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-12 12:56 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 12/02/2020 09:38, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> This code seems to come from since initial git repository 
>> (Linux-2.6.12-rc2).
>>
>> From a glibc standpoint, the error handling will be the same in fact,
>> since what indicates the syscall has failed is the carry condition code
>> value, not the syscall returned value ('o0' register).
> 
> The kernel will not set the carry condition code for large errors due
> to the faulty check.  I think before your changes, we would not treat
> these cases as errors because the carry condition is not set and we
> check the separate err value.  After your changes, the carry condition
> code is still not set, but the return value looks like an error return
> value if unchanged, so we now treat these leaked error codes as
> errors.

No, the sparc 'ret_sys_call' returns abs(errno) for syscall failure,
not the value in the range of the expected Linux failure values.

So, if kernel returns a value large than ERESTART_RESTARTBLOCK *without*
set the carry condition code set current syscall code results in:

  o0 = abs (errno)
  g1 = 0

And then the variable defined by INTERNAL_SYSCALL_DECL holds '0' and 
INTERNAL_SYSCALL_ERROR_P evaluates to false.

With this change:

  o0 = abs (errno)

And INTERNAL_SYSCALL_ERROR_P, which now uses the expected Linux kABI,
will evaluate to 0 as well.

> 
> But I don't think this should block your changes.
> 


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/15] powerpc: Consolidate Linux syscall definition
  2020-02-11 19:43 ` [PATCH 01/15] powerpc: Consolidate Linux syscall definition Florian Weimer
@ 2020-02-12 13:19   ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-12 13:19 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 16:43, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> +/* Define __set_errno() for INLINE_SYSCALL macro below.  */
>> +#ifndef __ASSEMBLER__
>> +#include <errno.h>
>> +#endif
> 
> Missing indentation (but the existing files are not consistent about
> that).
> 
>> +/* Pointer mangling support.  */
>> +#if defined(__PPC64__) || defined(__powerpc64__)
>> +# define LOAD  ld
>> +# define TPREG r13
>> +#else
>> +# define LOAD  lwz
>> +# define TPREG r2
>> +#endif
> 
> Can you restrict those to #ifdef __ASSEMBLER__?  <sysdep.h> is a
> fairly widely included header, and this has the potential of breaking
> future changes that compile on other architectures.

Ack.

> 
> Rest looks okay to me, but maybe a POWER maintainer wants to have a
> look as well.
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return
  2020-02-11 19:45   ` Florian Weimer
@ 2020-02-12 13:24     ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-12 13:24 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 11/02/2020 16:45, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> It changes the powerpc INTERNAL_VSYSCALL_CALL and INTERNAL_SYSCALL_NCS
>> to return a negative value instead of returning the CR value on 'err'
>> macro argument.
> 
> value on?  This part is unclear to me.
> 
>> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
>> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.
> 
> See my other comment about wording here.

Ack, I changed based on sparc comments.

> 
> The patch looks reasonable to me.
> 

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL
  2020-02-10 19:20 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
                     ` (2 preceding siblings ...)
  2020-02-11 12:48   ` Florian Weimer
@ 2020-02-15  7:51   ` Andreas Schwab
  2020-02-15  9:32     ` [PATCH] arm: fix use of INTERNAL_SYSCALL_CALL Andreas Schwab
  3 siblings, 1 reply; 63+ messages in thread
From: Andreas Schwab @ 2020-02-15  7:51 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

This series breaks arm:

/home/abuild/rpmbuild/BUILD/glibc-2.31.9000.139.gbc2eb9321e/cc-base/elf/sln /home/abuild/rpmbuild/BUILD/glibc-2.31.9000.139.gbc2eb9321e/cc-base/elf/symlink.list
make[1]: *** [Makefile:115: install-symbolic-link] Segmentation fault
make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/glibc-2.31.9000.139.gbc2eb9321e'

<https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc/a/armv7l>

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH] arm: fix use of INTERNAL_SYSCALL_CALL
  2020-02-15  7:51   ` Andreas Schwab
@ 2020-02-15  9:32     ` Andreas Schwab
  2020-02-15  9:55       ` Florian Weimer
  0 siblings, 1 reply; 63+ messages in thread
From: Andreas Schwab @ 2020-02-15  9:32 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

Remove extra argument from INTERNAL_SYSCALL_CALL macro call.  Fixes
commit bc2eb9321e ("linux: Remove INTERNAL_SYSCALL_DECL").
---
 sysdeps/unix/sysv/linux/arm/tls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h
index 1b520c6802..57b583dbd8 100644
--- a/sysdeps/unix/sysv/linux/arm/tls.h
+++ b/sysdeps/unix/sysv/linux/arm/tls.h
@@ -32,7 +32,7 @@
    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, 1, (tcbp));		\
+     result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp));		\
      INTERNAL_SYSCALL_ERROR_P (result_var)				\
        ? "unknown error" : NULL; })
 
-- 
2.25.0


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH] arm: fix use of INTERNAL_SYSCALL_CALL
  2020-02-15  9:32     ` [PATCH] arm: fix use of INTERNAL_SYSCALL_CALL Andreas Schwab
@ 2020-02-15  9:55       ` Florian Weimer
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Weimer @ 2020-02-15  9:55 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Adhemerval Zanella, libc-alpha

* Andreas Schwab:

> Remove extra argument from INTERNAL_SYSCALL_CALL macro call.  Fixes
> commit bc2eb9321e ("linux: Remove INTERNAL_SYSCALL_DECL").
> ---
>  sysdeps/unix/sysv/linux/arm/tls.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h
> index 1b520c6802..57b583dbd8 100644
> --- a/sysdeps/unix/sysv/linux/arm/tls.h
> +++ b/sysdeps/unix/sysv/linux/arm/tls.h
> @@ -32,7 +32,7 @@
>     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, 1, (tcbp));		\
> +     result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp));		\
>       INTERNAL_SYSCALL_ERROR_P (result_var)				\
>         ? "unknown error" : NULL; })

Looks okay.  Thanks.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-10 19:20 ` [PATCH 08/15] nios2: " Adhemerval Zanella
  2020-02-11 11:20   ` Florian Weimer
  2020-02-11 11:50   ` Andreas Schwab
@ 2020-02-19 21:40   ` Vineet Gupta
  2020-02-20 13:14     ` Adhemerval Zanella
  2 siblings, 1 reply; 63+ messages in thread
From: Vineet Gupta @ 2020-02-19 21:40 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha@sourceware.org; +Cc: arcml

On 2/10/20 11:20 AM, Adhemerval Zanella wrote:
> It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
> value instead of 'r2' register value on 'err' macro argument.
> 
> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.
> 
> Checked with a build against nios2-linux-gnu.
> ---
>  sysdeps/unix/sysv/linux/nios2/sysdep.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
> index b02730bd23..eab888df32 100644
> --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
> @@ -157,13 +157,14 @@
>       (int) result_var; })
>  
>  #undef INTERNAL_SYSCALL_DECL
> -#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>  
>  #undef INTERNAL_SYSCALL_ERROR_P
> -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
> +  ((unsigned long) (val) >= (unsigned long) -4095)
>  
>  #undef INTERNAL_SYSCALL_ERRNO
> -#define INTERNAL_SYSCALL_ERRNO(val, err)   ((void) (err), val)
> +#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
>  
>  #undef INTERNAL_SYSCALL_RAW
>  #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)            \
> @@ -180,8 +181,7 @@
>                       : "+r" (_r2), "=r" (_err)                  \
>                       : ASM_ARGS_##nr				\
>                       : __SYSCALL_CLOBBERS);                     \
> -       _sys_result = _r2;                                       \
> -       err = _err;                                              \
> +       _sys_result = _err != 0 ? -_r2 : -_r2;                   \

Is there a typo here ? both cases seem to be -ve

>       }                                                          \
>       (int) _sys_result; })
>  
> 


^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-19 21:40   ` Vineet Gupta
@ 2020-02-20 13:14     ` Adhemerval Zanella
  2020-02-20 20:39       ` Vineet Gupta
  0 siblings, 1 reply; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-20 13:14 UTC (permalink / raw)
  To: Vineet Gupta, libc-alpha@sourceware.org; +Cc: arcml



On 19/02/2020 18:40, Vineet Gupta wrote:
> On 2/10/20 11:20 AM, Adhemerval Zanella wrote:
>> It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
>> value instead of 'r2' register value on 'err' macro argument.
>>
>> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
>> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.
>>
>> Checked with a build against nios2-linux-gnu.
>> ---
>>  sysdeps/unix/sysv/linux/nios2/sysdep.h | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>> index b02730bd23..eab888df32 100644
>> --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>> @@ -157,13 +157,14 @@
>>       (int) result_var; })
>>  
>>  #undef INTERNAL_SYSCALL_DECL
>> -#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>>  
>>  #undef INTERNAL_SYSCALL_ERROR_P
>> -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
>> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
>> +  ((unsigned long) (val) >= (unsigned long) -4095)
>>  
>>  #undef INTERNAL_SYSCALL_ERRNO
>> -#define INTERNAL_SYSCALL_ERRNO(val, err)   ((void) (err), val)
>> +#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
>>  
>>  #undef INTERNAL_SYSCALL_RAW
>>  #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)            \
>> @@ -180,8 +181,7 @@
>>                       : "+r" (_r2), "=r" (_err)                  \
>>                       : ASM_ARGS_##nr				\
>>                       : __SYSCALL_CLOBBERS);                     \
>> -       _sys_result = _r2;                                       \
>> -       err = _err;                                              \
>> +       _sys_result = _err != 0 ? -_r2 : -_r2;                   \
> 
> Is there a typo here ? both cases seem to be -ve

It is, thanks for catching it. I have pushed b790c8c2ed to fix and
double checked nios2 syscall handling (arch/nios2/kernel/entry.S:205)
to certify that the modification does follow nios2 kABI.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-20 13:14     ` Adhemerval Zanella
@ 2020-02-20 20:39       ` Vineet Gupta
  2020-02-20 21:04         ` Vineet Gupta
  0 siblings, 1 reply; 63+ messages in thread
From: Vineet Gupta @ 2020-02-20 20:39 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha@sourceware.org; +Cc: arcml

Hi Adhemerval,

On 2/20/20 5:14 AM, Adhemerval Zanella wrote:
> 
> 
> On 19/02/2020 18:40, Vineet Gupta wrote:
>> On 2/10/20 11:20 AM, Adhemerval Zanella wrote:
>>> It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
>>> value instead of 'r2' register value on 'err' macro argument.
>>>
>>> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
>>> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.
>>>
>>> Checked with a build against nios2-linux-gnu.
>>> ---
>>>  sysdeps/unix/sysv/linux/nios2/sysdep.h | 10 +++++-----
>>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>>> index b02730bd23..eab888df32 100644
>>> --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
>>> +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>>> @@ -157,13 +157,14 @@
>>>       (int) result_var; })
>>>  
>>>  #undef INTERNAL_SYSCALL_DECL
>>> -#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
>>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>>>  
>>>  #undef INTERNAL_SYSCALL_ERROR_P
>>> -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
>>> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
>>> +  ((unsigned long) (val) >= (unsigned long) -4095)
>>>  
>>>  #undef INTERNAL_SYSCALL_ERRNO
>>> -#define INTERNAL_SYSCALL_ERRNO(val, err)   ((void) (err), val)
>>> +#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
>>>  
>>>  #undef INTERNAL_SYSCALL_RAW
>>>  #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)            \
>>> @@ -180,8 +181,7 @@
>>>                       : "+r" (_r2), "=r" (_err)                  \
>>>                       : ASM_ARGS_##nr				\
>>>                       : __SYSCALL_CLOBBERS);                     \
>>> -       _sys_result = _r2;                                       \
>>> -       err = _err;                                              \
>>> +       _sys_result = _err != 0 ? -_r2 : -_r2;                   \
>>
>> Is there a typo here ? both cases seem to be -ve
> 
> It is, thanks for catching it. I have pushed b790c8c2ed to fix and
> double checked nios2 syscall handling (arch/nios2/kernel/entry.S:205)
> to certify that the modification does follow nios2 kABI.

Actually the reason I spotted it was trying to replicate similar changes in ARC
port and it seems to be hosed now. It is quite likely a snaufu at my end, but I
don't quite understand the new logic.

Consider brk syscall which does

     __curbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);

Through a maze of defines this ends up calling INTERNAL_SYSCALL_RAW which seems be
unconditionally converting !0 value (success) into -ve and returning it. So won't
 it convert a legit brk address return into a -ve and save in __curbrk.

Am I not following this correctly ?

Thx,
-Vineet



^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-20 20:39       ` Vineet Gupta
@ 2020-02-20 21:04         ` Vineet Gupta
  2020-02-27 17:49           ` Adhemerval Zanella
  0 siblings, 1 reply; 63+ messages in thread
From: Vineet Gupta @ 2020-02-20 21:04 UTC (permalink / raw)
  To: Vineet Gupta, Adhemerval Zanella, libc-alpha@sourceware.org; +Cc: arcml

On 2/20/20 12:39 PM, Vineet Gupta wrote:
> Am I not following this correctly ?

Oh never mind, they use 2 seperate regs to convey syscall result and error, so
your code is right.

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
  2020-02-20 21:04         ` Vineet Gupta
@ 2020-02-27 17:49           ` Adhemerval Zanella
  0 siblings, 0 replies; 63+ messages in thread
From: Adhemerval Zanella @ 2020-02-27 17:49 UTC (permalink / raw)
  To: Vineet Gupta, libc-alpha@sourceware.org; +Cc: arcml



On 20/02/2020 18:04, Vineet Gupta wrote:
> 
> Through a maze of defines this ends up calling INTERNAL_SYSCALL_RAW which seems be
> unconditionally converting !0 value (success) into -ve and returning it. So won't
>  it convert a legit brk address return into a -ve and save in __curbrk.


> On 2/20/20 12:39 PM, Vineet Gupta wrote:
>> Am I not following this correctly ?
> 
> Oh never mind, they use 2 seperate regs to convey syscall result and error, so
> your code is right.
> 

One of my goals is to disentangle the {INTERNAL,INLINE}_SYSCALL macros
to consolidate their definitions and move the arch-specific bits to 
inline functions instead of macros.  Another one is to remove the
requirement to define similar assembly macros to be used by the 
auto-generated one.

The idea is an architecture will just need to define a set of
inline_syscall{0-6} functions.

^ permalink raw reply	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2020-02-27 17:49 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-10 19:20 [PATCH 01/15] powerpc: Consolidate Linux syscall definition Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 02/15] powerpc: Use Linux kABI for syscall return Adhemerval Zanella
2020-02-11 11:18   ` Florian Weimer
2020-02-11 12:14     ` Adhemerval Zanella
2020-02-11 12:31       ` Florian Weimer
2020-02-11 13:31         ` Adhemerval Zanella
2020-02-11 19:45           ` Florian Weimer
2020-02-11 19:45   ` Florian Weimer
2020-02-12 13:24     ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 03/15] sparc: " Adhemerval Zanella
2020-02-11 11:15   ` Florian Weimer
2020-02-11 18:55     ` Adhemerval Zanella
2020-02-11 19:24       ` Florian Weimer
2020-02-11 20:29         ` Adhemerval Zanella
2020-02-11 21:15           ` Florian Weimer
2020-02-12 12:35             ` Adhemerval Zanella
2020-02-12 12:38               ` Florian Weimer
2020-02-12 12:56                 ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 04/15] alpha: Refactor syscall and " Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 05/15] ia64: " Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 06/15] mips64: Consolidate Linux sysdep.h Adhemerval Zanella
2020-02-10 22:48   ` Joseph Myers
2020-02-11 19:05     ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 07/15] mips: Use Linux kABI for syscall return Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 08/15] nios2: " Adhemerval Zanella
2020-02-11 11:20   ` Florian Weimer
2020-02-11 19:09     ` Adhemerval Zanella
2020-02-11 11:50   ` Andreas Schwab
2020-02-19 21:40   ` Vineet Gupta
2020-02-20 13:14     ` Adhemerval Zanella
2020-02-20 20:39       ` Vineet Gupta
2020-02-20 21:04         ` Vineet Gupta
2020-02-27 17:49           ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall Adhemerval Zanella
2020-02-11 11:21   ` Florian Weimer
2020-02-11 19:10     ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 10/15] riscv: " Adhemerval Zanella
2020-02-10 19:51   ` DJ Delorie
2020-02-10 21:27     ` Palmer Dabbelt
2020-02-10 21:55       ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 11/15] s390: Consolidate Linux syscall definition Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall Adhemerval Zanella
2020-02-11 11:22   ` Florian Weimer
2020-02-11 19:17     ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 13/15] linux: Consolidate INLINE_SYSCALL Adhemerval Zanella
2020-02-11 12:03   ` Florian Weimer
2020-02-11 20:53     ` Adhemerval Zanella
2020-02-11 21:00       ` Florian Weimer
2020-02-10 19:20 ` [PATCH 14/15] nptl: Remove ununsed pthread-errnos.h rule Adhemerval Zanella
2020-02-11 11:23   ` Florian Weimer
2020-02-11 11:51     ` Florian Weimer
2020-02-11 21:01       ` Adhemerval Zanella
2020-02-10 19:20 ` [PATCH 15/15] linux: Remove INTERNAL_SYSCALL_DECL Adhemerval Zanella
2020-02-11 12:34   ` Florian Weimer
2020-02-11 12:36   ` Florian Weimer
2020-02-11 20:57     ` Adhemerval Zanella
2020-02-11 12:48   ` Florian Weimer
2020-02-11 20:55     ` Adhemerval Zanella
2020-02-15  7:51   ` Andreas Schwab
2020-02-15  9:32     ` [PATCH] arm: fix use of INTERNAL_SYSCALL_CALL Andreas Schwab
2020-02-15  9:55       ` Florian Weimer
2020-02-11 19:43 ` [PATCH 01/15] powerpc: Consolidate Linux syscall definition Florian Weimer
2020-02-12 13:19   ` 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).