Skip to content

Commit 2a97ccc

Browse files
committed
fix(probe): cast timeval fields to platform width (unblocks macOS/Windows build)
The setup-zig re-pin in the previous commit unmasked a pre-existing cross-platform compile error that the broken action had hidden by failing before the build ever ran. posix.timeval field widths vary by platform: - Linux: sec/usec are i64 -> compiled (only passing OS) - Windows: sec/usec are c_long/i32 -> error: expected c_long, found i64 (.sec) - macOS: sec i64, usec i32 -> error: expected i32, found i64 (.usec) Assigning i64 locals only compiled on Linux. Inline @intcast into the field initialisers so each value coerces to the platform field type. The matrix only compiles on macOS/Windows (run-integration: false), so this is sufficient for a green build; Winsock SO_RCVTIMEO runtime semantics are unchanged and out of scope here. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvsZgNxFbeqfRmrVFNhJ8G
1 parent 518a8ac commit 2a97ccc

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/interface/ffi/src/probe.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ fn udpExchange(
194194
);
195195
defer posix.close(sock);
196196

197-
// set receive timeout
198-
const timeout_sec: i64 = @intCast(timeout_ms / 1000);
199-
const timeout_usec: i64 = @intCast(@as(u64, timeout_ms % 1000) * 1000);
197+
// set receive timeout — cast into the timeval field types, whose width
198+
// varies by platform: sec/usec are i64 on Linux, c_long (i32) on Windows,
199+
// and i64/i32 (time_t/suseconds_t) on macOS. @intCast adapts to each.
200200
const tv = posix.timeval{
201-
.sec = timeout_sec,
202-
.usec = timeout_usec,
201+
.sec = @intCast(timeout_ms / 1000),
202+
.usec = @intCast(@as(u64, timeout_ms % 1000) * 1000),
203203
};
204204
try posix.setsockopt(sock, posix.SOL.SOCKET, posix.SO.RCVTIMEO, std.mem.asBytes(&tv));
205205

0 commit comments

Comments
 (0)