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 {
4545 level: u8,
4646
4747 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));
4949 }
5050
5151 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);
5353 }
5454
5555 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
9797 if (limb(x, limb_index) != 0) break true;
9898 } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0;
9999 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),
101101 )), @intCast(exponent));
102102}
103103
lib/compiler_rt/int_from_float.zig+1-1
......@@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul
141141 },
142142 .unsigned => @memset(result, 0),
143143 }
144 std.mem.writePackedIntNative(I, std.mem.sliceAsBytes(result), exponent, int);
144 std.mem.writePackedInt(I, std.mem.sliceAsBytes(result), exponent, int, .native);
145145}
146146
147147test {
lib/std/mem.zig-24
......@@ -1973,18 +1973,6 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T {
19731973 } else return @as(T, @bitCast(val));
19741974}
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
19881976/// Loads an integer from packed memory.
19891977/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
19901978pub 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)
21282116 writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big);
21292117}
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
21432119/// Stores an integer to packed memory.
21442120/// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.
21452121pub fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void {