I need to make some bigger changes to Thread allocation, so we'll need
to modify the storage of thrd_t.
#ifndef __THREADS_H__
#define __THREADS_H__
+/* Forward declaration */
+struct Thread; /* actually, class; but this is safe */
+
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*thrd_start_t)(void *);
- typedef int thrd_t;
+ typedef struct {
+ struct Thread *priv;
+ } thrd_t;
int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg);
int thrd_join(thrd_t);
int thrd_join(thrd_t t)
{
- Thread *th = model->get_thread(thrd_to_id(t));
+ Thread *th = t.priv;
model->switch_to_master(new ModelAction(THREAD_JOIN, std::memory_order_seq_cst, th, id_to_int(thrd_to_id(t))));
return 0;
}
static inline thread_id_t thrd_to_id(thrd_t t)
{
- return t;
+ return t.priv->get_id();
}
/**
model_print("Error in create_context\n");
id = model->get_next_id();
- *user_thread = id;
+ user_thread->priv = this;
parent = thread_current();
}