5 #include "threadimpl.h"
7 * To use this you need some patches to Valgrind that
8 * let it help out with detecting stack overflow.
11 #include <valgrind/memcheck.h>
15 launcher386(void (*f)(void *arg), void *arg)
22 _threadstacklimit(t->stk, t->stk+t->stksize);
29 _threadinitstack(Thread *t, void (*f)(void*), void *arg)
33 tos = (ulong*)&t->stk[t->stksize&~7];
36 t->sched.pc = (ulong)launcher386;
37 t->sched.sp = (ulong)tos - 8; /* old PC and new PC */
41 _threadinswitch(int enter)
46 VALGRIND_SET_STACK_LIMIT(0, 0, 0);
48 VALGRIND_SET_STACK_LIMIT(0, 0, 1);
53 _threadstacklimit(void *bottom, void *top)
59 VALGRIND_SET_STACK_LIMIT(1, bottom, top);