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