Skip to content

Commit

Permalink
fix: timestamp resolution to microseconds on Windows (getsentry#1039)
Browse files Browse the repository at this point in the history
* fix: timestamp resolution to microseconds on Windows

* chore: changelog comment

* feat: prefer GetSystemTimePreciseAsFileTime for the timestamp resolution on Windows
  • Loading branch information
ShawnCZek authored Sep 3, 2024
1 parent 4c47d97 commit a6ba26e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Fixes**:

- Correct the timestamp resolution to microseconds on Windows. ([#1039](https://github.com/getsentry/sentry-native/pull/1039))

## 0.7.9

**Fixes**:
Expand Down
8 changes: 5 additions & 3 deletions src/sentry_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ sentry__usec_time(void)
// Contains a 64-bit value representing the number of 100-nanosecond
// intervals since January 1, 1601 (UTC).
FILETIME file_time;
SYSTEMTIME system_time;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
# if _WIN32_WINNT >= 0x0602
GetSystemTimePreciseAsFileTime(&file_time);
# else
GetSystemTimeAsFileTime(&file_time);
# endif

uint64_t timestamp = (uint64_t)file_time.dwLowDateTime
+ ((uint64_t)file_time.dwHighDateTime << 32);
Expand Down

0 comments on commit a6ba26e

Please sign in to comment.