[PATCH v6 2/5] linux: Use long time_t __getitimer/__setitimer
Adhemerval Zanella
adhemerval.zanella@linaro.org
Mon Mar 30 14:48:29 GMT 2020
On 29/03/2020 19:19, Stepan Golosunov wrote:
> 29.03.2020 в 11:17:17 -0700 Alistair Francis написал:
>> On Sun, Mar 29, 2020 at 2:59 AM Stepan Golosunov <stepan@golosunov.pp.ru> wrote:
>>>
>>> 28.03.2020 в 08:22:46 -0700 Alistair Francis написал:
>>>> --- /dev/null
>>>> +++ b/sysdeps/unix/sysv/linux/getitimer.c
>>>
>>>> +int
>>>> +__getitimer64 (__itimer_which_t which, struct __itimerval64 *curr_value)
>>>> +{
>>>> +#if __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64
>>>> + return INLINE_SYSCALL_CALL (getitimer, which, curr_value);
>>>> +#else
>>>> + struct __itimerval32 curr_value_32;
>>>> +
>>>> + if (INLINE_SYSCALL_CALL (getitimer, which, &curr_value_32) == -1)
>>>> + return -1;
>>>> +
>>>> + curr_value->it_interval
>>>> + = valid_timeval32_to_timeval64 (curr_value_32.it_interval);
>>>> + curr_value->it_value
>>>> + = valid_timeval32_to_timeval64 (curr_value_32.it_value);
>>>> + return 0;
>>>> +#endif
>>>> +}
>>>> +
>>>> +#if __TIMESIZE != 64
>>>> +libc_hidden_def (__getitimer64)
>>>> +int
>>>> +__getitimer (__itimer_which_t which, struct itimerval *curr_value)
>>>> +{
>>>> + struct __itimerval64 val64;
>>>> +
>>>> + val64.it_interval
>>>> + = valid_timeval_to_timeval64 (curr_value->it_interval);
>>>> + val64.it_value
>>>> + = valid_timeval_to_timeval64 (curr_value->it_value);
>>>> +
>>>> + return __getitimer64 (which, &val64);
>>>> +}
>>>> +#endif
>>>> +weak_alias (__getitimer, getitimer)
>>>
>>> __getitimer treats curr_value as input-only variable, while it's an
>>> output-only one in __getitimer64. This won't work.
>>
>> I'm not sure what you mean here, can you please elaborate?
>
> __getitimer (…, &curr_value) will never write to curr_value (or do
> anything useful with it at all); while
> __getitimer64 (…, &curr_value) will write to curr_value as expected.
>
> Conversion in __getitimer shold be in opposite direction and after
> __getitimer64 call.
>
Indeed, it should be:
int
__getitimer64 (__itimer_which_t which, struct __itimerval64 *curr_value)
{
[...]
}
#if __TIMESIZE != 64
libc_hidden_def (__getitimer64)
int
__getitimer (__itimer_which_t which, struct itimerval *curr_value)
{
struct __itimerval64 val64;
if (__getitimer64 (which, &val64) != 0)
return -1;
curr_value->it_interval
= valid_timeval64_to_timeval (val64->it_interval);
curr_value->it_value
= valid_timeval64_to_timeval (val64->it_value);
return 0;
}
#endif
More information about the Libc-alpha
mailing list