This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] Fix time/tst-cpuclock1 intermitent failures


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]