]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: gettimeofday optimization by using IFUNC
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Tue, 5 Mar 2013 01:02:41 +0000 (22:02 -0300)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Tue, 5 Mar 2013 01:02:41 +0000 (22:02 -0300)
ChangeLog
sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
sysdeps/unix/sysv/linux/powerpc/gettimeofday.c

index 7ba99a7cc1746959a714c854bd708fa845252d63..ca3e120a21dd965fd1a916f45331aae0b95c0a1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-03-04  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+       * sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h: Add macro to
+       return vdso values correctly in IFUNC implementations.
+       * sysdeps/unix/sysv/linux/powerpc/gettimeofday.c (__gettimeofday):
+       Optimization by using IFUNC.
+
 2012-11-20  Thomas Schwinge  <thomas@codesourcery.com>
 
        * sysdeps/sh/dl-machine.h (ELF_MACHINE_RUNTIME_FIXUP_PARAMS): New
index 646e8c0e8ca4e171605bd7d17528d75c72fce8ef..97979431f5a824da34cec144f1343cbeec279b7e 100644 (file)
@@ -30,6 +30,14 @@ extern void *__vdso_clock_getres;
 
 extern void *__vdso_get_tbfreq;
 
+/* Macro to return vdso_xxx value on IFUNC implementations.
+   On PPC64 the returned value is actually an OPD entry.  */
+#if defined(__PPC64__) || defined(__powerpc64__)
+#define PTR_IFUNC_RET(value)  &value
+#else
+#define PTR_IFUNC_RET(value)  value
+#endif
+
 #endif
 
 #endif /* _LIBC_VDSO_H */
index 737613516f4073273d2838bb7d20baf1eb6edbd6..5943be77abc55b61ffc3a6dce954d54def6653b5 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
-#include <bp-checks.h>
-#include <stddef.h>
 #include <sys/time.h>
-#include <time.h>
-#include <hp-timing.h>
 
-#include <bits/libc-vdso.h>
+#ifdef SHARED
 
-/* Get the current time of day and timezone information,
-   putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.
-   Returns 0 on success, -1 on errors.  */
+# include <dl-vdso.h>
+# include <bits/libc-vdso.h>
 
-int
-__gettimeofday (tv, tz)
-     struct timeval *tv;
-     struct timezone *tz;
+void *gettimeofday_ifunc (void) __asm__ ("__gettimeofday");
+
+static int
+__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
+{
+  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
+}
+
+void *
+gettimeofday_ifunc (void)
 {
-  return INLINE_VSYSCALL (gettimeofday, 2, CHECK_1 (tv), CHECK_1 (tz));
+  /* If the vDSO is not available we fall back syscall.  */
+  return (__vdso_gettimeofday ? PTR_IFUNC_RET(__vdso_gettimeofday)
+         : __gettimeofday_syscall);
+}
+asm (".type __gettimeofday, %gnu_indirect_function");
+
+/* This is doing "libc_hidden_def (__gettimeofday)" but the compiler won't
+   let us do it in C because it doesn't know we're defining __gettimeofday
+   here in this file.  */
+asm (".globl __GI___gettimeofday\n"
+     "__GI___gettimeofday = __gettimeofday");
+
+#else
+
+# include <sysdep.h>
+# include <errno.h>
+
+__gettimeofday (struct timeval *tv, struct timezone *tz)
+{
+  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
 }
 libc_hidden_def (__gettimeofday)
+
+#endif
 weak_alias (__gettimeofday, gettimeofday)
 libc_hidden_weak (gettimeofday)