Since the rfork syscall has gone away, we need to switch lang/go to tfork,
as is done by the following diff. Passes 'make regress' on both amd64 and
i386.

ok?

Index: patches/patch-src_pkg_runtime_sys_openbsd_386_s
===================================================================
RCS file: /cvs/ports/lang/go/patches/patch-src_pkg_runtime_sys_openbsd_386_s,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-src_pkg_runtime_sys_openbsd_386_s
--- patches/patch-src_pkg_runtime_sys_openbsd_386_s     31 Mar 2012 12:37:16 
-0000      1.1.1.1
+++ patches/patch-src_pkg_runtime_sys_openbsd_386_s     15 Apr 2012 04:48:26 
-0000
@@ -1,6 +1,6 @@
 $OpenBSD$
---- src/pkg/runtime/sys_openbsd_386.s.orig     Mon Mar 19 00:13:54 2012
-+++ src/pkg/runtime/sys_openbsd_386.s  Mon Mar 19 00:13:54 2012
+--- src/pkg/runtime/sys_openbsd_386.s.orig     Wed Mar 28 15:49:26 2012
++++ src/pkg/runtime/sys_openbsd_386.s  Fri Mar  2 02:14:56 2012
 @@ -12,14 +12,16 @@
  TEXT runtime·exit(SB),7,$-4
        MOVL    $1, AX
@@ -50,7 +50,7 @@ $OpenBSD$
  TEXT runtime·sigtramp(SB),7,$44
        get_tls(CX)
  
-@@ -174,7 +184,7 @@ TEXT runtime·sigtramp(SB),7,$44
+@@ -174,40 +184,46 @@ TEXT runtime·sigtramp(SB),7,$44
        MOVL    AX, 4(SP)               // arg 1 - sigcontext
        MOVL    $103, AX                // sys_sigreturn
        INT     $0x80
@@ -58,8 +58,61 @@ $OpenBSD$
 +      MOVL    $0xf1, 0xf1             // crash
        RET
  
- // int32 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
-@@ -286,7 +296,7 @@ TEXT runtime·settls(SB),7,$16
+-// int32 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
+-TEXT runtime·rfork_thread(SB),7,$8
+-      MOVL    flags+8(SP), AX
+-      MOVL    stack+12(SP), CX
++// int32 tfork_thread(void *stack, M *m, G *g, void (*fn)(void));
++TEXT runtime·tfork_thread(SB),7,$20
+ 
+       // Copy m, g, fn off parent stack for use by child.
++      MOVL    stack+4(FP), CX
+       SUBL    $16, CX
+-      MOVL    mm+16(SP), SI
++      MOVL    mm+8(FP), SI
+       MOVL    SI, 0(CX)
+-      MOVL    gg+20(SP), SI
++      MOVL    gg+12(FP), SI
+       MOVL    SI, 4(CX)
+-      MOVL    fn+24(SP), SI
++      MOVL    fn+16(FP), SI
+       MOVL    SI, 8(CX)
+       MOVL    $1234, 12(CX)
+       MOVL    CX, SI
+ 
++      LEAL    8(SP), AX
++      MOVL    $0, 0(AX)               // tf_tcb
++      MOVL    $0, 4(AX)               // tf_tid
++      MOVL    $0, 8(AX)               // tf_flags
++
+       MOVL    $0, 0(SP)               // syscall gap
+-      MOVL    AX, 4(SP)               // arg 1 - flags
+-      MOVL    $251, AX                // sys_rfork
++      MOVL    AX, 4(SP)               // arg 1 - params
++      MOVL    $328, AX                // sys_tfork
+       INT     $0x80
+ 
+-      // Return if rfork syscall failed
+-      JCC     4(PC)
++      // Return if tfork syscall failed.
++      JCC     5(PC)
+       NEGL    AX
+-      MOVL    AX, 48(SP)
++      MOVL    ret+0(FP), DX
++      MOVL    AX, 0(DX)
+       RET
+ 
+       // In parent, return.
+       CMPL    AX, $0
+-      JEQ     3(PC)
+-      MOVL    AX, 48(SP)
++      JEQ     4(PC)
++      MOVL    ret+0(FP), DX
++      MOVL    AX, 0(DX)
+       RET
+ 
+       // In child, on new stack.
+@@ -286,7 +302,7 @@ TEXT runtime·settls(SB),7,$16
        MOVL    $165, AX                // sys_sysarch
        INT     $0x80
        JCC     2(PC)
