diff options
author | Keith Randall <khr@golang.org> | 2018-05-01 09:42:04 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2018-05-20 00:09:28 +0000 |
commit | cc09212f59ee215cae5345dc1ffcd1ed81664e1b (patch) | |
tree | f3848bd8adf10bf4a21ee4525659d05e17185ba8 /src/runtime/defs_darwin.go | |
parent | e86c26789dbc11c50c4c49bee55ea015847a97b7 (diff) | |
download | go-cc09212f59ee215cae5345dc1ffcd1ed81664e1b.tar.gz go-cc09212f59ee215cae5345dc1ffcd1ed81664e1b.zip |
runtime: use libc for nanotime on Darwin
Use mach_absolute_time and mach_timebase_info to get nanosecond-level
timing information from libc on Darwin.
The conversion code from Apple's arbitrary time unit to nanoseconds is
really annoying. It would be nice if we could replace the internal
runtime "time" with arbitrary units and put the conversion to nanoseconds
only in the places that really need it (so it isn't in every nanotime call).
It's especially annoying because numer==denom==1 for all the machines
I tried. Makes it hard to test the conversion code :(
Update #17490
Change-Id: I6c5d602a802f5c24e35184e33d5e8194aa7afa86
Reviewed-on: https://go-review.googlesource.com/110655
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/defs_darwin.go')
-rw-r--r-- | src/runtime/defs_darwin.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/defs_darwin.go b/src/runtime/defs_darwin.go index bedaf99961..e3a25c5312 100644 --- a/src/runtime/defs_darwin.go +++ b/src/runtime/defs_darwin.go @@ -17,6 +17,7 @@ package runtime #define __DARWIN_UNIX03 0 #include <mach/mach.h> #include <mach/message.h> +#include <mach/mach_time.h> #include <sys/types.h> #include <sys/time.h> #include <errno.h> @@ -184,3 +185,5 @@ type Kevent C.struct_kevent type Pthread C.pthread_t type PthreadAttr C.pthread_attr_t + +type MachTimebaseInfo C.mach_timebase_info_data_t |