cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: gettimeofday() on Win32

From: Wei Weng <wweng_at_kencast.com>
Date: Wed, 12 Jan 2005 11:39:58 -0500

Gisle Vanem wrote:
> Is there any reason why we use either GetLocalTime() with
> 10ms resulution or timeGetTime() with 1ms resolution when we can have
> 100ns resolution using GetSystemTimeAsFileTime()?
>
> Using this would have the added benefit of dropping winmm.lib from
> the link command. MSDN tells me this function is supported on
> Win95 and up. Anybody knows any problems with it?
>
> Here is a replacement function that should work with gcc:
>
> int gettimeofday (struct timeval *tv, void* tz)
> {
> union {
> LONG_LONG ns100; /*time since 1 Jan 1601 in 100ns units */
> FILETIME ft;
> } now;
>
> GetSystemTimeAsFileTime (&now.ft);
> tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL);
> tv->tv_sec = (long) ((now.ns100 - 116444736000000000LL) / 10000000LL);
> return (0);
> }
>
> ---gv
>
>
>

I think it is either LONGLONG or __int64, for signed 64bit integer under
windows.

Wei
Received on 2005-01-12