]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 2003-2021 Free Software Foundation, Inc. |
09402f5b | 2 | This file is part of the GNU C Library. |
09402f5b UD |
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 License as | |
6 | published by the Free Software Foundation; either version 2.1 of the | |
7 | 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 | |
59ba27a6 | 15 | License along with the GNU C Library; see the file COPYING.LIB. If |
5a82c748 | 16 | not, see <https://www.gnu.org/licenses/>. */ |
09402f5b UD |
17 | |
18 | #include <errno.h> | |
19 | #include <stdlib.h> | |
20 | #include <time.h> | |
21 | #include <sysdep.h> | |
562cdc19 | 22 | #include <kernel-features.h> |
09402f5b | 23 | #include "kernel-posix-timers.h" |
a1d6ed02 | 24 | #include <shlib-compat.h> |
09402f5b | 25 | |
a1d6ed02 | 26 | #if !TIMER_T_WAS_INT_COMPAT |
09402f5b | 27 | int |
a1d6ed02 | 28 | ___timer_gettime64 (timer_t timerid, struct __itimerspec64 *value) |
09402f5b | 29 | { |
7a887dd5 | 30 | kernel_timer_t ktimerid = timerid_to_kernel_timer (timerid); |
09402f5b | 31 | |
a1d6ed02 FW |
32 | # ifndef __NR_timer_gettime64 |
33 | # define __NR_timer_gettime64 __NR_timer_gettime | |
34 | # endif | |
7a887dd5 | 35 | int ret = INLINE_SYSCALL_CALL (timer_gettime64, ktimerid, value); |
a1d6ed02 | 36 | # ifndef __ASSUME_TIME64_SYSCALLS |
562cdc19 LM |
37 | if (ret == 0 || errno != ENOSYS) |
38 | return ret; | |
70746a06 | 39 | |
562cdc19 | 40 | struct itimerspec its32; |
7a887dd5 | 41 | ret = INLINE_SYSCALL_CALL (timer_gettime, ktimerid, &its32); |
70746a06 | 42 | if (ret == 0) |
562cdc19 LM |
43 | { |
44 | value->it_interval = valid_timespec_to_timespec64 (its32.it_interval); | |
45 | value->it_value = valid_timespec_to_timespec64 (its32.it_value); | |
46 | } | |
a1d6ed02 | 47 | # endif |
70746a06 | 48 | return ret; |
09402f5b | 49 | } |
562cdc19 | 50 | |
a1d6ed02 FW |
51 | # if __TIMESIZE == 64 |
52 | versioned_symbol (libc, ___timer_gettime64, timer_gettime, GLIBC_2_34); | |
53 | # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_34) | |
54 | compat_symbol (librt, ___timer_gettime64, timer_gettime, GLIBC_2_2); | |
55 | # endif | |
56 | ||
57 | # else /* __TIMESIZE != 64 */ | |
58 | libc_hidden_ver (___timer_gettime64, __timer_gettime64) | |
59 | versioned_symbol (libc, ___timer_gettime64, __timer_gettime64, GLIBC_2_34); | |
6befb33f | 60 | |
562cdc19 LM |
61 | int |
62 | __timer_gettime (timer_t timerid, struct itimerspec *value) | |
63 | { | |
64 | struct __itimerspec64 its64; | |
65 | int retval = __timer_gettime64 (timerid, &its64); | |
66 | if (retval == 0) | |
67 | { | |
68 | value->it_interval = valid_timespec64_to_timespec (its64.it_interval); | |
69 | value->it_value = valid_timespec64_to_timespec (its64.it_value); | |
70 | } | |
71 | ||
72 | return retval; | |
73 | } | |
a1d6ed02 FW |
74 | versioned_symbol (libc, __timer_gettime, timer_gettime, GLIBC_2_34); |
75 | ||
76 | # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_34) | |
77 | compat_symbol (librt, __timer_gettime, timer_gettime, GLIBC_2_2); | |
78 | # endif | |
79 | # endif /* __TIMESIZE != 64 */ | |
80 | ||
81 | #else /* TIMER_T_WAS_INT_COMPAT */ | |
82 | ||
83 | extern __typeof (timer_gettime) __timer_gettime_new; | |
84 | libc_hidden_proto (__timer_gettime_new) | |
85 | ||
86 | int | |
87 | ___timer_gettime_new (timer_t timerid, struct itimerspec *value) | |
88 | { | |
89 | kernel_timer_t ktimerid = timerid_to_kernel_timer (timerid); | |
90 | ||
91 | return INLINE_SYSCALL_CALL (timer_gettime, ktimerid, value); | |
92 | } | |
93 | versioned_symbol (libc, ___timer_gettime_new, timer_gettime, GLIBC_2_34); | |
94 | libc_hidden_ver (___timer_gettime_new, __timer_gettime_new) | |
95 | ||
96 | # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_3_3, GLIBC_2_34) | |
97 | compat_symbol (librt, ___timer_gettime_new, timer_gettime, GLIBC_2_3_3); | |
98 | # endif | |
99 | ||
100 | # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3) | |
101 | int | |
102 | __timer_gettime_old (int timerid, struct itimerspec *value) | |
103 | { | |
104 | return __timer_gettime_new (__timer_compat_list[timerid], value); | |
105 | } | |
106 | compat_symbol (librt, __timer_gettime_old, timer_gettime, GLIBC_2_2); | |
107 | # endif | |
108 | ||
109 | #endif /* TIMER_T_WAS_INT_COMPAT */ |