]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/x86_64/time.c
79f1fab9989bffd36e5a8430540fc94e49ea56d5
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / x86_64 / time.c
1 /* Copyright (C) 2001-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18 #ifdef SHARED
19 /* Redefine time so that the compiler won't complain about the type
20 mismatch with the IFUNC selector in strong_alias, below. */
21 #undef time
22 #define time __redirect_time
23 #include <time.h>
24
25 #include <dl-vdso.h>
26
27 #define VSYSCALL_ADDR_vtime 0xffffffffff600400
28
29 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
30 ifunc symbol properly. */
31 extern __typeof (__redirect_time) __libc_time;
32 void *time_ifunc (void) __asm__ ("__libc_time");
33
34 void *
35 time_ifunc (void)
36 {
37 PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
38
39 /* If the vDSO is not available we fall back on the old vsyscall. */
40 return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime;
41 }
42 __asm (".type __libc_time, %gnu_indirect_function");
43
44 #undef time
45 strong_alias (__libc_time, time)
46 libc_hidden_ver (__libc_time, time)
47
48 #else
49
50 # include <time.h>
51 # include <sysdep.h>
52
53 time_t
54 time (time_t *t)
55 {
56 INTERNAL_SYSCALL_DECL (err);
57 return INTERNAL_SYSCALL (time, err, 1, t);
58 }
59
60 #endif