|
|
147e83 |
From 3f38cbfa2a44bf510122d3fcb0f0504a208dbf5e Mon Sep 17 00:00:00 2001
|
|
|
147e83 |
From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
|
|
|
147e83 |
Date: Fri, 15 Mar 2013 10:58:56 -0300
|
|
|
147e83 |
Subject: [PATCH 19/42] PowerPC: gettimeofday optimization by using IFUNC
|
|
|
147e83 |
(backported from commit
|
|
|
147e83 |
ef26eece6331a1f6d959818e37c438cc7ce68e53)
|
|
|
147e83 |
|
|
|
147e83 |
---
|
|
|
147e83 |
sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h | 10 +++++
|
|
|
147e83 |
sysdeps/unix/sysv/linux/powerpc/gettimeofday.c | 48 +++++++++++++++++-------
|
|
|
147e83 |
3 files changed, 52 insertions(+), 13 deletions(-)
|
|
|
147e83 |
|
|
|
147e83 |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
|
|
|
147e83 |
index cda8491..e4ae630 100644
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
|
|
|
147e83 |
@@ -32,6 +32,16 @@ extern void *__vdso_get_tbfreq;
|
|
|
147e83 |
|
|
|
147e83 |
extern void *__vdso_getcpu;
|
|
|
147e83 |
|
|
|
147e83 |
+/* This macro is needed for PPC64 to return a skeleton OPD entry of a vDSO
|
|
|
147e83 |
+ symbol. This works because _dl_vdso_vsym always return the function
|
|
|
147e83 |
+ address, and no vDSO symbols use the TOC or chain pointers from the OPD
|
|
|
147e83 |
+ so we can allow them to be garbage. */
|
|
|
147e83 |
+#if defined(__PPC64__) || defined(__powerpc64__)
|
|
|
147e83 |
+#define VDSO_IFUNC_RET(value) &value
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+#define VDSO_IFUNC_RET(value) value
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+
|
|
|
147e83 |
#endif
|
|
|
147e83 |
|
|
|
147e83 |
#endif /* _LIBC_VDSO_H */
|
|
|
147e83 |
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
|
|
|
147e83 |
index 7376135..4f4abbd 100644
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
|
|
|
147e83 |
@@ -15,26 +15,48 @@
|
|
|
147e83 |
License along with the GNU C Library; if not, see
|
|
|
147e83 |
<http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
|
|
|
147e83 |
-#include <sysdep.h>
|
|
|
147e83 |
-#include <bp-checks.h>
|
|
|
147e83 |
-#include <stddef.h>
|
|
|
147e83 |
#include <sys/time.h>
|
|
|
147e83 |
-#include <time.h>
|
|
|
147e83 |
-#include <hp-timing.h>
|
|
|
147e83 |
|
|
|
147e83 |
-#include <bits/libc-vdso.h>
|
|
|
147e83 |
+#ifdef SHARED
|
|
|
147e83 |
|
|
|
147e83 |
-/* Get the current time of day and timezone information,
|
|
|
147e83 |
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
|
|
|
147e83 |
- Returns 0 on success, -1 on errors. */
|
|
|
147e83 |
+# include <dl-vdso.h>
|
|
|
147e83 |
+# include <bits/libc-vdso.h>
|
|
|
147e83 |
+
|
|
|
147e83 |
+void *gettimeofday_ifunc (void) __asm__ ("__gettimeofday");
|
|
|
147e83 |
+
|
|
|
147e83 |
+static int
|
|
|
147e83 |
+__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
|
|
|
147e83 |
+{
|
|
|
147e83 |
+ return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
|
|
|
147e83 |
+}
|
|
|
147e83 |
+
|
|
|
147e83 |
+void *
|
|
|
147e83 |
+gettimeofday_ifunc (void)
|
|
|
147e83 |
+{
|
|
|
147e83 |
+ /* If the vDSO is not available we fall back syscall. */
|
|
|
147e83 |
+ return (__vdso_gettimeofday ? VDSO_IFUNC_RET (__vdso_gettimeofday)
|
|
|
147e83 |
+ : __gettimeofday_syscall);
|
|
|
147e83 |
+}
|
|
|
147e83 |
+asm (".type __gettimeofday, %gnu_indirect_function");
|
|
|
147e83 |
+
|
|
|
147e83 |
+/* This is doing "libc_hidden_def (__gettimeofday)" but the compiler won't
|
|
|
147e83 |
+ let us do it in C because it doesn't know we're defining __gettimeofday
|
|
|
147e83 |
+ here in this file. */
|
|
|
147e83 |
+asm (".globl __GI___gettimeofday\n"
|
|
|
147e83 |
+ "__GI___gettimeofday = __gettimeofday");
|
|
|
147e83 |
+
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+
|
|
|
147e83 |
+# include <sysdep.h>
|
|
|
147e83 |
+# include <errno.h>
|
|
|
147e83 |
|
|
|
147e83 |
int
|
|
|
147e83 |
-__gettimeofday (tv, tz)
|
|
|
147e83 |
- struct timeval *tv;
|
|
|
147e83 |
- struct timezone *tz;
|
|
|
147e83 |
+__gettimeofday (struct timeval *tv, struct timezone *tz)
|
|
|
147e83 |
{
|
|
|
147e83 |
- return INLINE_VSYSCALL (gettimeofday, 2, CHECK_1 (tv), CHECK_1 (tz));
|
|
|
147e83 |
+ return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
|
|
|
147e83 |
}
|
|
|
147e83 |
libc_hidden_def (__gettimeofday)
|
|
|
147e83 |
+
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
weak_alias (__gettimeofday, gettimeofday)
|
|
|
147e83 |
libc_hidden_weak (gettimeofday)
|
|
|
147e83 |
--
|
|
|
147e83 |
1.7.11.7
|
|
|
147e83 |
|