fixup the obivous zig errors

This commit is contained in:
Luke Boswell 2024-07-24 18:57:31 +10:00
parent 5d4f820185
commit 011c13fb17
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
5 changed files with 180 additions and 180 deletions

View file

@ -56,20 +56,20 @@ fn testing_roc_dbg(loc: *anyopaque, message: *anyopaque, src: *anyopaque) callco
comptime {
// During tests, use the testing allocators to satisfy these functions.
if (builtin.is_test) {
@export(testing_roc_alloc, .{ .name = "roc_alloc", .linkage = .Strong });
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong });
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong });
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong });
@export(testing_roc_dbg, .{ .name = "roc_dbg", .linkage = .Strong });
@export(testing_roc_alloc, .{ .name = "roc_alloc", .linkage = .strong });
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .strong });
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .strong });
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .strong });
@export(testing_roc_dbg, .{ .name = "roc_dbg", .linkage = .strong });
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
@export(testing_roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
@export(testing_roc_mmap, .{ .name = "roc_mmap", .linkage = .Strong });
@export(testing_roc_shm_open, .{ .name = "roc_shm_open", .linkage = .Strong });
@export(testing_roc_getppid, .{ .name = "roc_getppid", .linkage = .strong });
@export(testing_roc_mmap, .{ .name = "roc_mmap", .linkage = .strong });
@export(testing_roc_shm_open, .{ .name = "roc_shm_open", .linkage = .strong });
}
if (builtin.os.tag == .windows) {
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .Strong });
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .strong });
}
}
}
@ -225,7 +225,7 @@ pub fn decrefRcPtrC(
// (NOT the start of the data, or the start of the allocation)
// this is of course unsafe, but we trust what we get from the llvm side
var bytes = @as([*]isize, @ptrCast(bytes_or_null));
const bytes = @as([*]isize, @ptrCast(bytes_or_null));
return @call(.always_inline, decref_ptr_to_refcount, .{ bytes, alignment, elements_refcounted });
}
@ -246,7 +246,7 @@ pub fn decrefDataPtrC(
alignment: u32,
elements_refcounted: bool,
) callconv(.C) void {
var bytes = bytes_or_null orelse return;
const bytes = bytes_or_null orelse return;
const data_ptr = @intFromPtr(bytes);
const tag_mask: usize = if (@sizeOf(usize) == 8) 0b111 else 0b11;
@ -262,7 +262,7 @@ pub fn increfDataPtrC(
bytes_or_null: ?[*]u8,
inc_amount: isize,
) callconv(.C) void {
var bytes = bytes_or_null orelse return;
const bytes = bytes_or_null orelse return;
const ptr = @intFromPtr(bytes);
const tag_mask: usize = if (@sizeOf(usize) == 8) 0b111 else 0b11;
@ -278,7 +278,7 @@ pub fn freeDataPtrC(
alignment: u32,
elements_refcounted: bool,
) callconv(.C) void {
var bytes = bytes_or_null orelse return;
const bytes = bytes_or_null orelse return;
const ptr = @intFromPtr(bytes);
const tag_mask: usize = if (@sizeOf(usize) == 8) 0b111 else 0b11;
@ -295,7 +295,7 @@ pub fn freeRcPtrC(
alignment: u32,
elements_refcounted: bool,
) callconv(.C) void {
var bytes = bytes_or_null orelse return;
const bytes = bytes_or_null orelse return;
return free_ptr_to_refcount(bytes, alignment, elements_refcounted);
}
@ -309,7 +309,7 @@ pub fn decref(
return;
}
var bytes = bytes_or_null orelse return;
const bytes = bytes_or_null orelse return;
const isizes: [*]isize = @as([*]isize, @ptrCast(@alignCast(bytes)));
@ -371,7 +371,7 @@ inline fn decref_ptr_to_refcount(
}
},
Refcount.atomic => {
var last = @atomicRmw(isize, &refcount_ptr[0], std.builtin.AtomicRmwOp.Sub, 1, Monotonic);
const last = @atomicRmw(isize, &refcount_ptr[0], std.builtin.AtomicRmwOp.Sub, 1, Monotonic);
if (last == REFCOUNT_ONE_ISIZE) {
free_ptr_to_refcount(refcount_ptr, alignment, elements_refcounted);
}
@ -384,7 +384,7 @@ inline fn decref_ptr_to_refcount(
pub fn isUnique(
bytes_or_null: ?[*]u8,
) callconv(.C) bool {
var bytes = bytes_or_null orelse return true;
const bytes = bytes_or_null orelse return true;
const ptr = @intFromPtr(bytes);
const tag_mask: usize = if (@sizeOf(usize) == 8) 0b111 else 0b11;
@ -470,7 +470,7 @@ pub fn allocateWithRefcount(
const extra_bytes = @max(required_space, element_alignment);
const length = extra_bytes + data_bytes;
var new_bytes: [*]u8 = alloc(length, alignment) orelse unreachable;
const new_bytes: [*]u8 = alloc(length, alignment) orelse unreachable;
if (DEBUG_ALLOC and builtin.target.cpu.arch != .wasm32) {
std.debug.print("+ allocated {*} ({} bytes with alignment {})\n", .{ new_bytes, data_bytes, alignment });
@ -529,14 +529,14 @@ pub const UpdateMode = enum(u8) {
test "increfC, refcounted data" {
var mock_rc: isize = REFCOUNT_ONE_ISIZE + 17;
var ptr_to_refcount: *isize = &mock_rc;
const ptr_to_refcount: *isize = &mock_rc;
increfRcPtrC(ptr_to_refcount, 2);
try std.testing.expectEqual(mock_rc, REFCOUNT_ONE_ISIZE + 19);
}
test "increfC, static data" {
var mock_rc: isize = REFCOUNT_MAX_ISIZE;
var ptr_to_refcount: *isize = &mock_rc;
const ptr_to_refcount: *isize = &mock_rc;
increfRcPtrC(ptr_to_refcount, 2);
try std.testing.expectEqual(mock_rc, REFCOUNT_MAX_ISIZE);
}