Skip to content

Commit

Permalink
runtime: Add vdso on freebsd/riscv64
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
MikaelUrankar authored and dr2chase committed Oct 20, 2022
1 parent 4b5558e commit 0e56c31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/runtime/sys_freebsd_riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion src/runtime/vdso_freebsd_riscv64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 0e56c31

Please sign in to comment.