From ba940ae61c4c33766e385b63ecf49bec25f301d7 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 18 Nov 2009 04:12:17 -0500 Subject: libthread: context switching for arm, still not complete --- src/libthread/Linux-arm-swapcontext.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/libthread/Linux-arm-swapcontext.c (limited to 'src/libthread/Linux-arm-swapcontext.c') 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 && iuc_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; +} + + -- cgit v1.2.3