From: Adhemerval Zanella Date: Tue, 5 Mar 2013 01:02:41 +0000 (-0300) Subject: PowerPC: gettimeofday optimization by using IFUNC X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc328ae264f5b97d2811a95d84112bb1c6c7cae3;p=thirdparty%2Fglibc.git PowerPC: gettimeofday optimization by using IFUNC --- diff --git a/ChangeLog b/ChangeLog index 7ba99a7cc17..ca3e120a21d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-03-04 Adhemerval Zanella + + * 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 * sysdeps/sh/dl-machine.h (ELF_MACHINE_RUNTIME_FIXUP_PARAMS): New diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h index 646e8c0e8ca..97979431f5a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h @@ -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 */ diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index 737613516f4..5943be77abc 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -15,26 +15,47 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include #include -#include -#include -#include +#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 +# include -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 +# include + +__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)