The outline __syscall_error already generate the most compact
code for riscv64 and riscv32:
--- sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.outline
+++ sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.inline
text data bss dec hex filename
- 973220 9460 8840 991520 f2120 libc.so
- 98209 4124 176 102509 1906d elf/ld.so
- 71063 800 8348 80211 13953 nptl/libpthread.so
- 17011 608 168 17787 457b rt/librt.so
+ 974466 9460 8840 992766 f25fe libc.so
+ 98331 4124 176 102631 190e7 elf/ld.so
+ 70939 800 8348 80087 138d7 nptl/libpthread.so
+ 17095 608 168 17871 45cf rt/librt.so
--- sizes-riscv64-linux-gnu-rv64imafdc-lp64d.outline
+++ sizes-riscv64-linux-gnu-rv64imafdc-lp64d.inline
text data bss dec hex filename
-1030902 18632 14472 1064006 103c46 libc.so
- 98320 6232 336 104888 199b8 elf/ld.so
- 76588 1596 16664 94848 17280 nptl/libpthread.so
- 18016 1156 232 19404 4bcc rt/librt.so
+1031680 18632 14472 1064784 103f50 libc.so
+ 98374 6232 336 104942 199ee elf/ld.so
+ 76544 1596 16664 94804 17254 nptl/libpthread.so
+ 18106 1156 232 19494 4c26 rt/librt.so
Checked with some basic tests to see if errno is set correctly
on both static and dynamic binaries with auto-generated syscals
and C implementation (which uses INTERNAL_SYSCALL_CALL).
---
sysdeps/riscv/nptl/Makefile | 5 --
sysdeps/riscv/nptl/nptl-sysdep.S | 2 -
sysdeps/unix/sysv/linux/riscv/syscall_error.h | 25 +++++++++
sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 -------------------
4 files changed, 25 insertions(+), 58 deletions(-)
delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S
create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_error.h
delete mode 100644 sysdeps/unix/sysv/linux/riscv/sysdep.S
@@ -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
deleted file mode 100644
@@ -1,2 +0,0 @@
-/* Pull in __syscall_error. */
-#include <sysdep.S>
new file mode 100644
@@ -0,0 +1,25 @@
+/* Linux wrappers for setting errno. RISCV version.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _SYSCALL_ERROR_H
+#define _SYSCALL_ERROR_H
+
+#define SYSCALL_ERROR_FUNC 1
+#define SYSCALL_ERROR_FUNC_ATTR
+
+#endif
deleted file mode 100644
@@ -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)