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