Commit 8cea1bf1 authored by Joel Sing's avatar Joel Sing

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
parent d7bc644b
......@@ -15,8 +15,10 @@ TEXT runtime·exit(SB),7,$-4
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
......@@ -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
......@@ -87,7 +89,8 @@ TEXT runtime·exit(SB),7,$-8
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
RET
......
......@@ -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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment