]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / aarch64 / gettimeofday.c
CommitLineData
04277e02 1/* Copyright (C) 2018-2019 Free Software Foundation, Inc.
3c7b9f1f
SE
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
3c7b9f1f
SE
18
19/* Get the current time of day and timezone information,
20 putting it into *tv and *tz. If tz is null, *tz is not filled.
21 Returns 0 on success, -1 on errors. */
22
23#ifdef SHARED
24
25# define __gettimeofday __redirect___gettimeofday
26# include <sys/time.h>
27# undef __gettimeofday
28# define HAVE_VSYSCALL
29# include <dl-vdso.h>
30# include <sysdep-vdso.h>
31
32/* Used as a fallback in the ifunc resolver if VDSO is not available
33 and for libc.so internal __gettimeofday calls. */
34
35static int
36__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
37{
38 return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
39}
40
85c748f9 41/* PREPARE_VERSION_KNOWN will need an __LP64__ ifdef when ILP32 support
3c7b9f1f
SE
42 goes in. See _libc_vdso_platform_setup in
43 sysdeps/unix/sysv/linux/aarch64/init-first.c. */
44
45# undef INIT_ARCH
46# define INIT_ARCH() \
85c748f9 47 PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6_39); \
3c7b9f1f
SE
48 void *vdso_gettimeofday = \
49 _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version);
50
51libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
52 vdso_gettimeofday ?: (void *) __gettimeofday_vsyscall)
53
54__hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday,
55 __gettimeofday_vsyscall);
56
57#else
58
59# include <sys/time.h>
60# include <sysdep.h>
61int
62__gettimeofday (struct timeval *tv, struct timezone *tz)
63{
64 return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
65}
66libc_hidden_def (__gettimeofday)
67
68#endif
69
70weak_alias (__gettimeofday, gettimeofday)
71libc_hidden_weak (gettimeofday)