diff options
Diffstat (limited to 'src/libthread/thread.c')
-rw-r--r-- | src/libthread/thread.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 2b6d1e37..b886e30b 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -169,6 +169,7 @@ _threadswitch(void) { Proc *p; + needstack(0); p = proc(); //print("threadswtch %p\n", p); contextswitch(&p->thread->context, &p->schedcontext); @@ -324,6 +325,20 @@ threadsetstate(char *fmt, ...) va_end(arg); } +void +needstack(int n) +{ + _Thread *t; + + t = proc()->thread; + + if((char*)&t <= (char*)t->stk + || (char*)&t - (char*)t->stk < 256+n){ + fprint(2, "thread stack overflow\n"); + abort(); + } +} + /* * locking */ @@ -499,11 +514,6 @@ threadmainstart(void *v) threadmain(threadargc, threadargv); } -void -threadlinklibrary(void) -{ -} - int main(int argc, char **argv) { |