runtime: add runtime.nanotime

This function returns the current timestamp, or 0 at compile time.

runtime.nanotime is used at package initialization by the time package
starting with Go 1.12.
This commit is contained in:
Ayke van Laethem
2019-02-27 20:36:04 +01:00
committed by Ron Evans
parent 9c41011e17
commit 4d82f42d61
3 changed files with 10 additions and 1 deletions
+5 -1
View File
@@ -84,9 +84,13 @@ func sleep(d int64) {
sleepTicks(timeUnit(d / tickMicros))
}
func nanotime() int64 {
return int64(ticks()) * tickMicros
}
//go:linkname now time.now
func now() (sec int64, nsec int32, mono int64) {
mono = int64(ticks()) * tickMicros
mono = nanotime()
sec = mono / (1000 * 1000 * 1000)
nsec = int32(mono - sec*(1000*1000*1000))
return