]>
Commit | Line | Data |
---|---|---|
ca677d3c | 1 | /* gettimeofday - get the time. Linux/x86 version. |
d614a753 | 2 | Copyright (C) 2015-2020 Free Software Foundation, Inc. |
ca677d3c AZ |
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 | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the 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/>. */ |
ca677d3c | 18 | |
5e46749c AZ |
19 | #include <time.h> |
20 | #include <sysdep.h> | |
ca677d3c | 21 | |
5e46749c AZ |
22 | #ifdef HAVE_GETTIMEOFDAY_VSYSCALL |
23 | # define HAVE_VSYSCALL | |
24 | #endif | |
25 | #include <sysdep-vdso.h> | |
7cbeabac AZ |
26 | |
27 | static int | |
2f2c76e1 | 28 | __gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) |
7cbeabac | 29 | { |
5e46749c AZ |
30 | if (__glibc_unlikely (tz != 0)) |
31 | memset (tz, 0, sizeof *tz); | |
32 | ||
33 | return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); | |
7cbeabac | 34 | } |
ca677d3c | 35 | |
5e46749c AZ |
36 | #ifdef SHARED |
37 | # include <dl-vdso.h> | |
38 | # include <libc-vdso.h> | |
e23faea6 | 39 | |
b8386c28 | 40 | # define INIT_ARCH() |
e23faea6 | 41 | /* If the vDSO is not available we fall back to syscall. */ |
5e46749c AZ |
42 | libc_ifunc (__gettimeofday, |
43 | (get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) | |
44 | ?: __gettimeofday_syscall)); | |
ca677d3c AZ |
45 | |
46 | #else | |
ca677d3c | 47 | int |
2f2c76e1 | 48 | __gettimeofday (struct timeval *restrict tv, void *restrict tz) |
ca677d3c | 49 | { |
5e46749c | 50 | return __gettimeofday_syscall (tv, tz); |
ca677d3c | 51 | } |
ca677d3c AZ |
52 | #endif |
53 | weak_alias (__gettimeofday, gettimeofday) |