From d5c37d9122240fe95d308fbe15874e14dd786c5a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 21 Oct 2026 14:38:16 -0300 Subject: Build with Zig 0.17 --- 9proc/src/core.zig | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to '9proc/src/core.zig') diff --git a/9proc/src/core.zig b/9proc/src/core.zig index 12ecff9..bdeb715 100644 --- a/9proc/src/core.zig +++ b/9proc/src/core.zig @@ -239,20 +239,20 @@ pub fn fieldsText(comptime T: type) []const u8 { @setEvalBranchQuota(200_000); var s: []const u8 = ""; switch (@typeInfo(T)) { - .@"struct" => |info| for (info.fields) |f| { + .@"struct" => |info| for (info.field_names, info.field_types, info.field_attrs) |name, F, attrs| { if (info.layout == .@"packed") { - s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}b\n", .{ f.name, @typeName(f.type), @bitOffsetOf(T, f.name) }); - } else if (f.is_comptime) { - s = s ++ std.fmt.comptimePrint("{s}: {s} (comptime)\n", .{ f.name, @typeName(f.type) }); + s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}b\n", .{ name, @typeName(F), @bitOffsetOf(T, name) }); + } else if (attrs.@"comptime") { + s = s ++ std.fmt.comptimePrint("{s}: {s} (comptime)\n", .{ name, @typeName(F) }); } else { - s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}\n", .{ f.name, @typeName(f.type), @offsetOf(T, f.name) }); + s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}\n", .{ name, @typeName(F), @offsetOf(T, name) }); } }, - .@"union" => |info| for (info.fields) |f| { - s = s ++ f.name ++ ": " ++ @typeName(f.type) ++ "\n"; + .@"union" => |info| for (info.field_names, info.field_types) |name, F| { + s = s ++ name ++ ": " ++ @typeName(F) ++ "\n"; }, - .@"enum" => |info| for (info.fields) |f| { - s = s ++ std.fmt.comptimePrint("{s} = {d}\n", .{ f.name, f.value }); + .@"enum" => |info| for (info.field_names, info.field_values) |name, value| { + s = s ++ std.fmt.comptimePrint("{s} = {d}\n", .{ name, value }); }, else => s = @typeName(T) ++ "\n", } @@ -264,11 +264,11 @@ fn declsText(comptime T: type) []const u8 { comptime { @setEvalBranchQuota(20_000); const decls = switch (@typeInfo(T)) { - inline .@"struct", .@"union", .@"enum", .@"opaque" => |info| info.decls, - else => &[_]std.builtin.Type.Declaration{}, + inline .@"struct", .@"union", .@"enum", .@"opaque" => |info| info.decl_names, + else => &[_][:0]const u8{}, }; var s: []const u8 = ""; - for (decls) |d| s = s ++ d.name ++ "\n"; + for (decls) |name| s = s ++ name ++ "\n"; return s; } } @@ -297,10 +297,10 @@ pub const Node = struct { } }; -fn genNodes(comptime Fns: type) [@typeInfo(Fns).@"struct".decls.len]Node { - const decls = @typeInfo(Fns).@"struct".decls; +fn genNodes(comptime Fns: type) [@typeInfo(Fns).@"struct".decl_names.len]Node { + const decls = @typeInfo(Fns).@"struct".decl_names; var arr: [decls.len]Node = undefined; - for (decls, 0..) |d, i| arr[i] = .{ .name = d.name, .kind = .dynamic, .gen = genFor(Fns, d.name) }; + for (decls, 0..) |name, i| arr[i] = .{ .name = name, .kind = .dynamic, .gen = genFor(Fns, name) }; return arr; } @@ -490,7 +490,7 @@ pub fn Server(comptime cfg: Config) type { pub fn expose(s: *Shared, name: []const u8, ptr: anytype) error{Full}!void { const P = @TypeOf(ptr); const info = @typeInfo(P); - if (info != .pointer or info.pointer.size != .one or info.pointer.is_const) @compileError("expose wants a *T, got " ++ @typeName(P)); + if (info != .pointer or info.pointer.size != .one or info.pointer.attrs.@"const") @compileError("expose wants a *T, got " ++ @typeName(P)); if (s.nvars == cfg.max_vars) return error.Full; std.debug.assert(validName(name) != error.BadName); std.debug.assert(s.findVar(name) == null); @@ -1759,7 +1759,7 @@ test "runtime/fn calls the function at open and at each read from offset 0" { defer x.deinit(); const names = try x.h.listPath(&.{ "runtime", "fn" }); defer TS.Harness.freeNames(names); - try testing.expectEqual(@typeInfo(TestFns).@"struct".decls.len, names.len); + try testing.expectEqual(@typeInfo(TestFns).@"struct".decl_names.len, names.len); const fib_text = try x.h.readPath(&.{ "runtime", "fn", "fib30" }); defer testing.allocator.free(fib_text); try testing.expectEqualStrings("832040", fib_text); @@ -2012,7 +2012,7 @@ test "provider: walk/list/stat/open/read/write/create/remove/wstat/clunk and err try testing.expectEqualStrings("fresh", rr.read); try x.h.walkTo(6, &.{"prov"}); try x.h.expectFail(.{ .create = .{ .fid = 6, .name = "new", .perm = 0o644, .mode = cloud9.oread } }, "file already exists"); - const long_name = [_]u8{'n'} ** (max_name + 1); + const long_name: [max_name + 1]u8 = @splat('n'); try x.h.expectFail(.{ .create = .{ .fid = 6, .name = &long_name, .perm = 0o644, .mode = cloud9.oread } }, e_illegal_name); try x.h.expectFail(.{ .create = .{ .fid = 6, .name = "d", .perm = cloud9.dmdir | 0o755, .mode = cloud9.owrite } }, e_perm); const dr = try x.h.ok(.{ .create = .{ .fid = 6, .name = "d", .perm = cloud9.dmdir | 0o755, .mode = cloud9.oread } }); @@ -2162,12 +2162,12 @@ test "msize: below the engine's floor the connection dies; at the floor everythi const st = try y.h.ok(.{ .stat = .{ .fid = 0 } }); try testing.expectEqualStrings("/", st.stat.name); // A full 16-element Rwalk is exactly msize_min. - const w = try y.h.ok(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &([_][]const u8{"."} ** 16) } }); + const w = try y.h.ok(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &@as([16][]const u8, @splat(".")) } }); try testing.expectEqual(@as(u16, 16), w.walk.nwqid); _ = try y.h.ok(.{ .clunk = .{ .fid = 1 } }); // An Rstat that cannot fit is an Rerror, not a dead connection. try y.h.walkTo(2, &.{"prov"}); - const long_name = [_]u8{'n'} ** 180; // Tcreate fits; the Rstat (61 + 180 bytes) does not + const long_name: [180]u8 = @splat('n'); // Tcreate fits; the Rstat (61 + 180 bytes) does not _ = try y.h.ok(.{ .create = .{ .fid = 2, .name = &long_name, .perm = 0o644, .mode = cloud9.oread } }); try y.h.expectFail(.{ .stat = .{ .fid = 2 } }, e_small_msize); _ = try y.h.ok(.{ .remove = .{ .fid = 2 } }); -- cgit v1.3