summaryrefslogtreecommitdiffstats
path: root/contrib/go/_std_1.25/src/runtime/time_plan9.go
blob: 0bd165d07c097fe2f1076a5c1e31f6613966de23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !faketime

package runtime

import _ "unsafe" // for go:linkname

// Do not remove or change the type signature.
// See comment in timestub.go.
//
//go:linkname time_now time.now
func time_now() (sec int64, nsec int32, mono int64) {
	var t [4]uint64
	if readtime(&t[0], 1, 4) == 4 {
		mono = int64(frombe(t[3])) // new kernel, use monotonic time
	} else {
		mono = int64(frombe(t[0])) // old kernel, fall back to unix time
	}
	sec, nsec = timesplit(frombe(t[0]))
	return
}