cyclegraph: return 'added' status for addEdge()
[c11tester.git] / libthreads.cc
1 #include <threads.h>
2 #include "common.h"
3 #include "threads-model.h"
4
5 /* global "model" object */
6 #include "model.h"
7
8 /*
9  * User program API functions
10  */
11 int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg)
12 {
13         Thread *thread;
14         thread = new Thread(t, start_routine, arg);
15         model->add_thread(thread);
16         /* seq_cst is just a 'don't care' parameter */
17         model->switch_to_master(new ModelAction(THREAD_CREATE, std::memory_order_seq_cst, thread, VALUE_NONE));
18         return 0;
19 }
20
21 int thrd_join(thrd_t t)
22 {
23         Thread *th = t.priv;
24         model->switch_to_master(new ModelAction(THREAD_JOIN, std::memory_order_seq_cst, th, id_to_int(thrd_to_id(t))));
25         return 0;
26 }
27
28 /** A no-op, for now */
29 void thrd_yield(void)
30 {
31         //model->switch_to_master(new ModelAction(THREAD_YIELD, std::memory_order_seq_cst, thread_current(), VALUE_NONE));
32 }
33
34 thrd_t thrd_current(void)
35 {
36         return thread_current()->get_thrd_t();
37 }