]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
463b678ad935aadbb81026c1ba95bcbad7ac7350
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / powerpc / gettimeofday.c
1 /* Copyright (C) 2005-2019 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 #if defined SHARED && !defined __powerpc64__
19 # define __gettimeofday __redirect___gettimeofday
20 #else
21 # define __redirect___gettimeofday __gettimeofday
22 #endif
23
24 #include <sys/time.h>
25
26 #ifdef SHARED
27
28 # include <dl-vdso.h>
29 # include <libc-vdso.h>
30 # include <dl-machine.h>
31
32 # ifndef __powerpc64__
33 # undef __gettimeofday
34
35 int
36 __gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
37 {
38 return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
39 }
40
41 /* __GI___gettimeofday is defined as hidden and for ppc32 it enables the
42 compiler make a local call (symbol@local) for internal GLIBC usage. It
43 means the PLT won't be used and the ifunc resolver will be called directly.
44 For ppc64 a call to a function in another translation unit might use a
45 different toc pointer thus disallowing direct branchess and making internal
46 ifuncs calls safe. */
47 # undef libc_hidden_def
48 # define libc_hidden_def(name) \
49 __hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday, \
50 __gettimeofday_vsyscall);
51
52 # endif /* !__powerpc64__ */
53
54 static int
55 __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
56 {
57 return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
58 }
59
60 # define INIT_ARCH() \
61 PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15); \
62 void *vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
63
64 /* If the vDSO is not available we fall back syscall. */
65 libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
66 vdso_gettimeofday
67 ? VDSO_IFUNC_RET (vdso_gettimeofday)
68 : (void *) __gettimeofday_syscall);
69 libc_hidden_def (__gettimeofday)
70
71 #else
72
73 # include <sysdep.h>
74 # include <errno.h>
75
76 int
77 __gettimeofday (struct timeval *tv, struct timezone *tz)
78 {
79 return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
80 }
81 libc_hidden_def (__gettimeofday)
82
83 #endif
84 weak_alias (__gettimeofday, gettimeofday)
85 libc_hidden_weak (gettimeofday)