This adds two clock interfaces: sys.Walltime and sys.Nanotime to allow implementations to override readings for purposes of security or determinism. The default values of both are a fake timestamp, to avoid the sandbox break we formerly had by returning the real time. This is similar to how we don't inherit OS Env values.
12 lines
266 B
Go
12 lines
266 B
Go
//go:build cgo
|
|
|
|
package platform
|
|
|
|
import _ "unsafe" // for go:linkname
|
|
|
|
// nanotime uses runtime.nanotime as it is available on all platforms and
|
|
// benchmarks faster than using time.Since.
|
|
//go:noescape
|
|
//go:linkname nanotime runtime.nanotime
|
|
func nanotime() int64
|