Files
zig/test/c/pthread.zig
T
GasInfinity f8e9593851 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`)
2026-04-21 14:45:24 +02:00

21 lines
773 B
Zig

const builtin = @import("builtin");
const std = @import("std");
const c = std.c;
const math = std.math;
const testing = std.testing;
test "pthread_spinlock_t" {
if (builtin.target.os.tag.isDarwin()) return; // Darwin doesn't have `pthread_spin_*`
var spin: c.pthread_spinlock_t = undefined;
_ = c.pthread_spin_init(&spin, c.PTHREAD_PROCESS_PRIVATE);
defer _ = c.pthread_spin_destroy(&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(@intFromEnum(c.E.SUCCESS), c.pthread_spin_lock(&spin));
try std.testing.expectEqual(@intFromEnum(c.E.SUCCESS), c.pthread_spin_unlock(&spin));
}