1 #include "threadimpl.h"
3 * To use this you need some patches to Valgrind that
4 * let it help out with detecting stack overflow.
8 #include <valgrind/memcheck.h>
12 launcher386(void (*f)(void *arg), void *arg)
19 _threadstacklimit(t->stk);
26 _threadinitstack(Thread *t, void (*f)(void*), void *arg)
30 tos = (ulong*)&t->stk[t->stksize&~7];
33 t->sched.pc = (ulong)launcher386;
34 t->sched.sp = (ulong)tos - 8; /* old PC and new PC */
38 _threadinswitch(int enter)
43 VALGRIND_SET_STACK_LIMIT(0, 0, 1);
45 VALGRIND_SET_STACK_LIMIT(0, 0, 0);
50 _threadstacklimit(void *addr)
55 VALGRIND_SET_STACK_LIMIT(1, addr, 0);