From 041c96ed89a8e1a583b416180977b0ce5b9b8d48 Mon Sep 17 00:00:00 2001 From: Matthew Sotoudeh Date: Tue, 28 May 2024 14:59:23 -0700 Subject: Libimc dump --- libptimc/libptimc.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libptimc/libptimc.h (limited to 'libptimc/libptimc.h') diff --git a/libptimc/libptimc.h b/libptimc/libptimc.h new file mode 100644 index 0000000..c6314dd --- /dev/null +++ b/libptimc/libptimc.h @@ -0,0 +1,49 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#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 -- cgit v1.2.3