Skip to content

Commit

Permalink
Merge pull request ceph#50559 from petrutlucian94/improve_win32_clock…
Browse files Browse the repository at this point in the history
…_check

common: avoid redefining clock type on Windows

Reviewed-by: Ilya Dryomov <[email protected]>
  • Loading branch information
idryomov authored Mar 17, 2023
2 parents 544635a + 489fd85 commit 15c86b7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/common/ceph_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@ int clock_gettime(int clk_id, struct timespec *tp);
#endif

#ifdef _WIN32
#define CLOCK_REALTIME_COARSE CLOCK_REALTIME
#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
// MINGW uses the QueryPerformanceCounter API behind the scenes.
// Clock precision:
// mingw < 8.0.1:
// * CLOCK_REALTIME: ~10-55ms (GetSystemTimeAsFileTime)
// mingw >= 8.0.1:
// * CLOCK_REALTIME: <1us (GetSystemTimePreciseAsFileTime)
// * CLOCK_REALTIME_COARSE: ~10-55ms (GetSystemTimeAsFileTime)
//
// * CLOCK_MONOTONIC: <1us if TSC is usable, ~10-55ms otherwise
// (QueryPerformanceCounter)
// https://github.com/mirror/mingw-w64/commit/dcd990ed423381cf35702df9495d44f1979ebe50
#ifndef CLOCK_REALTIME_COARSE
#define CLOCK_REALTIME_COARSE CLOCK_REALTIME
#endif
#ifndef CLOCK_MONOTONIC_COARSE
#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
#endif
#endif

struct ceph_timespec;
Expand Down

0 comments on commit 15c86b7

Please sign in to comment.