[PATCH 10/14] xfsprogs: Add a timer implementation for OS X
Jan Tulak
jtulak at redhat.com
Thu Sep 24 04:26:34 CDT 2015
On Wed, Sep 23, 2015 at 5:25 AM, Dave Chinner <david at fromorbit.com> wrote:
> On Tue, Sep 15, 2015 at 11:59:20AM +0200, Jan Tulak wrote:
> > OS X does not have the timer used in xfs_repair.
> > Add a simple implementation providing the required
> > capabilities.
> ....
> > #endif /* __XFS_DARWIN_H__ */
> > diff --git a/repair/progress.c b/repair/progress.c
> > index 27cbaef..0fee7dc 100644
> > --- a/repair/progress.c
> > +++ b/repair/progress.c
> > @@ -184,10 +184,22 @@ progress_rpt_thread (void *p)
> > */
> >
> > timespec.it_value.tv_sec = msgp->interval;
> > - timespec.it_value.tv_nsec = 0;
> > timespec.it_interval.tv_sec = msgp->interval;
> > + /*
> > + * On some platforms (like OS X), timers and time things are
> slightly
> > + * different: itimerspec is replaced with itimerval and timeval
> struct
> > + * has no tv_nsec, but just tv_usec member.
> > + * For compatibility, itimerspec is a macro defined to the existing
> > + * itimerval on these platforms, and in such case, use usec instead
> > + * of nsec.
> > + */
> > +#ifndef itimerspec
> > + timespec.it_value.tv_nsec = 0;
> > timespec.it_interval.tv_nsec = 0;
> > -
> > +#else
> > + timespec.it_value.tv_usec = 0;
> > + timespec.it_interval.tv_usec = 0;
> > +#endif
>
> That's pretty nasty. How about this:
>
> memset(×pec, 0, sizeof(timespec));
> timespec.it_value.tv_sec = msgp->interval;
> timespec.it_interval.tv_sec = msgp->interval;
>
This is much better and elegant solution. :-)
Cheers,
Jan
--
Jan Tulak
jtulak at redhat.com / jan at tulak.me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oss.sgi.com/pipermail/xfs/attachments/20150924/a4fbd87d/attachment-0001.html>
More information about the xfs
mailing list