Use rdtime to retrieve the timecounter, same as the FreeBSD libc.
Updates #53466
Change-Id: I48816e9100036f1ef483e4d3afcf10db0d3b85f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/443036
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
MOV $SYS_fcntl, T0
ECALL
RET
+
+// func getCntxct() uint32
+TEXT runtime·getCntxct(SB),NOSPLIT|NOFRAME,$0
+ RDTIME A0
+ MOVW A0, ret+0(FP)
+ RET
package runtime
+const (
+ _VDSO_TH_ALGO_RISCV_RDTIME = 1
+)
+
+func getCntxct() uint32
+
//go:nosplit
func (th *vdsoTimehands) getTimecounter() (uint32, bool) {
- return 0, false
+ switch th.algo {
+ case _VDSO_TH_ALGO_RISCV_RDTIME:
+ return getCntxct(), true
+ default:
+ return 0, false
+ }
}