Skip to content

Commit cc88092

Browse files
crvvianlancetaylor
authored andcommitted
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/89235 Reviewed-by: Carlos Eduardo Seo <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 665b9b3 commit cc88092

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

src/runtime/export_linux_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66

77
package runtime
88

9+
import "unsafe"
10+
911
var NewOSProc0 = newosproc0
1012
var Mincore = mincore
13+
14+
func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 {
15+
return epollctl(epfd, op, fd, (*epollevent)(ev))
16+
}

src/runtime/runtime_linux_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,12 @@ func TestMincoreErrorSign(t *testing.T) {
5252
t.Errorf("mincore = %v, want %v", v, -EINVAL)
5353
}
5454
}
55+
56+
func TestEpollctlErrorSign(t *testing.T) {
57+
v := Epollctl(-1, 1, -1, unsafe.Pointer(&struct{}{}))
58+
59+
const EBADF = 0x09
60+
if v != -EBADF {
61+
t.Errorf("epollctl = %v, want %v", v, -EBADF)
62+
}
63+
}

src/runtime/sys_linux_mips64x.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0
410410
MOVV ev+16(FP), R7
411411
MOVV $SYS_epoll_ctl, R2
412412
SYSCALL
413+
SUBVU R2, R0, R2 // caller expects negative errno
413414
MOVW R2, ret+24(FP)
414415
RET
415416

src/runtime/sys_linux_mipsx.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0-20
444444
MOVW ev+12(FP), R7
445445
MOVW $SYS_epoll_ctl, R2
446446
SYSCALL
447+
SUBU R2, R0, R2 // caller expects negative errno
447448
MOVW R2, ret+16(FP)
448449
RET
449450

src/runtime/sys_linux_ppc64x.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0
496496
MOVW fd+8(FP), R5
497497
MOVD ev+16(FP), R6
498498
SYSCALL $SYS_epoll_ctl
499+
NEG R3 // caller expects negative errno
499500
MOVW R3, ret+24(FP)
500501
RET
501502

0 commit comments

Comments
 (0)