mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Add xadd to chibicc
This commit is contained in:
parent
56eff8544f
commit
1216b6e7c7
2 changed files with 23 additions and 0 deletions
13
third_party/chibicc/test/atomic_test.c
vendored
13
third_party/chibicc/test/atomic_test.c
vendored
|
@ -37,5 +37,18 @@ main() {
|
|||
ASSERT(4, x);
|
||||
ASSERT(4, lock);
|
||||
|
||||
// CAS success #3
|
||||
x = 4;
|
||||
ASSERT(1, __atomic_compare_exchange_n(&lock, &x, 31337, 0, __ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST));
|
||||
ASSERT(4, x);
|
||||
ASSERT(31337, lock);
|
||||
|
||||
// xadd
|
||||
ASSERT(31337, __atomic_fetch_add(&lock, 31337, __ATOMIC_SEQ_CST));
|
||||
ASSERT(62674, lock);
|
||||
ASSERT(62674, __atomic_fetch_sub(&lock, 31337, __ATOMIC_SEQ_CST));
|
||||
ASSERT(31337, lock);
|
||||
|
||||
//
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue