diff options
| author | Eric Joldasov <bratishkaerik@getgoogleoff.me> | 2023-06-14 17:22:43 +0600 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-14 18:25:56 -0700 |
| commit | 610b02c432072c85f079f3ddf315cb864aa5dbf5 (patch) | |
| tree | 833383b2af44cfc1d485f14215590107d68d7924 /lib/std | |
| parent | b975701a4d98f2bf124fd4e66ca57e337827ec5a (diff) | |
| download | zig-610b02c432072c85f079f3ddf315cb864aa5dbf5.tar.gz zig-610b02c432072c85f079f3ddf315cb864aa5dbf5.zip | |
std.atomic.Atomic: update tests to new for-loop syntax, re-enable test with isel
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/atomic/Atomic.zig | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/std/atomic/Atomic.zig b/lib/std/atomic/Atomic.zig index 5bb25e9bde..6c0c477725 100644 --- a/lib/std/atomic/Atomic.zig +++ b/lib/std/atomic/Atomic.zig @@ -374,10 +374,6 @@ const atomic_rmw_orderings = [_]Ordering{ }; test "Atomic.swap" { - // TODO: Re-enable when LLVM is released with a bugfix for isel of - // atomic load (currently fixed on trunk, broken on 15.0.2) - if (builtin.cpu.arch == .powerpc64le) return error.SkipZigTest; - inline for (atomic_rmw_orderings) |ordering| { var x = Atomic(usize).init(5); try testing.expectEqual(x.swap(10, ordering), 5); @@ -546,9 +542,8 @@ test "Atomic.bitSet" { inline for (atomicIntTypes()) |Int| { inline for (atomic_rmw_orderings) |ordering| { var x = Atomic(Int).init(0); - const bit_array = @as([@bitSizeOf(Int)]void, undefined); - for (bit_array, 0..) |_, bit_index| { + for (0..@bitSizeOf(Int)) |bit_index| { const bit = @intCast(std.math.Log2Int(Int), bit_index); const mask = @as(Int, 1) << bit; @@ -562,7 +557,7 @@ test "Atomic.bitSet" { try testing.expect(x.load(.SeqCst) & mask != 0); // all the previous bits should have not changed (still be set) - for (bit_array[0..bit_index], 0..) |_, prev_bit_index| { + for (0..bit_index) |prev_bit_index| { const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index); const prev_mask = @as(Int, 1) << prev_bit; try testing.expect(x.load(.SeqCst) & prev_mask != 0); @@ -576,9 +571,8 @@ test "Atomic.bitReset" { inline for (atomicIntTypes()) |Int| { inline for (atomic_rmw_orderings) |ordering| { var x = Atomic(Int).init(0); - const bit_array = @as([@bitSizeOf(Int)]void, undefined); - for (bit_array, 0..) |_, bit_index| { + for (0..@bitSizeOf(Int)) |bit_index| { const bit = @intCast(std.math.Log2Int(Int), bit_index); const mask = @as(Int, 1) << bit; x.storeUnchecked(x.loadUnchecked() | mask); @@ -593,7 +587,7 @@ test "Atomic.bitReset" { try testing.expect(x.load(.SeqCst) & mask == 0); // all the previous bits should have not changed (still be reset) - for (bit_array[0..bit_index], 0..) |_, prev_bit_index| { + for (0..bit_index) |prev_bit_index| { const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index); const prev_mask = @as(Int, 1) << prev_bit; try testing.expect(x.load(.SeqCst) & prev_mask == 0); @@ -607,9 +601,8 @@ test "Atomic.bitToggle" { inline for (atomicIntTypes()) |Int| { inline for (atomic_rmw_orderings) |ordering| { var x = Atomic(Int).init(0); - const bit_array = @as([@bitSizeOf(Int)]void, undefined); - for (bit_array, 0..) |_, bit_index| { + for (0..@bitSizeOf(Int)) |bit_index| { const bit = @intCast(std.math.Log2Int(Int), bit_index); const mask = @as(Int, 1) << bit; @@ -623,7 +616,7 @@ test "Atomic.bitToggle" { try testing.expect(x.load(.SeqCst) & mask == 0); // all the previous bits should have not changed (still be toggled back) - for (bit_array[0..bit_index], 0..) |_, prev_bit_index| { + for (0..bit_index) |prev_bit_index| { const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index); const prev_mask = @as(Int, 1) << prev_bit; try testing.expect(x.load(.SeqCst) & prev_mask == 0); |
