]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: Add vdso on freebsd/riscv64
authorMikael Urankar <mikael@FreeBSD.org>
Mon, 19 Sep 2022 16:46:36 +0000 (18:46 +0200)
committerDavid Chase <drchase@google.com>
Thu, 20 Oct 2022 15:14:38 +0000 (15:14 +0000)
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>

src/runtime/sys_freebsd_riscv64.s
src/runtime/vdso_freebsd_riscv64.go

index 4b8699e2bff912636fee0e7545b05aee1739ef05..30deed2573a99e301339eea5cd9509a6ba6f68df 100644 (file)
@@ -428,3 +428,9 @@ TEXT runtime·closeonexec(SB),NOSPLIT|NOFRAME,$0
        MOV     $SYS_fcntl, T0
        ECALL
        RET
+
+// func getCntxct() uint32
+TEXT runtime·getCntxct(SB),NOSPLIT|NOFRAME,$0
+       RDTIME  A0
+       MOVW    A0, ret+0(FP)
+       RET
index ce2dd9c4393509496e0e43abe2d2135f80fa1a4d..a4fff4b1db1fe07bbdf7144660c2afe5f2145b9f 100644 (file)
@@ -4,7 +4,18 @@
 
 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
+       }
 }