switch from monotonic coarse to monotonic

This commit is contained in:
Josh Bleecher Snyder
2021-07-19 15:43:41 -07:00
parent a43f939828
commit 2a8ca8a592
2 changed files with 13 additions and 6 deletions

View File

@@ -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:

View File

@@ -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