Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / x86_64 / gettimeofday.c
blob440ca7f82a5ed4434092c70f007dc3be65cf66a1
1 /* Copyright (C) 2002-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #include <sys/time.h>
20 #ifdef SHARED
22 # include <dl-vdso.h>
24 # define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul
26 void *gettimeofday_ifunc (void) __asm__ ("__gettimeofday");
28 void *
29 gettimeofday_ifunc (void)
31 PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
33 /* If the vDSO is not available we fall back on the old vsyscall. */
34 return (_dl_vdso_vsym ("__vdso_gettimeofday", &linux26)
35 ?: (void *) VSYSCALL_ADDR_vgettimeofday);
37 asm (".type __gettimeofday, %gnu_indirect_function");
39 /* This is doing "libc_hidden_def (__gettimeofday)" but the compiler won't
40 let us do it in C because it doesn't know we're defining __gettimeofday
41 here in this file. */
42 asm (".globl __GI___gettimeofday\n"
43 "__GI___gettimeofday = __gettimeofday");
45 #else
47 # include <sysdep.h>
48 # include <errno.h>
50 int
51 __gettimeofday (struct timeval *tv, struct timezone *tz)
53 return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
55 libc_hidden_def (__gettimeofday)
57 #endif
58 weak_alias (__gettimeofday, gettimeofday)
59 libc_hidden_weak (gettimeofday)