From 61d5daea0aca4fcb14f0090685327132a8e1a7f2 Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Wed, 24 Aug 2016 17:44:27 -0400 Subject: [PATCH] runtime: use clock_gettime for time.now() on s390x This should improve the precision of time.now() from microseconds to nanoseconds. Also, modify runtime.nanotime to keep it consistent with cleanup done to time.now. Updates #11222 for s390x. Change-Id: I27864115ea1fee7299360d9003cd3a8355f624d3 Reviewed-on: https://go-review.googlesource.com/27710 Reviewed-by: Brad Fitzpatrick --- src/runtime/sys_linux_s390x.s | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/runtime/sys_linux_s390x.s b/src/runtime/sys_linux_s390x.s index f43792bd51..4922f6158f 100644 --- a/src/runtime/sys_linux_s390x.s +++ b/src/runtime/sys_linux_s390x.s @@ -171,30 +171,26 @@ TEXT runtime·mincore(SB),NOSPLIT|NOFRAME,$0-28 // func now() (sec int64, nsec int32) TEXT time·now(SB),NOSPLIT,$16 - MOVD $0(R15), R2 - MOVD $0, R3 - MOVW $SYS_gettimeofday, R1 - SYSCALL - MOVD 0(R15), R2 // sec - MOVD 8(R15), R4 // usec - MOVD $1000, R3 - MULLD R3, R4 + MOVW $0, R2 // CLOCK_REALTIME + MOVD $tp-16(SP), R3 + MOVW $SYS_clock_gettime, R1 + SYSCALL + LMG tp-16(SP), R2, R3 + // sec is in R2, nsec in R3 MOVD R2, sec+0(FP) - MOVW R4, nsec+8(FP) + MOVW R3, nsec+8(FP) RET TEXT runtime·nanotime(SB),NOSPLIT,$16 MOVW $1, R2 // CLOCK_MONOTONIC - MOVD $0(R15), R3 + MOVD $tp-16(SP), R3 MOVW $SYS_clock_gettime, R1 SYSCALL - MOVD 0(R15), R2 // sec - MOVD 8(R15), R4 // nsec - // sec is in R2, nsec in R4 + LMG tp-16(SP), R2, R3 + // sec is in R2, nsec in R3 // return nsec in R2 - MOVD $1000000000, R3 - MULLD R3, R2 - ADD R4, R2 + MULLD $1000000000, R2 + ADD R3, R2 MOVD R2, ret+0(FP) RET -- 2.48.1