[20/23] linux: Use generic __syscall_error for riscv

Message ID 20201109201826.120534-21-adhemerval.zanella@linaro.org
State Superseded
Headers
Series Simplify internal Linux syscall |

Commit Message

Adhemerval Zanella Nov. 9, 2020, 8:18 p.m. UTC
  The outline __syscall_error already generate the most compact
code for riscv64 and riscv32:

--- sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.outline
+++ sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.inline
    text           data     bss     dec     hex filename
- 973220           9460    8840  991520   f2120 libc.so
-  98209           4124     176  102509   1906d elf/ld.so
-  71063            800    8348   80211   13953 nptl/libpthread.so
-  17011            608     168   17787    457b rt/librt.so
+ 974466           9460    8840  992766   f25fe libc.so
+  98331           4124     176  102631   190e7 elf/ld.so
+  70939            800    8348   80087   138d7 nptl/libpthread.so
+  17095            608     168   17871    45cf rt/librt.so

--- sizes-riscv64-linux-gnu-rv64imafdc-lp64d.outline
+++ sizes-riscv64-linux-gnu-rv64imafdc-lp64d.inline
    text           data     bss     dec     hex filename
-1030902          18632   14472 1064006  103c46 libc.so
-  98320           6232     336  104888   199b8 elf/ld.so
-  76588           1596   16664   94848   17280 nptl/libpthread.so
-  18016           1156     232   19404    4bcc rt/librt.so
+1031680          18632   14472 1064784  103f50 libc.so
+  98374           6232     336  104942   199ee elf/ld.so
+  76544           1596   16664   94804   17254 nptl/libpthread.so
+  18106           1156     232   19494    4c26 rt/librt.so

Checked with some basic tests to see if errno is set correctly
on both static and dynamic binaries with auto-generated syscals
and C implementation (which uses INTERNAL_SYSCALL_CALL).
---
 sysdeps/riscv/nptl/Makefile            |  5 ---
 sysdeps/riscv/nptl/nptl-sysdep.S       |  2 -
 sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 --------------------------
 sysdeps/unix/sysv/linux/riscv/sysdep.h |  2 +
 4 files changed, 2 insertions(+), 58 deletions(-)
 delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S
 delete mode 100644 sysdeps/unix/sysv/linux/riscv/sysdep.S
  

Patch

diff --git a/sysdeps/riscv/nptl/Makefile b/sysdeps/riscv/nptl/Makefile
index 1af6fa6a55..3f6428b0de 100644
--- a/sysdeps/riscv/nptl/Makefile
+++ b/sysdeps/riscv/nptl/Makefile
@@ -19,8 +19,3 @@ 
 ifeq ($(subdir),csu)
 gen-as-const-headers += tcb-offsets.sym
 endif
-
-ifeq ($(subdir),nptl)
-libpthread-sysdep_routines += nptl-sysdep
-libpthread-shared-only-routines += nptl-sysdep
-endif
diff --git a/sysdeps/riscv/nptl/nptl-sysdep.S b/sysdeps/riscv/nptl/nptl-sysdep.S
deleted file mode 100644
index 3f5c2a364a..0000000000
--- a/sysdeps/riscv/nptl/nptl-sysdep.S
+++ /dev/null
@@ -1,2 +0,0 @@ 
-/* Pull in __syscall_error.  */
-#include <sysdep.S>
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.S b/sysdeps/unix/sysv/linux/riscv/sysdep.S
deleted file mode 100644
index 64daa84aac..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.S
+++ /dev/null
@@ -1,51 +0,0 @@ 
-/* syscall error handlers
-   Copyright (C) 2011-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-#if IS_IN (libc)
-# define errno __libc_errno
-#endif
-
-ENTRY (__syscall_error)
-	mv t0, ra
-	/* Fall through to __syscall_set_errno.  */
-END (__syscall_error)
-
-/* Non-standard calling convention: argument in a0, return address in t0,
-   and clobber only t1.  */
-ENTRY (__syscall_set_errno)
-	/* We got here because a0 < 0, but only codes in the range [-4095, -1]
-	  represent errors.  Otherwise, just return the result normally.  */
-	li t1, -4096
-	bleu a0, t1, 1f
-	neg a0, a0
-#if RTLD_PRIVATE_ERRNO
-	sw a0, rtld_errno, t1
-#elif defined(__PIC__)
-	la.tls.ie t1, errno
-	add t1, t1, tp
-	sw a0, 0(t1)
-#else
-	lui t1, %tprel_hi(errno)
-	add t1, t1, tp, %tprel_add(errno)
-	sw a0, %tprel_lo(errno)(t1)
-#endif
-	li a0, -1
-1:	jr t0
-END (__syscall_set_errno)
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index e94afbf106..1bcd942e31 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -19,6 +19,8 @@ 
 #ifndef _LINUX_RISCV_SYSDEP_H
 #define _LINUX_RISCV_SYSDEP_H 1
 
+#define SYSCALL_ERROR_FUNC
+
 #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>