]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/timer_settime.c
1 /* Copyright (C) 2003-2021 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_settime64 (timer_t timerid
, int flags
,
29 const struct __itimerspec64
*value
,
30 struct __itimerspec64
*ovalue
)
32 kernel_timer_t ktimerid
= timerid_to_kernel_timer (timerid
);
34 # ifdef __ASSUME_TIME64_SYSCALLS
35 # ifndef __NR_timer_settime64
36 # define __NR_timer_settime64 __NR_timer_settime
38 return INLINE_SYSCALL_CALL (timer_settime64
, ktimerid
, flags
, value
,
41 # ifdef __NR_timer_settime64
42 int ret
= INLINE_SYSCALL_CALL (timer_settime64
, ktimerid
, flags
, value
,
44 if (ret
== 0 || errno
!= ENOSYS
)
47 struct itimerspec its32
, oits32
;
49 if (! in_time_t_range ((value
->it_value
).tv_sec
)
50 || ! in_time_t_range ((value
->it_interval
).tv_sec
))
52 __set_errno (EOVERFLOW
);
56 its32
.it_interval
= valid_timespec64_to_timespec (value
->it_interval
);
57 its32
.it_value
= valid_timespec64_to_timespec (value
->it_value
);
59 int retval
= INLINE_SYSCALL_CALL (timer_settime
, ktimerid
, flags
,
60 &its32
, ovalue
? &oits32
: NULL
);
61 if (retval
== 0 && ovalue
)
63 ovalue
->it_interval
= valid_timespec_to_timespec64 (oits32
.it_interval
);
64 ovalue
->it_value
= valid_timespec_to_timespec64 (oits32
.it_value
);
72 versioned_symbol (libc
, ___timer_settime64
, timer_settime
, GLIBC_2_34
);
73 # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_34)
74 compat_symbol (librt
, ___timer_settime64
, timer_settime
, GLIBC_2_2
);
77 #else /* __TIMESIZE != 64 */
78 libc_hidden_ver (___timer_settime64
, __timer_settime64
)
79 versioned_symbol (libc
, ___timer_settime64
, __timer_settime64
, GLIBC_2_34
);
82 __timer_settime (timer_t timerid
, int flags
, const struct itimerspec
*value
,
83 struct itimerspec
*ovalue
)
85 struct __itimerspec64 its64
, oits64
;
88 its64
.it_interval
= valid_timespec_to_timespec64 (value
->it_interval
);
89 its64
.it_value
= valid_timespec_to_timespec64 (value
->it_value
);
91 retval
= __timer_settime64 (timerid
, flags
, &its64
, ovalue
? &oits64
: NULL
);
92 if (retval
== 0 && ovalue
)
94 ovalue
->it_interval
= valid_timespec64_to_timespec (oits64
.it_interval
);
95 ovalue
->it_value
= valid_timespec64_to_timespec (oits64
.it_value
);
100 versioned_symbol (libc
, __timer_settime
, timer_settime
, GLIBC_2_34
);
102 # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_34)
103 compat_symbol (librt
, __timer_settime
, timer_settime
, GLIBC_2_2
);
105 # endif /* __TIMESIZE != 64 */
107 #else /* TIMER_T_WAS_INT_COMPAT */
109 extern __typeof (timer_settime
) __timer_settime_new
;
110 libc_hidden_proto (__timer_settime_new
)
113 ___timer_settime_new (timer_t timerid
, int flags
,
114 const struct itimerspec
*value
,
115 struct itimerspec
*ovalue
)
117 kernel_timer_t ktimerid
= timerid_to_kernel_timer (timerid
);
119 return INLINE_SYSCALL_CALL (timer_settime
, ktimerid
, flags
, value
, ovalue
);
121 versioned_symbol (libc
, ___timer_settime_new
, timer_settime
, GLIBC_2_34
);
122 libc_hidden_ver (___timer_settime_new
, __timer_settime_new
)
124 # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_3_3, GLIBC_2_34)
125 compat_symbol (librt
, ___timer_settime_new
, timer_settime
, GLIBC_2_3_3
);
128 # if OTHER_SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_3_3)
130 __timer_settime_old (int timerid
, int flags
, const struct itimerspec
*value
,
131 struct itimerspec
*ovalue
)
133 return __timer_settime_new (__timer_compat_list
[timerid
], flags
,
136 compat_symbol (librt
, __timer_settime_old
, timer_settime
, GLIBC_2_2
);
139 #endif /* TIMER_T_WAS_INT_COMPAT */