aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_openbsd2.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2021-12-01 13:41:45 -0500
committerAustin Clements <austin@google.com>2021-12-02 15:48:58 +0000
commit28ec0fdeb500b4d0ab5c0ac07cba2f5ebc12ae32 (patch)
tree1467272f787a3a04d6a34ebc358e05748d05bc17 /src/runtime/sys_openbsd2.go
parentd34051bf16d86a88e6c5764aa076219069702045 (diff)
downloadgo-28ec0fdeb500b4d0ab5c0ac07cba2f5ebc12ae32.tar.xz
runtime: print errno on clock_gettime failure on OpenBSD
For #49532. Change-Id: I5afc64c987f0519903128550a7dac3a0f5e592cf Reviewed-on: https://go-review.googlesource.com/c/go/+/368334 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/runtime/sys_openbsd2.go')
-rw-r--r--src/runtime/sys_openbsd2.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/runtime/sys_openbsd2.go b/src/runtime/sys_openbsd2.go
index a7786fe65a..4d50b4f6b1 100644
--- a/src/runtime/sys_openbsd2.go
+++ b/src/runtime/sys_openbsd2.go
@@ -174,7 +174,13 @@ func nanotime1() int64 {
clock_id int32
tp unsafe.Pointer
}{_CLOCK_MONOTONIC, unsafe.Pointer(&ts)}
- libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args))
+ if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
+ // Avoid growing the nosplit stack.
+ systemstack(func() {
+ println("runtime: errno", -errno)
+ throw("clock_gettime failed")
+ })
+ }
return ts.tv_sec*1e9 + int64(ts.tv_nsec)
}
func clock_gettime_trampoline()
@@ -186,7 +192,13 @@ func walltime() (int64, int32) {
clock_id int32
tp unsafe.Pointer
}{_CLOCK_REALTIME, unsafe.Pointer(&ts)}
- libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args))
+ if errno := libcCall(unsafe.Pointer(abi.FuncPCABI0(clock_gettime_trampoline)), unsafe.Pointer(&args)); errno < 0 {
+ // Avoid growing the nosplit stack.
+ systemstack(func() {
+ println("runtime: errno", -errno)
+ throw("clock_gettime failed")
+ })
+ }
return ts.tv_sec, int32(ts.tv_nsec)
}