xref: /plan9/sys/src/libthread/386.c (revision ff8c3af2f44d95267f67219afa20ba82ff6cf7e4)
1 #include <u.h>
2 #include <libc.h>
3 #include <thread.h>
4 #include "threadimpl.h"
5 
6 static void
7 launcher386(void (*f)(void *arg), void *arg)
8 {
9 	(*f)(arg);
10 	threadexits(nil);
11 }
12 
13 void
14 _threadinitstack(Thread *t, void (*f)(void*), void *arg)
15 {
16 	ulong *tos;
17 
18 	tos = (ulong*)&t->stk[t->stksize&~7];
19 	*--tos = (ulong)arg;
20 	*--tos = (ulong)f;
21 	t->sched[JMPBUFPC] = (ulong)launcher386+JMPBUFDPC;
22 	t->sched[JMPBUFSP] = (ulong)tos - 8;		/* old PC and new PC */
23 }
24 
25