| 1880 | }; |
| 1881 | |
| 1882 | uint64_t timer_int() { |
| 1883 | #ifdef _WIN32 |
| 1884 | static const int64_t FILETIME_C_EPOCH = |
| 1885 | 11644473600LL * |
| 1886 | 10000000LL; // Difference between FILETIME epoch (1601) and Unix epoch (1970) in 100ns FILETIME ticks |
| 1887 | FILETIME fileTime; |
| 1888 | GetSystemTimeAsFileTime(&fileTime); |
| 1889 | static_assert(sizeof(fileTime) == sizeof(uint64_t), "FILETIME size wrong"); |
| 1890 | return (*(uint64_t*)&fileTime - FILETIME_C_EPOCH); |
| 1891 | #elif defined(__linux__) || defined(__FreeBSD__) |
| 1892 | struct timespec ts; |
| 1893 | clock_gettime(CLOCK_REALTIME, &ts); |
| 1894 | return uint64_t(ts.tv_sec) * 1e9 + ts.tv_nsec; |
| 1895 | #elif defined(__APPLE__) |
| 1896 | struct timeval tv; |
| 1897 | gettimeofday(&tv, nullptr); |
| 1898 | return uint64_t(tv.tv_sec) * 1e9 + (tv.tv_usec * 1e3); |
| 1899 | #else |
| 1900 | #error Port me! |
| 1901 | #endif |
| 1902 | }; |
| 1903 | |
| 1904 | void getLocalTime(const time_t* timep, struct tm* result) { |
| 1905 | #ifdef _WIN32 |
no outgoing calls
no test coverage detected