[PATCH v6 2/5] linux: Use long time_t __getitimer/__setitimer
Stepan Golosunov
stepan@golosunov.pp.ru
Sun Mar 29 22:19:31 GMT 2020
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.
More information about the Libc-alpha
mailing list