Vector Optimized Library of Kernels  2.2
Architecture-tuned implementations of math kernels
time.h
Go to the documentation of this file.
1 #ifndef _MSC_VER // [
2 #error "Use this header only with Microsoft Visual C++ compilers!"
3 #endif // _MSC_VER ]
4 
5 #ifndef _MSC_SYS_TIME_H_
6 #define _MSC_SYS_TIME_H_
7 
8 // prevent windows.h from clobbering min and max functions with macros
9 #ifndef NOMINMAX
10 #define NOMINMAX
11 #endif
12 
13 // http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/430449b3-f6dd-4e18-84de-eebd26a8d668
14 #include < time.h >
15 #include <windows.h> //I've omitted this line.
16 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
17 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
18 #else
19 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
20 #endif
21 
22 #if _MSC_VER < 1900
23 struct timespec {
24 
25  time_t tv_sec; /* Seconds since 00:00:00 GMT, */
26 
27  /* 1 January 1970 */
28 
29  long tv_nsec; /* Additional nanoseconds since */
30 
31  /* tv_sec */
32 };
33 #endif
34 
35 struct timezone {
36  int tz_minuteswest; /* minutes W of Greenwich */
37  int tz_dsttime; /* type of dst correction */
38 };
39 
40 static inline int gettimeofday(struct timeval* tv, struct timezone* tz)
41 {
42  FILETIME ft;
43  unsigned __int64 tmpres = 0;
44  static int tzflag;
45 
46  if (NULL != tv) {
47  GetSystemTimeAsFileTime(&ft);
48 
49  tmpres |= ft.dwHighDateTime;
50  tmpres <<= 32;
51  tmpres |= ft.dwLowDateTime;
52 
53  /*converting file time to unix epoch*/
54  tmpres -= DELTA_EPOCH_IN_MICROSECS;
55  tv->tv_sec = (long)(tmpres / 1000000UL);
56  tv->tv_usec = (long)(tmpres % 1000000UL);
57  }
58 
59  if (NULL != tz) {
60  if (!tzflag) {
61  _tzset();
62  tzflag++;
63  }
64  tz->tz_minuteswest = _timezone / 60;
65  tz->tz_dsttime = _daylight;
66  }
67 
68  return 0;
69 }
70 
71 #endif //_MSC_SYS_TIME_H_
int tz_dsttime
Definition: time.h:37
static int gettimeofday(struct timeval *tv, struct timezone *tz)
Definition: time.h:40
time_t tv_sec
Definition: time.h:25
long tv_nsec
Definition: time.h:29
#define DELTA_EPOCH_IN_MICROSECS
Definition: time.h:19
Definition: time.h:23
Definition: time.h:35
int tz_minuteswest
Definition: time.h:36