From f8e9593851d4305a24836bdd3636255fb8c4243a Mon Sep 17 00:00:00 2001 From: GasInfinity Date: Tue, 21 Apr 2026 14:45:24 +0200 Subject: [PATCH] fix: wasm requires strict function prototypes * `pthread_mutex_*` and friends are also invalid then but they're not currently tested (and there's no wasi prong in `pthread_mutex_t`) --- lib/std/c.zig | 10 +++++----- test/c/pthread.zig | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index 337e602e77..b9d705286e 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -10977,11 +10977,11 @@ else pub const PTHREAD_PROCESS_SHARED: c_int = 1; -pub extern "c" fn pthread_spin_init(spin: *pthread_spinlock_t, pshared: c_int) E; -pub extern "c" fn pthread_spin_lock(spin: *pthread_spinlock_t) E; -pub extern "c" fn pthread_spin_unlock(spin: *pthread_spinlock_t) E; -pub extern "c" fn pthread_spin_trylock(spin: *pthread_spinlock_t) E; -pub extern "c" fn pthread_spin_destroy(spin: *pthread_spinlock_t) E; +pub extern "c" fn pthread_spin_init(spin: *pthread_spinlock_t, pshared: c_int) c_int; +pub extern "c" fn pthread_spin_lock(spin: *pthread_spinlock_t) c_int; +pub extern "c" fn pthread_spin_unlock(spin: *pthread_spinlock_t) c_int; +pub extern "c" fn pthread_spin_trylock(spin: *pthread_spinlock_t) c_int; +pub extern "c" fn pthread_spin_destroy(spin: *pthread_spinlock_t) c_int; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = .{}; pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E; diff --git a/test/c/pthread.zig b/test/c/pthread.zig index 0ef98ab035..7dd050ad81 100644 --- a/test/c/pthread.zig +++ b/test/c/pthread.zig @@ -12,9 +12,9 @@ test "pthread_spinlock_t" { _ = c.pthread_spin_init(&spin, c.PTHREAD_PROCESS_PRIVATE); defer _ = c.pthread_spin_destroy(&spin); - try std.testing.expectEqual(.SUCCESS, c.pthread_spin_trylock(&spin)); - try std.testing.expectEqual(.SUCCESS, c.pthread_spin_unlock(&spin)); + try std.testing.expectEqual(@intFromEnum(c.E.SUCCESS), c.pthread_spin_trylock(&spin)); + try std.testing.expectEqual(@intFromEnum(c.E.SUCCESS), c.pthread_spin_unlock(&spin)); - try std.testing.expectEqual(.SUCCESS, c.pthread_spin_lock(&spin)); - try std.testing.expectEqual(.SUCCESS, c.pthread_spin_unlock(&spin)); + try std.testing.expectEqual(@intFromEnum(c.E.SUCCESS), c.pthread_spin_lock(&spin)); + try std.testing.expectEqual(@intFromEnum(c.E.SUCCESS), c.pthread_spin_unlock(&spin)); }