File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ func main() {
142
142
}
143
143
144
144
runtime_init () // must be before defer
145
+ if nanotime () == 0 {
146
+ throw ("nanotime returning zero" )
147
+ }
145
148
146
149
// Defer unlock so that runtime.Goexit during init does the unlock too.
147
150
needUnlock := true
Original file line number Diff line number Diff line change @@ -309,4 +309,10 @@ func time_runtimeNano() int64 {
309
309
return nanotime ()
310
310
}
311
311
312
- var startNano int64 = nanotime ()
312
+ // Monotonic times are reported as offsets from startNano.
313
+ // We initialize startNano to nanotime() - 1 so that on systems where
314
+ // monotonic time resolution is fairly low (e.g. Windows 2008
315
+ // which appears to have a default resolution of 15ms),
316
+ // we avoid ever reporting a nanotime of 0.
317
+ // (Callers may want to use 0 as "time not set".)
318
+ var startNano int64 = nanotime () - 1
You can’t perform that action at this time.
0 commit comments