-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibptimc.h
49 lines (38 loc) · 983 Bytes
/
libptimc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ucontext.h>
#include "libimc.h"
enum thread_state {
THREAD_STATE_FETUS,
THREAD_STATE_ALIVE,
THREAD_STATE_DEAD,
};
typedef struct imcthread {
void *(*fn)(void *);
void *arg;
enum thread_state state;
int id;
struct imcthread *waiting_on;
void *retval;
ucontext_t ctx;
} *imcthread_t;
typedef int imcthread_attr_t;
int imcthread_create(imcthread_t *thread,
// only support NULL attr for now
imcthread_attr_t *attr,
void *(*start_routine)(void *),
void *arg);
int imcthread_yield(void);
int imcthread_join(imcthread_t thread, void **retval);
int imcthread_yieldh(hash_t hash);
int imcthread_joinh(imcthread_t thread, void **retval, hash_t hash);
void check_main(void);
extern void imc_check_main(void);
#ifdef __cplusplus
}
#endif