1
0
mirror of https://github.com/golang/go synced 2024-11-19 20:14: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:
Joel Sing 2012-04-11 22:02:08 +10:00
parent d7bc644ba2
commit 8cea1bf102
3 changed files with 33 additions and 28 deletions

View File

@ -15,8 +15,10 @@ TEXT runtime·exit(SB),7,$-4
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET
TEXT runtime·exit1(SB),7,$-4 TEXT runtime·exit1(SB),7,$8
MOVL $302, AX // sys_threxit MOVL $0, 0(SP)
MOVL $0, 4(SP) // arg 1 - notdead
MOVL $302, AX // sys___threxit
INT $0x80 INT $0x80
JAE 2(PC) JAE 2(PC)
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
@ -303,12 +305,12 @@ TEXT runtime·osyield(SB),7,$-4
RET RET
TEXT runtime·thrsleep(SB),7,$-4 TEXT runtime·thrsleep(SB),7,$-4
MOVL $300, AX // sys_thrsleep MOVL $300, AX // sys___thrsleep
INT $0x80 INT $0x80
RET RET
TEXT runtime·thrwakeup(SB),7,$-4 TEXT runtime·thrwakeup(SB),7,$-4
MOVL $301, AX // sys_thrwakeup MOVL $301, AX // sys___thrwakeup
INT $0x80 INT $0x80
RET RET

View File

@ -53,7 +53,8 @@ TEXT runtime·rfork_thread(SB),7,$0
CALL R12 CALL R12
// It shouldn't return. If it does, exit // 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 SYSCALL
JMP -3(PC) // keep exiting JMP -3(PC) // keep exiting
@ -67,14 +68,15 @@ TEXT runtime·thrsleep(SB),7,$0
MOVL 16(SP), SI // arg 2 - clock_id MOVL 16(SP), SI // arg 2 - clock_id
MOVQ 24(SP), DX // arg 3 - tp MOVQ 24(SP), DX // arg 3 - tp
MOVQ 32(SP), R10 // arg 4 - lock 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 SYSCALL
RET RET
TEXT runtime·thrwakeup(SB),7,$0 TEXT runtime·thrwakeup(SB),7,$0
MOVQ 8(SP), DI // arg 1 - ident MOVQ 8(SP), DI // arg 1 - ident
MOVL 16(SP), SI // arg 2 - n MOVL 16(SP), SI // arg 2 - n
MOVL $301, AX // sys_thrwakeup MOVL $301, AX // sys___thrwakeup
SYSCALL SYSCALL
RET RET
@ -87,7 +89,8 @@ TEXT runtime·exit(SB),7,$-8
RET RET
TEXT runtime·exit1(SB),7,$-8 TEXT runtime·exit1(SB),7,$-8
MOVL $302, AX // sys_threxit MOVQ $0, DI // arg 1 - notdead
MOVL $302, AX // sys___threxit
SYSCALL SYSCALL
MOVL $0xf1, 0xf1 // crash MOVL $0xf1, 0xf1 // crash
RET RET

View File

@ -24,7 +24,7 @@ static Sigset sigset_all = ~(Sigset)0;
static Sigset sigset_none; static Sigset sigset_none;
extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void)); 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); extern int32 runtime·thrwakeup(void *ident, int32 n);
// From OpenBSD's <sys/sysctl.h> // From OpenBSD's <sys/sysctl.h>
@ -72,12 +72,12 @@ runtime·semasleep(int64 ns)
// sleep until semaphore != 0 or timeout. // sleep until semaphore != 0 or timeout.
// thrsleep unlocks m->waitsemalock. // thrsleep unlocks m->waitsemalock.
if(ns < 0) if(ns < 0)
runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock); runtime·thrsleep(&m->waitsemacount, 0, nil, &m->waitsemalock, nil);
else { else {
ns += runtime·nanotime(); ns += runtime·nanotime();
ts.tv_sec = ns/1000000000LL; ts.tv_sec = ns/1000000000LL;
ts.tv_nsec = 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 // reacquire lock
while(runtime·xchg(&m->waitsemalock, 1)) while(runtime·xchg(&m->waitsemalock, 1))