summaryrefslogtreecommitdiff
path: root/libptimc/libptimc.h
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-05-28 14:59:23 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-05-28 14:59:23 -0700
commit041c96ed89a8e1a583b416180977b0ce5b9b8d48 (patch)
treee70f3402a7fe634a30c8a7aa03cd61786332f500 /libptimc/libptimc.h
Libimc dumpHEADmaster
Diffstat (limited to 'libptimc/libptimc.h')
-rw-r--r--libptimc/libptimc.h49
1 files changed, 49 insertions, 0 deletions
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 <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
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback