Fix snapshot code
[model-checker.git] / test / pending-release.c
index 37433b150fb5ed7163d31d69aaf3876997cf37c9..a68f24dfc7b005fd279e9c4c7078d25baedc6598 100644 (file)
@@ -6,15 +6,17 @@
  */
 
 #include <stdio.h>
+#include <threads.h>
+#include <stdatomic.h>
 
-#include "libthreads.h"
 #include "librace.h"
-#include "stdatomic.h"
 
 atomic_int x;
+int var = 0;
 
 static void a(void *obj)
 {
+       store_32(&var, 1);
        atomic_store_explicit(&x, *((int *)obj), memory_order_release);
        atomic_store_explicit(&x, *((int *)obj) + 1, memory_order_relaxed);
 }
@@ -22,7 +24,8 @@ static void a(void *obj)
 static void b2(void *obj)
 {
        int r = atomic_load_explicit(&x, memory_order_acquire);
-       printf("r = %u\n", r);
+       printf("r = %d\n", r);
+       store_32(&var, 3);
 }
 
 static void b1(void *obj)
@@ -30,7 +33,8 @@ static void b1(void *obj)
        thrd_t t3, t4;
        int i = 7;
        int r = atomic_load_explicit(&x, memory_order_acquire);
-       printf("r = %u\n", r);
+       printf("r = %d\n", r);
+       store_32(&var, 2);
        thrd_create(&t3, (thrd_start_t)&a, &i);
        thrd_create(&t4, (thrd_start_t)&b2, NULL);
        thrd_join(t3);
@@ -42,7 +46,7 @@ static void c(void *obj)
        atomic_store_explicit(&x, 22, memory_order_relaxed);
 }
 
-void user_main()
+int user_main(int argc, char **argv)
 {
        thrd_t t1, t2, t5;
        int i = 4;
@@ -56,4 +60,6 @@ void user_main()
        thrd_join(t1);
        thrd_join(t2);
        thrd_join(t5);
+
+       return 0;
 }