1 /* Copyright (C) 2003-2022 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 License as
6 published by the Free Software Foundation; either version 2.1 of the
7 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; see the file COPYING.LIB. If
16 not, see <https://www.gnu.org/licenses/>. */
22 #include <kernel-features.h>
23 #include "kernel-posix-timers.h"
24 #include <shlib-compat.h>
26 #if !TIMER_T_WAS_INT_COMPAT
28 ___timer_gettime64 (timer_t timerid
, struct __itimerspec64
*value
)
30 kernel_timer_t ktimerid
= timerid_to_kernel_timer (timerid
);
32 # ifndef __NR_timer_gettime64
33 # define __NR_timer_gettime64 __NR_timer_gettime
35 int ret
= INLINE_SYSCALL_CALL (timer_gettime64
, ktimerid
, value
);
36 # ifndef __ASSUME_TIME64_SYSCALLS
37 if (ret
== 0 || errno
!= ENOSYS
)
40 struct itimerspec its32
;
41 ret
= INLINE_SYSCALL_CALL (timer_gettime
, ktimerid
, &its32
);
44 value
->it_interval
= valid_timespec_to_timespec64 (its32
.it_interval
);
45 value
->it_value
= valid_timespec_to_timespec64 (its32
.it_value
);
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
);
57 # else /* __TIMESIZE != 64 */
58 libc_hidden_ver (___timer_gettime64
, __timer_gettime64
)
59 versioned_symbol (libc
, ___timer_gettime64
, __timer_gettime64
, GLIBC_2_34
);
62 __timer_gettime (timer_t timerid
, struct itimerspec
*value
)
64 struct __itimerspec64 its64
;
65 int retval
= __timer_gettime64 (timerid
, &its64
);
68 value
->it_interval
= valid_timespec64_to_timespec (its64
.it_interval
);
69 value
->it_value
= valid_timespec64_to_timespec (its64
.it_value
);
74 versioned_symbol (libc
, __timer_gettime
, timer_gettime
, GLIBC_2_34
);
76 # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_34)
77 compat_symbol (librt
, __timer_gettime
, timer_gettime
, GLIBC_2_2
);
79 # endif /* __TIMESIZE != 64 */
81 #else /* TIMER_T_WAS_INT_COMPAT */
83 extern __typeof (timer_gettime
) __timer_gettime_new
;
84 libc_hidden_proto (__timer_gettime_new
)
87 ___timer_gettime_new (timer_t timerid
, struct itimerspec
*value
)
89 kernel_timer_t ktimerid
= timerid_to_kernel_timer (timerid
);
91 return INLINE_SYSCALL_CALL (timer_gettime
, ktimerid
, value
);
93 versioned_symbol (libc
, ___timer_gettime_new
, timer_gettime
, GLIBC_2_34
);
94 libc_hidden_ver (___timer_gettime_new
, __timer_gettime_new
)
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
);
100 # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3)
102 __timer_gettime_old (int timerid
, struct itimerspec
*value
)
104 return __timer_gettime_new (__timer_compat_list
[timerid
], value
);
106 compat_symbol (librt
, __timer_gettime_old
, timer_gettime
, GLIBC_2_2
);
109 #endif /* TIMER_T_WAS_INT_COMPAT */