Skip to content

Commit b990db2

Browse files
Try to rescue Windows builds
1 parent 952dceb commit b990db2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/benchmark_divlu.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
#include <stdint.h>
77
#include <stdio.h>
88
#include <stdlib.h>
9+
10+
#ifdef _WIN32
11+
#define WIN32_LEAN_AND_MEAN
12+
#include <windows.h>
13+
#else
914
#include <time.h>
15+
#endif
1016

1117
uint32_t divlu(uint32_t numhi, uint32_t numlo, uint32_t den, uint32_t *r);
1218
uint64_t divllu(uint64_t numhi, uint64_t numlo, uint64_t den, uint64_t *r);
@@ -16,11 +22,23 @@ uint64_t divllu(uint64_t numhi, uint64_t numlo, uint64_t den, uint64_t *r);
1622

1723
typedef unsigned long long ullong;
1824

25+
#ifdef _WIN32
26+
static uint64_t now_ns(void) {
27+
static LARGE_INTEGER freq = {0};
28+
LARGE_INTEGER counter;
29+
if (freq.QuadPart == 0) {
30+
QueryPerformanceFrequency(&freq);
31+
}
32+
QueryPerformanceCounter(&counter);
33+
return (uint64_t)(counter.QuadPart * 1000000000ULL / freq.QuadPart);
34+
}
35+
#else
1936
static uint64_t now_ns(void) {
2037
struct timespec ts;
2138
clock_gettime(CLOCK_MONOTONIC, &ts);
2239
return (uint64_t)ts.tv_sec * UINT64_C(1000000000) + (uint64_t)ts.tv_nsec;
2340
}
41+
#endif
2442

2543
// xorshift64 RNG.
2644
static uint64_t rng = UINT64_C(0x1234567890ABCDEF);

0 commit comments

Comments
 (0)