]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.8] runtime: use pselect6 for usleep on linux/amd64 and linux/arm
authorAustin Clements <austin@google.com>
Thu, 18 May 2017 20:56:48 +0000 (16:56 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 23 May 2017 23:21:13 +0000 (23:21 +0000)
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 <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 4dcba023c62d7f7968abc54fa5d38d2bf11412ba)
Reviewed-on: https://go-review.googlesource.com/44001
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
src/runtime/sys_linux_amd64.s
src/runtime/sys_linux_arm.s

index 6ddcb30ae204ddfa5e2f639cf4968646c44c223a..8ab8d12d0f93d7c27edaff58d070ad6820d0f142 100644 (file)
@@ -82,15 +82,18 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
        MOVL    $1000000, CX
        DIVL    CX
        MOVQ    AX, 0(SP)
-       MOVQ    DX, 8(SP)
+       MOVL    $1000, AX       // usec to nsec
+       MULL    DX
+       MOVQ    AX, 8(SP)
 
-       // select(0, 0, 0, 0, &tv)
+       // pselect6(0, 0, 0, 0, &ts, 0)
        MOVL    $0, DI
        MOVL    $0, SI
        MOVL    $0, DX
        MOVL    $0, R10
        MOVQ    SP, R8
-       MOVL    $23, AX
+       MOVL    $0, R9
+       MOVL    $270, AX
        SYSCALL
        RET
 
index 666b879f02387633fdc02a8e804eb235e00405d6..f21a351c05048b0cbf540b23847e70f8205b64c1 100644 (file)
@@ -36,7 +36,7 @@
 #define SYS_gettid (SYS_BASE + 224)
 #define SYS_tkill (SYS_BASE + 238)
 #define SYS_sched_yield (SYS_BASE + 158)
-#define SYS_select (SYS_BASE + 142) // newselect
+#define SYS_pselect6 (SYS_BASE + 335)
 #define SYS_ugetrlimit (SYS_BASE + 191)
 #define SYS_sched_getaffinity (SYS_BASE + 242)
 #define SYS_clock_gettime (SYS_BASE + 263)
@@ -387,13 +387,16 @@ TEXT runtime·usleep(SB),NOSPLIT,$12
        MOVW    usec+0(FP), R0
        CALL    runtime·usplitR0(SB)
        MOVW    R0, 4(R13)
+       MOVW    $1000, R0       // usec to nsec
+       MUL     R0, R1
        MOVW    R1, 8(R13)
        MOVW    $0, R0
        MOVW    $0, R1
        MOVW    $0, R2
        MOVW    $0, R3
        MOVW    $4(R13), R4
-       MOVW    $SYS_select, R7
+       MOVW    $0, R5
+       MOVW    $SYS_pselect6, R7
        SWI     $0
        RET