mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
f8e9593851
* `pthread_mutex_*` and friends are also invalid then but they're not currently tested (and there's no wasi prong in `pthread_mutex_t`)
21 lines
773 B
Zig
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));
|
|
}
|