Skip to content

Commit 0e56c31

Browse files
MikaelUrankardr2chase
authored andcommitted
runtime: Add vdso on freebsd/riscv64
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 <[email protected]> Reviewed-by: Dmitri Goutnik <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Yuval Pavel Zholkover <[email protected]> Run-TryBot: Meng Zhuo <[email protected]>
1 parent 4b5558e commit 0e56c31

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/runtime/sys_freebsd_riscv64.s

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,9 @@ TEXT runtime·closeonexec(SB),NOSPLIT|NOFRAME,$0
428428
MOV $SYS_fcntl, T0
429429
ECALL
430430
RET
431+
432+
// func getCntxct() uint32
433+
TEXT runtime·getCntxct(SB),NOSPLIT|NOFRAME,$0
434+
RDTIME A0
435+
MOVW A0, ret+0(FP)
436+
RET

src/runtime/vdso_freebsd_riscv64.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44

55
package runtime
66

7+
const (
8+
_VDSO_TH_ALGO_RISCV_RDTIME = 1
9+
)
10+
11+
func getCntxct() uint32
12+
713
//go:nosplit
814
func (th *vdsoTimehands) getTimecounter() (uint32, bool) {
9-
return 0, false
15+
switch th.algo {
16+
case _VDSO_TH_ALGO_RISCV_RDTIME:
17+
return getCntxct(), true
18+
default:
19+
return 0, false
20+
}
1021
}

0 commit comments

Comments
 (0)