Skip to content

Commit c4f1336

Browse files
YUXclaude
andcommitted
fix: use i64 for RateLimiter timestamps instead of i128
x86_64 Linux does not support atomic operations on 128-bit integers. Changed timestamp fields from i128 to i64, which is sufficient for nanosecond precision until year 2262. This fixes cross-compilation for x86_64-linux-gnu and x86_64-linux-musl targets in the Release workflow. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 872ede2 commit c4f1336

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/common.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ pub fn recvAllFromFd(fd: posix.fd_t, buffer: []u8) !void {
266266
pub const RateLimiter = struct {
267267
tokens: std.atomic.Value(u32),
268268
max_tokens: u32,
269-
refill_interval_ns: i128,
270-
last_refill: std.atomic.Value(i128),
269+
refill_interval_ns: i64,
270+
last_refill: std.atomic.Value(i64),
271271

272272
/// Create a rate limiter allowing `max_per_second` operations per second
273273
pub fn init(max_per_second: u32) RateLimiter {
274274
return .{
275275
.tokens = std.atomic.Value(u32).init(max_per_second),
276276
.max_tokens = max_per_second,
277-
.refill_interval_ns = @divTrunc(std.time.ns_per_s, max_per_second),
278-
.last_refill = std.atomic.Value(i128).init(std.time.nanoTimestamp()),
277+
.refill_interval_ns = @intCast(@divTrunc(std.time.ns_per_s, max_per_second)),
278+
.last_refill = std.atomic.Value(i64).init(@intCast(std.time.nanoTimestamp())),
279279
};
280280
}
281281

@@ -302,7 +302,7 @@ pub const RateLimiter = struct {
302302
}
303303

304304
// Refill if needed
305-
const now = std.time.nanoTimestamp();
305+
const now: i64 = @intCast(std.time.nanoTimestamp());
306306
const last = self.last_refill.load(.monotonic);
307307
const elapsed = now - last;
308308

0 commit comments

Comments
 (0)