> 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*/
> 
> }

For speed reason, you can use GetSystemTimeAsFileTime(), which is
very efficient. The Win32 is little-endian only operating system.
You can use the following code.

void gettimeofday(struct timeval* pTv, void *pDummy);
{
    __int64 l;
    GetSystemTimeAsFileTime((LPFILETIME) &l);

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

You missed the cast.

Hong

Reply via email to