Debian Codegraph @

timeval.h

raw symbols SCIP
1 /*
2 * timeval.h 1.0 01/12/19
3 *
4 * Defines gettimeofday, timeval, etc. for Win32
5 *
6 * By Wu Yongwei
7 *
8 */
9
10 #ifndef _TIMEVAL_H
11 #define _TIMEVAL_H
12
13 #ifdef _WIN32
14
15 #define WIN32_LEAN_AND_MEAN
16 #include <windows.h>
17 #include <time.h>
18
19 #ifndef __GNUC__
20 #define EPOCHFILETIME (116444736000000000i64)
21 #else
22 #define EPOCHFILETIME (116444736000000000LL)
23 #endif /* not __GNUC__ */
24
25 #if 0
26 struct timeval {
27 long tv_sec; /* seconds */
28 long tv_usec; /* microseconds */
29 };
30 #endif /* 0 */
31
32 struct timezone {
33 int tz_minuteswest; /* minutes W of Greenwich */
34 int tz_dsttime; /* type of dst correction */
35 };
36
37 __inline int gettimeofday(struct timeval *tv, struct timezone *tz)
38 {
39 FILETIME ft;
40 LARGE_INTEGER li;
41 __int64 t;
42 static int tzflag;
43
44 if (tv)
45 {
46 GetSystemTimeAsFileTime(&ft);
47 li.LowPart = ft.dwLowDateTime;
48 li.HighPart = ft.dwHighDateTime;
49 t = li.QuadPart; /* In 100-nanosecond intervals */
50 t -= EPOCHFILETIME; /* Offset to the Epoch time */
51 t /= 10; /* In microseconds */
52 tv->tv_sec = (long)(t / 1000000);
53 tv->tv_usec = (long)(t % 1000000);
54 }
55
56 if (tz)
57 {
58 if (!tzflag)
59 {
60 _tzset();
61 tzflag++;
62 }
63 tz->tz_minuteswest = _timezone / 60;
64 tz->tz_dsttime = _daylight;
65 }
66
67 return 0;
68 }
69
70 #else /* _WIN32 */
71
72 #include <sys/time.h>
73
74 #endif /* _WIN32 */
75
76 #endif /* _TIMEVAL_H */