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/89235
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
package runtime
+import "unsafe"
+
var NewOSProc0 = newosproc0
var Mincore = mincore
+
+func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 {
+ return epollctl(epfd, op, fd, (*epollevent)(ev))
+}
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)
+ }
+}
MOVV ev+16(FP), R7
MOVV $SYS_epoll_ctl, R2
SYSCALL
+ SUBVU R2, R0, R2 // caller expects negative errno
MOVW R2, ret+24(FP)
RET
MOVW ev+12(FP), R7
MOVW $SYS_epoll_ctl, R2
SYSCALL
+ SUBU R2, R0, R2 // caller expects negative errno
MOVW R2, ret+16(FP)
RET
MOVW fd+8(FP), R5
MOVD ev+16(FP), R6
SYSCALL $SYS_epoll_ctl
+ NEG R3 // caller expects negative errno
MOVW R3, ret+24(FP)
RET