olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh977110-2.patch

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