mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
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:
committed by
Ron Evans
parent
9c41011e17
commit
4d82f42d61
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user