aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/arm-ucontext.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread/arm-ucontext.c')
-rw-r--r--src/libthread/arm-ucontext.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libthread/arm-ucontext.c b/src/libthread/arm-ucontext.c
new file mode 100644
index 00000000..512ca973
--- /dev/null
+++ b/src/libthread/arm-ucontext.c
@@ -0,0 +1,24 @@
+#include "threadimpl.h"
+
+void
+makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...)
+{
+ int i, *sp;
+ va_list arg;
+
+ sp = USPALIGN(uc, 4);
+ va_start(arg, argc);
+ for(i=0; i<4 && i<argc; i++)
+ (&uc->uc_mcontext.arm_r0)[i] = va_arg(arg, uint);
+ va_end(arg);
+ uc->uc_mcontext.arm_sp = (uint)sp;
+ uc->uc_mcontext.arm_lr = (uint)fn;
+}
+
+int
+swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
+{
+ if(getcontext(oucp) == 0)
+ setcontext(ucp);
+ return 0;
+}