This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v3] Fix time/tst-cpuclock1 intermitent failures
- From: "Lucas A. M. Magalhaes" <lamm at linux dot ibm dot com>
- To: Matheus Castanho <msc at linux dot ibm dot com>, libc-alpha at sourceware dot org
- Date: Fri, 06 Mar 2020 14:31:49 -0300
- Subject: Re: [PATCH v3] Fix time/tst-cpuclock1 intermitent failures
- References: <20200206144819.19046-1-lamm@linux.ibm.com> <20200220181747.12898-1-lamm@linux.ibm.com> <3af6c811-e74f-dbae-6bc9-dbc00abd612c@linux.ibm.com>
Quoting Matheus Castanho (2020-03-04 16:24:14)
> Hi Lucas,
>
> I believe the main idea behind Carlos' initial suggestion was to make
> something more generic that could also be used in other places. The
> patch is following in this direction alright but I think there are still
> a few details that could be improved in this regard. Comments below.
>
Hi Matheus,
Thanks for the review. AFAIU Carlos was specifically pointing out that this
could be reused on tst-cpuclock2. So, this was my target during the development
of this patch. From what I got you believe that the timespec functions could be
completely generic. I agree so I will rewrite the patch for this.
> > +#include "support_cpuclock.h"
> > +#include <stdlib.h>
> > +#include <assert.h>
> > +
> > +#define TIMESPEC_HZ 1000000000.0
> > +
> > +/* Returns t normalized timespec with .tv_nsec < TIMESPEC_HZ
> > + and the overflows added to .tv_sec. */
> > +struct timespec
> > +support_timespec_normalize (struct timespec t)
> > +{
> > + int diff;
> > + diff = (t.tv_nsec / TIMESPEC_HZ);
> > + t.tv_sec += diff;
> > + t.tv_nsec += -(diff * TIMESPEC_HZ);
> > + return t;
> > +}
>
> Wouldn't something like:
>
> struct timespec
> support_timespec_normalize (struct timespec t)
> {
> t.tv_sec += (t.tv_nsec / TIMESPEC_HZ);
> t.tv_nsec = (t.tv_nsec % TIMESPEC_HZ);
> return t;
> }
>
> be more straightforward?
>
Yes, Nice. Thanks to point this out.