Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 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