2 * This test performs some relaxed, release, acquire opeations on a single
3 * atomic variable. It can give some rough idea of release sequence support but
4 * probably should be improved to give better information.
6 * This test tries to establish two release sequences, where we should always
7 * either establish both or establish neither. (Note that this is only true for
8 * a few executions of interest, where both load-acquire's read from the same
14 #include <stdatomic.h>
21 static void a(void *obj)
24 atomic_store_explicit(&x, 1, memory_order_release);
25 atomic_store_explicit(&x, 42, memory_order_relaxed);
28 static void b(void *obj)
30 int r = atomic_load_explicit(&x, memory_order_acquire);
31 printf("r = %d\n", r);
32 printf("load %d\n", load_32(&var));
35 static void c(void *obj)
37 atomic_store_explicit(&x, 2, memory_order_relaxed);
40 int user_main(int argc, char **argv)
42 thrd_t t1, t2, t3, t4;
46 printf("Main thread: creating 4 threads\n");
47 thrd_create(&t1, (thrd_start_t)&a, NULL);
48 thrd_create(&t2, (thrd_start_t)&b, NULL);
49 thrd_create(&t3, (thrd_start_t)&b, NULL);
50 thrd_create(&t4, (thrd_start_t)&c, NULL);
56 printf("Main thread is finished\n");