authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-28 17:56:53+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-29 20:39:11+01:00
log4330c405963ad7db2bfdb639c556e04793d386a1
treec29d9a3e800815062540ab6f3ab3768200bf8646
parent401910a2ca8e4b9689180c63d0b8e190adcf7cfa
signaturelock-open Commit is signed but in an unrecognized format.

std: avoid field/decl name conflicts

Most of these changes seem like improvements. The PDB thing had a TODO saying it used to crash; I anticipate it works now, we'll see what CI does. The `std.os.uefi` field renames are a notable breaking change.

7 files changed, 42 insertions(+), 48 deletions(-)

lib/std/crypto/poly1305.zig+5-5
...@@ -12,7 +12,7 @@ pub const Poly1305 = struct {...@@ -12,7 +12,7 @@ pub const Poly1305 = struct {
12 // accumulated hash12 // accumulated hash
13 h: [3]u64 = [_]u64{ 0, 0, 0 },13 h: [3]u64 = [_]u64{ 0, 0, 0 },
14 // random number added at the end (from the secret key)14 // random number added at the end (from the secret key)
15 pad: [2]u64,15 end_pad: [2]u64,
16 // how many bytes are waiting to be processed in a partial block16 // how many bytes are waiting to be processed in a partial block
17 leftover: usize = 0,17 leftover: usize = 0,
18 // partial block buffer18 // partial block buffer
...@@ -24,7 +24,7 @@ pub const Poly1305 = struct {...@@ -24,7 +24,7 @@ pub const Poly1305 = struct {
24 mem.readInt(u64, key[0..8], .little) & 0x0ffffffc0fffffff,24 mem.readInt(u64, key[0..8], .little) & 0x0ffffffc0fffffff,
25 mem.readInt(u64, key[8..16], .little) & 0x0ffffffc0ffffffc,25 mem.readInt(u64, key[8..16], .little) & 0x0ffffffc0ffffffc,
26 },26 },
27 .pad = [_]u64{27 .end_pad = [_]u64{
28 mem.readInt(u64, key[16..24], .little),28 mem.readInt(u64, key[16..24], .little),
29 mem.readInt(u64, key[24..32], .little),29 mem.readInt(u64, key[24..32], .little),
30 },30 },
...@@ -177,9 +177,9 @@ pub const Poly1305 = struct {...@@ -177,9 +177,9 @@ pub const Poly1305 = struct {
177 h1 ^= mask & (h1 ^ h_p1);177 h1 ^= mask & (h1 ^ h_p1);
178178
179 // Add the first half of the key, we intentionally don't use @addWithOverflow() here.179 // Add the first half of the key, we intentionally don't use @addWithOverflow() here.
180 st.h[0] = h0 +% st.pad[0];180 st.h[0] = h0 +% st.end_pad[0];
181 const c = ((h0 & st.pad[0]) | ((h0 | st.pad[0]) & ~st.h[0])) >> 63;181 const c = ((h0 & st.end_pad[0]) | ((h0 | st.end_pad[0]) & ~st.h[0])) >> 63;
182 st.h[1] = h1 +% st.pad[1] +% c;182 st.h[1] = h1 +% st.end_pad[1] +% c;
183183
184 mem.writeInt(u64, out[0..8], st.h[0], .little);184 mem.writeInt(u64, out[0..8], st.h[0], .little);
185 mem.writeInt(u64, out[8..16], st.h[1], .little);185 mem.writeInt(u64, out[8..16], st.h[1], .little);
lib/std/debug/Pdb.zig+1-2
...@@ -300,11 +300,10 @@ pub fn getLineNumberInfo(self: *Pdb, module: *Module, address: u64) !std.debug.S...@@ -300,11 +300,10 @@ pub fn getLineNumberInfo(self: *Pdb, module: *Module, address: u64) !std.debug.S
300300
301 const found_line_index = start_line_index + line_entry_idx * @sizeOf(pdb.LineNumberEntry);301 const found_line_index = start_line_index + line_entry_idx * @sizeOf(pdb.LineNumberEntry);
302 const line_num_entry: *align(1) pdb.LineNumberEntry = @ptrCast(&subsect_info[found_line_index]);302 const line_num_entry: *align(1) pdb.LineNumberEntry = @ptrCast(&subsect_info[found_line_index]);
303 const flags: *align(1) pdb.LineNumberEntry.Flags = @ptrCast(&line_num_entry.Flags);
304303
305 return .{304 return .{
306 .file_name = source_file_name,305 .file_name = source_file_name,
307 .line = flags.Start,306 .line = line_num_entry.Flags.Start,
308 .column = column,307 .column = column,
309 };308 };
310 }309 }
lib/std/enums.zig+1-1
...@@ -1501,7 +1501,7 @@ test values {...@@ -1501,7 +1501,7 @@ test values {
1501 X,1501 X,
1502 Y,1502 Y,
1503 Z,1503 Z,
1504 pub const X = 1;1504 const A = 1;
1505 };1505 };
1506 try testing.expectEqualSlices(E, &.{ .X, .Y, .Z }, values(E));1506 try testing.expectEqualSlices(E, &.{ .X, .Y, .Z }, values(E));
1507}1507}
lib/std/heap/sbrk_allocator.zig+1-3
...@@ -7,7 +7,7 @@ const assert = std.debug.assert;...@@ -7,7 +7,7 @@ const assert = std.debug.assert;
77
8pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {8pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {
9 return struct {9 return struct {
10 pub const vtable = Allocator.VTable{10 pub const vtable: Allocator.VTable = .{
11 .alloc = alloc,11 .alloc = alloc,
12 .resize = resize,12 .resize = resize,
13 .free = free,13 .free = free,
...@@ -15,8 +15,6 @@ pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {...@@ -15,8 +15,6 @@ pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {
1515
16 pub const Error = Allocator.Error;16 pub const Error = Allocator.Error;
1717
18 lock: std.Thread.Mutex = .{},
19
20 const max_usize = math.maxInt(usize);18 const max_usize = math.maxInt(usize);
21 const ushift = math.Log2Int(usize);19 const ushift = math.Log2Int(usize);
22 const bigpage_size = 64 * 1024;20 const bigpage_size = 64 * 1024;
lib/std/meta.zig+2-2
...@@ -294,7 +294,7 @@ test declarations {...@@ -294,7 +294,7 @@ test declarations {
294 pub fn a() void {}294 pub fn a() void {}
295 };295 };
296 const U1 = union {296 const U1 = union {
297 a: u8,297 b: u8,
298298
299 pub fn a() void {}299 pub fn a() void {}
300 };300 };
...@@ -334,7 +334,7 @@ test declarationInfo {...@@ -334,7 +334,7 @@ test declarationInfo {
334 pub fn a() void {}334 pub fn a() void {}
335 };335 };
336 const U1 = union {336 const U1 = union {
337 a: u8,337 b: u8,
338338
339 pub fn a() void {}339 pub fn a() void {}
340 };340 };
lib/std/os/uefi/device_path.zig+30-30
...@@ -4,38 +4,38 @@ const uefi = std.os.uefi;...@@ -4,38 +4,38 @@ const uefi = std.os.uefi;
4const Guid = uefi.Guid;4const Guid = uefi.Guid;
55
6pub const DevicePath = union(Type) {6pub const DevicePath = union(Type) {
7 Hardware: Hardware,7 hardware: Hardware,
8 Acpi: Acpi,8 acpi: Acpi,
9 Messaging: Messaging,9 messaging: Messaging,
10 Media: Media,10 media: Media,
11 BiosBootSpecification: BiosBootSpecification,11 bios_boot_specification: BiosBootSpecification,
12 End: End,12 end: End,
1313
14 pub const Type = enum(u8) {14 pub const Type = enum(u8) {
15 Hardware = 0x01,15 hardware = 0x01,
16 Acpi = 0x02,16 acpi = 0x02,
17 Messaging = 0x03,17 messaging = 0x03,
18 Media = 0x04,18 media = 0x04,
19 BiosBootSpecification = 0x05,19 bios_boot_specification = 0x05,
20 End = 0x7f,20 end = 0x7f,
21 _,21 _,
22 };22 };
2323
24 pub const Hardware = union(Subtype) {24 pub const Hardware = union(Subtype) {
25 Pci: *const PciDevicePath,25 pci: *const PciDevicePath,
26 PcCard: *const PcCardDevicePath,26 pc_card: *const PcCardDevicePath,
27 MemoryMapped: *const MemoryMappedDevicePath,27 memory_mapped: *const MemoryMappedDevicePath,
28 Vendor: *const VendorDevicePath,28 vendor: *const VendorDevicePath,
29 Controller: *const ControllerDevicePath,29 controller: *const ControllerDevicePath,
30 Bmc: *const BmcDevicePath,30 bmc: *const BmcDevicePath,
3131
32 pub const Subtype = enum(u8) {32 pub const Subtype = enum(u8) {
33 Pci = 1,33 pci = 1,
34 PcCard = 2,34 pc_card = 2,
35 MemoryMapped = 3,35 memory_mapped = 3,
36 Vendor = 4,36 vendor = 4,
37 Controller = 5,37 controller = 5,
38 Bmc = 6,38 bmc = 6,
39 _,39 _,
40 };40 };
4141
...@@ -151,14 +151,14 @@ pub const DevicePath = union(Type) {...@@ -151,14 +151,14 @@ pub const DevicePath = union(Type) {
151 };151 };
152152
153 pub const Acpi = union(Subtype) {153 pub const Acpi = union(Subtype) {
154 Acpi: *const BaseAcpiDevicePath,154 acpi: *const BaseAcpiDevicePath,
155 ExpandedAcpi: *const ExpandedAcpiDevicePath,155 expanded_acpi: *const ExpandedAcpiDevicePath,
156 Adr: *const AdrDevicePath,156 adr: *const AdrDevicePath,
157157
158 pub const Subtype = enum(u8) {158 pub const Subtype = enum(u8) {
159 Acpi = 1,159 acpi = 1,
160 ExpandedAcpi = 2,160 expanded_acpi = 2,
161 Adr = 3,161 adr = 3,
162 _,162 _,
163 };163 };
164164
lib/std/pdb.zig+2-5
...@@ -399,17 +399,14 @@ pub const LineBlockFragmentHeader = extern struct {...@@ -399,17 +399,14 @@ pub const LineBlockFragmentHeader = extern struct {
399pub const LineNumberEntry = extern struct {399pub const LineNumberEntry = extern struct {
400 /// Offset to start of code bytes for line number400 /// Offset to start of code bytes for line number
401 Offset: u32,401 Offset: u32,
402 Flags: u32,402 Flags: packed struct(u32) {
403
404 /// TODO runtime crash when I make the actual type of Flags this
405 pub const Flags = packed struct {
406 /// Start line number403 /// Start line number
407 Start: u24,404 Start: u24,
408 /// Delta of lines to the end of the expression. Still unclear.405 /// Delta of lines to the end of the expression. Still unclear.
409 // TODO figure out the point of this field.406 // TODO figure out the point of this field.
410 End: u7,407 End: u7,
411 IsStatement: bool,408 IsStatement: bool,
412 };409 },
413};410};
414411
415pub const ColumnNumberEntry = extern struct {412pub const ColumnNumberEntry = extern struct {