]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: calculate nanoseconds in usleep on linux/loong64
authorGuoqi Chen <chenguoqi@loongson.cn>
Tue, 28 Mar 2023 21:08:28 +0000 (05:08 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 9 May 2023 14:42:43 +0000 (14:42 +0000)
Change-Id: Ia4cfdea3df8834e6260527ce8e6e894a0547070f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425299
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
src/runtime/sys_linux_loong64.s

index 006c4bf2d518f8e518e578a0c8785130adec2450..486a9b1570d2ddd740832b80251f4379acef454a 100644 (file)
@@ -120,19 +120,19 @@ TEXT runtimeĀ·pipe2(SB),NOSPLIT|NOFRAME,$0-20
 
 // func usleep(usec uint32)
 TEXT runtimeĀ·usleep(SB),NOSPLIT,$16-4
-       MOVWU   usec+0(FP), R6
-       MOVV    R6, R5
-       MOVW    $1000000, R4
-       DIVVU   R4, R6, R6
-       MOVV    R6, 8(R3)
-       MOVW    $1000, R4
-       MULVU   R6, R4, R4
-       SUBVU   R4, R5
-       MOVV    R5, 16(R3)
+       MOVWU   usec+0(FP), R7
+       MOVV    $1000, R6
+       MULVU   R6, R7, R7
+       MOVV    $1000000000, R6
+
+       DIVVU   R6, R7, R5      // ts->tv_sec
+       REMVU   R6, R7, R4      // ts->tv_nsec
+       MOVV    R5, 8(R3)
+       MOVV    R4, 16(R3)
 
        // nanosleep(&ts, 0)
        ADDV    $8, R3, R4
-       MOVW    $0, R5
+       MOVV    R0, R5
        MOVV    $SYS_nanosleep, R11
        SYSCALL
        RET