From: Russ Cox Date: Mon, 6 Feb 2012 23:04:12 +0000 (-0500) Subject: syscall: add Timeval.Nano, Timespec.Nano, for conversion to Duration X-Git-Tag: weekly.2012-02-07~26 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=32f011e46b8bf188db0d485cfd38d4e7cf19eb75;p=gostls13.git syscall: add Timeval.Nano, Timespec.Nano, for conversion to Duration Fixes #2534. R=golang-dev, dsymonds, bradfitz CC=golang-dev https://golang.org/cl/5635051 --- diff --git a/src/pkg/syscall/syscall.go b/src/pkg/syscall/syscall.go index b10358ab82..335559fc3a 100644 --- a/src/pkg/syscall/syscall.go +++ b/src/pkg/syscall/syscall.go @@ -37,3 +37,11 @@ func (ts *Timespec) Unix() (sec int64, nsec int64) { func (tv *Timeval) Unix() (sec int64, nsec int64) { return int64(tv.Sec), int64(tv.Usec) * 1000 } + +func (ts *Timespec) Nano() int64 { + return int64(ts.Sec)*1e9 + int64(ts.Nsec) +} + +func (tv *Timeval) Nano() int64 { + return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 +}