@@ -68,7 +121,7 @@ $OpenBSD$
        RET
  
  TEXT runtime·osyield(SB),7,$-4
-@@ -295,12 +305,12 @@ TEXT runtime·osyield(SB),7,$-4
+@@ -295,12 +311,12 @@ TEXT runtime·osyield(SB),7,$-4
        RET
  
  TEXT runtime·thrsleep(SB),7,$-4
Index: patches/patch-src_pkg_runtime_sys_openbsd_amd64_s
===================================================================
RCS file: /cvs/ports/lang/go/patches/patch-src_pkg_runtime_sys_openbsd_amd64_s,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-src_pkg_runtime_sys_openbsd_amd64_s
--- patches/patch-src_pkg_runtime_sys_openbsd_amd64_s   31 Mar 2012 12:37:16 
-0000      1.1.1.1
+++ patches/patch-src_pkg_runtime_sys_openbsd_amd64_s   15 Apr 2012 04:48:26 
-0000
@@ -1,7 +1,41 @@
 $OpenBSD$
---- src/pkg/runtime/sys_openbsd_amd64.s.orig   Mon Mar 19 00:13:54 2012
-+++ src/pkg/runtime/sys_openbsd_amd64.s        Mon Mar 19 00:13:54 2012
-@@ -53,7 +53,8 @@ TEXT runtime·rfork_thread(SB),7,$0
+--- src/pkg/runtime/sys_openbsd_amd64.s.orig   Wed Mar 28 15:49:26 2012
++++ src/pkg/runtime/sys_openbsd_amd64.s        Fri Mar  2 02:03:18 2012
+@@ -8,20 +8,23 @@
+ 
+ #include "zasm_GOOS_GOARCH.h"
+ 
+-// int64 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
+-TEXT runtime·rfork_thread(SB),7,$0
+-      MOVL    flags+8(SP), DI
+-      MOVQ    stack+16(SP), SI
++// int64 tfork_thread(void *stack, M *m, G *g, void (*fn)(void));
++TEXT runtime·tfork_thread(SB),7,$32
+ 
+-      // Copy m, g, fn off parent stack for use by child.
+-      MOVQ    mm+24(SP), R8
+-      MOVQ    gg+32(SP), R9
+-      MOVQ    fn+40(SP), R12
++      // Copy stack, m, g, fn off parent stack for use by child.
++      MOVQ    stack+0(FP), SI
++      MOVQ    mm+8(FP), R8
++      MOVQ    gg+16(FP), R9
++      MOVQ    fn+24(FP), R12
+ 
+-      MOVL    $251, AX                // sys_rfork
++      LEAQ    8(SP), DI
++      MOVQ    $0, 0(DI)               // tf_tcb
++      MOVQ    $0, 8(DI)               // tf_tid
++      MOVL    $0, 16(DI)              // tf_flags
++      MOVL    $328, AX                // sys___tfork
+       SYSCALL
+ 
+-      // Return if rfork syscall failed
++      // Return if tfork syscall failed
+       JCC     3(PC)
+       NEGL    AX
+       RET
+@@ -53,7 +56,8 @@ TEXT runtime·rfork_thread(SB),7,$0
        CALL    R12
  
        // It shouldn't return.  If it does, exit
@@ -11,7 +45,7 @@ $OpenBSD$
        SYSCALL
        JMP     -3(PC)                  // keep exiting
  
