mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
feat(libzigc): add common implementations of pthread_spin_*
* and remove their mingw, musl and wasi implementations
This commit is contained in:
@@ -4,6 +4,7 @@ const std = @import("std");
|
||||
test {
|
||||
_ = @import("c/inttypes.zig");
|
||||
_ = @import("c/math.zig");
|
||||
_ = @import("c/pthread.zig");
|
||||
_ = @import("c/search.zig");
|
||||
_ = @import("c/stdlib.zig");
|
||||
_ = @import("c/string.zig");
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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(.SUCCESS, c.pthread_spin_trylock(&spin));
|
||||
try std.testing.expectEqual(.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));
|
||||
}
|
||||
Reference in New Issue
Block a user