[Pvfs2-developers] Re: [Pvfs2-cvs] commit by slang in pvfs2/src/common/misc: pint-util.c pint-util.h

Sam Lang slang at mcs.anl.gov
Fri Aug 15 13:00:21 EDT 2008



On Aug 14, 2008, at 5:43 PM, Pete Wyckoff wrote:

> cvs at parl.clemson.edu wrote on Thu, 14 Aug 2008 18:11 -0400:
>> +struct timespec PINT_util_get_abs_timespec(int microsecs)
>> +{
>> +    struct timeval now;
>> +    struct timespec tv;
>> +
>> +    gettimeofday(&now, NULL);
>> +    tv.tv_sec = now.tv_sec + (microsecs / 1e6);
>> +    tv.tv_nsec = (now.tv_usec * 1e3) + (microsecs * 1e3);
>> +    return tv;
>> +}
>
> I don't think this gives the nsec you want.  Some integer arithmetic
> and a % would help.  Or you could calculate nsec first then
> normalize any extra up into sec.  Or do the work with timeradd() (in
> tree somewhere I think?) and use TIMEVAL_TO_TIMESPEC from sys/time.h
> to do the final conversion.

Thanks Pete.  Went with option b.  I don't think TIMEVAL_TO_TIMESPEC  
is defined by default.
-sam

>
>
> 		-- Pete
>



More information about the Pvfs2-developers mailing list