-@@ -67,14 +68,15 @@ TEXT runtime·thrsleep(SB),7,$0
+@@ -67,14 +71,15 @@ TEXT runtime·thrsleep(SB),7,$0
        MOVL    16(SP), SI              // arg 2 - clock_id
        MOVQ    24(SP), DX              // arg 3 - tp
        MOVQ    32(SP), R10             // arg 4 - lock
@@ -29,7 +63,7 @@ $OpenBSD$
        SYSCALL
        RET
  
-@@ -83,13 +85,14 @@ TEXT runtime·exit(SB),7,$-8
+@@ -83,13 +88,14 @@ TEXT runtime·exit(SB),7,$-8
        MOVL    8(SP), DI               // arg 1 - exit status
        MOVL    $1, AX                  // sys_exit
        SYSCALL
@@ -47,7 +81,7 @@ $OpenBSD$
        RET
  
  TEXT runtime·write(SB),7,$-8
-@@ -140,7 +143,7 @@ TEXT time·now(SB), 7, $32
+@@ -140,7 +146,7 @@ TEXT time·now(SB), 7, $32
        MOVL    $116, AX                // sys_gettimeofday
        SYSCALL
        MOVQ    8(SP), AX               // sec
@@ -56,7 +90,7 @@ $OpenBSD$
  
        // sec is in AX, usec in DX
        MOVQ    AX, sec+0(FP)
-@@ -154,7 +157,7 @@ TEXT runtime·nanotime(SB),7,$32
+@@ -154,7 +160,7 @@ TEXT runtime·nanotime(SB),7,$32
        MOVL    $116, AX                // sys_gettimeofday
        SYSCALL
        MOVQ    8(SP), AX               // sec
@@ -65,7 +99,7 @@ $OpenBSD$
  
        // sec is in AX, usec in DX
        // return nsec in AX
-@@ -170,9 +173,19 @@ TEXT runtime·sigaction(SB),7,$-8
+@@ -170,9 +176,19 @@ TEXT runtime·sigaction(SB),7,$-8
        MOVL    $46, AX
        SYSCALL
        JCC     2(PC)
@@ -86,7 +120,7 @@ $OpenBSD$
  TEXT runtime·sigtramp(SB),7,$64
        get_tls(BX)
        
-@@ -226,7 +239,7 @@ TEXT runtime·munmap(SB),7,$0
+@@ -226,7 +242,7 @@ TEXT runtime·munmap(SB),7,$0
        MOVL    $73, AX                 // sys_munmap
        SYSCALL
        JCC     2(PC)
@@ -95,7 +129,7 @@ $OpenBSD$
        RET
  
  TEXT runtime·sigaltstack(SB),7,$-8
-@@ -235,7 +248,7 @@ TEXT runtime·sigaltstack(SB),7,$-8
+@@ -235,7 +251,7 @@ TEXT runtime·sigaltstack(SB),7,$-8
        MOVQ    $288, AX                // sys_sigaltstack
        SYSCALL
        JCC     2(PC)
@@ -104,7 +138,7 @@ $OpenBSD$
        RET
  
  // set tls base to DI
-@@ -248,7 +261,7 @@ TEXT runtime·settls(SB),7,$8
+@@ -248,7 +264,7 @@ TEXT runtime·settls(SB),7,$8
        MOVQ    $165, AX                // sys_sysarch
        SYSCALL
        JCC     2(PC)
@@ -113,7 +147,7 @@ $OpenBSD$
        RET
  
  TEXT runtime·sysctl(SB),7,$0
-@@ -260,7 +273,7 @@ TEXT runtime·sysctl(SB),7,$0
+@@ -260,7 +276,7 @@ TEXT runtime·sysctl(SB),7,$0
        MOVQ    48(SP), R9              // arg 6 - newlen
        MOVQ    $202, AX                // sys___sysctl
        SYSCALL
