[PATCH v3 03/19] RISC-V: Use 64-bit-time syscall numbers with the 32-bit port

Alistair Francis alistair.francis@wdc.com
Sun Jul 12 15:47:28 GMT 2020


This patches adds any required syscall suppression for 32-bit
off_t/time_t to fixup-asm-unistd.h so arch-syscall.h will have only
the required definitions.

sysdep.h redefines only the syscall where the generic implementation
still does not have actual 64-bit time_t support:

   /* "workarounds" for generic code needing to handle 64-bit time_t.  */

   /* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c.  */
   #define __NR_clock_getres    __NR_clock_getres_time64
   /* Fix sysdeps/nptl/lowlevellock-futex.h.  */
   #define __NR_futex           __NR_futex_time64
   [...]

This patch also adds a comment that it is a workaround to handle 64-bit
time_t and on each #define comment for which implementation it intends
to.
---
 .../unix/sysv/linux/riscv/fixup-asm-unistd.h  | 45 +++++++++++++++++++
 sysdeps/unix/sysv/linux/riscv/sysdep.h        | 27 +++++++++++
 2 files changed, 72 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/riscv/fixup-asm-unistd.h

diff --git a/sysdeps/unix/sysv/linux/riscv/fixup-asm-unistd.h b/sysdeps/unix/sysv/linux/riscv/fixup-asm-unistd.h
new file mode 100644
index 0000000000..bc8b10e283
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/riscv/fixup-asm-unistd.h
@@ -0,0 +1,45 @@
+/* Regularize <asm/unistd.h> definitions.  RISC-V version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+
+   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/>.  */
+
+/* Adjustments to RISC-V asm-generic syscall for 64-bit time_t support.  */
+
+/* fstat64 and fstatat64 need to be replaced with statx.  */
+
+#undef __NR_fstat64
+#undef __NR_fstatat64
+
+/* Replace all other 32-bit time syscalls with 64-bit variants.  */
+
+# undef __NR_clock_adjtime
+# undef __NR_clock_getres
+# undef __NR_clock_gettime
+# undef __NR_clock_nanosleep
+# undef __NR_clock_settime
+# undef __NR_futex
+# undef __NR_mq_timedreceive
+# undef __NR_mq_timedsend
+# undef __NR_ppoll
+# undef __NR_pselect6
+# undef __NR_recvmmsg
+# undef __NR_rt_sigtimedwait
+# undef __NR_sched_rr_get_interval
+# undef __NR_semtimedop
+# undef __NR_timer_gettime
+# undef __NR_timer_settime
+# undef __NR_timerfd_gettime
+# undef __NR_timerfd_settime
+# undef __NR_utimensat
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 429686cebe..62a9551f50 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -22,6 +22,33 @@
 #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
+#if __WORDSIZE == 32
+
+
+/* "workarounds" for generic code needing to handle 64-bit time_t.  */
+
+/* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c.  */
+#define __NR_clock_getres      __NR_clock_getres_time64
+/* Fix sysdeps/nptl/lowlevellock-futex.h.  */
+#define __NR_futex             __NR_futex_time64
+/* Fix sysdeps/unix/sysv/linux/pause.c.  */
+#define __NR_ppoll             __NR_ppoll_time64
+/* Fix sysdeps/unix/sysv/linux/select.c.  */
+#define __NR_pselect6          __NR_pselect6_time64
+/* Fix sysdeps/unix/sysv/linux/recvmmsg.c.  */
+#define __NR_recvmmsg          __NR_recvmmsg_time64
+/* Fix sysdeps/unix/sysv/linux/sigtimedwait.c.  */
+#define __NR_rt_sigtimedwait   __NR_rt_sigtimedwait_time64
+/* Fix sysdeps/unix/sysv/linux/semtimedop.c.  */
+#define __NR_semtimedop                __NR_semtimedop_time64
+/* Hack sysdeps/unix/sysv/linux/generic/utimes.c.  */
+#define __NR_utimensat         __NR_utimensat_time64
+
+#endif /* __WORDSIZE == 32 */
+
+#undef SYS_ify
+#define SYS_ify(syscall_name)	__NR_##syscall_name
+
 #ifdef __ASSEMBLER__
 
 # include <sys/asm.h>
-- 
2.27.0



More information about the Libc-alpha mailing list