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