Index: patches/patch-src_pkg_runtime_thread_openbsd_c
===================================================================
RCS file: /cvs/ports/lang/go/patches/patch-src_pkg_runtime_thread_openbsd_c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-src_pkg_runtime_thread_openbsd_c
--- patches/patch-src_pkg_runtime_thread_openbsd_c      31 Mar 2012 12:37:16 
-0000      1.1.1.1
+++ patches/patch-src_pkg_runtime_thread_openbsd_c      15 Apr 2012 04:48:26 
-0000
@@ -1,15 +1,16 @@
 $OpenBSD$
---- src/pkg/runtime/thread_openbsd.c.orig      Mon Mar 19 00:13:54 2012
-+++ src/pkg/runtime/thread_openbsd.c   Mon Mar 19 00:13:54 2012
+--- src/pkg/runtime/thread_openbsd.c.orig      Wed Mar 28 15:49:26 2012
++++ src/pkg/runtime/thread_openbsd.c   Fri Mar  2 02:03:18 2012
 @@ -20,8 +20,11 @@ enum
  
  extern SigTab runtime·sigtab[];
  
+-extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void 
(*fn)(void));
+-extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void 
*lock);
 +static Sigset sigset_all = ~(Sigset)0;
 +static Sigset sigset_none;
 +
- extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void 
(*fn)(void));
--extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void 
*lock);
++extern int64 runtime·tfork_thread(void *stack, M *m, G *g, void (*fn)(void));
 +extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void 
*lock, const int32 *abort);
  extern int32 runtime·thrwakeup(void *ident, int32 n);
  
@@ -29,28 +30,44 @@ $OpenBSD$
                        }
                        // reacquire lock
                        while(runtime·xchg(&m->waitsemalock, 1))
-@@ -128,6 +131,7 @@ runtime·semawakeup(M *mp)
+@@ -119,21 +122,13 @@ runtime·semawakeup(M *mp)
+       runtime·atomicstore(&mp->waitsemalock, 0);
+ }
+ 
+-// From OpenBSD's sys/param.h
+-#define       RFPROC          (1<<4)  /* change child (else changes curproc) 
*/
+-#define       RFMEM           (1<<5)  /* share `address space' */
+-#define       RFNOWAIT        (1<<6)  /* parent need not wait() on child */
+-#define       RFTHREAD        (1<<13) /* create a thread, not a process */
+-
  void
  runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
  {
+-      int32 flags;
 +      Sigset oset;
-       int32 flags;
        int32 ret;
  
-@@ -141,7 +145,11 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(v
+-      flags = RFPROC | RFTHREAD | RFMEM | RFNOWAIT;
+-
+-      if (0) {
++      if(0) {
+               runtime·printf(
+                       "newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
+                       stk, m, g, fn, m->id, m->tls[0], &m);
+@@ -141,7 +136,11 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(v
  
        m->tls[0] = m->id;      // so 386 asm can find it
  
 -      if((ret = runtime·rfork_thread(flags, stk, m, g, fn)) < 0) {
 +      oset = runtime·sigprocmask(SIG_SETMASK, sigset_all);
-+      ret = runtime·rfork_thread(flags, stk, m, g, fn);
++      ret = runtime·tfork_thread(stk, m, g, fn);
 +      runtime·sigprocmask(SIG_SETMASK, oset);
 +
 +      if(ret < 0) {
                runtime·printf("runtime: failed to create new OS thread (have 
%d already; errno=%d)\n", runtime·mcount() - 1, -ret);
                if (ret == -ENOTSUP)
                        runtime·printf("runtime: is kern.rthreads 
disabled?\n");
-@@ -168,6 +176,7 @@ runtime·minit(void)
+@@ -168,6 +167,7 @@ runtime·minit(void)
        // Initialize signal handling
        m->gsignal = runtime·malg(32*1024);
        runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);

-- 

    "Reason is not automatic. Those who deny it cannot be conquered by it.
     Do not count on them. Leave them alone." -- Ayn Rand

Reply via email to