int thrd_yield(void);
thrd_t thrd_current(void);
- void user_main(void);
+ int user_main(int, char**);
#ifdef __cplusplus
}
int main_argc;
char **main_argv;
+/** Wrapper to run the user's main function, with appropriate arguments */
+void wrapper_user_main(void *)
+{
+ user_main(main_argc, main_argv);
+}
+
/** The model_main function contains the main model checking loop. */
static void model_main() {
thrd_t user_thread;
snapshotObject->snapshotStep(0);
do {
/* Start user program */
- model->add_thread(new Thread(&user_thread, (void (*)(void *)) &user_main, NULL));
+ model->add_thread(new Thread(&user_thread, &wrapper_user_main, NULL));
/* Wait for all threads to complete */
model->finish_execution();
atomic_store_explicit(&x, 2, memory_order_relaxed);
}
-void user_main()
+int user_main(int argc, char **argv)
{
thrd_t t1, t2, t3, t4;
thrd_join(t3);
thrd_join(t4);
printf("Thread %d is finished\n", thrd_current());
+
+ return 0;
}
}
}
-void user_main()
+int user_main(int argc, char **argv)
{
thrd_t t1, t2;
atomic_init(&mylock.lock, RW_LOCK_BIAS);
thrd_join(t1);
thrd_join(t2);
+
+ return 0;
}
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;
thrd_join(t1);
thrd_join(t2);
thrd_join(t5);
+
+ return 0;
}
atomic_store_explicit(&x, 2, memory_order_relaxed);
}
-void user_main()
+int user_main(int argc, char **argv)
{
thrd_t t1, t2, t3;
thrd_join(t2);
thrd_join(t3);
printf("Thread %d is finished\n", thrd_current());
+
+ return 0;
}
atomic_fetch_add_explicit(&x, 1, memory_order_relaxed);
}
-void user_main()
+int user_main(int argc, char **argv)
{
thrd_t t1, t2;
thrd_join(t1);
thrd_join(t2);
+
+ return 0;
}
printf("r2=%u\n",r2);
}
-void user_main()
+int user_main(int argc, char **argv)
{
thrd_t t1, t2;
thrd_join(t1);
thrd_join(t2);
printf("Thread %d is finished\n", thrd_current());
+
+ return 0;
}