authorgravatar for bratishkaerik@getgoogleoff.meEric Joldasov <bratishkaerik@getgoogleoff.me> 2023-06-14 17:22:43+06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-14 18:25:56-07:00
log610b02c432072c85f079f3ddf315cb864aa5dbf5
tree833383b2af44cfc1d485f14215590107d68d7924
parentb975701a4d98f2bf124fd4e66ca57e337827ec5a

std.atomic.Atomic: update tests to new for-loop syntax, re-enable test with isel

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>

1 files changed, 6 insertions(+), 13 deletions(-)

lib/std/atomic/Atomic.zig+6-13
......@@ -374,10 +374,6 @@ const atomic_rmw_orderings = [_]Ordering{
374374};
375375
376376test "Atomic.swap" {
377 // TODO: Re-enable when LLVM is released with a bugfix for isel of
378 // atomic load (currently fixed on trunk, broken on 15.0.2)
379 if (builtin.cpu.arch == .powerpc64le) return error.SkipZigTest;
380
381377 inline for (atomic_rmw_orderings) |ordering| {
382378 var x = Atomic(usize).init(5);
383379 try testing.expectEqual(x.swap(10, ordering), 5);
......@@ -546,9 +542,8 @@ test "Atomic.bitSet" {
546542 inline for (atomicIntTypes()) |Int| {
547543 inline for (atomic_rmw_orderings) |ordering| {
548544 var x = Atomic(Int).init(0);
549 const bit_array = @as([@bitSizeOf(Int)]void, undefined);
550545
551 for (bit_array, 0..) |_, bit_index| {
546 for (0..@bitSizeOf(Int)) |bit_index| {
552547 const bit = @intCast(std.math.Log2Int(Int), bit_index);
553548 const mask = @as(Int, 1) << bit;
554549
......@@ -562,7 +557,7 @@ test "Atomic.bitSet" {
562557 try testing.expect(x.load(.SeqCst) & mask != 0);
563558
564559 // all the previous bits should have not changed (still be set)
565 for (bit_array[0..bit_index], 0..) |_, prev_bit_index| {
560 for (0..bit_index) |prev_bit_index| {
566561 const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index);
567562 const prev_mask = @as(Int, 1) << prev_bit;
568563 try testing.expect(x.load(.SeqCst) & prev_mask != 0);
......@@ -576,9 +571,8 @@ test "Atomic.bitReset" {
576571 inline for (atomicIntTypes()) |Int| {
577572 inline for (atomic_rmw_orderings) |ordering| {
578573 var x = Atomic(Int).init(0);
579 const bit_array = @as([@bitSizeOf(Int)]void, undefined);
580574
581 for (bit_array, 0..) |_, bit_index| {
575 for (0..@bitSizeOf(Int)) |bit_index| {
582576 const bit = @intCast(std.math.Log2Int(Int), bit_index);
583577 const mask = @as(Int, 1) << bit;
584578 x.storeUnchecked(x.loadUnchecked() | mask);
......@@ -593,7 +587,7 @@ test "Atomic.bitReset" {
593587 try testing.expect(x.load(.SeqCst) & mask == 0);
594588
595589 // all the previous bits should have not changed (still be reset)
596 for (bit_array[0..bit_index], 0..) |_, prev_bit_index| {
590 for (0..bit_index) |prev_bit_index| {
597591 const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index);
598592 const prev_mask = @as(Int, 1) << prev_bit;
599593 try testing.expect(x.load(.SeqCst) & prev_mask == 0);
......@@ -607,9 +601,8 @@ test "Atomic.bitToggle" {
607601 inline for (atomicIntTypes()) |Int| {
608602 inline for (atomic_rmw_orderings) |ordering| {
609603 var x = Atomic(Int).init(0);
610 const bit_array = @as([@bitSizeOf(Int)]void, undefined);
611604
612 for (bit_array, 0..) |_, bit_index| {
605 for (0..@bitSizeOf(Int)) |bit_index| {
613606 const bit = @intCast(std.math.Log2Int(Int), bit_index);
614607 const mask = @as(Int, 1) << bit;
615608
......@@ -623,7 +616,7 @@ test "Atomic.bitToggle" {
623616 try testing.expect(x.load(.SeqCst) & mask == 0);
624617
625618 // all the previous bits should have not changed (still be toggled back)
626 for (bit_array[0..bit_index], 0..) |_, prev_bit_index| {
619 for (0..bit_index) |prev_bit_index| {
627620 const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index);
628621 const prev_mask = @as(Int, 1) << prev_bit;
629622 try testing.expect(x.load(.SeqCst) & prev_mask == 0);