From 94e4c2c381ae2300497bca77db5b7ead72fe1da2 Mon Sep 17 00:00:00 2001 From: rvcas Date: Wed, 9 Feb 2022 19:04:09 -0500 Subject: [PATCH] fix: c_void is gone use anyopaque --- compiler/builtins/bitcode/src/expect.zig | 42 ++++-------------------- compiler/builtins/bitcode/src/utils.zig | 4 +-- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/compiler/builtins/bitcode/src/expect.zig b/compiler/builtins/bitcode/src/expect.zig index 3734b578ce..cc111b7005 100644 --- a/compiler/builtins/bitcode/src/expect.zig +++ b/compiler/builtins/bitcode/src/expect.zig @@ -27,18 +27,8 @@ pub fn expectFailed( // Lock the failures mutex before reading from any of the failures globals, // and then release the lock once we're done modifying things. - - // TODO FOR ZIG 0.9: this API changed in https://github.com/ziglang/zig/commit/008b0ec5e58fc7e31f3b989868a7d1ea4df3f41d - // to this: https://github.com/ziglang/zig/blob/c710d5eefe3f83226f1651947239730e77af43cb/lib/std/Thread/Mutex.zig - // - // ...so just use these two lines of code instead of the non-commented-out ones to make this work in Zig 0.9: - // - // failures_mutex.lock(); - // defer failures_mutex.release(); - // - // 👆 👆 👆 IF UPGRADING TO ZIG 0.9, LOOK HERE! 👆 👆 👆 - const held = failures_mutex.acquire(); - defer held.release(); + failures_mutex.lock(); + defer failures_mutex.unlock(); // If we don't have enough capacity to add a failure, allocate a new failures pointer. if (failure_length >= failure_capacity) { @@ -87,17 +77,8 @@ pub fn expectFailedC( } pub fn getExpectFailures() []Failure { - // TODO FOR ZIG 0.9: this API changed in https://github.com/ziglang/zig/commit/008b0ec5e58fc7e31f3b989868a7d1ea4df3f41d - // to this: https://github.com/ziglang/zig/blob/c710d5eefe3f83226f1651947239730e77af43cb/lib/std/Thread/Mutex.zig - // - // ...so just use these two lines of code instead of the non-commented-out ones to make this work in Zig 0.9: - // - // failures_mutex.lock(); - // defer failures_mutex.release(); - // - // 👆 👆 👆 IF UPGRADING TO ZIG 0.9, LOOK HERE! 👆 👆 👆 - const held = failures_mutex.acquire(); - defer held.release(); + failures_mutex.lock(); + defer failures_mutex.unlock(); if (failure_length > 0) { // defensively clone failures, in case someone modifies the originals after the mutex has been released. @@ -116,23 +97,14 @@ pub fn getExpectFailures() []Failure { } pub fn getExpectFailuresC() callconv(.C) CSlice { - var bytes = @ptrCast(*c_void, failures); + var bytes = @ptrCast(*anyopaque, failures); return .{ .pointer = bytes, .len = failure_length }; } pub fn deinitFailures() void { - // TODO FOR ZIG 0.9: this API changed in https://github.com/ziglang/zig/commit/008b0ec5e58fc7e31f3b989868a7d1ea4df3f41d - // to this: https://github.com/ziglang/zig/blob/c710d5eefe3f83226f1651947239730e77af43cb/lib/std/Thread/Mutex.zig - // - // ...so just use these two lines of code instead of the non-commented-out ones to make this work in Zig 0.9: - // - // failures_mutex.lock(); - // defer failures_mutex.release(); - // - // 👆 👆 👆 IF UPGRADING TO ZIG 0.9, LOOK HERE! 👆 👆 👆 - const held = failures_mutex.acquire(); - defer held.release(); + failures_mutex.lock(); + defer failures_mutex.unlock(); utils.dealloc(@ptrCast([*]u8, failures), @alignOf(Failure)); failure_length = 0; diff --git a/compiler/builtins/bitcode/src/utils.zig b/compiler/builtins/bitcode/src/utils.zig index 5b14e3623f..3de9b9af02 100644 --- a/compiler/builtins/bitcode/src/utils.zig +++ b/compiler/builtins/bitcode/src/utils.zig @@ -57,7 +57,7 @@ fn testing_roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void { @panic("Roc panicked"); } -fn testing_roc_memcpy(dest: *c_void, src: *c_void, bytes: usize) callconv(.C) ?*c_void { +fn testing_roc_memcpy(dest: *anyopaque, src: *anyopaque, bytes: usize) callconv(.C) ?*anyopaque { const zig_dest = @ptrCast([*]u8, dest); const zig_src = @ptrCast([*]u8, src); @@ -237,7 +237,7 @@ pub fn allocateWithRefcount( } pub const CSlice = extern struct { - pointer: *c_void, + pointer: *anyopaque, len: usize, };