mirror of
https://github.com/golang/go
synced 2024-11-19 14:54:43 -07:00
runtime: update openbsd thread related syscalls to match kernel
Update the threxit and thrsleep syscalls to match the ABI of the OpenBSD 5.1 kernel. These changes are backwards compatible with older kernels. Fixes #3311. R=golang-dev, rsc, devon.odell CC=golang-dev https://golang.org/cl/5777079
This commit is contained in:
parent
d7bc644ba2
commit
8cea1bf102
@ -12,14 +12,16 @@
|
||||
TEXT runtime·exit(SB),7,$-4
|
||||
MOVL $1, AX
|
||||
INT $0x80
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·exit1(SB),7,$-4
|
||||
MOVL $302, AX // sys_threxit
|
||||
TEXT runtime·exit1(SB),7,$8
|
||||
MOVL $0, 0(SP)
|
||||
MOVL $0, 4(SP) // arg 1 - notdead
|
||||
MOVL $302, AX // sys___threxit
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·write(SB),7,$-4
|
||||
@ -79,7 +81,7 @@ TEXT runtime·munmap(SB),7,$-4
|
||||
MOVL $73, AX // sys_munmap
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·setitimer(SB),7,$-4
|
||||
@ -132,14 +134,14 @@ TEXT runtime·sigaction(SB),7,$-4
|
||||
MOVL $46, AX // sys_sigaction
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·sigprocmask(SB),7,$-4
|
||||
MOVL $48, AX // sys_sigprocmask
|
||||
INT $0x80
|
||||
JAE 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL AX, oset+0(FP)
|
||||
RET
|
||||
|
||||
@ -182,7 +184,7 @@ TEXT runtime·sigtramp(SB),7,$44
|
||||
MOVL AX, 4(SP) // arg 1 - sigcontext
|
||||
MOVL $103, AX // sys_sigreturn
|
||||
INT $0x80
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
// int32 rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
|
||||
@ -294,7 +296,7 @@ TEXT runtime·settls(SB),7,$16
|
||||
MOVL $165, AX // sys_sysarch
|
||||
INT $0x80
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·osyield(SB),7,$-4
|
||||
@ -303,12 +305,12 @@ TEXT runtime·osyield(SB),7,$-4
|
||||
RET
|
||||
|
||||
TEXT runtime·thrsleep(SB),7,$-4
|
||||
MOVL $300, AX // sys_thrsleep
|
||||
MOVL $300, AX // sys___thrsleep
|
||||
INT $0x80
|
||||
RET
|
||||
|
||||
TEXT runtime·thrwakeup(SB),7,$-4
|
||||
MOVL $301, AX // sys_thrwakeup
|
||||
MOVL $301, AX // sys___thrwakeup
|
||||
INT $0x80
|
||||
RET
|
||||
|
||||
|
@ -53,7 +53,8 @@ TEXT runtime·rfork_thread(SB),7,$0
|
||||
CALL R12
|
||||
|
||||
// It shouldn't return. If it does, exit
|
||||
MOVL $302, AX // sys_threxit
|
||||
MOVQ $0, DI // arg 1 - notdead
|
||||
MOVL $302, AX // sys___threxit
|
||||
SYSCALL
|
||||
JMP -3(PC) // keep exiting
|
||||
|
||||
@ -67,14 +68,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
|
||||
MOVL $300, AX // sys_thrsleep
|
||||
MOVQ 40(SP), R8 // arg 5 - abort
|
||||
MOVL $300, AX // sys___thrsleep
|
||||
SYSCALL
|
||||
RET
|
||||
|
||||
TEXT runtime·thrwakeup(SB),7,$0
|
||||
MOVQ 8(SP), DI // arg 1 - ident
|
||||
MOVL 16(SP), SI // arg 2 - n
|
||||
MOVL $301, AX // sys_thrwakeup
|
||||
MOVL $301, AX // sys___thrwakeup
|
||||
SYSCALL
|
||||
RET
|
||||
|
||||
@ -83,13 +85,14 @@ TEXT runtime·exit(SB),7,$-8
|
||||
MOVL 8(SP), DI // arg 1 - exit status
|
||||
MOVL $1, AX // sys_exit
|
||||
SYSCALL
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·exit1(SB),7,$-8
|
||||
MOVL $302, AX // sys_threxit
|
||||
MOVQ $0, DI // arg 1 - notdead
|
||||
MOVL $302, AX // sys___threxit
|
||||
SYSCALL
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·write(SB),7,$-8
|
||||
@ -140,7 +143,7 @@ TEXT time·now(SB), 7, $32
|
||||
MOVL $116, AX // sys_gettimeofday
|
||||
SYSCALL
|
||||
MOVQ 8(SP), AX // sec
|
||||
MOVL 16(SP), DX // usec
|
||||
MOVL 16(SP), DX // usec
|
||||
|
||||
// sec is in AX, usec in DX
|
||||
MOVQ AX, sec+0(FP)
|
||||
@ -154,7 +157,7 @@ TEXT runtime·nanotime(SB),7,$32
|
||||
MOVL $116, AX // sys_gettimeofday
|
||||
SYSCALL
|
||||
MOVQ 8(SP), AX // sec
|
||||
MOVL 16(SP), DX // usec
|
||||
MOVL 16(SP), DX // usec
|
||||
|
||||
// sec is in AX, usec in DX
|
||||
// return nsec in AX
|
||||
@ -170,7 +173,7 @@ TEXT runtime·sigaction(SB),7,$-8
|
||||
MOVL $46, AX
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·sigprocmask(SB),7,$0
|
||||
@ -179,7 +182,7 @@ TEXT runtime·sigprocmask(SB),7,$0
|
||||
MOVL $48, AX // sys_sigprocmask
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL AX, oset+0(FP) // Return oset
|
||||
RET
|
||||
|
||||
@ -236,7 +239,7 @@ TEXT runtime·munmap(SB),7,$0
|
||||
MOVL $73, AX // sys_munmap
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·sigaltstack(SB),7,$-8
|
||||
@ -245,7 +248,7 @@ TEXT runtime·sigaltstack(SB),7,$-8
|
||||
MOVQ $288, AX // sys_sigaltstack
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
// set tls base to DI
|
||||
@ -258,7 +261,7 @@ TEXT runtime·settls(SB),7,$8
|
||||
MOVQ $165, AX // sys_sysarch
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
RET
|
||||
|
||||
TEXT runtime·sysctl(SB),7,$0
|
||||
@ -270,7 +273,7 @@ TEXT runtime·sysctl(SB),7,$0
|
||||
MOVQ 48(SP), R9 // arg 6 - newlen
|
||||
MOVQ $202, AX // sys___sysctl
|
||||
SYSCALL
|
||||
JCC 3(PC)
|
||||
JCC 3(PC)
|
||||
NEGL AX
|
||||
RET
|
||||
MOVL $0, AX
|
||||
|
@ -24,7 +24,7 @@ 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 int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock, const int32 *abort);
|
||||
extern int32 runtime·thrwakeup(void *ident, int32 n);
|
||||
|
||||
// From OpenBSD's <sys/sysctl.h>
|
||||
@ -72,12 +72,12 @@ runtime·semasleep(int64 ns)
|
||||
// sleep until semaphore != 0 or timeout.
|
||||
// thrsleep unlocks m->waitsemalock.
|
||||
if(ns < 0)
|
||||
runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock);
|
||||
runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock, nil);
|
||||
else {
|
||||
ns += runtime·nanotime();
|
||||
ts.tv_sec = ns/1000000000LL;
|
||||
ts.tv_nsec = ns%1000000000LL;
|
||||
runtime·thrsleep(&m->waitsemacount, CLOCK_REALTIME, &ts, &m->waitsemalock);
|
||||
runtime·thrsleep(&m->waitsemacount, CLOCK_REALTIME, &ts, &m->waitsemalock, nil);
|
||||
}
|
||||
// reacquire lock
|
||||
while(runtime·xchg(&m->waitsemalock, 1))
|
||||
|
Loading…
Reference in New Issue
Block a user