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 {
1212 // accumulated hash
1313 h: [3]u64 = [_]u64{ 0, 0, 0 },
1414 // random number added at the end (from the secret key)
15 pad: [2]u64,
15 end_pad: [2]u64,
1616 // how many bytes are waiting to be processed in a partial block
1717 leftover: usize = 0,
1818 // partial block buffer
......@@ -24,7 +24,7 @@ pub const Poly1305 = struct {
2424 mem.readInt(u64, key[0..8], .little) & 0x0ffffffc0fffffff,
2525 mem.readInt(u64, key[8..16], .little) & 0x0ffffffc0ffffffc,
2626 },
27 .pad = [_]u64{
27 .end_pad = [_]u64{
2828 mem.readInt(u64, key[16..24], .little),
2929 mem.readInt(u64, key[24..32], .little),
3030 },
......@@ -177,9 +177,9 @@ pub const Poly1305 = struct {
177177 h1 ^= mask & (h1 ^ h_p1);
178178
179179 // Add the first half of the key, we intentionally don't use @addWithOverflow() here.
180 st.h[0] = h0 +% st.pad[0];
181 const c = ((h0 & st.pad[0]) | ((h0 | st.pad[0]) & ~st.h[0])) >> 63;
182 st.h[1] = h1 +% st.pad[1] +% c;
180 st.h[0] = h0 +% st.end_pad[0];
181 const c = ((h0 & st.end_pad[0]) | ((h0 | st.end_pad[0]) & ~st.h[0])) >> 63;
182 st.h[1] = h1 +% st.end_pad[1] +% c;
183183
184184 mem.writeInt(u64, out[0..8], st.h[0], .little);
185185 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
300300
301301 const found_line_index = start_line_index + line_entry_idx * @sizeOf(pdb.LineNumberEntry);
302302 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
305304 return .{
306305 .file_name = source_file_name,
307 .line = flags.Start,
306 .line = line_num_entry.Flags.Start,
308307 .column = column,
309308 };
310309 }
lib/std/enums.zig+1-1
......@@ -1501,7 +1501,7 @@ test values {
15011501 X,
15021502 Y,
15031503 Z,
1504 pub const X = 1;
1504 const A = 1;
15051505 };
15061506 try testing.expectEqualSlices(E, &.{ .X, .Y, .Z }, values(E));
15071507}
lib/std/heap/sbrk_allocator.zig+1-3
......@@ -7,7 +7,7 @@ const assert = std.debug.assert;
77
88pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {
99 return struct {
10 pub const vtable = Allocator.VTable{
10 pub const vtable: Allocator.VTable = .{
1111 .alloc = alloc,
1212 .resize = resize,
1313 .free = free,
......@@ -15,8 +15,6 @@ pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {
1515
1616 pub const Error = Allocator.Error;
1717
18 lock: std.Thread.Mutex = .{},
19
2018 const max_usize = math.maxInt(usize);
2119 const ushift = math.Log2Int(usize);
2220 const bigpage_size = 64 * 1024;
lib/std/meta.zig+2-2
......@@ -294,7 +294,7 @@ test declarations {
294294 pub fn a() void {}
295295 };
296296 const U1 = union {
297 a: u8,
297 b: u8,
298298
299299 pub fn a() void {}
300300 };
......@@ -334,7 +334,7 @@ test declarationInfo {
334334 pub fn a() void {}
335335 };
336336 const U1 = union {
337 a: u8,
337 b: u8,
338338
339339 pub fn a() void {}
340340 };
lib/std/os/uefi/device_path.zig+30-30
......@@ -4,38 +4,38 @@ const uefi = std.os.uefi;
44const Guid = uefi.Guid;
55
66pub const DevicePath = union(Type) {
7 Hardware: Hardware,
8 Acpi: Acpi,
9 Messaging: Messaging,
10 Media: Media,
11 BiosBootSpecification: BiosBootSpecification,
12 End: End,
7 hardware: Hardware,
8 acpi: Acpi,
9 messaging: Messaging,
10 media: Media,
11 bios_boot_specification: BiosBootSpecification,
12 end: End,
1313
1414 pub const Type = enum(u8) {
15 Hardware = 0x01,
16 Acpi = 0x02,
17 Messaging = 0x03,
18 Media = 0x04,
19 BiosBootSpecification = 0x05,
20 End = 0x7f,
15 hardware = 0x01,
16 acpi = 0x02,
17 messaging = 0x03,
18 media = 0x04,
19 bios_boot_specification = 0x05,
20 end = 0x7f,
2121 _,
2222 };
2323
2424 pub const Hardware = union(Subtype) {
25 Pci: *const PciDevicePath,
26 PcCard: *const PcCardDevicePath,
27 MemoryMapped: *const MemoryMappedDevicePath,
28 Vendor: *const VendorDevicePath,
29 Controller: *const ControllerDevicePath,
30 Bmc: *const BmcDevicePath,
25 pci: *const PciDevicePath,
26 pc_card: *const PcCardDevicePath,
27 memory_mapped: *const MemoryMappedDevicePath,
28 vendor: *const VendorDevicePath,
29 controller: *const ControllerDevicePath,
30 bmc: *const BmcDevicePath,
3131
3232 pub const Subtype = enum(u8) {
33 Pci = 1,
34 PcCard = 2,
35 MemoryMapped = 3,
36 Vendor = 4,
37 Controller = 5,
38 Bmc = 6,
33 pci = 1,
34 pc_card = 2,
35 memory_mapped = 3,
36 vendor = 4,
37 controller = 5,
38 bmc = 6,
3939 _,
4040 };
4141
......@@ -151,14 +151,14 @@ pub const DevicePath = union(Type) {
151151 };
152152
153153 pub const Acpi = union(Subtype) {
154 Acpi: *const BaseAcpiDevicePath,
155 ExpandedAcpi: *const ExpandedAcpiDevicePath,
156 Adr: *const AdrDevicePath,
154 acpi: *const BaseAcpiDevicePath,
155 expanded_acpi: *const ExpandedAcpiDevicePath,
156 adr: *const AdrDevicePath,
157157
158158 pub const Subtype = enum(u8) {
159 Acpi = 1,
160 ExpandedAcpi = 2,
161 Adr = 3,
159 acpi = 1,
160 expanded_acpi = 2,
161 adr = 3,
162162 _,
163163 };
164164
lib/std/pdb.zig+2-5
......@@ -399,17 +399,14 @@ pub const LineBlockFragmentHeader = extern struct {
399399pub const LineNumberEntry = extern struct {
400400 /// Offset to start of code bytes for line number
401401 Offset: u32,
402 Flags: u32,
403
404 /// TODO runtime crash when I make the actual type of Flags this
405 pub const Flags = packed struct {
402 Flags: packed struct(u32) {
406403 /// Start line number
407404 Start: u24,
408405 /// Delta of lines to the end of the expression. Still unclear.
409406 // TODO figure out the point of this field.
410407 End: u7,
411408 IsStatement: bool,
412 };
409 },
413410};
414411
415412pub const ColumnNumberEntry = extern struct {