| 1 |
// Copyright 2025 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
//go:build !faketime |
| 6 |
|
| 7 |
package runtime |
| 8 |
|
| 9 |
import _ "unsafe" // for go:linkname |
| 10 |
|
| 11 |
// Do not remove or change the type signature. |
| 12 |
// See comment in timestub.go. |
| 13 |
// |
| 14 |
//go:linkname time_now time.now |
| 15 |
func time_now() (sec int64, nsec int32, mono int64) { |
| 16 |
var t [4]uint64 |
| 17 |
if readtime(&t[0], 1, 4) == 4 { |
| 18 |
mono = int64(frombe(t[3])) // new kernel, use monotonic time |
| 19 |
} else { |
| 20 |
mono = int64(frombe(t[0])) // old kernel, fall back to unix time |
| 21 |
} |
| 22 |
sec, nsec = timesplit(frombe(t[0])) |
| 23 |
return |
| 24 |
} |