$OpenBSD: patch-j2sdk1_3_1_src_solaris_hpi_green_threads_src_context_c,v 1.4 2007/07/18 14:19:27 kurt Exp $
--- j2sdk1.3.1/src/solaris/hpi/green_threads/src/context.c.orig	Wed Jul 18 09:36:12 2007
+++ j2sdk1.3.1/src/solaris/hpi/green_threads/src/context.c	Wed Jul 18 09:36:14 2007
@@ -183,7 +183,7 @@ currentStackPointer(sys_thread_t *tp)
 #if (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
     context_t *context = &tp->mdcontext;
     lj_ucontext_t *uc = &(context->lj_ucontext);
-#if defined(__NetBSD__) && defined(__powerpc__)
+#if defined(__powerpc__)
     return (void *)CONTEXT(tp)->current_sp;
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
     return (void *)(uc->jmpbuf[BSD_STACK_POINTER]);
@@ -579,7 +579,60 @@ initContext(lj_ucontext_t *uc, gstack_t *stack, unsign
     uc->jmpbuf->_sjb[35] = (long)0xACEDBADD;	/* magic number for longjmp */
 }
 
-#elif defined(__NetBSD__) && defined(__powerpc__)
+#elif defined(__OpenBSD__) && defined(__arm__)
+
+void
+initContext(lj_ucontext_t *uc, gstack_t *stack, unsigned int pc,
+         void (*death_func)(void), unsigned int arg)
+{
+    unsigned char *sp;
+    int *p;
+
+    memset(uc, 0, sizeof(lj_ucontext_t));
+
+    sp = (unsigned char *)stack->base;
+    sp -= sizeof(sys_thread_t *);
+    /* Force sp to be double aligned! */
+    sp = (unsigned char *)((unsigned long)(sp) & ~7L);
+
+    uc->pc = pc;
+    uc->arg = arg;
+
+    uc->jmpbuf[BSD_MAGIC] = (unsigned int)0x4278f501;
+    uc->jmpbuf[BSD_LINK_REGISTER] = (unsigned int)death_func;
+    uc->jmpbuf[BSD_STACK_POINTER] = (unsigned int)sp;
+
+    /* break back chain */
+    p = (int *)sp;
+    *p-- = (int ) 0;
+}
+
+#elif defined(__OpenBSD__) && defined(__sparc__)
+
+void
+initContext(lj_ucontext_t *uc, gstack_t *stack, unsigned int pc,
+         void (*death_func)(void), unsigned int arg)
+{
+    unsigned char *sp;
+    int *p;
+
+    getcontext(uc);
+
+    sp = (unsigned char *)stack->base;
+    sp -= (sizeof(sys_thread_t *) + WINDOWSIZE + SA(MINFRAME));
+    /* Force sp to be double aligned! */
+    sp = (unsigned char *)((unsigned long)(sp) & ~7L);
+
+    uc->pc = pc;
+    uc->arg = arg;
+
+    uc->jmpbuf[BSD_STACK_POINTER] = (unsigned int)sp;
+    uc->jmpbuf[BSD_PC] = (unsigned int)death_func;
+    uc->jmpbuf[BSD_nPC] = (unsigned int)death_func+4;
+
+}
+
+#elif (defined(__NetBSD__) || defined(__OpenBSD__)) && defined(__powerpc__)
 
 /* NetBSD/powerpc version */
 
