aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/defs_freebsd.go
diff options
context:
space:
mode:
authorYuval Pavel Zholkover <paulzhol@gmail.com>2018-02-05 17:11:27 +0200
committerIan Lance Taylor <iant@golang.org>2018-04-18 21:54:26 +0000
commit744ccbb852f18241c637b2c6314b35fce7359916 (patch)
tree7201dea7cc3ce21462c40af6a646f7ff0c0427db /src/runtime/defs_freebsd.go
parent236c567ba9b7767b6f1ebe32eb2d8f0018de8780 (diff)
downloadgo-744ccbb852f18241c637b2c6314b35fce7359916.tar.gz
go-744ccbb852f18241c637b2c6314b35fce7359916.zip
runtime: fast clock_gettime call on FreeBSD
Use AT_TIMEKEEP ELF aux entry to access a kernel mapped ring of timehands structs. The timehands are updated by the kernel periodically, but for accurate measure the timecounter still needs to be queried. Currently the fast path is used only when kern.timecounter.hardware==TSC-low or kern.timecounter.hardware=='ARM MPCore Timecounter', other timecounters revert back to regular system call. TODO: add support for HPET timecounter on 386/amd64. Change-Id: I321ca4e92be63ba21a2574b758ef5c1e729086ad Reviewed-on: https://go-review.googlesource.com/93156 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/defs_freebsd.go')
-rw-r--r--src/runtime/defs_freebsd.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/runtime/defs_freebsd.go b/src/runtime/defs_freebsd.go
index 9d55111786..f8eaf4167c 100644
--- a/src/runtime/defs_freebsd.go
+++ b/src/runtime/defs_freebsd.go
@@ -31,6 +31,7 @@ package runtime
#include <sys/sysctl.h>
#include <sys/cpuset.h>
#include <sys/param.h>
+#include <sys/vdso.h>
*/
import "C"
@@ -62,6 +63,7 @@ const (
SA_ONSTACK = C.SA_ONSTACK
CLOCK_MONOTONIC = C.CLOCK_MONOTONIC
+ CLOCK_REALTIME = C.CLOCK_REALTIME
UMTX_OP_WAIT_UINT = C.UMTX_OP_WAIT_UINT
UMTX_OP_WAIT_UINT_PRIVATE = C.UMTX_OP_WAIT_UINT_PRIVATE
@@ -147,3 +149,14 @@ type Itimerval C.struct_itimerval
type Umtx_time C.struct__umtx_time
type Kevent C.struct_kevent
+
+type bintime C.struct_bintime
+type vdsoTimehands C.struct_vdso_timehands
+type vdsoTimekeep C.struct_vdso_timekeep
+
+const (
+ _VDSO_TK_VER_CURR = C.VDSO_TK_VER_CURR
+
+ vdsoTimehandsSize = C.sizeof_struct_vdso_timehands
+ vdsoTimekeepSize = C.sizeof_struct_vdso_timekeep
+)