mem: fix ub in writeInt
Use inline to vastly simplify the exposed API. This allows a comptime-known endian parameter to be propogated, making extra functions for a specific endianness completely unnecessary.
This commit is contained in:
@@ -1351,6 +1351,7 @@ test "under-aligned struct field" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
|
||||
const U = extern union {
|
||||
fd: i32,
|
||||
@@ -1364,7 +1365,7 @@ test "under-aligned struct field" {
|
||||
var runtime: usize = 1234;
|
||||
const ptr = &S{ .events = 0, .data = .{ .u64 = runtime } };
|
||||
const array = @as(*const [12]u8, @ptrCast(ptr));
|
||||
const result = std.mem.readIntNative(u64, array[4..12]);
|
||||
const result = std.mem.readInt(u64, array[4..12], native_endian);
|
||||
try expect(result == 1234);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user