3 #include <urcu/uatomic.h>
12 static struct testvals vals
;
14 #define do_test(ptr) \
16 __typeof__(*(ptr)) v; \
18 uatomic_add(ptr, 10); \
19 assert(uatomic_read(ptr) == 10); \
20 uatomic_add(ptr, -11UL); \
21 assert(uatomic_read(ptr) == (__typeof__(*(ptr)))-1UL); \
22 v = uatomic_cmpxchg(ptr, -1UL, 22); \
23 assert(uatomic_read(ptr) == 22); \
24 assert(v == (__typeof__(*(ptr)))-1UL); \
25 v = uatomic_cmpxchg(ptr, 33, 44); \
26 assert(uatomic_read(ptr) == 22); \
28 v = uatomic_xchg(ptr, 55); \
29 assert(uatomic_read(ptr) == 55); \
31 uatomic_set(ptr, 22); \
33 assert(uatomic_read(ptr) == 23); \
35 assert(uatomic_read(ptr) == 22); \
36 v = uatomic_add_return(ptr, 74); \
38 assert(uatomic_read(ptr) == 96); \
39 uatomic_or(ptr, 58); \
40 assert(uatomic_read(ptr) == 122); \
41 v = uatomic_sub_return(ptr, 1); \
43 assert(uatomic_read(ptr) == 121); \
44 uatomic_and(ptr, 129); \
45 assert(uatomic_read(ptr) == 1); \
48 int main(int argc
, char **argv
)
50 #ifdef UATOMIC_HAS_ATOMIC_BYTE
53 #ifdef UATOMIC_HAS_ATOMIC_SHORT
58 printf("Atomic ops test OK\n");
This page took 0.033797 seconds and 4 git commands to generate.