From 6cbe2a73019921978dae6a3c5cf98ed38268db9c Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 28 May 2002 13:59:24 +0000 Subject: [PATCH] create_thread now reserves room for PR on the stack git-svn-id: svn://svn.rockbox.org/rockbox/trunk@762 a1c6a512-1295-4272-9138-f99709370657 --- firmware/thread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/firmware/thread.c b/firmware/thread.c index e358079aba..77fdb06ec9 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -36,7 +36,7 @@ typedef struct { int created; int current; - ctx_t ctx[MAXTHREADS] __attribute__ ((aligned (32))); + ctx_t ctx[MAXTHREADS]; } thread_t; static thread_t threads = {1, 0}; @@ -118,7 +118,9 @@ int create_thread(void* fp, void* sp, int stk_size) { ctx_t* ctxp = &t->ctx[t->created++]; stctx(ctxp); - ctxp->regs.sp = (void*)(((unsigned int)sp + stk_size) & ~31); + /* Subtract 4 to leave room for the PR push in ldctx() + Align it on an even 32 bit boundary */ + ctxp->regs.sp = (void*)(((unsigned int)sp + stk_size - 4) & ~3; ctxp->regs.pr = fp; } return 0;