mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 00:52:52 +00:00
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.
This commit is contained in:
parent
401910a2ca
commit
4330c40596
@ -12,7 +12,7 @@ pub const Poly1305 = struct {
|
||||
// accumulated hash
|
||||
h: [3]u64 = [_]u64{ 0, 0, 0 },
|
||||
// random number added at the end (from the secret key)
|
||||
pad: [2]u64,
|
||||
end_pad: [2]u64,
|
||||
// how many bytes are waiting to be processed in a partial block
|
||||
leftover: usize = 0,
|
||||
// partial block buffer
|
||||
@ -24,7 +24,7 @@ pub const Poly1305 = struct {
|
||||
mem.readInt(u64, key[0..8], .little) & 0x0ffffffc0fffffff,
|
||||
mem.readInt(u64, key[8..16], .little) & 0x0ffffffc0ffffffc,
|
||||
},
|
||||
.pad = [_]u64{
|
||||
.end_pad = [_]u64{
|
||||
mem.readInt(u64, key[16..24], .little),
|
||||
mem.readInt(u64, key[24..32], .little),
|
||||
},
|
||||
@ -177,9 +177,9 @@ pub const Poly1305 = struct {
|
||||
h1 ^= mask & (h1 ^ h_p1);
|
||||
|
||||
// Add the first half of the key, we intentionally don't use @addWithOverflow() here.
|
||||
st.h[0] = h0 +% st.pad[0];
|
||||
const c = ((h0 & st.pad[0]) | ((h0 | st.pad[0]) & ~st.h[0])) >> 63;
|
||||
st.h[1] = h1 +% st.pad[1] +% c;
|
||||
st.h[0] = h0 +% st.end_pad[0];
|
||||
const c = ((h0 & st.end_pad[0]) | ((h0 | st.end_pad[0]) & ~st.h[0])) >> 63;
|
||||
st.h[1] = h1 +% st.end_pad[1] +% c;
|
||||
|
||||
mem.writeInt(u64, out[0..8], st.h[0], .little);
|
||||
mem.writeInt(u64, out[8..16], st.h[1], .little);
|
||||
|
@ -300,11 +300,10 @@ pub fn getLineNumberInfo(self: *Pdb, module: *Module, address: u64) !std.debug.S
|
||||
|
||||
const found_line_index = start_line_index + line_entry_idx * @sizeOf(pdb.LineNumberEntry);
|
||||
const line_num_entry: *align(1) pdb.LineNumberEntry = @ptrCast(&subsect_info[found_line_index]);
|
||||
const flags: *align(1) pdb.LineNumberEntry.Flags = @ptrCast(&line_num_entry.Flags);
|
||||
|
||||
return .{
|
||||
.file_name = source_file_name,
|
||||
.line = flags.Start,
|
||||
.line = line_num_entry.Flags.Start,
|
||||
.column = column,
|
||||
};
|
||||
}
|
||||
|
@ -1501,7 +1501,7 @@ test values {
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
pub const X = 1;
|
||||
const A = 1;
|
||||
};
|
||||
try testing.expectEqualSlices(E, &.{ .X, .Y, .Z }, values(E));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ const assert = std.debug.assert;
|
||||
|
||||
pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {
|
||||
return struct {
|
||||
pub const vtable = Allocator.VTable{
|
||||
pub const vtable: Allocator.VTable = .{
|
||||
.alloc = alloc,
|
||||
.resize = resize,
|
||||
.free = free,
|
||||
@ -15,8 +15,6 @@ pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {
|
||||
|
||||
pub const Error = Allocator.Error;
|
||||
|
||||
lock: std.Thread.Mutex = .{},
|
||||
|
||||
const max_usize = math.maxInt(usize);
|
||||
const ushift = math.Log2Int(usize);
|
||||
const bigpage_size = 64 * 1024;
|
||||
|
@ -294,7 +294,7 @@ test declarations {
|
||||
pub fn a() void {}
|
||||
};
|
||||
const U1 = union {
|
||||
a: u8,
|
||||
b: u8,
|
||||
|
||||
pub fn a() void {}
|
||||
};
|
||||
@ -334,7 +334,7 @@ test declarationInfo {
|
||||
pub fn a() void {}
|
||||
};
|
||||
const U1 = union {
|
||||
a: u8,
|
||||
b: u8,
|
||||
|
||||
pub fn a() void {}
|
||||
};
|
||||
|
@ -4,38 +4,38 @@ const uefi = std.os.uefi;
|
||||
const Guid = uefi.Guid;
|
||||
|
||||
pub const DevicePath = union(Type) {
|
||||
Hardware: Hardware,
|
||||
Acpi: Acpi,
|
||||
Messaging: Messaging,
|
||||
Media: Media,
|
||||
BiosBootSpecification: BiosBootSpecification,
|
||||
End: End,
|
||||
hardware: Hardware,
|
||||
acpi: Acpi,
|
||||
messaging: Messaging,
|
||||
media: Media,
|
||||
bios_boot_specification: BiosBootSpecification,
|
||||
end: End,
|
||||
|
||||
pub const Type = enum(u8) {
|
||||
Hardware = 0x01,
|
||||
Acpi = 0x02,
|
||||
Messaging = 0x03,
|
||||
Media = 0x04,
|
||||
BiosBootSpecification = 0x05,
|
||||
End = 0x7f,
|
||||
hardware = 0x01,
|
||||
acpi = 0x02,
|
||||
messaging = 0x03,
|
||||
media = 0x04,
|
||||
bios_boot_specification = 0x05,
|
||||
end = 0x7f,
|
||||
_,
|
||||
};
|
||||
|
||||
pub const Hardware = union(Subtype) {
|
||||
Pci: *const PciDevicePath,
|
||||
PcCard: *const PcCardDevicePath,
|
||||
MemoryMapped: *const MemoryMappedDevicePath,
|
||||
Vendor: *const VendorDevicePath,
|
||||
Controller: *const ControllerDevicePath,
|
||||
Bmc: *const BmcDevicePath,
|
||||
pci: *const PciDevicePath,
|
||||
pc_card: *const PcCardDevicePath,
|
||||
memory_mapped: *const MemoryMappedDevicePath,
|
||||
vendor: *const VendorDevicePath,
|
||||
controller: *const ControllerDevicePath,
|
||||
bmc: *const BmcDevicePath,
|
||||
|
||||
pub const Subtype = enum(u8) {
|
||||
Pci = 1,
|
||||
PcCard = 2,
|
||||
MemoryMapped = 3,
|
||||
Vendor = 4,
|
||||
Controller = 5,
|
||||
Bmc = 6,
|
||||
pci = 1,
|
||||
pc_card = 2,
|
||||
memory_mapped = 3,
|
||||
vendor = 4,
|
||||
controller = 5,
|
||||
bmc = 6,
|
||||
_,
|
||||
};
|
||||
|
||||
@ -151,14 +151,14 @@ pub const DevicePath = union(Type) {
|
||||
};
|
||||
|
||||
pub const Acpi = union(Subtype) {
|
||||
Acpi: *const BaseAcpiDevicePath,
|
||||
ExpandedAcpi: *const ExpandedAcpiDevicePath,
|
||||
Adr: *const AdrDevicePath,
|
||||
acpi: *const BaseAcpiDevicePath,
|
||||
expanded_acpi: *const ExpandedAcpiDevicePath,
|
||||
adr: *const AdrDevicePath,
|
||||
|
||||
pub const Subtype = enum(u8) {
|
||||
Acpi = 1,
|
||||
ExpandedAcpi = 2,
|
||||
Adr = 3,
|
||||
acpi = 1,
|
||||
expanded_acpi = 2,
|
||||
adr = 3,
|
||||
_,
|
||||
};
|
||||
|
||||
|
@ -399,17 +399,14 @@ pub const LineBlockFragmentHeader = extern struct {
|
||||
pub const LineNumberEntry = extern struct {
|
||||
/// Offset to start of code bytes for line number
|
||||
Offset: u32,
|
||||
Flags: u32,
|
||||
|
||||
/// TODO runtime crash when I make the actual type of Flags this
|
||||
pub const Flags = packed struct {
|
||||
Flags: packed struct(u32) {
|
||||
/// Start line number
|
||||
Start: u24,
|
||||
/// Delta of lines to the end of the expression. Still unclear.
|
||||
// TODO figure out the point of this field.
|
||||
End: u7,
|
||||
IsStatement: bool,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
pub const ColumnNumberEntry = extern struct {
|
||||
|
Loading…
Reference in New Issue
Block a user