Skip to content

Commit 20b46c7

Browse files
ianlancetaylortklauser
authored andcommitted
runtime: negate errno value for mips pipe/pipe2
The callers expect negative errno values, so negate them when necessary. No test because there is no reasonable way to make pipe/pipe2 fail. This was reported on a system on which pipe2 returned ENOSYS. Fixes #37997 Change-Id: I3ad6cbbc2521cf495f8df6ec991a3f781122b508 Reviewed-on: https://go-review.googlesource.com/c/go/+/224592 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Tobias Klauser <[email protected]>
1 parent 9ef61d5 commit 20b46c7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/runtime/sys_linux_mips64x.s

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ TEXT runtime·pipe(SB),NOSPLIT|NOFRAME,$0-12
117117
MOVV R0, R5
118118
MOVV $SYS_pipe2, R2
119119
SYSCALL
120+
BEQ R7, 2(PC)
121+
SUBVU R2, R0, R2 // caller expects negative errno
120122
MOVW R2, errno+8(FP)
121123
RET
122124

@@ -126,6 +128,8 @@ TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
126128
MOVW flags+0(FP), R5
127129
MOVV $SYS_pipe2, R2
128130
SYSCALL
131+
BEQ R7, 2(PC)
132+
SUBVU R2, R0, R2 // caller expects negative errno
129133
MOVW R2, errno+16(FP)
130134
RET
131135

src/runtime/sys_linux_mipsx.s

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ TEXT runtime·pipe(SB),NOSPLIT,$0-12
118118
MOVW $-1, R1
119119
MOVW R1, r+0(FP)
120120
MOVW R1, w+4(FP)
121+
SUBU R2, R0, R2 // caller expects negative errno
121122
MOVW R2, errno+8(FP)
122123
RET
123124
pipeok:
@@ -132,6 +133,8 @@ TEXT runtime·pipe2(SB),NOSPLIT,$0-16
132133
MOVW flags+0(FP), R5
133134
MOVW $SYS_pipe2, R2
134135
SYSCALL
136+
BEQ R7, 2(PC)
137+
SUBU R2, R0, R2 // caller expects negative errno
135138
MOVW R2, errno+12(FP)
136139
RET
137140

0 commit comments

Comments
 (0)