diff options
| author | Russ Cox <rsc@swtch.com> | 2009-11-18 04:12:17 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@swtch.com> | 2009-11-18 04:12:17 -0500 |
| commit | ba940ae61c4c33766e385b63ecf49bec25f301d7 (patch) | |
| tree | a2e97d18eff26dffb32306ae6cf18af14c6bc6ce /src/libthread/Linux-arm-swapcontext.c | |
| parent | 778ec84c9c817be65404193e2156c8fdb90b846a (diff) | |
| download | plan9port-ba940ae61c4c33766e385b63ecf49bec25f301d7.tar.gz plan9port-ba940ae61c4c33766e385b63ecf49bec25f301d7.zip | |
libthread: context switching for arm, still not complete
Diffstat (limited to 'src/libthread/Linux-arm-swapcontext.c')
| -rw-r--r-- | src/libthread/Linux-arm-swapcontext.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libthread/Linux-arm-swapcontext.c b/src/libthread/Linux-arm-swapcontext.c new file mode 100644 index 00000000..43358800 --- /dev/null +++ b/src/libthread/Linux-arm-swapcontext.c @@ -0,0 +1,26 @@ +#include "threadimpl.h" + +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[i] = va_arg(arg, uint); + va_end(arg); + uc->uc_mcontext.gregs[13] = (uint)sp; + uc->uc_mcontext.gregs[14] = (uint)fn; +} + +int +swapcontext(ucontext_t *oucp, const ucontext_t *ucp) +{ + if(getcontext(oucp) == 0) + setcontext(ucp); + return 0; +} + + |
