Skip to content

Commit 3e83507

Browse files
unamedkrclaude
andcommitted
Fix Windows CI round 3: dirent.h, stdatomic, VLA, M_PI
- tq_convert.c: guard dirent.h with #ifndef _WIN32 - quant.h: add _MSC_VER stdatomic shim (interlocked intrinsics) - quant.c: fix timespec guard for MSVC CRT - test_threading.cpp: replace VLA with std::vector (MSVC no VLA) - test_adaptive.cpp: add _USE_MATH_DEFINES for M_PI Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e0e8efa commit 3e83507

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

quant.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,16 @@ const char* quant_version(void);
104104
#include <mach/mach_time.h>
105105
#endif
106106

107+
#if defined(_MSC_VER)
108+
/* MSVC: use interlocked intrinsics */
109+
#include <intrin.h>
110+
typedef volatile long atomic_int;
111+
#define atomic_store(p, v) _InterlockedExchange((p), (v))
112+
#define atomic_load(p) _InterlockedCompareExchange((p), 0, 0)
113+
#define atomic_fetch_add(p, v) _InterlockedExchangeAdd((p), (v))
114+
#else
107115
#include <stdatomic.h>
116+
#endif
108117

109118
#ifdef __ARM_NEON
110119
#include <arm_neon.h>

tests/test_adaptive.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define _USE_MATH_DEFINES
2+
#include <cmath>
13
/**
24
* test_adaptive.cpp -- Tests for adaptive compression features
35
*

tests/test_threading.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ TEST(Threading, ConcurrentAttention) {
9797
for (int i = 0; i < 128; i++)
9898
query[i] = cosf(i * 0.1f + t);
9999

100-
float scores[seq_len];
100+
std::vector<float> scores_vec(seq_len);
101+
float* scores = scores_vec.data();
101102
tq_status s = tq_attention(ctx, query, blocks.data(),
102103
seq_len, head_dim,
103104
TQ_TYPE_POLAR_3B, scores);

tools/quant.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#ifndef CLOCK_MONOTONIC
4444
#define CLOCK_MONOTONIC 1
4545
#endif
46-
#ifndef _TIMESPEC_DEFINED
46+
#if defined(_WIN32) && !defined(_TIMESPEC_DEFINED)
4747
#define _TIMESPEC_DEFINED
4848
struct timespec { long tv_sec; long tv_nsec; };
4949
#endif

tools/tq_convert.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
#ifndef _WIN32
1818
#include <unistd.h>
1919
#endif
20+
#ifndef _WIN32
2021
#include <dirent.h>
22+
#endif
2123

2224
static void print_usage(const char* prog) {
2325
fprintf(stderr, "TQM Converter — Pre-quantize models for instant loading\n\n");

0 commit comments

Comments
 (0)