backport some changes needed for zig 10

This commit is contained in:
Folkert 2022-12-17 22:17:27 +01:00
parent fd2c6adc6f
commit a522d49558
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -90,19 +90,19 @@ fn testing_roc_memcpy(dest: *anyopaque, src: *anyopaque, bytes: usize) callconv(
} }
pub fn alloc(size: usize, alignment: u32) ?[*]u8 { pub fn alloc(size: usize, alignment: u32) ?[*]u8 {
return @ptrCast(?[*]u8, @call(.{ .modifier = always_inline }, roc_alloc, .{ size, alignment })); return @ptrCast(?[*]u8, roc_alloc(size, alignment));
} }
pub fn realloc(c_ptr: [*]u8, new_size: usize, old_size: usize, alignment: u32) [*]u8 { pub fn realloc(c_ptr: [*]u8, new_size: usize, old_size: usize, alignment: u32) [*]u8 {
return @ptrCast([*]u8, @call(.{ .modifier = always_inline }, roc_realloc, .{ c_ptr, new_size, old_size, alignment })); return @ptrCast([*]u8, roc_realloc(c_ptr, new_size, old_size, alignment));
} }
pub fn dealloc(c_ptr: [*]u8, alignment: u32) void { pub fn dealloc(c_ptr: [*]u8, alignment: u32) void {
return @call(.{ .modifier = always_inline }, roc_dealloc, .{ c_ptr, alignment }); return roc_dealloc(c_ptr, alignment);
} }
pub fn memcpy(dst: [*]u8, src: [*]u8, size: usize) void { pub fn memcpy(dst: [*]u8, src: [*]u8, size: usize) void {
@call(.{ .modifier = always_inline }, roc_memcpy, .{ dst, src, size }); roc_memcpy(dst, src, size);
} }
// indirection because otherwise zig creates an alias to the panic function which our LLVM code // indirection because otherwise zig creates an alias to the panic function which our LLVM code
@ -275,7 +275,8 @@ pub inline fn calculateCapacity(
} else { } else {
new_capacity = (old_capacity * 3 + 1) / 2; new_capacity = (old_capacity * 3 + 1) / 2;
} }
return @maximum(new_capacity, requested_length);
return std.math.max(new_capacity, requested_length);
} }
pub fn allocateWithRefcountC( pub fn allocateWithRefcountC(