]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/timerfd_settime.c
7c55e7e8d6e3391d16b658582e2aa20853ac1ef5
1 /* timerfd_settime -- start or stop the timer referred to by file descriptor.
2 Copyright (C) 2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <https://www.gnu.org/licenses/>. */
23 #include <kernel-features.h>
26 __timerfd_settime64 (int fd
, int flags
, const struct __itimerspec64
*value
,
27 struct __itimerspec64
*ovalue
)
29 #ifndef __NR_timerfd_settime64
30 # define __NR_timerfd_settime64 __NR_timerfd_settime
32 int ret
= INLINE_SYSCALL_CALL (timerfd_settime64
, fd
, flags
, value
, ovalue
);
33 #ifndef __ASSUME_TIME64_SYSCALLS
34 if (ret
== 0 || errno
!= ENOSYS
)
37 if (! in_time_t_range ((value
->it_value
).tv_sec
)
38 || ! in_time_t_range ((value
->it_interval
).tv_sec
))
40 __set_errno (EOVERFLOW
);
44 struct itimerspec its32
, oits32
;
45 its32
.it_interval
= valid_timespec64_to_timespec (value
->it_interval
);
46 its32
.it_value
= valid_timespec64_to_timespec (value
->it_value
);
48 ret
= INLINE_SYSCALL_CALL (timerfd_settime
, fd
, flags
,
49 &its32
, ovalue
? &oits32
: NULL
);
50 if (ret
== 0 && ovalue
!= NULL
)
52 ovalue
->it_interval
= valid_timespec_to_timespec64 (oits32
.it_interval
);
53 ovalue
->it_value
= valid_timespec_to_timespec64 (oits32
.it_value
);
60 libc_hidden_def (__timerfd_settime64
)
63 __timerfd_settime (int fd
, int flags
, const struct itimerspec
*value
,
64 struct itimerspec
*ovalue
)
66 struct __itimerspec64 its64
, oits64
;
69 its64
.it_interval
= valid_timespec_to_timespec64 (value
->it_interval
);
70 its64
.it_value
= valid_timespec_to_timespec64 (value
->it_value
);
72 retval
= __timerfd_settime64 (fd
, flags
, &its64
, ovalue
? &oits64
: NULL
);
73 if (retval
== 0 && ovalue
)
75 ovalue
->it_interval
= valid_timespec64_to_timespec (oits64
.it_interval
);
76 ovalue
->it_value
= valid_timespec64_to_timespec (oits64
.it_value
);
82 strong_alias (__timerfd_settime
, timerfd_settime
)