5 static unsigned long test_cmpxchgb(unsigned long orig
)
9 asm("cmpxchgb %b[cmp],%[mem]"
10 : [ mem
] "+m"(mem
), [ rax
] "=a"(ret
)
11 : [ cmp
] "r"(0x77), "a"(orig
));
15 static unsigned long test_cmpxchgw(unsigned long orig
)
19 asm("cmpxchgw %w[cmp],%[mem]"
20 : [ mem
] "+m"(mem
), [ rax
] "=a"(ret
)
21 : [ cmp
] "r"(0x7777), "a"(orig
));
25 static unsigned long test_cmpxchgl(unsigned long orig
)
29 asm("cmpxchgl %[cmp],%[mem]"
30 : [ mem
] "+m"(mem
), [ rax
] "=a"(ret
)
31 : [ cmp
] "r"(0x77777777u
), "a"(orig
));
37 unsigned long test
= 0xdeadbeef12345678ull
;
38 assert(test
== test_cmpxchgb(test
));
39 assert(test
== test_cmpxchgw(test
));
40 assert(test
== test_cmpxchgl(test
));