On Thu, Oct 08, 2009 at 09:23:38PM -0600, Eric Blake wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>According to Christopher Faylor on 10/8/2009 3:24 PM:
>>> I think we need to implement a companion to systime(), which returns the 
>>> system 
>>> time without any truncation, so that the function 
>>> clock_gettime(CLOCK_REALTIME) 
>>> can report time with resolution to the 10th of a microsecond rather than to 
>>> plain microseconds.  Then utimensat needs to use clock_gettime rather than 
>>> gettimeofday, so that it is not needlessly truncating the 10th of 
>>> microsecond 
>>> resolution available from Windows.
>> 
>> Why not send these type of musings to the cygwin-developers list?  It really
>> is more appropriate for this type of discussion.
>
>Sorry about the wrong list.  At any rate, what about this patch?
>
>2009-10-08  Eric Blake  <[email protected]>
>
>       * hires.h (hires_ms): Change initime_us to initime_ns, with 10x
>       more resolution.
>       (hires_ms::nsecs): New prototype.
>       (hires_ms::usecs, hires_ms::msecs, hires_ms::uptime): Adjust.
>       * times.cc (NSPERMS, MILLION, BILLION): New helper macros; use
>       throughout to avoid long runs of 0.
>       (systime_ns): New helper function.
>       (hires_ms::prime): Use it for more resolution.
>       (hires_ms::usecs): Change to...
>       (hires_ms::nsecs): ...with more resolution.
>       (clock_gettime): Use more resolution.
>       * fhandler_disk_file.cc (utimens_fs): Get current time before
>       opening handle, using higher resolution.

I don't like "MILLION" or "BILLION".  I think a real number is clearer
for that.  Maybe it's jsut me but when I see million I can't help myself
from checking to see if it's 1000000 or 1024*1024.  And, if you're going
to assign constants to 1 with a bunch of zeros where do you draw the
line?

It looks like you either don't need the systime() call or it should
call systime_ns.

>       long long x = time_in->tv_sec * NSPERSEC +
>-                          time_in->tv_nsec / (NSPERSEC/100000) + FACTOR;
>+                          time_in->tv_nsec / (BILLION / NSPERSEC) + FACTOR;

I'm too tired now to figure out why you switched these but it seems
odd that you switched the numerator and denominator  here but

>       out->dwHighDateTime = x >> 32;
>       out->dwLowDateTime = x;
>     }
>@@ -202,7 +217,7 @@ void __stdcall
> timeval_to_filetime (const struct timeval *time_in, FILETIME *out)
> {
>   long long x = time_in->tv_sec * NSPERSEC +
>-                      time_in->tv_usec * (NSPERSEC/1000000) + FACTOR;
>+                      time_in->tv_usec * (NSPERSEC / MILLION) + FACTOR;

not here.

cgf

Reply via email to