ReactOS  0.4.15-dev-2103-g9dff498
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 
11 int 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 }
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
_CRTIMP void __cdecl _tzset(void)
Definition: timezone.c:92
unsigned long tv_sec
Definition: linux.h:1738
DWORD dwHighDateTime
Definition: mapidefs.h:66
unsigned long tv_usec
Definition: linux.h:1739
#define DELTA_EPOCH_IN_MICROSECS
Definition: gettimeofday.c:8
int _daylight
Definition: timezone.c:30
long _timezone
Definition: timezone.c:46
int gettimeofday(struct timeval *tv, struct timezone *tz)
Definition: gettimeofday.c:11
#define long
Definition: qsort.c:33
GLbyte GLbyte tz
Definition: glext.h:8756
#define NULL
Definition: types.h:112
Definition: fake.h:14
#define UL
Definition: tui.h:82
DWORD dwLowDateTime
Definition: mapidefs.h:65
#define __int64
Definition: basetyps.h:16