Vector Optimized Library of Kernels  2.0
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 };
34 #endif
35 
36 struct timezone
37 {
38  int tz_minuteswest; /* minutes W of Greenwich */
39  int tz_dsttime; /* type of dst correction */
40 };
41 
42 static inline int gettimeofday(struct timeval *tv, struct timezone *tz)
43 {
44  FILETIME ft;
45  unsigned __int64 tmpres = 0;
46  static int tzflag;
47 
48  if (NULL != tv)
49  {
50  GetSystemTimeAsFileTime(&ft);
51 
52  tmpres |= ft.dwHighDateTime;
53  tmpres <<= 32;
54  tmpres |= ft.dwLowDateTime;
55 
56  /*converting file time to unix epoch*/
57  tmpres -= DELTA_EPOCH_IN_MICROSECS;
58  tv->tv_sec = (long)(tmpres / 1000000UL);
59  tv->tv_usec = (long)(tmpres % 1000000UL);
60  }
61 
62  if (NULL != tz)
63  {
64  if (!tzflag)
65  {
66  _tzset();
67  tzflag++;
68  }
69  tz->tz_minuteswest = _timezone / 60;
70  tz->tz_dsttime = _daylight;
71  }
72 
73  return 0;
74 }
75 
76 #endif //_MSC_SYS_TIME_H_
int tz_dsttime
Definition: time.h:39
static int gettimeofday(struct timeval *tv, struct timezone *tz)
Definition: time.h:42
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:36
int tz_minuteswest
Definition: time.h:38