]> sourceware.org Git - glibc.git/blame - sysdeps/unix/sysv/linux/time.c
AArch64: Small optimisation in AdvSIMD erf and erfc
[glibc.git] / sysdeps / unix / sysv / linux / time.c
CommitLineData
e760874e 1/* time -- Get number of seconds since Epoch. Linux version.
dff8da6b 2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
e760874e
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
17 <https://www.gnu.org/licenses/>. */
18
19/* Optimize the function call by setting the PLT directly to vDSO symbol. */
20#ifdef USE_IFUNC_TIME
21# include <time.h>
22# include <sysdep.h>
23# include <sysdep-vdso.h>
24
25#ifdef SHARED
26# include <dl-vdso.h>
1bdda52f 27# include <libc-vdso.h>
e760874e
AZ
28
29static time_t
30time_syscall (time_t *t)
31{
32 return INLINE_SYSCALL_CALL (time, t);
33}
34
35# undef INIT_ARCH
55d33108 36# define INIT_ARCH()
e760874e 37libc_ifunc (time,
55d33108
AZ
38 GLRO(dl_vdso_time) != NULL ? VDSO_IFUNC_RET (GLRO(dl_vdso_time))
39 : (void *) time_syscall);
e760874e
AZ
40
41# else
42time_t
43time (time_t *t)
44{
45 return INLINE_VSYSCALL (time, 1, t);
46}
47# endif /* !SHARED */
48#else /* USE_IFUNC_TIME */
75c4044b
LM
49# include <time.h>
50# include <time-clockid.h>
51# include <errno.h>
52
53/* Return the time now, and store it in *TIMER if not NULL. */
54
55__time64_t
56__time64 (__time64_t *timer)
57{
58 struct __timespec64 ts;
59 __clock_gettime64 (TIME_CLOCK_GETTIME_CLOCKID, &ts);
60
61 if (timer != NULL)
62 *timer = ts.tv_sec;
63 return ts.tv_sec;
64}
65
66# if __TIMESIZE != 64
67libc_hidden_def (__time64)
68
69time_t
70__time (time_t *timer)
71{
72 __time64_t t = __time64 (NULL);
73
74 if (! in_time_t_range (t))
75 {
76 __set_errno (EOVERFLOW);
77 return -1;
78 }
79
80 if (timer != NULL)
81 *timer = t;
82 return t;
83}
84# endif
85weak_alias (__time, time)
e760874e 86#endif
This page took 0.266681 seconds and 6 git commands to generate.