2 #include <arch_atomic.h>
12 static struct testvals vals
;
14 #define do_test(ptr) \
16 __typeof__(*(ptr)) v; \
18 atomic_add(ptr, 10); \
19 assert(atomic_read(ptr) == 10); \
20 atomic_add(ptr, -11UL); \
21 assert(atomic_read(ptr) == (__typeof__(*(ptr)))-1UL); \
22 v = cmpxchg(ptr, -1UL, 22); \
23 assert(atomic_read(ptr) == 22); \
24 assert(v == (__typeof__(*(ptr)))-1UL); \
25 v = cmpxchg(ptr, 33, 44); \
26 assert(atomic_read(ptr) == 22); \
29 assert(atomic_read(ptr) == 55); \
31 atomic_set(ptr, 22); \
33 assert(atomic_read(ptr) == 23); \
35 assert(atomic_read(ptr) == 22); \
36 v = atomic_add_return(ptr, 100); \
38 assert(atomic_read(ptr) == 122); \
39 v = atomic_sub_return(ptr, 1); \
41 assert(atomic_read(ptr) == 121); \
44 int main(int argc
, char **argv
)
50 printf("Atomic ops test OK\n");
This page took 0.031021 seconds and 5 git commands to generate.