libMesh
Classes | Typedefs | Functions
win_gettimeofday.h File Reference

Go to the source code of this file.

Classes

struct  timeval
 

Typedefs

typedef struct timeval timeval
 

Functions

int gettimeofday (struct timeval *tp, struct timezone *tzp)
 

Typedef Documentation

◆ timeval

typedef struct timeval timeval

Function Documentation

◆ gettimeofday()

int gettimeofday ( struct timeval tp,
struct timezone *  tzp 
)
inline

Definition at line 23 of file win_gettimeofday.h.

References timeval::tv_sec, and timeval::tv_usec.

Referenced by libMesh::PerfLog::clear(), libMesh::PerfLog::get_elapsed_time(), libMesh::PerfLog::get_perf_info(), libMesh::PerfData::pause_for(), libMesh::PerfLog::PerfLog(), libMesh::PerfMon::print(), libMesh::PerfMon::reset(), libMesh::PerfData::restart(), libMesh::PerfData::start(), and libMesh::PerfData::stop_or_pause().

24 {
25  // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
26  // until 00:00:00 January 1, 1970
27  static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
28 
29  SYSTEMTIME system_time;
30  FILETIME file_time;
31  uint64_t time;
32 
33  GetSystemTime(&system_time);
34  SystemTimeToFileTime(&system_time, &file_time);
35  time = ((uint64_t)file_time.dwLowDateTime );
36  time += ((uint64_t)file_time.dwHighDateTime) << 32;
37 
38  tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
39  tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
40  return 0;
41 }