All pastes #2010668 Raw Edit

Stuff

public text v1 · immutable
#2010668 ·published 2010-12-04 20:55 UTC
rendered paste body
ayourtch@ubuntu:/mnt/store/mongrel2-test/mongrel2-1.4git$ uname -a
Linux ubuntu 2.6.30.2 #11 PREEMPT Wed Jul 22 19:53:31 MDT 2009 armv5tel GNU/Linux
ayourtch@ubuntu:/mnt/store/mongrel2-test/mongrel2-1.4git$ git diff
diff --git a/src/task/context.c b/src/task/context.c
index 33b3f9b..4ae9bd7 100644
--- a/src/task/context.c
+++ b/src/task/context.c
@@ -92,14 +92,15 @@ void makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...)
     
     sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4;
     va_start(arg, argc);
-
-    for(i=0; i<4 && i<argc; i++) {
-        uc->uc_mcontext.gregs[i] = va_arg(arg, uint);
-    }
+    
+    if(argc-- > 0) uc->uc_mcontext.arm_r0 = va_arg(arg, uint);
+    if(argc-- > 0) uc->uc_mcontext.arm_r1 = va_arg(arg, uint);
+    if(argc-- > 0) uc->uc_mcontext.arm_r2 = va_arg(arg, uint);
+    if(argc-- > 0) uc->uc_mcontext.arm_r3 = va_arg(arg, uint);
 
     va_end(arg);
-    uc->uc_mcontext.gregs[13] = (uint)sp;
-    uc->uc_mcontext.gregs[14] = (uint)fn;
+    uc->uc_mcontext.arm_sp = (uint)sp;
+    uc->uc_mcontext.arm_lr = (uint)fn;
 }
 #endif
 
diff --git a/src/task/taskimpl.h b/src/task/taskimpl.h
index 6185552..46f5504 100644
--- a/src/task/taskimpl.h
+++ b/src/task/taskimpl.h
@@ -105,8 +105,8 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*);
 #if defined(__arm__)
 int getmcontext(mcontext_t*);
 void setmcontext(const mcontext_t*);
-#define    setcontext(u)    setmcontext(&(u)->uc_mcontext)
-#define    getcontext(u)    getmcontext(&(u)->uc_mcontext)
+#define    setcontext(u)    setmcontext((void *)&((u)->uc_mcontext.arm_r0))
+#define    getcontext(u)    getmcontext((void *)&((u)->uc_mcontext.arm_r0))
 #endif
 
 typedef struct Context Context;
ayourtch@ubuntu:/mnt/store/mongrel2-test/mongrel2-1.4git$