diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux/x86/gettimeofday.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/x86/gettimeofday.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c index e125859c1a..190127d31e 100644 --- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c @@ -1,5 +1,5 @@ /* gettimeofday - get the time. Linux/x86 version. - Copyright (C) 2015-2018 Free Software Foundation, Inc. + Copyright (C) 2015-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -14,48 +14,40 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ + <https://www.gnu.org/licenses/>. */ -#include <sys/time.h> +#include <time.h> +#include <sysdep.h> -#ifdef SHARED - -# include <dl-vdso.h> -# include <errno.h> +#ifdef HAVE_GETTIMEOFDAY_VSYSCALL +# define HAVE_VSYSCALL +#endif +#include <sysdep-vdso.h> static int -__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) +__gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) { - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); + if (__glibc_unlikely (tz != 0)) + memset (tz, 0, sizeof *tz); + + return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); } -# ifndef __gettimeofday_type -/* The i386 gettimeofday.c includes this file with a defined - __gettimeofday_type macro. For x86_64 we have to define it to __gettimeofday - as the internal symbol is the ifunc'ed one. */ -# define __gettimeofday_type __gettimeofday -# endif +#ifdef SHARED +# include <dl-vdso.h> +# include <libc-vdso.h> -# undef INIT_ARCH -# define INIT_ARCH() PREPARE_VERSION_KNOWN (linux26, LINUX_2_6) +# define INIT_ARCH() /* If the vDSO is not available we fall back to syscall. */ -libc_ifunc_hidden (__gettimeofday_type, __gettimeofday, - (_dl_vdso_vsym ("__vdso_gettimeofday", &linux26) - ?: &__gettimeofday_syscall)) -libc_hidden_def (__gettimeofday) +libc_ifunc (__gettimeofday, + (get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) + ?: __gettimeofday_syscall)); #else - -# include <sysdep.h> -# include <errno.h> - int -__gettimeofday (struct timeval *tv, struct timezone *tz) +__gettimeofday (struct timeval *restrict tv, void *restrict tz) { - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); + return __gettimeofday_syscall (tv, tz); } -libc_hidden_def (__gettimeofday) - #endif weak_alias (__gettimeofday, gettimeofday) -libc_hidden_weak (gettimeofday) |