aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/defs_freebsd.go
diff options
context:
space:
mode:
authorMike Appleby <mike@app.leby.org>2016-09-28 16:01:27 -0500
committerIan Lance Taylor <iant@golang.org>2016-10-01 01:25:21 +0000
commit360f2e43b78a3ea119ea8dce9649f7c1227d793b (patch)
tree3a9ef335748f095044392a0c883e1504a8c41025 /src/runtime/defs_freebsd.go
parentd1f4e0413fd2b5cb78a7b645e802565f202d1926 (diff)
downloadgo-360f2e43b78a3ea119ea8dce9649f7c1227d793b.tar.gz
go-360f2e43b78a3ea119ea8dce9649f7c1227d793b.zip
runtime: sleep on CLOCK_MONOTONIC in futexsleep1 on freebsd
In FreeBSD 10.0, the _umtx_op syscall was changed to allow sleeping on any supported clock, but the default clock was switched from a monotonic clock to CLOCK_REALTIME. Prior to 10.0, the __umtx_op_wait* functions ignored the fourth argument to _umtx_op (uaddr1), expected the fifth argument (uaddr2) to be a struct timespec pointer, and used a monotonic clock (nanouptime(9)) for timeout calculations. Since 10.0, if callers want a clock other than CLOCK_REALTIME, they must call _umtx_op with uaddr1 set to a value greater than sizeof(struct timespec), and with uaddr2 as pointer to a struct _umtx_time, rather than a timespec. Callers can set the _clockid field of the struct _umtx_time to request the clock they want. The relevant FreeBSD commit: https://svnweb.freebsd.org/base?view=revision&revision=232144 Fixes #17168 Change-Id: I3dd7b32b683622b8d7b4a6a8f9eb56401bed6bdf Reviewed-on: https://go-review.googlesource.com/30154 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/defs_freebsd.go')
-rw-r--r--src/runtime/defs_freebsd.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/runtime/defs_freebsd.go b/src/runtime/defs_freebsd.go
index 089cc0f818..73422b7af2 100644
--- a/src/runtime/defs_freebsd.go
+++ b/src/runtime/defs_freebsd.go
@@ -23,6 +23,7 @@ package runtime
#include <sys/mman.h>
#include <sys/ucontext.h>
#include <sys/umtx.h>
+#include <sys/_umtx.h>
#include <sys/rtprio.h>
#include <sys/thr.h>
#include <sys/_sigset.h>
@@ -49,6 +50,8 @@ const (
SA_RESTART = C.SA_RESTART
SA_ONSTACK = C.SA_ONSTACK
+ CLOCK_MONOTONIC = C.CLOCK_MONOTONIC
+
UMTX_OP_WAIT_UINT = C.UMTX_OP_WAIT_UINT
UMTX_OP_WAIT_UINT_PRIVATE = C.UMTX_OP_WAIT_UINT_PRIVATE
UMTX_OP_WAKE = C.UMTX_OP_WAKE
@@ -129,4 +132,6 @@ type Timespec C.struct_timespec
type Timeval C.struct_timeval
type Itimerval C.struct_itimerval
+type Umtx_time C.struct__umtx_time
+
type Kevent C.struct_kevent