From 32f011e46b8bf188db0d485cfd38d4e7cf19eb75 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 6 Feb 2012 18:04:12 -0500 Subject: [PATCH] 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 --- src/pkg/syscall/syscall.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pkg/syscall/syscall.go b/src/pkg/syscall/syscall.go index b10358ab820..335559fc3ac 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 +}