mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Skip 128-bit cmpxchg test if CMPXCHG16B is not supported
This commit is contained in:
parent
d19e1709b3
commit
f91782c6d1
@ -75,20 +75,28 @@ test "cmpxchg with ptr" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "128-bit cmpxchg" {
|
test "128-bit cmpxchg" {
|
||||||
var x: u128 = 1234;
|
try test_u128_cmpxchg();
|
||||||
if (@cmpxchgWeak(u128, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| {
|
comptime try test_u128_cmpxchg();
|
||||||
try expect(x1 == 1234);
|
}
|
||||||
} else {
|
|
||||||
@panic("cmpxchg should have failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
while (@cmpxchgWeak(u128, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| {
|
fn test_u128_cmpxchg() !void {
|
||||||
try expect(x1 == 1234);
|
if (std.Target.current.cpu.arch != .x86_64) return error.SkipZigTest;
|
||||||
}
|
if (comptime !std.Target.x86.featureSetHas(std.Target.current.cpu.features, .cx16)) return error.SkipZigTest;
|
||||||
try expect(x == 5678);
|
|
||||||
|
|
||||||
try expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null);
|
var x: u128 = 1234;
|
||||||
try expect(x == 42);
|
if (@cmpxchgWeak(u128, &x, 99, 5678, .SeqCst, .SeqCst)) |x1| {
|
||||||
|
try expect(x1 == 1234);
|
||||||
|
} else {
|
||||||
|
@panic("cmpxchg should have failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (@cmpxchgWeak(u128, &x, 1234, 5678, .SeqCst, .SeqCst)) |x1| {
|
||||||
|
try expect(x1 == 1234);
|
||||||
|
}
|
||||||
|
try expect(x == 5678);
|
||||||
|
|
||||||
|
try expect(@cmpxchgStrong(u128, &x, 5678, 42, .SeqCst, .SeqCst) == null);
|
||||||
|
try expect(x == 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "cmpxchg with ignored result" {
|
test "cmpxchg with ignored result" {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user