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_amd64.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_amd64.go')
-rw-r--r-- | src/runtime/defs_darwin_amd64.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/defs_darwin_amd64.go b/src/runtime/defs_darwin_amd64.go index d1483e7db5..f35b90a5fa 100644 --- a/src/runtime/defs_darwin_amd64.go +++ b/src/runtime/defs_darwin_amd64.go @@ -398,3 +398,7 @@ type pthreadattr struct { X__sig int64 X__opaque [56]int8 } +type machTimebaseInfo struct { + numer uint32 + denom uint32 +} |