ROSE 0.11.145.192
timing.h
1#ifndef ROSE_TIMING_H
2#define ROSE_TIMING_H
3/*
407/17/2017 This is moved from src/3rdPartyLibraries/POET
5to remove dependece on POET
6*/
7
8#ifdef _MSC_VER
9#include <winsock.h> /* struct timeval */
10// replacement gettimeofday function for Windows
11// If we only put the function signature here, we encounter the
12// following error while compiling fixupInClassDataInitialization.C:
13// error C2129: static function declared but not defined
14static int
15gettimeofday(struct timeval *tp, void *dummy)
16{
17 FILETIME ft;
18 LARGE_INTEGER li;
19 __int64 t;
20
21 SYSTEMTIME st;
22 FILETIME ft2;
23 LARGE_INTEGER li2;
24 __int64 t2;
25
26 st.wYear = 1970;
27 st.wHour = 0;
28 st.wMinute = 0;
29 st.wSecond = 0;
30 st.wMilliseconds = 1;
31
32 SystemTimeToFileTime(&st, &ft2);
33 li2.LowPart = ft2.dwLowDateTime;
34 li2.HighPart = ft2.dwHighDateTime;
35 t2 = li2.QuadPart;
36
37 GetSystemTimeAsFileTime(&ft);
38 li.LowPart = ft.dwLowDateTime;
39 li.HighPart = ft.dwHighDateTime;
40 t = li.QuadPart;
41 t -= t2; // From 1970
42 t /= 10; // In microseconds
43 tp->tv_sec = (long)(t / 1000000);
44 tp->tv_usec = (long)(t % 1000000);
45 return 0;
46}
47#else
48#include <sys/time.h>
49#endif
50
51#endif