@@ -20,10 +20,6 @@
# include <time/sys/time.h>
# ifndef _ISOMAC
-extern int __gettimeofday (struct timeval *__tv,
- struct timezone *__tz);
-libc_hidden_proto (__gettimeofday)
-libc_hidden_proto (gettimeofday)
extern int __settimezone (const struct timezone *__tz)
attribute_hidden;
extern int __adjtime (const struct timeval *__delta,
similarity index 65%
rename from sysdeps/unix/clock_gettime.c
rename to sysdeps/mach/clock_gettime.c
@@ -1,5 +1,4 @@
-/* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version.
- Copyright (C) 1999-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1991-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
@@ -18,32 +17,28 @@
#include <errno.h>
#include <time.h>
-#include <sys/time.h>
+#include <mach.h>
#include <shlib-compat.h>
-/* Get current value of CLOCK and store it in TP. */
+/* Get the current time of day, putting it into *TS.
+ Returns 0 on success, -1 on errors. */
int
-__clock_gettime (clockid_t clock_id, struct timespec *tp)
+__clock_gettime (clockid_t clock_id, struct timespec *ts)
{
- int retval = -1;
-
- switch (clock_id)
+ if (clock_id != CLOCK_REALTIME)
{
- case CLOCK_REALTIME:
- {
- struct timeval tv;
- retval = __gettimeofday (&tv, NULL);
- if (retval == 0)
- TIMEVAL_TO_TIMESPEC (&tv, tp);
- }
- break;
-
- default:
- __set_errno (EINVAL);
- break;
+ errno = EINVAL;
+ return -1;
}
- return retval;
+ /* __host_get_time can only fail if passed an invalid host_t.
+ __mach_host_self could theoretically fail (producing an
+ invalid host_t) due to resource exhaustion, but we assume
+ this will never happen. */
+ time_value_t tv;
+ __host_get_time (__mach_host_self (), &tv);
+ TIME_VALUE_TO_TIMESPEC (&tv, ts);
+ return 0;
}
libc_hidden_def (__clock_gettime)
deleted file mode 100644
@@ -1,43 +0,0 @@
-/* Copyright (C) 1991-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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#include <errno.h>
-#include <stddef.h>
-#include <sys/time.h>
-#include <mach.h>
-
-/* 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. */
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
- kern_return_t err;
-
- if (tz != NULL)
- *tz = (struct timezone){0, 0}; /* XXX */
-
- if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv))
- {
- errno = err;
- return -1;
- }
- return 0;
-}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
deleted file mode 100644
@@ -1,67 +0,0 @@
-/* Copyright (C) 1991-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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-
-/* 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. */
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
- if (tv == NULL)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- tv->tv_sec = (long int) time ((time_t *) NULL);
- tv->tv_usec = 0L;
-
- if (tz != NULL)
- {
- const time_t timer = tv->tv_sec;
- struct tm tm;
- const struct tm *tmp;
-
- const long int save_timezone = __timezone;
- const long int save_daylight = __daylight;
- char *save_tzname[2];
- save_tzname[0] = __tzname[0];
- save_tzname[1] = __tzname[1];
-
- tmp = localtime_r (&timer, &tm);
-
- tz->tz_minuteswest = __timezone / 60;
- tz->tz_dsttime = __daylight;
-
- __timezone = save_timezone;
- __daylight = save_daylight;
- __tzname[0] = save_tzname[0];
- __tzname[1] = save_tzname[1];
-
- if (tmp == NULL)
- return -1;
- }
-
- return 0;
-}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
@@ -33,7 +33,6 @@ getrlimit - getrlimit i:ip __getrlimit getrlimit
getrusage - getrusage i:ip __getrusage getrusage
getsockname - getsockname i:ibN __getsockname getsockname
getsockopt - getsockopt i:iiiBN getsockopt
-gettimeofday - gettimeofday i:pP __gettimeofday gettimeofday
getuid - getuid Ei: __getuid getuid
ioctl - ioctl i:iiI __ioctl ioctl
kill - kill i:ii __kill kill
deleted file mode 100644
@@ -1,71 +0,0 @@
-/* Copyright (C) 2018-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
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-/* 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. */
-
-#ifdef SHARED
-
-# define __gettimeofday __redirect___gettimeofday
-# include <sys/time.h>
-# undef __gettimeofday
-# define HAVE_VSYSCALL
-# include <dl-vdso.h>
-# include <sysdep-vdso.h>
-
-/* Used as a fallback in the ifunc resolver if VDSO is not available
- and for libc.so internal __gettimeofday calls. */
-
-static int
-__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
-{
- return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-/* PREPARE_VERSION_KNOWN will need an __LP64__ ifdef when ILP32 support
- goes in. See _libc_vdso_platform_setup in
- sysdeps/unix/sysv/linux/aarch64/init-first.c. */
-
-# undef INIT_ARCH
-# define INIT_ARCH() \
- PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6_39); \
- void *vdso_gettimeofday = \
- _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version);
-
-libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
- vdso_gettimeofday ?: (void *) __gettimeofday_vsyscall)
-
-__hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday,
- __gettimeofday_vsyscall);
-
-#else
-
-# include <sys/time.h>
-# include <sysdep.h>
-int
-__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)
@@ -19,23 +19,20 @@
#include <dl-vdso.h>
#include <libc-vdso.h>
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
static inline void
_libc_vdso_platform_setup (void)
{
+ void *p;
+
#ifdef __LP64__
PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6_39);
#else
PREPARE_VERSION_KNOWN (linux_version, LINUX_4_9);
#endif
- void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version);
- PTR_MANGLE (p);
- VDSO_SYMBOL(gettimeofday) = p;
-
p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux_version);
PTR_MANGLE (p);
VDSO_SYMBOL(clock_gettime) = p;
@@ -22,8 +22,6 @@
#include <sysdep.h>
#include <sysdep-vdso.h>
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
similarity index 58%
rename from sysdeps/unix/sysv/linux/i386/gettimeofday.c
rename to sysdeps/unix/sysv/linux/alpha/gettimeofday.c
@@ -1,5 +1,5 @@
-/* gettimeofday - get the time. Linux/i386 version.
- Copyright (C) 2015-2019 Free Software Foundation, Inc.
+/* gettimeofday -- Get the current time of day. Linux/Alpha/tv64 version.
+ Copyright (C) 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
@@ -16,20 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#ifdef SHARED
-# define __gettimeofday __redirect___gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-# undef __gettimeofday
-# define __gettimeofday_type __redirect___gettimeofday
-
-# undef libc_hidden_def
-# define libc_hidden_def(name) \
- __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \
- __gettimeofday_syscall);
-#endif
-
-#include <sysdeps/unix/sysv/linux/x86/gettimeofday.c>
+/* We can use the generic implementation, but we have to override its
+ default symbol version. */
+#define VERSION_gettimeofday GLIBC_2.1
+#include <time/gettimeofday.c>
@@ -20,6 +20,8 @@
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+#include <string.h>
+#include <time.h>
#include <sys/time.h>
#include <tv32-compat.h>
@@ -30,10 +32,13 @@ int
attribute_compat_text_section
__gettimeofday_tv32 (struct timeval32 *restrict tv32, void *restrict tz)
{
- struct timeval tv;
- __gettimeofday (&tv, tz);
+ if (__glibc_unlikely (tz != 0))
+ memset (tz, 0, sizeof (struct timezone));
- TV64_TO_TV32 (tv32, &tv);
+ struct timespec ts;
+ __clock_gettime (CLOCK_REALTIME, &ts);
+
+ TS64_TO_TV32 (tv32, &ts);
return 0;
}
@@ -23,7 +23,6 @@ pciconfig_write EXTRA pciconfig_write 5 pciconfig_write
pciconfig_iobase EXTRA pciconfig_iobase 3 __pciconfig_iobase pciconfig_iobase
# timeval64 entry points (see osf_*.c for GLIBC_2.0 timeval32 equivalents)
-gettimeofday - gettimeofday i:pP __GI___gettimeofday gettimeofday@@GLIBC_2.1 __gettimeofday@@GLIBC_2.1
getitimer - getitimer i:ip __getitimer getitimer@@GLIBC_2.1
setitimer - setitimer i:ipP __setitimer setitimer@@GLIBC_2.1
utimes - utimes i:sp __utimes utimes@@GLIBC_2.1
@@ -21,17 +21,14 @@
#include <libc-vdso.h>
#include <sysdep-vdso.h>
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
static inline void
_libc_vdso_platform_setup (void)
{
- PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
+ void *p;
- void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
- PTR_MANGLE (p);
- VDSO_SYMBOL (gettimeofday) = p;
+ PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
PTR_MANGLE (p);
@@ -22,8 +22,6 @@
#include <sysdep-vdso.h>
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
#endif /* _LIBC_VDSO_H */
deleted file mode 100644
@@ -1,49 +0,0 @@
-/* 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
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#include <errno.h>
-#include <sys/time.h>
-
-#undef __gettimeofday
-
-#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
-# define HAVE_VSYSCALL
-#endif
-#include <sysdep-vdso.h>
-
-/* 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. */
-int
-___gettimeofday (struct timeval *tv, struct timezone *tz)
-{
- return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-#ifdef VERSION_gettimeofday
-weak_alias (___gettimeofday, __wgettimeofday);
-default_symbol_version (___gettimeofday, __gettimeofday, VERSION_gettimeofday);
-default_symbol_version (__wgettimeofday, gettimeofday, VERSION_gettimeofday);
-libc_hidden_ver (___gettimeofday, __gettimeofday);
-libc_hidden_ver (___gettimeofday, gettimeofday);
-#else
-strong_alias (___gettimeofday, __gettimeofday)
-weak_alias (___gettimeofday, gettimeofday)
-libc_hidden_def (__gettimeofday)
-libc_hidden_weak (gettimeofday)
-#endif
@@ -20,17 +20,14 @@
#include <dl-vdso.h>
#include <libc-vdso.h>
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
static inline void
_libc_vdso_platform_setup (void)
{
- PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
+ void *p;
- void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
- PTR_MANGLE (p);
- VDSO_SYMBOL (gettimeofday) = p;
+ PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
PTR_MANGLE (p);
@@ -22,8 +22,6 @@
#include <sysdep-vdso.h>
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
#endif /* _LIBC_VDSO_H */
deleted file mode 100644
@@ -1,85 +0,0 @@
-/* Copyright (C) 2005-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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#if defined SHARED && !defined __powerpc64__
-# define __gettimeofday __redirect___gettimeofday
-#else
-# define __redirect___gettimeofday __gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <libc-vdso.h>
-# include <dl-machine.h>
-
-# ifndef __powerpc64__
-# undef __gettimeofday
-
-int
-__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
-{
- return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-/* __GI___gettimeofday is defined as hidden and for ppc32 it enables the
- compiler make a local call (symbol@local) for internal GLIBC usage. It
- means the PLT won't be used and the ifunc resolver will be called directly.
- For ppc64 a call to a function in another translation unit might use a
- different toc pointer thus disallowing direct branchess and making internal
- ifuncs calls safe. */
-# undef libc_hidden_def
-# define libc_hidden_def(name) \
- __hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday, \
- __gettimeofday_vsyscall);
-
-# endif /* !__powerpc64__ */
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
- return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# define INIT_ARCH() \
- PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15); \
- void *vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
-
-/* If the vDSO is not available we fall back syscall. */
-libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
- vdso_gettimeofday
- ? VDSO_IFUNC_RET (vdso_gettimeofday)
- : (void *) __gettimeofday_syscall);
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__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)
@@ -19,8 +19,6 @@
#include <dl-vdso.h>
#include <libc-vdso.h>
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
@@ -36,11 +34,9 @@ void *VDSO_SYMBOL(sigtramp_rt32);
static inline void
_libc_vdso_platform_setup (void)
{
- PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15);
+ void *p;
- void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
- PTR_MANGLE (p);
- VDSO_SYMBOL (gettimeofday) = p;
+ PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15);
p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2615);
PTR_MANGLE (p);
@@ -23,8 +23,6 @@
#include <sysdep.h>
#include <sysdep-vdso.h>
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
@@ -22,8 +22,6 @@
long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
attribute_hidden;
-long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
attribute_hidden;
long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
@@ -32,16 +30,14 @@ long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
static inline void
_libc_vdso_platform_setup (void)
{
+ void *p;
+
PREPARE_VERSION_KNOWN (linux_version, LINUX_4_15);
- void *p = _dl_vdso_vsym ("__vdso_getcpu", &linux_version);
+ p = _dl_vdso_vsym ("__vdso_getcpu", &linux_version);
PTR_MANGLE (p);
VDSO_SYMBOL (getcpu) = p;
- p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
- PTR_MANGLE (p);
- VDSO_SYMBOL (gettimeofday) = p;
-
p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
PTR_MANGLE (p);
VDSO_SYMBOL (clock_gettime) = p;
@@ -24,8 +24,6 @@
extern long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
attribute_hidden;
-extern long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
extern long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
attribute_hidden;
extern long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
@@ -19,9 +19,6 @@
#include <dl-vdso.h>
#include <libc-vdso.h>
-long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
-
long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
__attribute__ ((nocommon));
@@ -34,11 +31,9 @@ long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
static inline void
_libc_vdso_platform_setup (void)
{
- PREPARE_VERSION_KNOWN (linux2629, LINUX_2_6_29);
+ void *p;
- void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2629);
- PTR_MANGLE (p);
- VDSO_SYMBOL (gettimeofday) = p;
+ PREPARE_VERSION_KNOWN (linux2629, LINUX_2_6_29);
p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2629);
PTR_MANGLE (p);
@@ -22,9 +22,6 @@
#include <sysdep-vdso.h>
-extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
-
extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
extern long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
@@ -20,19 +20,15 @@
#include <dl-vdso.h>
#include <libc-vdso.h>
-long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
attribute_hidden;
static inline void
_libc_vdso_platform_setup (void)
{
- PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6);
+ void *p;
- void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
- PTR_MANGLE (p);
- VDSO_SYMBOL (gettimeofday) = p;
+ PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6);
p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
PTR_MANGLE (p);
@@ -22,8 +22,6 @@
#include <sysdep-vdso.h>
-extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
- attribute_hidden;
extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
#endif /* _LIBC_VDSO_H */
deleted file mode 100644
@@ -1,61 +0,0 @@
-/* gettimeofday - get the time. Linux/x86 version.
- 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <errno.h>
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
- return INLINE_SYSCALL (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
-
-# undef INIT_ARCH
-# define INIT_ARCH() PREPARE_VERSION_KNOWN (linux26, LINUX_2_6)
-/* 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)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__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)
@@ -1,5 +1,4 @@
# File name Caller Syscall name # args Strong name Weak names
-gettimeofday - gettimeofday:__vdso_gettimeofday@LINUX_2.6 i:pP __gettimeofday gettimeofday
personality EXTRA personality Ei:i __personality personality
posix_fadvise64 - fadvise64 Vi:iiii posix_fadvise posix_fadvise64
@@ -15,20 +15,32 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
+#include <string.h>
+#include <time.h>
#include <sys/time.h>
-/* Get the current time of day and timezone information,
- putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+/* Get the current time of day, putting it into *TV.
+ If *TZ is not NULL, clear it.
Returns 0 on success, -1 on errors. */
int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
+___gettimeofday (struct timeval *tv, struct timezone *tz)
{
- __set_errno (ENOSYS);
- return -1;
+ if (__glibc_unlikely (tz != 0))
+ memset (tz, 0, sizeof *tz);
+
+ struct timespec ts;
+ if (__clock_gettime (CLOCK_REALTIME, &ts))
+ return -1;
+
+ TIMESPEC_TO_TIMEVAL (tv, &ts);
+ return 0;
}
-libc_hidden_def (__gettimeofday)
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
-stub_warning (gettimeofday)
+#ifdef VERSION_gettimeofday
+weak_alias (___gettimeofday, __wgettimeofday);
+default_symbol_version (___gettimeofday, __gettimeofday, VERSION_gettimeofday);
+default_symbol_version (__wgettimeofday, gettimeofday, VERSION_gettimeofday);
+#else
+strong_alias (___gettimeofday, __gettimeofday)
+weak_alias (___gettimeofday, gettimeofday)
+#endif