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

Pete Wyckoff pw at padd.com
Thu Aug 14 18:43:53 EDT 2008


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.

		-- Pete



More information about the Pvfs2-developers mailing list