bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: GNULib Module gettime Breaks CVS Build On Windows


From: Jim.Hyslop
Subject: RE: GNULib Module gettime Breaks CVS Build On Windows
Date: Wed, 12 May 2004 09:29:23 -0400

Conrad T. Pino wrote:
> We can provide an implementation but that's not the current
> first choice.  I'm including my current idea for such in
> implementation in case it's useful to you.  I believe the
> design is correct but it's untested code so far.
[...]
> /* FILETIME unit is 100 nanoseconds */

> gettime( struct timespec *ts )
> {
>       ULONGLONG diff_100_nsec;
>       union
>       {
>               FILETIME                f;
>               ULARGE_INTEGER  u;
>       } now;
> 
>       GetSystemTimeAsFileTime( &now.f );
> 
>       diff_100_nsec = now.u.QuadPart - ix_epoch;
> 
>       ts->tv_sec = (time_t) ( diff_100_nsec / div_100_nsec );
>       ts->tv_nsec = (long) ( ( diff_100_nsec % div_100_nsec ) 
> * 100l );
>       return 0;
> }
The implementation looks reasonable on a quick glance (I haven't checked it
in detail), but one thing you should be aware of is that, although the
FILETIME is capable of containing times on the order of hectonanoseconds,
the operating system only refreshes the time returned every 10.4
milliseconds or so. This function will *not* give you a high-resolution
time.

Just something to be aware of.

-- 
Jim Hyslop
Senior Software Designer
Leitch Technology International Inc. (http://www.leitch.com)
Columnist, C/C++ Users Journal (http://www.cuj.com/experts)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]