Patchwork [RFC,v5,20/21] RISC-V: Use 64-bit vdso syscalls for RV32

login
register
mail settings
Submitter Alistair Francis
Date Aug. 29, 2019, 4:50 p.m.
Message ID <7a2929b5d0ddbebe1e7eead00429eb3dabfda00c.1567097252.git.alistair.francis@wdc.com>
Download mbox | patch
Permalink /patch/34343/
State New
Headers show

Comments

Alistair Francis - Aug. 29, 2019, 4:50 p.m.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

	* sysdeps/unix/sysv/linux/clock_getres.c: Use 64-bit vdso syscalls
	for RV32
	* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
---
 sysdeps/unix/sysv/linux/clock_getres.c     |  4 ++++
 sysdeps/unix/sysv/linux/riscv/init-first.c | 19 ++++++++++++-------
 sysdeps/unix/sysv/linux/riscv/libc-vdso.h  |  9 ++++++---
 3 files changed, 22 insertions(+), 10 deletions(-)

Patch

diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c
index 24b2299938c..6982c754d6f 100644
--- a/sysdeps/unix/sysv/linux/clock_getres.c
+++ b/sysdeps/unix/sysv/linux/clock_getres.c
@@ -30,6 +30,10 @@ 
 int
 __clock_getres (clockid_t clock_id, struct timespec *res)
 {
+#ifndef __vdso_clock_getres
+   return INLINE_SYSCALL_CALL (clock_getres, clock_id, res);
+#else
   return INLINE_VSYSCALL (clock_getres, 2, clock_id, res);
+#endif
 }
 weak_alias (__clock_getres, clock_getres)
diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
index 35dc8a8d386..7b7457a7a8b 100644
--- a/sysdeps/unix/sysv/linux/riscv/init-first.c
+++ b/sysdeps/unix/sysv/linux/riscv/init-first.c
@@ -22,12 +22,15 @@ 
 
 long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
     attribute_hidden;
-long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (__clock_gettime64)) (clockid_t, struct __timespec64 *)
+long int (*VDSO_SYMBOL (clock_gettime64)) (clockid_t, struct timespec *)
     attribute_hidden;
+
+#if __riscv_xlen == 64
 long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
     attribute_hidden;
+long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
+    attribute_hidden;
+#endif
 
 static inline void
 _libc_vdso_platform_setup (void)
@@ -38,17 +41,19 @@  _libc_vdso_platform_setup (void)
   PTR_MANGLE (p);
   VDSO_SYMBOL (getcpu) = p;
 
-  p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
+  p = _dl_vdso_vsym ("__vdso_clock_gettime64", &linux_version);
   PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
+  VDSO_SYMBOL (clock_gettime64) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
+#if __riscv_xlen == 64
+  p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
   PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
+  VDSO_SYMBOL (gettimeofday) = p;
 
   p = _dl_vdso_vsym ("__vdso_clock_getres", &linux_version);
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_getres) = p;
+#endif
 }
 
 #define VDSO_SETUP _libc_vdso_platform_setup
diff --git a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
index 16905d5b78d..3684168df4b 100644
--- a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
@@ -24,11 +24,14 @@ 
 
 extern long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
     attribute_hidden;
-extern long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-extern long int (*VDSO_SYMBOL (__clock_gettime64)) (clockid_t, struct __timespec64 *)
+extern long int (*VDSO_SYMBOL (clock_gettime64)) (clockid_t, struct timespec *)
     attribute_hidden;
+
+#if __riscv_xlen == 64
 extern long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
     attribute_hidden;
+extern long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
+    attribute_hidden;
+#endif
 
 #endif /* _LIBC_VDSO_H */