Skip to content

Commit 958c64b

Browse files
aclementsbradfitz
authored andcommitted
[release-branch.go1.8] runtime: use pselect6 for usleep on linux/amd64 and linux/arm
Android O black-lists the select system call because its libc, Bionic, does not use this system call. Replace our use of select with pselect6 (which is allowed) on the platforms that support targeting Android. linux/arm64 already uses pselect6 because there is no select on arm64, so only linux/amd64 and linux/arm need changing. pselect6 has been available since Linux 2.6.16, which is before Go's minimum requirement. Fixes #20409. Change-Id: Ic526b5b259a9e01d2f145a1f4d2e76e8c49ce809 Reviewed-on: https://go-review.googlesource.com/43641 Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> (cherry picked from commit 4dcba02) Reviewed-on: https://go-review.googlesource.com/44001 Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Chris Broadfoot <[email protected]>
1 parent 195e20a commit 958c64b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/runtime/sys_linux_amd64.s

+6-3
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
8282
MOVL $1000000, CX
8383
DIVL CX
8484
MOVQ AX, 0(SP)
85-
MOVQ DX, 8(SP)
85+
MOVL $1000, AX // usec to nsec
86+
MULL DX
87+
MOVQ AX, 8(SP)
8688

87-
// select(0, 0, 0, 0, &tv)
89+
// pselect6(0, 0, 0, 0, &ts, 0)
8890
MOVL $0, DI
8991
MOVL $0, SI
9092
MOVL $0, DX
9193
MOVL $0, R10
9294
MOVQ SP, R8
93-
MOVL $23, AX
95+
MOVL $0, R9
96+
MOVL $270, AX
9497
SYSCALL
9598
RET
9699

src/runtime/sys_linux_arm.s

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define SYS_gettid (SYS_BASE + 224)
3737
#define SYS_tkill (SYS_BASE + 238)
3838
#define SYS_sched_yield (SYS_BASE + 158)
39-
#define SYS_select (SYS_BASE + 142) // newselect
39+
#define SYS_pselect6 (SYS_BASE + 335)
4040
#define SYS_ugetrlimit (SYS_BASE + 191)
4141
#define SYS_sched_getaffinity (SYS_BASE + 242)
4242
#define SYS_clock_gettime (SYS_BASE + 263)
@@ -387,13 +387,16 @@ TEXT runtime·usleep(SB),NOSPLIT,$12
387387
MOVW usec+0(FP), R0
388388
CALL runtime·usplitR0(SB)
389389
MOVW R0, 4(R13)
390+
MOVW $1000, R0 // usec to nsec
391+
MUL R0, R1
390392
MOVW R1, 8(R13)
391393
MOVW $0, R0
392394
MOVW $0, R1
393395
MOVW $0, R2
394396
MOVW $0, R3
395397
MOVW $4(R13), R4
396-
MOVW $SYS_select, R7
398+
MOVW $0, R5
399+
MOVW $SYS_pselect6, R7
397400
SWI $0
398401
RET
399402

0 commit comments

Comments
 (0)