diff options
| author | rsc <devnull@localhost> | 2005-11-01 18:35:44 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2005-11-01 18:35:44 +0000 |
| commit | f51bf048784abd642dea4f033bc95acbd4468b6a (patch) | |
| tree | 76f75b1e48b8955250867b69fe404c60cd3db484 /src/libthread/Linux.c | |
| parent | 48ca8d21f75b734a15091b77abf5ed4a92be90f2 (diff) | |
arm
Diffstat (limited to 'src/libthread/Linux.c')
| -rw-r--r-- | src/libthread/Linux.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libthread/Linux.c b/src/libthread/Linux.c index dab12d3f..5d033248 100644 --- a/src/libthread/Linux.c +++ b/src/libthread/Linux.c @@ -436,3 +436,43 @@ _threadpexit(void) _exit(0); } +#ifdef __arm__ +extern int getmcontext(mcontext_t*); +extern int setmcontext(const mcontext_t*); + +void +makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) +{ + int i, *sp; + va_list arg; + + 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[0] = va_arg(arg, uint); + uc->uc_mcontext.gregs[13] = (uint)sp; + uc->uc_mcontext.gregs[14] = (uint)fn; +} + +int +getcontext(ucontext_t *uc) +{ + return getmcontext(&uc->uc_mcontext); +} + +int +setcontext(const ucontext_t *uc) +{ + setmcontext(&uc->uc_mcontext); + return 0; /* not reached */ +} + +int +swapcontext(ucontext_t *oucp, const ucontext_t *ucp) +{ + if(getcontext(oucp) == 0) + setcontext(ucp); + return 0; +} +#endif + |