aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os3_solaris.go
diff options
context:
space:
mode:
authorJerrin Shaji George <jerrinsg@gmail.com>2019-10-07 12:27:33 -0700
committerIan Lance Taylor <iant@golang.org>2019-10-11 20:01:28 +0000
commit2df5cdbadf5fbcb23f017c9f00b75dc341a69adf (patch)
treeb56a5b279afdaf5e91a2fd4682184639455eef6d /src/runtime/os3_solaris.go
parentc1ccae4d149ac23b376d17fdef486e631a92f775 (diff)
downloadgo-2df5cdbadf5fbcb23f017c9f00b75dc341a69adf.tar.xz
runtime: make nanotime use monotonic clock in Solaris
nanotime() currently uses the REALTIME clock to get the elapsed time in Solaris. This commit changes it to use the MONOTONIC clock instead, similar to how it's done in Linux and other OSs. Also changed nanotime() and walltime() to call clock_gettime() library function directly from Go code rather than from assembly. Fixes #33674 Change-Id: Ie4a687b17d2140998ecd97af6ce048c86cf5fc02 Reviewed-on: https://go-review.googlesource.com/c/go/+/199502 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Diffstat (limited to 'src/runtime/os3_solaris.go')
-rw-r--r--src/runtime/os3_solaris.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/runtime/os3_solaris.go b/src/runtime/os3_solaris.go
index afda44295b..cdec190de5 100644
--- a/src/runtime/os3_solaris.go
+++ b/src/runtime/os3_solaris.go
@@ -393,11 +393,16 @@ func munmap(addr unsafe.Pointer, n uintptr) {
sysvicall2(&libc_munmap, uintptr(addr), uintptr(n))
}
-func nanotime2()
+const (
+ _CLOCK_REALTIME = 3
+ _CLOCK_MONOTONIC = 4
+)
//go:nosplit
func nanotime1() int64 {
- return int64(sysvicall0((*libcFunc)(unsafe.Pointer(funcPC(nanotime2)))))
+ var ts mts
+ sysvicall2(&libc_clock_gettime, _CLOCK_MONOTONIC, uintptr(unsafe.Pointer(&ts)))
+ return ts.tv_sec*1e9 + ts.tv_nsec
}
//go:nosplit
@@ -498,6 +503,12 @@ func usleep(µs uint32) {
usleep1(µs)
}
+func walltime1() (sec int64, nsec int32) {
+ var ts mts
+ sysvicall2(&libc_clock_gettime, _CLOCK_REALTIME, uintptr(unsafe.Pointer(&ts)))
+ return ts.tv_sec, int32(ts.tv_nsec)
+}
+
//go:nosplit
func write1(fd uintptr, buf unsafe.Pointer, nbyte int32) int32 {
return int32(sysvicall3(&libc_write, uintptr(fd), uintptr(buf), uintptr(nbyte)))