From 2a8ca8a5926903382743aebc75c19e6a1dee80ee Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 19 Jul 2021 15:43:41 -0700 Subject: [PATCH] switch from monotonic coarse to monotonic --- tstime/monocoarse_linux_amd64.s | 9 ++++++--- tstime/monocoarse_linux_arm64.s | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tstime/monocoarse_linux_amd64.s b/tstime/monocoarse_linux_amd64.s index 16a99aca5..7e1801570 100644 --- a/tstime/monocoarse_linux_amd64.s +++ b/tstime/monocoarse_linux_amd64.s @@ -42,7 +42,7 @@ #define m_vdsoSP 832 #define m_vdsoPC 840 -#define CLOCK_MONOTONIC_COARSE 6 +#define CLOCK_MONOTONIC 1 // func MonotonicCoarse() int64 TEXT ·MonotonicCoarse(SB),NOSPLIT,$16-8 @@ -77,7 +77,7 @@ noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code - MOVL $CLOCK_MONOTONIC_COARSE, DI + MOVL $CLOCK_MONOTONIC, DI LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 @@ -96,7 +96,10 @@ ret: MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) - // sec is in AX; return it + // sec is in AX, nsec in DX + // return nsec in AX + IMULQ $1000000000, AX + ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: diff --git a/tstime/monocoarse_linux_arm64.s b/tstime/monocoarse_linux_arm64.s index c2c3605fc..b13e1c051 100644 --- a/tstime/monocoarse_linux_arm64.s +++ b/tstime/monocoarse_linux_arm64.s @@ -45,7 +45,7 @@ #define m_vdsoPC 840 #define m_gsignal 80 -#define CLOCK_MONOTONIC_COARSE 6 +#define CLOCK_MONOTONIC 1 // func MonotonicCoarse() int64 TEXT ·MonotonicCoarse(SB),NOSPLIT,$24-8 @@ -77,7 +77,7 @@ noswitch: BIC $15, R1 MOVD R1, RSP - MOVW $CLOCK_MONOTONIC_COARSE, R0 + MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback @@ -127,6 +127,10 @@ finish: MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) - // sec is in R3; return it + // sec is in R3, nsec in R5 + // return nsec in R3 + MOVD $1000000000, R4 + MUL R4, R3 + ADD R5, R3 MOVD R3, ret+0(FP) RET