diff mbox series

[v2,15/16] linux: Add support for clock_getres64 vDSO

Message ID 20191217214728.2886-15-adhemerval.zanella@linaro.org
State Accepted
Commit 0dc1a378b135ec46fcc451d96c4a3a64c08e2ace
Headers show
Series [v2,01/16] linux: Fix vDSO macros build with time64 interfaces | expand

Commit Message

Adhemerval Zanella Dec. 17, 2019, 9:47 p.m. UTC
Changes from previous version:

  - Rename HAVE_CLOCK_GETTIME_VSYSCALL to
    HAVE_CLOCK_GETTIME64_VSYSCALL on 64 bit time_t architectures.

--

No architecture currently defines the vDSO symbol.  On archictures
with 64-bit time_t the HAVE_CLOCK_GETRES_VSYSCALL is renamed to
HAVE_CLOCK_GETRES64_VSYSCALL, it simplifies clock_gettime code.
---
 sysdeps/unix/sysv/linux/aarch64/sysdep.h |  2 +-
 sysdeps/unix/sysv/linux/clock_getres.c   | 17 ++++++++++-------
 sysdeps/unix/sysv/linux/dl-vdso-setup.c  |  4 ++++
 sysdeps/unix/sysv/linux/dl-vdso-setup.h  |  3 +++
 sysdeps/unix/sysv/linux/powerpc/sysdep.h |  3 ++-
 sysdeps/unix/sysv/linux/riscv/sysdep.h   |  2 +-
 sysdeps/unix/sysv/linux/s390/sysdep.h    |  3 ++-
 sysdeps/unix/sysv/linux/x86_64/sysdep.h  |  2 +-
 8 files changed, 24 insertions(+), 12 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index 26aa2f9779..f50b3f95b9 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -160,7 +160,7 @@ 
 # endif
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
+# define HAVE_CLOCK_GETRES64_VSYSCALL	"__kernel_clock_getres"
 # define HAVE_CLOCK_GETTIME64_VSYSCALL	"__kernel_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 
diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c
index 52671fa641..3d59f11d71 100644
--- a/sysdeps/unix/sysv/linux/clock_getres.c
+++ b/sysdeps/unix/sysv/linux/clock_getres.c
@@ -30,20 +30,23 @@  __clock_getres64 (clockid_t clock_id, struct __timespec64 *res)
 {
 #ifdef __ASSUME_TIME64_SYSCALLS
   /* 64 bit ABIs or Newer 32-bit ABIs that only support 64-bit time_t.  */
-# ifdef __NR_clock_getres_time64
-  return INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res);
+# ifndef __NR_clock_getres_time64
+#  define __NR_clock_getres_time64 __NR_clock_getres
+# endif
+# ifdef HAVE_CLOCK_GETRES64_VSYSCALL
+  return INLINE_VSYSCALL (clock_getres_time64, 2, clock_id, res);
 # else
-#  ifdef HAVE_CLOCK_GETRES_VSYSCALL
-  return INLINE_VSYSCALL (clock_getres, 2, clock_id, res);
-#  else
-  return INLINE_SYSCALL_CALL (clock_getres, clock_id, res);
-#  endif
+  return INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res);
 # endif
 #else
   int r;
   /* Old 32-bit ABI with possible 64-bit time_t support.  */
 # ifdef __NR_clock_getres_time64
+#  ifdef HAVE_CLOCK_GETRES64_VSYSCALL
+  r = INLINE_VSYSCALL (clock_getres_time64, 2, clock_id, res);
+#  else
   r = INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res);
+#  endif
   if (r == 0 || errno != ENOSYS)
     return r;
 # endif
diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.c b/sysdeps/unix/sysv/linux/dl-vdso-setup.c
index b0b692f78c..594316342a 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso-setup.c
+++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.c
@@ -62,6 +62,10 @@  PROCINFO_CLASS int (*_dl_vdso_getcpu) (unsigned *, unsigned *, void *) RELRO;
 PROCINFO_CLASS int (*_dl_vdso_clock_getres) (clockid_t,
 					     struct timespec *) RELRO;
 # endif
+# ifdef HAVE_CLOCK_GETRES64_VSYSCALL
+PROCINFO_CLASS int (*_dl_vdso_clock_getres_time64) (clockid_t,
+						    struct __timespec64 *) RELRO;
+# endif
 
 /* PowerPC specific ones.  */
 # ifdef HAVE_GET_TBFREQ
diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.h b/sysdeps/unix/sysv/linux/dl-vdso-setup.h
index 8a89e100c8..036f62b1c4 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso-setup.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.h
@@ -41,6 +41,9 @@  setup_vdso_pointers (void)
 #ifdef HAVE_CLOCK_GETRES_VSYSCALL
   GLRO(dl_vdso_clock_getres) = dl_vdso_vsym (HAVE_CLOCK_GETRES_VSYSCALL);
 #endif
+#ifdef HAVE_CLOCK_GETRES64_VSYSCALL
+  GLRO(dl_vdso_clock_getres_time64) = dl_vdso_vsym (HAVE_CLOCK_GETRES64_VSYSCALL);
+#endif
 #ifdef HAVE_GET_TBFREQ
   GLRO(dl_vdso_get_tbfreq) = dl_vdso_vsym (HAVE_GET_TBFREQ);
 #endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index c42659a9c4..d36aa6dbcb 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -20,10 +20,11 @@ 
 #define VDSO_HASH  123718565
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
 #if defined(__PPC64__) || defined(__powerpc64__)
+#define HAVE_CLOCK_GETRES64_VSYSCALL	"__kernel_clock_getres"
 #define HAVE_CLOCK_GETTIME64_VSYSCALL	"__kernel_clock_gettime"
 #else
+#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #endif
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 7f43595cb0..201bf9a91b 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -125,7 +125,7 @@ 
 # define VDSO_HASH  182943605
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	"__vdso_clock_getres"
+# define HAVE_CLOCK_GETRES64_VSYSCALL	"__vdso_clock_getres"
 # define HAVE_CLOCK_GETTIME64_VSYSCALL	"__vdso_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
index 030bd59ad0..2df5705050 100644
--- a/sysdeps/unix/sysv/linux/s390/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -20,10 +20,11 @@ 
 #define VDSO_HASH  123718585
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
 #ifdef __s390x__
+#define HAVE_CLOCK_GETRES64_VSYSCALL	"__kernel_clock_getres"
 #define HAVE_CLOCK_GETTIME64_VSYSCALL	"__kernel_clock_gettime"
 #else
+#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #endif
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 57a64dce31..8a699de6b7 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -378,7 +378,7 @@ 
 # define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
 # define HAVE_TIME_VSYSCALL             "__vdso_time"
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
-# define HAVE_CLOCK_GETRES_VSYSCALL     "__vdso_clock_getres"
+# define HAVE_CLOCK_GETRES64_VSYSCALL   "__vdso_clock_getres"
 
 # define SINGLE_THREAD_BY_GLOBAL		1