On 28 April 2015 at 17:25, Arnd Bergmann <[email protected]> wrote:

> On Tuesday 28 April 2015 16:05:43 Baolin Wang wrote:
> > This patch introduces the 'struct itimerspec64' for 64bit to replace
> itimerspec,
> > and also introduces the conversion methods: itimerspec64_to_itimerspec()
> and
> > itimerspec_to_itimerspec64(), that makes itimerspec ready for 2038 year.
> >
> > Signed-off-by: Baolin Wang <[email protected]>
> > ---
> >  include/linux/time64.h |   25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> >
> > diff --git a/include/linux/time64.h b/include/linux/time64.h
> > index a383147..031b69a 100644
> > --- a/include/linux/time64.h
> > +++ b/include/linux/time64.h
> > @@ -11,11 +11,18 @@ typedef __s64 time64_t;
> >   */
> >  #if __BITS_PER_LONG == 64
> >  # define timespec64 timespec
> > +#define itimerspec64 itimerspec
> >  #else
> >  struct timespec64 {
> >       time64_t        tv_sec;                 /* seconds */
> >       long            tv_nsec;                /* nanoseconds */
> >  };
> > +
> > +struct itimerspec64 {
> > +     struct timespec64 it_interval;  /* timer period */
> > +     struct timespec64 it_value;     /* timer expiration */
> > +};
> > +
> >  #endif
>
> This part looks ok now, it's what Thomas suggested
>
> >  /* Parameters used to convert the timespec values: */
> > @@ -187,4 +194,22 @@ static __always_inline void
> timespec64_add_ns(struct timespec64 *a, u64 ns)
> >
> >  #endif
> >
> > +static inline struct itimerspec itimerspec64_to_itimerspec(struct
> itimerspec64 *its64)
> > +{
> > +     struct itimerspec ret;
> > +
> > +     ret.it_interval = timespec64_to_timespec(its64->it_interval);
> > +     ret.it_value = timespec64_to_timespec(its64->it_value);
> > +     return ret;
> > +}
> > +
> > +static inline struct itimerspec64 itimerspec_to_itimerspec64(struct
> itimerspec *its)
> > +{
> > +     struct itimerspec64 ret;
> > +
> > +     ret.it_interval = timespec_to_timespec64(its->it_interval);
> > +     ret.it_value = timespec_to_timespec64(its->it_value);
> > +     return ret;
> > +}
> > +
> >  #endif /* _LINUX_TIME64_H */
> >
>
> However here you forgot to adapt to the change above. While this code does
> the right
> think on 64-bit, it would be more efficient to use assignment or memcpy
> here
> for the case that itimerspec and itimerspec64 are defined to be the same.
>
>         Arnd
>
Sorry for missing that, i'll fix that in next patch.


-- 
Baolin.wang
Best Regards
_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

Reply via email to