Commit cc880923 authored by Wèi Cōngruì's avatar Wèi Cōngruì Committed by Ian Lance Taylor

runtime: fix errno sign for epollctl on mips, mips64 and ppc64

The caller of epollctl expects it to return a negative errno value,
but it returns a positive errno value on mips, mips64 and ppc64.
The change fixes this.

Updates #23446

Change-Id: Ie6372eca6c23de21964caaaa433c9a45ef93531e
Reviewed-on: https://go-review.googlesource.com/89235Reviewed-by: default avatarCarlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 665b9b34
...@@ -6,5 +6,11 @@ ...@@ -6,5 +6,11 @@
package runtime package runtime
import "unsafe"
var NewOSProc0 = newosproc0 var NewOSProc0 = newosproc0
var Mincore = mincore var Mincore = mincore
func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 {
return epollctl(epfd, op, fd, (*epollevent)(ev))
}
...@@ -52,3 +52,12 @@ func TestMincoreErrorSign(t *testing.T) { ...@@ -52,3 +52,12 @@ func TestMincoreErrorSign(t *testing.T) {
t.Errorf("mincore = %v, want %v", v, -EINVAL) t.Errorf("mincore = %v, want %v", v, -EINVAL)
} }
} }
func TestEpollctlErrorSign(t *testing.T) {
v := Epollctl(-1, 1, -1, unsafe.Pointer(&struct{}{}))
const EBADF = 0x09
if v != -EBADF {
t.Errorf("epollctl = %v, want %v", v, -EBADF)
}
}
...@@ -410,6 +410,7 @@ TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0 ...@@ -410,6 +410,7 @@ TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0
MOVV ev+16(FP), R7 MOVV ev+16(FP), R7
MOVV $SYS_epoll_ctl, R2 MOVV $SYS_epoll_ctl, R2
SYSCALL SYSCALL
SUBVU R2, R0, R2 // caller expects negative errno
MOVW R2, ret+24(FP) MOVW R2, ret+24(FP)
RET RET
......
...@@ -444,6 +444,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0-20 ...@@ -444,6 +444,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0-20
MOVW ev+12(FP), R7 MOVW ev+12(FP), R7
MOVW $SYS_epoll_ctl, R2 MOVW $SYS_epoll_ctl, R2
SYSCALL SYSCALL
SUBU R2, R0, R2 // caller expects negative errno
MOVW R2, ret+16(FP) MOVW R2, ret+16(FP)
RET RET
......
...@@ -496,6 +496,7 @@ TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0 ...@@ -496,6 +496,7 @@ TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0
MOVW fd+8(FP), R5 MOVW fd+8(FP), R5
MOVD ev+16(FP), R6 MOVD ev+16(FP), R6
SYSCALL $SYS_epoll_ctl SYSCALL $SYS_epoll_ctl
NEG R3 // caller expects negative errno
MOVW R3, ret+24(FP) MOVW R3, ret+24(FP)
RET RET
......
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