authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2026-05-08 21:57:24+01:00
committergravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2026-05-08 21:59:09+01:00
log83da6827fdda6f0304228bba3e78e8624c4540ee
treecfa420a140126a467978ad20a968540677b8ebc6
parent4590712804a0392d838a839572c722cf8640960c

std.mem: Remove native/foreign variants of {read,write}PackedInt()


4 files changed, 4 insertions(+), 28 deletions(-)

lib/compiler/aro/aro/Preprocessor.zig+2-2
...@@ -45,11 +45,11 @@ const IfContext = struct {...@@ -45,11 +45,11 @@ const IfContext = struct {
45 level: u8,45 level: u8,
4646
47 fn get(self: *const IfContext) Nesting {47 fn get(self: *const IfContext) Nesting {
48 return @enumFromInt(std.mem.readPackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2));48 return @enumFromInt(std.mem.readPackedInt(Backing, &self.kind, @as(usize, self.level) * 2, .native));
49 }49 }
5050
51 fn set(self: *IfContext, context: Nesting) void {51 fn set(self: *IfContext, context: Nesting) void {
52 std.mem.writePackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context));52 std.mem.writePackedInt(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context), .native);
53 }53 }
5454
55 fn increment(self: *IfContext) bool {55 fn increment(self: *IfContext) bool {
lib/compiler_rt/float_from_int.zig+1-1
...@@ -97,7 +97,7 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin...@@ -97,7 +97,7 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin
97 if (limb(x, limb_index) != 0) break true;97 if (limb(x, limb_index) != 0) break true;
98 } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0;98 } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0;
99 return math.ldexp(@as(T, @floatFromInt(99 return math.ldexp(@as(T, @floatFromInt(
100 std.mem.readPackedIntNative(I, std.mem.sliceAsBytes(x), exponent) | @intFromBool(sticky),100 std.mem.readPackedInt(I, std.mem.sliceAsBytes(x), exponent, .native) | @intFromBool(sticky),
101 )), @intCast(exponent));101 )), @intCast(exponent));
102}102}
103103
lib/compiler_rt/int_from_float.zig+1-1
...@@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul...@@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul
141 },141 },
142 .unsigned => @memset(result, 0),142 .unsigned => @memset(result, 0),
143 }143 }
144 std.mem.writePackedIntNative(I, std.mem.sliceAsBytes(result), exponent, int);144 std.mem.writePackedInt(I, std.mem.sliceAsBytes(result), exponent, int, .native);
145}145}
146146
147test {147test {
lib/std/mem.zig-24
...@@ -1973,18 +1973,6 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T {...@@ -1973,18 +1973,6 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T {
1973 } else return @as(T, @bitCast(val));1973 } else return @as(T, @bitCast(val));
1974}1974}
19751975
1976/// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .native)
1977pub const readPackedIntNative = switch (native_endian) {
1978 .little => readPackedIntLittle,
1979 .big => readPackedIntBig,
1980};
1981
1982/// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .foreign)
1983pub const readPackedIntForeign = switch (native_endian) {
1984 .little => readPackedIntBig,
1985 .big => readPackedIntLittle,
1986};
1987
1988/// Loads an integer from packed memory.1976/// Loads an integer from packed memory.
1989/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.1977/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
1990pub fn readPackedInt(comptime T: type, bytes: []const u8, bit_offset: usize, endian: Endian) T {1978pub fn readPackedInt(comptime T: type, bytes: []const u8, bit_offset: usize, endian: Endian) T {
...@@ -2128,18 +2116,6 @@ fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T)...@@ -2128,18 +2116,6 @@ fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T)
2128 writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big);2116 writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big);
2129}2117}
21302118
2131/// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .native)
2132pub const writePackedIntNative = switch (native_endian) {
2133 .little => writePackedIntLittle,
2134 .big => writePackedIntBig,
2135};
2136
2137/// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .foreign)
2138pub const writePackedIntForeign = switch (native_endian) {
2139 .little => writePackedIntBig,
2140 .big => writePackedIntLittle,
2141};
2142
2143/// Stores an integer to packed memory.2119/// Stores an integer to packed memory.
2144/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.2120/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
2145pub fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void {2121pub fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void {