]>
Commit | Line | Data |
---|---|---|
1 | #include <darwintest.h> | |
2 | #include <os/atomic_private.h> | |
3 | ||
4 | T_GLOBAL_META( | |
5 | T_META_RUN_CONCURRENTLY(true), | |
6 | T_META_CHECK_LEAKS(false) | |
7 | ); | |
8 | ||
9 | T_DECL(os_atomic, "Just to make sure things build at all in c++ mode") | |
10 | { | |
11 | os_atomic(int) i = 0; | |
12 | int old_i = 0; | |
13 | volatile int v_i = 0; | |
14 | int a, b; | |
15 | ||
16 | T_ASSERT_EQ(os_atomic_inc_orig(&i, relaxed), 0, "atomic inc"); | |
17 | T_ASSERT_EQ(os_atomic_cmpxchg(&i, 1, 0, relaxed), true, "os_atomic_cmpxchg"); | |
18 | os_atomic_rmw_loop(&i, a, b, relaxed, { | |
19 | b = a; | |
20 | }); | |
21 | ||
22 | T_ASSERT_EQ(os_atomic_inc_orig(&old_i, relaxed), 0, "atomic inc"); | |
23 | T_ASSERT_EQ(os_atomic_cmpxchg(&old_i, 1, 0, relaxed), true, "os_atomic_cmpxchg"); | |
24 | os_atomic_rmw_loop(&old_i, a, b, relaxed, { | |
25 | b = a; | |
26 | }); | |
27 | ||
28 | T_ASSERT_EQ(os_atomic_inc_orig(&v_i, relaxed), 0, "atomic inc"); | |
29 | T_ASSERT_EQ(os_atomic_cmpxchg(&v_i, 1, 0, relaxed), true, "os_atomic_cmpxchg"); | |
30 | os_atomic_rmw_loop(&v_i, a, b, relaxed, { | |
31 | b = a; | |
32 | }); | |
33 | } |