| ... | ... | @@ -70,22 +70,23 @@ test "cmpxchg with ptr" { |
| 70 | 70 | expect(x == &data2); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | | test "128-bit cmpxchg" { |
| 74 | | if (builtin.arch != .x86_64) { |
| 75 | | return error.SkipZigTest; |
| 76 | | } |
| 77 | | var x: u128 align(16) = 1234; // TODO: https://github.com/ziglang/zig/issues/2987 |
| 78 | | if (@cmpxchgWeak(u128, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| { |
| 79 | | expect(x1 == 1234); |
| 80 | | } else { |
| 81 | | @panic("cmpxchg should have failed"); |
| 82 | | } |
| 83 | | |
| 84 | | while (@cmpxchgWeak(u128, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| { |
| 85 | | expect(x1 == 1234); |
| 86 | | } |
| 87 | | expect(x == 5678); |
| 88 | | |
| 89 | | expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null); |
| 90 | | expect(x == 42); |
| 91 | | } |
| 73 | // TODO this test is disabled until this issue is resolved: |
| 74 | // https://github.com/ziglang/zig/issues/2883 |
| 75 | // otherwise cross compiling will result in: |
| 76 | // lld: error: undefined symbol: __sync_val_compare_and_swap_16 |
| 77 | //test "128-bit cmpxchg" { |
| 78 | // var x: u128 align(16) = 1234; // TODO: https://github.com/ziglang/zig/issues/2987 |
| 79 | // if (@cmpxchgWeak(u128, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| { |
| 80 | // expect(x1 == 1234); |
| 81 | // } else { |
| 82 | // @panic("cmpxchg should have failed"); |
| 83 | // } |
| 84 | // |
| 85 | // while (@cmpxchgWeak(u128, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| { |
| 86 | // expect(x1 == 1234); |
| 87 | // } |
| 88 | // expect(x == 5678); |
| 89 | // |
| 90 | // expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null); |
| 91 | // expect(x == 42); |
| 92 | //} |