Fix bug that prevents graph generation from compiling.
[model-checker.git] / test / sctest.c
1 #include <stdio.h>
2 #include <threads.h>
3 #include <stdatomic.h>
4
5 #include "librace.h"
6
7 atomic_int x;
8 atomic_int y;
9 atomic_int z;
10
11 static void a(void *obj)
12 {
13         atomic_store_explicit(&z, 1, memory_order_relaxed);
14 }
15
16 static void b(void *obj)
17 {
18         atomic_store_explicit(&x, 1, memory_order_relaxed);
19         atomic_store_explicit(&y, 1, memory_order_relaxed);
20         int r1=atomic_load_explicit(&z, memory_order_relaxed);
21 }
22 static void c(void *obj)
23 {
24         atomic_store_explicit(&z, 2, memory_order_relaxed);
25         atomic_store_explicit(&x, 2, memory_order_relaxed);
26         int r2=atomic_load_explicit(&y, memory_order_relaxed);
27 }
28
29 static void d(void *obj)
30 {
31         atomic_store_explicit(&z, 3, memory_order_relaxed);
32         atomic_store_explicit(&y, 2, memory_order_relaxed);
33         int r3=atomic_load_explicit(&x, memory_order_relaxed);
34 }
35
36 int user_main(int argc, char **argv)
37 {
38         thrd_t t1, t2,t3, t4;
39
40         atomic_init(&x, 0);
41         atomic_init(&y, 0);
42         atomic_init(&z, 0);
43
44         thrd_create(&t1, (thrd_start_t)&a, NULL);
45         thrd_create(&t2, (thrd_start_t)&b, NULL);
46         thrd_create(&t3, (thrd_start_t)&c, NULL);
47         thrd_create(&t4, (thrd_start_t)&d, NULL);
48
49         thrd_join(t1);
50         thrd_join(t2);
51         thrd_join(t3);
52         thrd_join(t4);
53
54         return 0;
55 }