1 /* setitimer -- Set the state of an interval timer. Linux/32 version.
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
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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; if not, see
17 <http://www.gnu.org/licenses/>. */
21 #include <sys/types.h>
23 #include <tv32-compat.h>
26 __setitimer64 (__itimer_which_t which
,
27 const struct __itimerval64
*restrict new_value
,
28 struct __itimerval64
*restrict old_value
)
30 #if __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
31 return INLINE_SYSCALL_CALL (setitimer
, which
, new_value
, old_value
);
33 struct __itimerval32 new_value_32
;
35 if (! in_time_t_range (new_value
->it_interval
.tv_sec
)
36 || ! in_time_t_range (new_value
->it_value
.tv_sec
))
38 __set_errno (EOVERFLOW
);
41 new_value_32
.it_interval
42 = valid_timeval64_to_timeval32 (new_value
->it_interval
);
44 = valid_timeval64_to_timeval32 (new_value
->it_value
);
46 if (old_value
== NULL
)
47 return INLINE_SYSCALL_CALL (setitimer
, which
, &new_value_32
, NULL
);
49 struct __itimerval32 old_value_32
;
50 if (INLINE_SYSCALL_CALL (setitimer
, which
, &new_value_32
, &old_value_32
)
54 old_value
->it_interval
55 = valid_timeval32_to_timeval64 (old_value_32
.it_interval
);
57 = valid_timeval32_to_timeval64 (old_value_32
.it_value
);
63 libc_hidden_def (__setitimer64
)
65 __setitimer (__itimer_which_t which
,
66 const struct itimerval
*restrict new_value
,
67 struct itimerval
*restrict old_value
)
70 struct __itimerval64 new64
, old64
;
73 = valid_timeval_to_timeval64 (new_value
->it_interval
);
75 = valid_timeval_to_timeval64 (new_value
->it_value
);
77 ret
= __setitimer64 (which
, &new64
, old_value
? &old64
: NULL
);
79 if (ret
== 0 && old_value
!= NULL
)
81 old_value
->it_interval
82 = valid_timeval64_to_timeval (old64
.it_interval
);
84 = valid_timeval64_to_timeval (old64
.it_value
);
90 weak_alias (__setitimer
, setitimer
)