diff mbox

[[PATCH,RFC,2] 15/63] Y2038: powerpc: implement clock_gettime64 as a VDSO symbol

Message ID 20180418201819.15952-16-albert.aribaud@3adev.fr
State New
Headers show

Commit Message

Albert ARIBAUD April 18, 2018, 8:17 p.m. UTC
---
 sysdeps/powerpc/powerpc32/backtrace.c        |  1 +
 sysdeps/unix/sysv/linux/powerpc/init-first.c | 16 ++++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h  |  2 ++
 3 files changed, 19 insertions(+)
diff mbox

Patch

diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c
index 5422fdd50d..6db460dbc1 100644
--- a/sysdeps/powerpc/powerpc32/backtrace.c
+++ b/sysdeps/powerpc/powerpc32/backtrace.c
@@ -20,6 +20,7 @@ 
 #include <stddef.h>
 #include <string.h>
 #include <signal.h>
+#include <dl-vdso.h>
 #include <libc-vdso.h>
 
 /* This is the stack layout we see with every stack frame.
diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c
index 0a4becbed6..b17ea92a1f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/init-first.c
+++ b/sysdeps/unix/sysv/linux/powerpc/init-first.c
@@ -28,6 +28,15 @@  unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
 int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
 time_t (*VDSO_SYMBOL(time)) (time_t *);
 
+long (*VDSO_SYMBOL(clock_gettime64)) (clockid_t, struct __timespec64 *);
+
+int __y2038_linux_support;
+
+int __y2038_kernel_support (void)
+{
+  return __y2038_linux_support;
+}
+ 
 #if defined(__PPC64__) || defined(__powerpc64__)
 void *VDSO_SYMBOL(sigtramp_rt64);
 #else
@@ -64,6 +73,13 @@  _libc_vdso_platform_setup (void)
   PTR_MANGLE (p);
   VDSO_SYMBOL (time) = p;
 
+  /* (aaribaud) TODO: map to version where clock_gettime64 officially appears */
+  p = _dl_vdso_vsym ("__vdso_clock_gettime64", NULL);
+  PTR_MANGLE (p);
+  VDSO_SYMBOL (clock_gettime64) = p;
+
+  __y2038_linux_support = (p != NULL) ? 1 : 0;
+
   /* PPC64 uses only one signal trampoline symbol, while PPC32 will use
      two depending if SA_SIGINFO is used (__kernel_sigtramp_rt32) or not
      (__kernel_sigtramp32).
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index 5fe817d6cb..de8d44e95e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -32,6 +32,8 @@  extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
 extern int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
 extern time_t (*VDSO_SYMBOL(time)) (time_t *);
 
+extern long (*VDSO_SYMBOL(clock_gettime64)) (clockid_t, struct __timespec64 *);
+
 #if defined(__PPC64__) || defined(__powerpc64__)
 extern void *VDSO_SYMBOL(sigtramp_rt64);
 #else