diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-02-18 05:25:36 +0100 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-06-05 06:12:00 +0200 |
| commit | 9d534790ebc869ec933e932abe4be8b9e3593bbc (patch) | |
| tree | 70652dde381fd0c0d536d8e7665e725e0924bb51 /lib/std/Thread/Futex.zig | |
| parent | 14873f9a3434a0d753ca8438f389a7931956cf26 (diff) | |
| download | zig-9d534790ebc869ec933e932abe4be8b9e3593bbc.tar.gz zig-9d534790ebc869ec933e932abe4be8b9e3593bbc.zip | |
std.Target: Introduce Cpu convenience functions for feature tests.
Before:
* std.Target.arm.featureSetHas(target.cpu.features, .has_v7)
* std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov })
* std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory })
After:
* target.cpu.has(.arm, .has_v7)
* target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov })
* target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
Diffstat (limited to 'lib/std/Thread/Futex.zig')
| -rw-r--r-- | lib/std/Thread/Futex.zig | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig index 69ed57a908..5e942924c3 100644 --- a/lib/std/Thread/Futex.zig +++ b/lib/std/Thread/Futex.zig @@ -461,9 +461,8 @@ const DragonflyImpl = struct { const WasmImpl = struct { fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout: ?u64) error{Timeout}!void { - if (!comptime std.Target.wasm.featureSetHas(builtin.target.cpu.features, .atomics)) { - @compileError("WASI target missing cpu feature 'atomics'"); - } + if (!comptime builtin.cpu.has(.wasm, .atomics)) @compileError("WASI target missing cpu feature 'atomics'"); + const to: i64 = if (timeout) |to| @intCast(to) else -1; const result = asm volatile ( \\local.get %[ptr] @@ -485,9 +484,8 @@ const WasmImpl = struct { } fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { - if (!comptime std.Target.wasm.featureSetHas(builtin.target.cpu.features, .atomics)) { - @compileError("WASI target missing cpu feature 'atomics'"); - } + if (!comptime builtin.cpu.has(.wasm, .atomics)) @compileError("WASI target missing cpu feature 'atomics'"); + assert(max_waiters != 0); const woken_count = asm volatile ( \\local.get %[ptr] |
