mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-28 19:00:52 +08:00
Converts usages of `@intFromEnum` and `@enumFromInt` to instead use the new `@backingInt` and `@fromBackingInt` builtins.
22 lines
871 B
Zig
22 lines
871 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_*`
|
|
if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // winpthreads-only
|
|
|
|
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(@backingInt(c.E.SUCCESS), c.pthread_spin_trylock(&spin));
|
|
try std.testing.expectEqual(@backingInt(c.E.SUCCESS), c.pthread_spin_unlock(&spin));
|
|
|
|
try std.testing.expectEqual(@backingInt(c.E.SUCCESS), c.pthread_spin_lock(&spin));
|
|
try std.testing.expectEqual(@backingInt(c.E.SUCCESS), c.pthread_spin_unlock(&spin));
|
|
}
|