summaryrefslogtreecommitdiff
path: root/9proc/src/linux/probe.zig
diff options
context:
space:
mode:
Diffstat (limited to '9proc/src/linux/probe.zig')
-rw-r--r--9proc/src/linux/probe.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/9proc/src/linux/probe.zig b/9proc/src/linux/probe.zig
index 00c256e..f9cb585 100644
--- a/9proc/src/linux/probe.zig
+++ b/9proc/src/linux/probe.zig
@@ -141,7 +141,7 @@ pub fn Probe(comptime Srv: type) type {
refused: u64 = 0,
stopping: std.atomic.Value(bool) = .init(false),
/// Slots whose request is being handled (excluded from nested servicing and eviction).
- serving: std.StaticBitSet(256) = .initEmpty(),
+ serving: std.StaticBitSet(256) = .empty,
/// Current `sleepServing` nesting depth.
nested: u8 = 0,
debug_ready: bool = false,
@@ -569,7 +569,7 @@ pub fn Probe(comptime Srv: type) type {
const rc = linux.statx(linux.AT.FDCWD, path, 0, .{ .TYPE = true, .INO = true }, &stx);
const s: isize = @bitCast(rc);
if (s == 0) return stx;
- const noent: isize = @intCast(@intFromEnum(linux.E.NOENT));
+ const noent: isize = @intCast(@backingInt(linux.E.NOENT));
if (s == -noent) return null;
return error.StatFailed;
}
@@ -616,7 +616,7 @@ pub fn parseIpv4(text: []const u8) ?linux.sockaddr.in {
var it = std.mem.splitScalar(u8, text[0..colon], '.');
for (&octets) |*o| o.* = std.fmt.parseInt(u8, it.next() orelse return null, 10) catch return null;
if (it.next() != null) return null;
- return .{ .port = std.mem.nativeToBig(u16, port), .addr = @bitCast(octets) };
+ return .{ .port = std.mem.nativeToBig(u16, port), .addr = std.mem.bytesToValue(u32, &octets) };
}
/// Names the calling thread (comm, at most 15 bytes) via prctl.
@@ -624,7 +624,7 @@ pub fn setThreadName(name: []const u8) void {
var buf: [16]u8 = @splat(0);
const n = @min(name.len, 15);
@memcpy(buf[0..n], name[0..n]);
- _ = linux.prctl(@intFromEnum(linux.PR.SET_NAME), @intFromPtr(&buf), 0, 0, 0);
+ _ = linux.prctl(@backingInt(linux.PR.SET_NAME), @intFromPtr(&buf), 0, 0, 0);
}
pub fn sleepMs(ms: u64) void {
@@ -863,7 +863,7 @@ test "probe: single pre-connected client mode ends when the client hangs up" {
test "parseIpv4 and sleepServing off the probe thread" {
const sa = parseIpv4("127.0.0.1:564").?;
try testing.expectEqual(std.mem.nativeToBig(u16, 564), sa.port);
- try testing.expectEqual(@as(u32, @bitCast([4]u8{ 127, 0, 0, 1 })), sa.addr);
+ try testing.expectEqual(std.mem.bytesToValue(u32, &[4]u8{ 127, 0, 0, 1 }), sa.addr);
try testing.expect(parseIpv4("localhost:1") == null);
try testing.expect(parseIpv4("1.2.3:1") == null);
try testing.expect(parseIpv4("1.2.3.4") == null);
@@ -871,7 +871,7 @@ test "parseIpv4 and sleepServing off the probe thread" {
const t0 = monotonicMs();
var probe: TP = undefined;
probe.thread_tid = .init(0);
- probe.serving = .initEmpty();
+ probe.serving = .empty;
probe.nested = 0;
probe.sleepServing(20);
try testing.expect(monotonicMs() - t0 >= 20);