]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: implement getcontext and sigprocmask for netbsd
authorJoel Sing <jsing@google.com>
Tue, 15 May 2012 18:32:49 +0000 (04:32 +1000)
committerJoel Sing <jsing@google.com>
Tue, 15 May 2012 18:32:49 +0000 (04:32 +1000)
Implement getcontext and sigprocmask for NetBSD - these will soon be
used by the thread handling code.

Also fix netbsd/386 signal handling - there is no sigreturn, just
return so that we hit the trampoline.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6215049

src/pkg/runtime/os_netbsd.h
src/pkg/runtime/sys_netbsd_386.s
src/pkg/runtime/sys_netbsd_amd64.s

index 4ecf78d882f21598b600254252522baa59c6b784..50983a3e5eae7154bbea0e9c152f68eddaec10d4 100644 (file)
@@ -5,17 +5,22 @@
 #define SIG_DFL ((void*)0)
 #define SIG_IGN ((void*)1)
 
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
+#define SIG_SETMASK 3
+
 struct sigaction;
 
-void   runtime·sigpanic(void);
-void   runtime·sigaltstack(Sigaltstack*, Sigaltstack*);
-void   runtime·sigaction(int32, struct sigaction*, struct sigaction*);
+void   runtime·raisesigpipe(void);
 void   runtime·setsig(int32, void(*)(int32, Siginfo*, void*, G*), bool);
 void   runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp);
+void   runtime·sigpanic(void);
+
+void   runtime·sigaction(int32, struct sigaction*, struct sigaction*);
+void   runtime·sigaltstack(Sigaltstack*, Sigaltstack*);
 void   runtime·setitimer(int32, Itimerval*, Itimerval*);
+void   runtime·sigprocmask(int32, Sigset*, Sigset*);
 int32  runtime·sysctl(uint32*, uint32, byte*, uintptr*, byte*, uintptr);
 
-void   runtime·raisesigpipe(void);
-
 #define        NSIG 33
 #define        SI_USER 0
index 9b99807ad6d5ee5c08d82d8e84fa880336851cd4..d88467ceff0f0afef5f99fe880d9554e16675b6a 100644 (file)
@@ -122,12 +122,26 @@ TEXT runtime·nanotime(SB),7,$32
        IMULL   $1000, BX
        ADDL    BX, AX
        ADCL    $0, DX
-       
+
        MOVL    ret+0(FP), DI
        MOVL    AX, 0(DI)
        MOVL    DX, 4(DI)
        RET
 
+TEXT runtime·getcontext(SB),7,$-4
+       MOVL    $307, AX                // sys_getcontext
+       INT     $0x80
+       JAE     2(PC)
+       MOVL    $0xf1, 0xf1             // crash
+       RET
+
+TEXT runtime·sigprocmask(SB),7,$-4
+       MOVL    $293, AX                // sys_sigprocmask
+       INT     $0x80
+       JAE     2(PC)
+       MOVL    $0xf1, 0xf1             // crash
+       RET
+
 TEXT runtime·sigreturn_tramp(SB),7,$0
        LEAL    140(SP), AX             // Load address of ucontext
        MOVL    AX, 4(SP)
@@ -166,7 +180,7 @@ TEXT runtime·sigtramp(SB),7,$44
        // save g
        MOVL    g(CX), DI
        MOVL    DI, 20(SP)
-       
+
        // g = m->gsignal
        MOVL    m_gsignal(BX), BX
        MOVL    BX, g(CX)
@@ -186,14 +200,6 @@ TEXT runtime·sigtramp(SB),7,$44
        get_tls(CX)
        MOVL    20(SP), BX
        MOVL    BX, g(CX)
-       
-       // call sigreturn
-       MOVL    context+8(FP), AX
-       MOVL    $0, 0(SP)               // syscall gap
-       MOVL    AX, 4(SP)               // arg 1 - sigcontext
-       MOVL    $103, AX                // sys_sigreturn
-       INT     $0x80
-       MOVL    $0xf1, 0xf1             // crash
        RET
 
 // int32 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
@@ -255,7 +261,7 @@ TEXT runtime·rfork_thread(SB),7,$8
        CALL    runtime·settls(SB)
        POPL    AX
        POPAL
-       
+
        // Now segment is established.  Initialize m, g.
        get_tls(AX)
        MOVL    DX, g(AX)
index c57d413bc494d3325c928b6eab78573b0efa9637..940eb226755d71486b4c4168a73b3e701b4b2bcd 100644 (file)
@@ -163,6 +163,24 @@ TEXT runtime·nanotime(SB),7,$32
        ADDQ    DX, AX
        RET
 
+TEXT runtime·getcontext(SB),7,$-8
+       MOVQ    8(SP), DI               // arg 1 - context
+       MOVL    $307, AX                // sys_getcontext
+       SYSCALL
+       JCC     2(PC)
+       MOVL    $0xf1, 0xf1             // crash
+       RET
+
+TEXT runtime·sigprocmask(SB),7,$0
+       MOVL    8(SP), DI               // arg 1 - how
+       MOVQ    16(SP), SI              // arg 2 - set
+       MOVQ    24(SP), DX              // arg 3 - oset
+       MOVL    $293, AX                // sys_sigprocmask
+       SYSCALL
+       JCC     2(PC)
+       MOVL    $0xf1, 0xf1             // crash
+       RET
+
 TEXT runtime·sigreturn_tramp(SB),7,$-8
        MOVQ    R15, DI                 // Load address of ucontext
        MOVQ    $308, AX                // sys_setcontext
@@ -186,7 +204,7 @@ TEXT runtime·sigaction(SB),7,$-8
 
 TEXT runtime·sigtramp(SB),7,$64
        get_tls(BX)
-       
+
        // check that m exists
        MOVQ    m(BX), BP
        CMPQ    BP, $0
@@ -196,16 +214,16 @@ TEXT runtime·sigtramp(SB),7,$64
        // save g
        MOVQ    g(BX), R10
        MOVQ    R10, 40(SP)
-       
+
        // g = m->signal
        MOVQ    m_gsignal(BP), BP
        MOVQ    BP, g(BX)
-       
+
        MOVQ    DI, 0(SP)
        MOVQ    SI, 8(SP)
        MOVQ    DX, 16(SP)
        MOVQ    R10, 24(SP)
-       
+
        CALL    runtime·sighandler(SB)
 
        // restore g