utils-windows.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #ifdef WIN32
11 #include < Windows.h >
13 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
14 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
15 #else
16 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
17 #endif
18 
19 int gettimeofday(struct timeval *tv, struct timezone *tz) {
20  FILETIME ft;
21  unsigned __int64 tmpres = 0;
22  static int tzflag;
23 
24  if (NULL != tv) {
25  GetSystemTimeAsFileTime(&ft);
26 
27  tmpres |= ft.dwHighDateTime;
28  tmpres <<= 32;
29  tmpres |= ft.dwLowDateTime;
30 
31  /*converting file time to unix epoch*/
32  tmpres /= 10; /*convert into microseconds*/
33  tmpres -= DELTA_EPOCH_IN_MICROSECS;
34  tv->tv_sec = (long)(tmpres / 1000000UL);
35  tv->tv_usec = (long)(tmpres % 1000000UL);
36  }
37 
38  if (NULL != tz) {
39  if (!tzflag) {
40  _tzset();
41  tzflag++;
42  }
43  tz->tz_minuteswest = _timezone / 60;
44  tz->tz_dsttime = _daylight;
45  }
46 
47  return 0;
48 }
49 
50 #endif /*WIN32*/


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26