10 static void a(void *obj)
14 short * pt = &expected;
16 printf("expected was %d, but x is %d\n", expected, x);
18 short v1 = atomic_compare_exchange_weak_explicit(&x, pt, desire, memory_order_relaxed, memory_order_acquire);
19 printf("Then v1 = %d, x = %d\n", v1, x);
20 printf("expected: %d\n", expected);
22 short v1 = atomic_exchange_explicit(&x, 8, memory_order_relaxed);
23 short v2 = atomic_exchange_explicit(&x, -10, memory_order_relaxed);
24 short v3 = atomic_load_explicit(&x, memory_order_relaxed);
25 printf("v1 = %d, v2 = %d, v3 = %d\n", v1, v2, v3);
29 static void b(void *obj)
31 int v3=atomic_fetch_add_explicit(&y, 2, memory_order_relaxed);
32 int v4=atomic_fetch_add_explicit(&x, -5, memory_order_relaxed);
33 printf("v3 = %d, v4=%d\n", v3, v4);
36 int user_main(int argc, char **argv)
43 thrd_create(&t1, (thrd_start_t)&a, NULL);
44 // thrd_create(&t2, (thrd_start_t)&b, NULL);