]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: negate errno value for mips pipe/pipe2
authorIan Lance Taylor <iant@golang.org>
Sun, 22 Mar 2020 19:57:36 +0000 (12:57 -0700)
committerTobias Klauser <tobias.klauser@gmail.com>
Tue, 24 Mar 2020 11:03:07 +0000 (11:03 +0000)
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 <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
src/runtime/sys_linux_mips64x.s
src/runtime/sys_linux_mipsx.s

index 723cfe43d90c17e875b85f3fea63876335903655..6668a0fd862f64979a2cbfc5da08038aa4528765 100644 (file)
@@ -117,6 +117,8 @@ TEXT runtime·pipe(SB),NOSPLIT|NOFRAME,$0-12
        MOVV    R0, R5
        MOVV    $SYS_pipe2, R2
        SYSCALL
+       BEQ     R7, 2(PC)
+       SUBVU   R2, R0, R2      // caller expects negative errno
        MOVW    R2, errno+8(FP)
        RET
 
@@ -126,6 +128,8 @@ TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
        MOVW    flags+0(FP), R5
        MOVV    $SYS_pipe2, R2
        SYSCALL
+       BEQ     R7, 2(PC)
+       SUBVU   R2, R0, R2      // caller expects negative errno
        MOVW    R2, errno+16(FP)
        RET
 
index 15893a7a28bc567332e89f4804ef8ca8aa08f6c9..fab2ab3892d7a01c80da81faa27722171f28d7f6 100644 (file)
@@ -118,6 +118,7 @@ TEXT runtime·pipe(SB),NOSPLIT,$0-12
        MOVW    $-1, R1
        MOVW    R1, r+0(FP)
        MOVW    R1, w+4(FP)
+       SUBU    R2, R0, R2      // caller expects negative errno
        MOVW    R2, errno+8(FP)
        RET
 pipeok:
@@ -132,6 +133,8 @@ TEXT runtime·pipe2(SB),NOSPLIT,$0-16
        MOVW    flags+0(FP), R5
        MOVW    $SYS_pipe2, R2
        SYSCALL
+       BEQ     R7, 2(PC)
+       SUBU    R2, R0, R2      // caller expects negative errno
        MOVW    R2, errno+12(FP)
        RET