GetTimeOfDay on Windows
Steven Edwards
steven_ed4153 at yahoo.com
Fri Jun 20 17:05:46 CDT 2003
Hello,
What do you think about me adding a case for GetTimeOfDay to libwine for the Windows port? I dont
expect every case of it to be reimplemented from scratch and it seems that winsock2.h defines
typedef struct timeval {
long tv_sec;
long tv_usec;
} timeval;
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/timeval_2.asp
/*
* Defines gettimeofday
*
* Based on timeval.h by Wu Yongwei
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#ifndef HAVE_GETTIMEOFDAY
__inline int gettimeofday(struct timeval *tv, struct timezone *tz)
#ifdef _WINDOWS
{
FILETIME ft;
LARGE_INTEGER li;
__int64 t;
static int tzflag;
if (tv)
{
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
t = li.QuadPart; /* In 100-nanosecond intervals */
t -= EPOCHFILETIME; /* Offset to the Epoch time */
t /= 10; /* In microseconds */
tv->tv_sec = (long)(t / 1000000);
tv->tv_usec = (long)(t % 1000000);
}
if (tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
#else /* !defined(_WINDOWS) */
errno = ENOSYS;
return -1;
#endif /* _WINDOWS */
#endif /* HAVE_GETTIMEOFDAY */
}
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
More information about the wine-devel
mailing list