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