aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_darwin.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2018-05-26 09:58:26 -0700
committerKeith Randall <khr@golang.org>2018-05-29 22:32:30 +0000
commit6c6e22e5a9b70f22750e4fc210cd67175c6d1187 (patch)
tree39488ab465f7802655aaf9a9808a1165397e40d5 /src/runtime/sys_darwin.go
parentb0ac2546b1851a4835ad687e649dead7f610f6a9 (diff)
downloadgo-6c6e22e5a9b70f22750e4fc210cd67175c6d1187.tar.gz
go-6c6e22e5a9b70f22750e4fc210cd67175c6d1187.zip
runtime: implement time.now using libc
Change-Id: Ibdd9202d9711ea8aab2446c9950ddb8e1f6bf4e0 Reviewed-on: https://go-review.googlesource.com/114799 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/sys_darwin.go')
-rw-r--r--src/runtime/sys_darwin.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/runtime/sys_darwin.go b/src/runtime/sys_darwin.go
index 124b2fee5e..d8b5441b31 100644
--- a/src/runtime/sys_darwin.go
+++ b/src/runtime/sys_darwin.go
@@ -170,6 +170,15 @@ func nanotime() int64 {
}
func nanotime_trampoline()
+//go:nosplit
+//go:cgo_unsafe_args
+func walltime() (int64, int32) {
+ var t timeval
+ libcCall(unsafe.Pointer(funcPC(walltime_trampoline)), unsafe.Pointer(&t))
+ return int64(t.tv_sec), 1000 * t.tv_usec
+}
+func walltime_trampoline()
+
// Not used on Darwin, but must be defined.
func exitThread(wait *uint32) {
}
@@ -197,6 +206,7 @@ func exitThread(wait *uint32) {
//go:cgo_import_dynamic libc_mach_timebase_info mach_timebase_info "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic libc_mach_absolute_time mach_absolute_time "/usr/lib/libSystem.B.dylib"
+//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
// Magic incantation to get libSystem actually dynamically linked.
// TODO: Why does the code require this? See cmd/compile/internal/ld/go.go:210