From 82a70c79b8b6087a62397731c33bc525194ebfdc Mon Sep 17 00:00:00 2001 From: Mattthew Heath Date: Fri, 6 Dec 2024 17:33:12 +0000 Subject: [PATCH] aligns as 8 --- crates/compiler/builtins/bitcode/src/utils.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/compiler/builtins/bitcode/src/utils.zig b/crates/compiler/builtins/bitcode/src/utils.zig index 405cbd11eb..11b3a6b9fa 100644 --- a/crates/compiler/builtins/bitcode/src/utils.zig +++ b/crates/compiler/builtins/bitcode/src/utils.zig @@ -75,12 +75,13 @@ comptime { } fn testing_roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque { - if (alignment > @alignOf(usize)) { - @panic("alignments larger than that of usize are not currently supported"); + const real_alignment = 8; + if (alignment > real_alignment) { + @panic("alignments larger than 8 are not currently supported"); } // We store an extra usize which is the size of the full allocation. const full_size = size + @sizeOf(usize); - var raw_ptr = (std.testing.allocator.alignedAlloc(u8, @alignOf(usize), full_size) catch unreachable).ptr; + var raw_ptr = (std.testing.allocator.alignedAlloc(u8, real_alignment, full_size) catch unreachable).ptr; @as([*]usize, @alignCast(@ptrCast(raw_ptr)))[0] = full_size; raw_ptr += @sizeOf(usize); const ptr = @as(?*anyopaque, @ptrCast(raw_ptr)); @@ -110,7 +111,8 @@ fn testing_roc_realloc(c_ptr: *anyopaque, new_size: usize, old_size: usize, _: u } fn testing_roc_dealloc(c_ptr: *anyopaque, _: u32) callconv(.C) void { - const raw_ptr = @as([*]align(@alignOf(usize)) u8, @alignCast(@ptrCast(c_ptr))) - @sizeOf(usize); + const actual_alignment = 8; + const raw_ptr = @as([*]align(actual_alignment) u8, @alignCast(@ptrCast(c_ptr))) - @sizeOf(usize); const full_size = @as([*]usize, @alignCast(@ptrCast(raw_ptr)))[0]; const slice = raw_ptr[0..full_size];