#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
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)
// save g
MOVL g(CX), DI
MOVL DI, 20(SP)
-
+
// g = m->gsignal
MOVL m_gsignal(BX), BX
MOVL BX, g(CX)
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));
CALL runtime·settls(SB)
POPL AX
POPAL
-
+
// Now segment is established. Initialize m, g.
get_tls(AX)
MOVL DX, g(AX)
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
TEXT runtime·sigtramp(SB),7,$64
get_tls(BX)
-
+
// check that m exists
MOVQ m(BX), BP
CMPQ BP, $0
// 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