authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-08-12 16:42:37+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-08-12 16:42:37+02:00
log394d287778971c3d06fc401e688fc048cdf9860a
tree1c1cf30c6cc402fbea5cb4b9d93e4df661857697
parentf49aa960a93b401b8e33292cf37a0de1eec312c0
parentf91782c6d1f7a8ef1ee3196147bb33c9e1ac059d
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #9535 from FnControlOption/128-bit-cmpxchg-test

Re-enable 128-bit cmpxchg test

1 files changed, 24 insertions(+), 20 deletions(-)

test/behavior/atomics.zig+24-20
...@@ -74,26 +74,30 @@ test "cmpxchg with ptr" {...@@ -74,26 +74,30 @@ test "cmpxchg with ptr" {
74 try expect(x == &data2);74 try expect(x == &data2);
75}75}
7676
77// TODO this test is disabled until this issue is resolved:77test "128-bit cmpxchg" {
78// https://github.com/ziglang/zig/issues/288378 try test_u128_cmpxchg();
79// otherwise cross compiling will result in:79 comptime try test_u128_cmpxchg();
80// lld: error: undefined symbol: __sync_val_compare_and_swap_1680}
81//test "128-bit cmpxchg" {81
82// var x: u128 align(16) = 1234; // TODO: https://github.com/ziglang/zig/issues/298782fn test_u128_cmpxchg() !void {
83// if (@cmpxchgWeak(u128, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| {83 if (std.Target.current.cpu.arch != .x86_64) return error.SkipZigTest;
84// try expect(x1 == 1234);84 if (comptime !std.Target.x86.featureSetHas(std.Target.current.cpu.features, .cx16)) return error.SkipZigTest;
85// } else {85
86// @panic("cmpxchg should have failed");86 var x: u128 = 1234;
87// }87 if (@cmpxchgWeak(u128, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| {
88//88 try expect(x1 == 1234);
89// while (@cmpxchgWeak(u128, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| {89 } else {
90// try expect(x1 == 1234);90 @panic("cmpxchg should have failed");
91// }91 }
92// try expect(x == 5678);92
93//93 while (@cmpxchgWeak(u128, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| {
94// try expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null);94 try expect(x1 == 1234);
95// try expect(x == 42);95 }
96//}96 try expect(x == 5678);
97
98 try expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null);
99 try expect(x == 42);
100}
97101
98test "cmpxchg with ignored result" {102test "cmpxchg with ignored result" {
99 var x: i32 = 1234;103 var x: i32 = 1234;