ReactOS 0.4.15-dev-7942-gd23573b
gettimeofday.c
Go to the documentation of this file.
1/* XXX NEED Copyright info */
2#include <wintirpc.h>
3#include <time.h>
4
5#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
6 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
7#else
8 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
9#endif
10
11int gettimeofday(struct timeval *tv, struct timezone *tz)
12{
13 FILETIME ft;
14 unsigned __int64 tmpres = 0;
15 static int tzflag;
16
17 if (NULL != tv)
18 {
20
21 tmpres |= ft.dwHighDateTime;
22 tmpres <<= 32;
23 tmpres |= ft.dwLowDateTime;
24
25 /*converting file time to unix epoch*/
26 tmpres /= 10; /*convert into microseconds*/
27 tmpres -= DELTA_EPOCH_IN_MICROSECS;
28 tv->tv_sec = (long)(tmpres / 1000000UL);
29 tv->tv_usec = (long)(tmpres % 1000000UL);
30 }
31
32 if (NULL != tz)
33 {
34 if (!tzflag)
35 {
36 _tzset();
37 tzflag++;
38 }
39 tz->tz_minuteswest = _timezone / 60;
40 tz->tz_dsttime = _daylight;
41 }
42
43 return 0;
44}
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
#define __int64
Definition: basetyps.h:16
#define DELTA_EPOCH_IN_MICROSECS
Definition: gettimeofday.c:8
#define NULL
Definition: types.h:112
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
GLbyte GLbyte tz
Definition: glext.h:8756
#define long
Definition: qsort.c:33
_CRTIMP void __cdecl _tzset(void)
Definition: timezone.c:92
int _daylight
Definition: timezone.c:30
long _timezone
Definition: timezone.c:46
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
unsigned long tv_sec
Definition: linux.h:1738
unsigned long tv_usec
Definition: linux.h:1739
Definition: fake.h:14