Commit 61d5daea authored by Michael Munday's avatar Michael Munday Committed by Brad Fitzpatrick

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/27710Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 3167ff7c
...@@ -171,30 +171,26 @@ TEXT runtime·mincore(SB),NOSPLIT|NOFRAME,$0-28 ...@@ -171,30 +171,26 @@ TEXT runtime·mincore(SB),NOSPLIT|NOFRAME,$0-28
// func now() (sec int64, nsec int32) // func now() (sec int64, nsec int32)
TEXT time·now(SB),NOSPLIT,$16 TEXT time·now(SB),NOSPLIT,$16
MOVD $0(R15), R2 MOVW $0, R2 // CLOCK_REALTIME
MOVD $0, R3 MOVD $tp-16(SP), R3
MOVW $SYS_gettimeofday, R1 MOVW $SYS_clock_gettime, R1
SYSCALL SYSCALL
MOVD 0(R15), R2 // sec LMG tp-16(SP), R2, R3
MOVD 8(R15), R4 // usec // sec is in R2, nsec in R3
MOVD $1000, R3
MULLD R3, R4
MOVD R2, sec+0(FP) MOVD R2, sec+0(FP)
MOVW R4, nsec+8(FP) MOVW R3, nsec+8(FP)
RET RET
TEXT runtime·nanotime(SB),NOSPLIT,$16 TEXT runtime·nanotime(SB),NOSPLIT,$16
MOVW $1, R2 // CLOCK_MONOTONIC MOVW $1, R2 // CLOCK_MONOTONIC
MOVD $0(R15), R3 MOVD $tp-16(SP), R3
MOVW $SYS_clock_gettime, R1 MOVW $SYS_clock_gettime, R1
SYSCALL SYSCALL
MOVD 0(R15), R2 // sec LMG tp-16(SP), R2, R3
MOVD 8(R15), R4 // nsec // sec is in R2, nsec in R3
// sec is in R2, nsec in R4
// return nsec in R2 // return nsec in R2
MOVD $1000000000, R3 MULLD $1000000000, R2
MULLD R3, R2 ADD R3, R2
ADD R4, R2
MOVD R2, ret+0(FP) MOVD R2, ret+0(FP)
RET RET
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment