aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/386.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread/386.c')
-rw-r--r--src/libthread/386.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libthread/386.c b/src/libthread/386.c
new file mode 100644
index 00000000..2f391bff
--- /dev/null
+++ b/src/libthread/386.c
@@ -0,0 +1,21 @@
+#include "threadimpl.h"
+
+static void
+launcher386(void (*f)(void *arg), void *arg)
+{
+ (*f)(arg);
+ threadexits(nil);
+}
+
+void
+_threadinitstack(Thread *t, void (*f)(void*), void *arg)
+{
+ ulong *tos;
+
+ tos = (ulong*)&t->stk[t->stksize&~7];
+ *--tos = (ulong)arg;
+ *--tos = (ulong)f;
+ t->sched.pc = (ulong)launcher386;
+ t->sched.sp = (ulong)tos - 8; /* old PC and new PC */
+}
+