Permalink
Browse files

Merge pull request #228 from limburgher/master

Patch for ARM builds
  • Loading branch information...
2 parents 10badbd + bbddc60 commit bb02b5101c07328743c0f00cfcf2e2b64eea85a7 @stevedekorte stevedekorte committed Sep 22, 2012
Showing with 10 additions and 6 deletions.
  1. +8 −4 libs/coroutine/source/context.c
  2. +2 −2 libs/coroutine/source/taskimpl.h
View
12 libs/coroutine/source/context.c
@@ -100,11 +100,15 @@ 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
View
4 libs/coroutine/source/taskimpl.h
@@ -143,8 +143,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
/*

0 comments on commit bb02b51

Please sign in to comment.