Skip to content

Commit

Permalink
qemu-io-cmds.c: Implement clock_gettime for WIN32
Browse files Browse the repository at this point in the history
  • Loading branch information
mborgerson committed Dec 30, 2024
1 parent cff4504 commit da662b6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions qemu-io-cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@
#include "qemu/cutils.h"
#include "qemu/memalign.h"

#ifdef _WIN32
/* clock_gettime depends on pthreads. We only use it for measuring IO perf below
* so simply implement it here for now. */
static int clock_gettime_monotonic(struct timespec *tp)
{
LARGE_INTEGER freq, ticks;
if (!QueryPerformanceFrequency(&freq) || !QueryPerformanceCounter(&ticks)) {
return -1;
}
tp->tv_sec = ticks.QuadPart / freq.QuadPart;
tp->tv_nsec = (ticks.QuadPart % freq.QuadPart) * 1000000000 / freq.QuadPart;
return 0;
}
#define clock_gettime(c, ts) clock_gettime_monotonic(ts)
#endif

#define CMD_NOFILE_OK 0x01

bool qemuio_misalign;
Expand Down

0 comments on commit da662b6

Please sign in to comment.