From 83da6827fdda6f0304228bba3e78e8624c4540ee Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 8 May 2026 21:57:24 +0100 Subject: [PATCH] std.mem: Remove native/foreign variants of {read,write}PackedInt() --- lib/compiler/aro/aro/Preprocessor.zig | 4 ++-- lib/compiler_rt/float_from_int.zig | 2 +- lib/compiler_rt/int_from_float.zig | 2 +- lib/std/mem.zig | 24 ------------------------ 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/lib/compiler/aro/aro/Preprocessor.zig b/lib/compiler/aro/aro/Preprocessor.zig index 15ac3b0a1bf4ccc4e3eb8e437c35c1d8985a837b..6b52492e7d9a09a1650c7ffdf27cd6ffd09cdad4 100644 --- a/lib/compiler/aro/aro/Preprocessor.zig +++ b/lib/compiler/aro/aro/Preprocessor.zig @@ -45,11 +45,11 @@ const IfContext = struct { level: u8, fn get(self: *const IfContext) Nesting { - return @enumFromInt(std.mem.readPackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2)); + return @enumFromInt(std.mem.readPackedInt(Backing, &self.kind, @as(usize, self.level) * 2, .native)); } fn set(self: *IfContext, context: Nesting) void { - std.mem.writePackedIntNative(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context)); + std.mem.writePackedInt(Backing, &self.kind, @as(usize, self.level) * 2, @intFromEnum(context), .native); } fn increment(self: *IfContext) bool { diff --git a/lib/compiler_rt/float_from_int.zig b/lib/compiler_rt/float_from_int.zig index 2fddcaea9505ce31fb7bb4a0c0299b4f00590b8c..d275e181799b4de5ef87a12933beca8e355af935 100644 --- a/lib/compiler_rt/float_from_int.zig +++ b/lib/compiler_rt/float_from_int.zig @@ -97,7 +97,7 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin if (limb(x, limb_index) != 0) break true; } else limb(x, exponent_limb) & ((@as(u32, 1) << @truncate(exponent)) - 1) != 0; return math.ldexp(@as(T, @floatFromInt( - std.mem.readPackedIntNative(I, std.mem.sliceAsBytes(x), exponent) | @intFromBool(sticky), + std.mem.readPackedInt(I, std.mem.sliceAsBytes(x), exponent, .native) | @intFromBool(sticky), )), @intCast(exponent)); } diff --git a/lib/compiler_rt/int_from_float.zig b/lib/compiler_rt/int_from_float.zig index 146456fd110812e036413fc4638412d73cd0ac87..494ac6cdc392001e356f713bee733c73b19069e1 100644 --- a/lib/compiler_rt/int_from_float.zig +++ b/lib/compiler_rt/int_from_float.zig @@ -141,7 +141,7 @@ pub inline fn bigIntFromFloat(comptime signedness: std.builtin.Signedness, resul }, .unsigned => @memset(result, 0), } - std.mem.writePackedIntNative(I, std.mem.sliceAsBytes(result), exponent, int); + std.mem.writePackedInt(I, std.mem.sliceAsBytes(result), exponent, int, .native); } test { diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 07c197fbc244b2831e31bdcbbaf4465dee6bfee1..a61b5adf1fcd948117f972dfbeb9ca46f3f8fac9 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1973,18 +1973,6 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T { } else return @as(T, @bitCast(val)); } -/// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .native) -pub const readPackedIntNative = switch (native_endian) { - .little => readPackedIntLittle, - .big => readPackedIntBig, -}; - -/// Deprecated: use readPackedInt(T, bytes, bit_offset, value, .foreign) -pub const readPackedIntForeign = switch (native_endian) { - .little => readPackedIntBig, - .big => readPackedIntLittle, -}; - /// Loads an integer from packed memory. /// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits. pub 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) writeInt(StoreInt, write_bytes[(byte_count - store_size)..][0..store_size], write_value, .big); } -/// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .native) -pub const writePackedIntNative = switch (native_endian) { - .little => writePackedIntLittle, - .big => writePackedIntBig, -}; - -/// Deprecated: use writePackedInt(T, bytes, bit_offset, value, .foreign) -pub const writePackedIntForeign = switch (native_endian) { - .little => writePackedIntBig, - .big => writePackedIntLittle, -}; - /// Stores an integer to packed memory. /// Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits. pub fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void { -- 2.54.0