diff options
Diffstat (limited to '9proc/src/linux')
| -rw-r--r-- | 9proc/src/linux/debug.zig | 16 | ||||
| -rw-r--r-- | 9proc/src/linux/probe.zig | 12 | ||||
| -rw-r--r-- | 9proc/src/linux/runtime.zig | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/9proc/src/linux/debug.zig b/9proc/src/linux/debug.zig index a344380..8bbee52 100644 --- a/9proc/src/linux/debug.zig +++ b/9proc/src/linux/debug.zig @@ -163,7 +163,7 @@ pub const Debug = struct { max_paused: u8, capture: CaptureSlot = .{}, - paused: [max_paused_cap]PauseSlot = [_]PauseSlot{.{}} ** max_paused_cap, + paused: [max_paused_cap]PauseSlot = @splat(.{}), old_capture_action: linux.Sigaction = undefined, old_trap_action: linux.Sigaction = undefined, @@ -187,7 +187,7 @@ pub const Debug = struct { d.* = .{ .io = opts.io, .text_buf = opts.text_buf, - .capture_signal = @enumFromInt(opts.capture_signal), + .capture_signal = @fromBackingInt(@intCast(opts.capture_signal)), .capture_timeout_ns = opts.capture_timeout_ns, .max_paused = opts.max_paused, }; @@ -249,7 +249,7 @@ pub const Debug = struct { pub fn threadExists(d: *Debug, tid: u32) bool { _ = d; var path_buf: [64]u8 = undefined; - const path = std.fmt.bufPrintZ(&path_buf, "/proc/self/task/{d}/comm", .{tid}) catch return false; + const path = std.fmt.bufPrintSentinel(&path_buf, "/proc/self/task/{d}/comm", .{tid}, 0) catch return false; var buf: [32]u8 = undefined; _ = readFile(path, &buf) catch return false; return true; @@ -259,7 +259,7 @@ pub const Debug = struct { pub fn threadName(d: *Debug, tid: u32, w: *Writer) Error!void { _ = d; var path_buf: [64]u8 = undefined; - const path = std.fmt.bufPrintZ(&path_buf, "/proc/self/task/{d}/comm", .{tid}) catch return error.Unexpected; + const path = std.fmt.bufPrintSentinel(&path_buf, "/proc/self/task/{d}/comm", .{tid}, 0) catch return error.Unexpected; var buf: [64]u8 = undefined; const text = readFile(path, &buf) catch |err| switch (err) { error.NotFound => return error.NoThread, @@ -273,7 +273,7 @@ pub const Debug = struct { pub fn threadStat(d: *Debug, tid: u32, w: *Writer) Error!void { _ = d; var path_buf: [64]u8 = undefined; - const path = std.fmt.bufPrintZ(&path_buf, "/proc/self/task/{d}/stat", .{tid}) catch return error.Unexpected; + const path = std.fmt.bufPrintSentinel(&path_buf, "/proc/self/task/{d}/stat", .{tid}, 0) catch return error.Unexpected; var buf: [1024]u8 = undefined; const text = readFile(path, &buf) catch |err| switch (err) { error.NotFound => return error.NoThread, @@ -924,8 +924,8 @@ fn writeHexLines(base: usize, bytes: []const u8, w: *Writer) Error!void { fn writeRegs(ctx: *const Native, w: *Writer) Error!void { if (comptime arch == .x86_64) { - inline for (@typeInfo(Native.Gpr).@"enum".fields) |f| { - w.print("{s} 0x{x}\n", .{ f.name, ctx.gprs.get(@field(Native.Gpr, f.name)) }) catch return error.WriteFailed; + inline for (@typeInfo(Native.GprName).@"enum".field_names) |name| { + w.print("{s} 0x{x}\n", .{ name, ctx.gprs.get(@field(Native.GprName, name)) }) catch return error.WriteFailed; } w.print("pc 0x{x}\nsp 0x{x}\nfp 0x{x}\n", .{ ctx.gprs.get(.rip), ctx.gprs.get(.rsp), ctx.gprs.get(.rbp), @@ -1369,7 +1369,7 @@ test "panic record path" { // A long message is truncated, not overflowed. resetPanicRecord(); - const long = [_]u8{'x'} ** (panic_msg_cap + 100); + const long: [panic_msg_cap + 100]u8 = @splat('x'); try testing.expect(recordPanic(&long, null)); out.clearRetainingCapacity(); try d.panicMessage(&out.writer); 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); diff --git a/9proc/src/linux/runtime.zig b/9proc/src/linux/runtime.zig index 503d6c2..c7a7366 100644 --- a/9proc/src/linux/runtime.zig +++ b/9proc/src/linux/runtime.zig @@ -86,5 +86,5 @@ test "runtime generators read Info through the context" { w = .fixed(&buf); try F.pid(&ctx, &w); try std.testing.expectEqual(linux.getpid(), try std.fmt.parseInt(i32, w.buffered(), 10)); - try std.testing.expectEqual(@as(usize, 7), @typeInfo(F).@"struct".decls.len); + try std.testing.expectEqual(@as(usize, 7), @typeInfo(F).@"struct".decl_names.len); } |
