Current get fails to build on Win32[1]

There are a host of problems (not the least being the object files not 
going where the linker is expecting them), then aside the first is the 
lack of a gettimeofday function. This is used in time_n.
Here's my Win32 version:

void gettimeofday(struct timeval* pTv, void *pDummy);
{
    SYSTEMTIME sysTime;
    FILETIME fileTime;  /* 100ns == 1 */
    LARGE_INTEGER i;

    GetSystemTime(&sysTime);
    SystemTimeToFileTime(&sysTime, &fileTime);
    /* Documented as the way to get a 64 bit from a FILETIME. */
    memcpy(&i, &fileTime, sizeof(LARGE_INTEGER));

    pTv->tv_sec = i.QuadPart / 10000000; /*10e7*/
    pTv->tv_usec = (i.QuadPart / 10) % 1000000; /*10e6*/

}

Given a suitable definition of struct timeval for the prototype (there is 
a definition in windows.h[2]) but making Windows.h a header across all the 
builds causes its own problems (with BOOL for a start).

I'm not sure what a timeval of {0, 0} nominally represents, the above will 
give seconds since 1 Jan 1601, so a fiddle factor is likely to be needed.

(I'm not sure what the best way to incorporate this is... for my test I 
added an extra .c with a special include, but I think some form of common 
OS abstraction layer is going to be needed rather than assuming one 
ABI/API and then emulating elsewhere.)


[1] Windows 2000, Visual Studio 6 SP5 & MS Platform SDK (Feb 01 edition)
[2] Well, more correctly in winsock2.h which windows.h includes.
-- 
[EMAIL PROTECTED]

Reply via email to