Commit 4dbd0dbf authored by Matthew Dempsky's avatar Matthew Dempsky Committed by Ian Lance Taylor

runtime: fix openbsd/386

In revision 05c3fee13eb3, openbsd/386's tfork implementation was
accidentally changed in one instruction from using the "params"
parameter to using the "psize" parameter.

While here, OpenBSD's __tfork system call returns a pid_t which is an
int32 on all OpenBSD architectures, so change runtime.tfork's return
type from int64 to int32 and update the assembly implementations
accordingly.

LGTM=iant
R=rsc, iant
CC=golang-codereviews, jsing
https://golang.org/cl/133190043
parent c46bcd4d
......@@ -26,7 +26,7 @@ extern SigTab runtime·sigtab[];
static Sigset sigset_none;
static Sigset sigset_all = ~(Sigset)0;
extern int64 runtime·tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
extern int32 runtime·tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock, const int32 *abort);
extern int32 runtime·thrwakeup(void *ident, int32 n);
......
......@@ -15,6 +15,6 @@ func raise(sig int32)
func kqueue() int32
func kevent(fd int32, ev1 unsafe.Pointer, nev1 int32, ev2 unsafe.Pointer, nev2 int32, ts unsafe.Pointer) int32
func closeonexec(fd int32)
func tfork(param unsafe.Pointer, psize uintptr, mm, gg, fn unsafe.Pointer) int64
func tfork(param unsafe.Pointer, psize uintptr, mm, gg, fn unsafe.Pointer) int32
func thrsleep(ident unsafe.Pointer, clock_id int32, tsp, lock, abort unsafe.Pointer) int32
func thrwakeup(ident unsafe.Pointer, n int32) int32
......@@ -226,7 +226,7 @@ sigtramp_ret:
TEXT runtime·tfork(SB),NOSPLIT,$12
// Copy mp, gp and fn from the parent stack onto the child stack.
MOVL psize+4(FP), AX
MOVL param+0(FP), AX
MOVL 8(AX), CX // tf_stack
SUBL $16, CX
MOVL CX, 8(AX)
......@@ -247,17 +247,15 @@ TEXT runtime·tfork(SB),NOSPLIT,$12
INT $0x80
// Return if tfork syscall failed.
JCC 5(PC)
JCC 4(PC)
NEGL AX
MOVL AX, ret_lo+20(FP)
MOVL $-1, ret_hi+24(FP)
MOVL AX, ret+20(FP)
RET
// In parent, return.
CMPL AX, $0
JEQ 4(PC)
MOVL AX, ret_lo+20(FP)
MOVL $0, ret_hi+24(FP)
JEQ 3(PC)
MOVL AX, ret+20(FP)
RET
// Paranoia: check that SP is as we expect.
......
......@@ -11,7 +11,7 @@
#define CLOCK_MONOTONIC $3
// int64 tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
// int32 tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
TEXT runtime·tfork(SB),NOSPLIT,$32
// Copy mp, gp and fn off parent stack for use by child.
......@@ -27,13 +27,13 @@ TEXT runtime·tfork(SB),NOSPLIT,$32
// Return if tfork syscall failed.
JCC 4(PC)
NEGQ AX
MOVQ AX, ret+40(FP)
MOVL AX, ret+40(FP)
RET
// In parent, return.
CMPL AX, $0
JEQ 3(PC)
MOVQ AX, ret+40(FP)
MOVL AX, ret+40(FP)
RET
// Set FS to point at m->tls.
......
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