Commit 844e6423 authored by Keisuke Kishimoto's avatar Keisuke Kishimoto Committed by Brad Fitzpatrick

syscall: minor cleanup of duplicated code

Call the Nano methods of Timespec and Timeval in TimespecToNsec and
TimevalToNsec respectively, instead of duplicating the implementation.

Change-Id: I17551ea54c59c1e45ce472e029c625093a67251a
GitHub-Last-Rev: fecf43d163f4ebe72e8bb1d3854d4ad962c08b03
GitHub-Pull-Request: golang/go#33390
Reviewed-on: https://go-review.googlesource.com/c/go/+/188397Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 0efbd101
......@@ -8,7 +8,7 @@ package syscall
// TimespecToNsec converts a Timespec value into a number of
// nanoseconds since the Unix epoch.
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }
// NsecToTimespec takes a number of nanoseconds since the Unix epoch
// and returns the corresponding Timespec value.
......@@ -24,7 +24,7 @@ func NsecToTimespec(nsec int64) Timespec {
// TimevalToNsec converts a Timeval value into a number of nanoseconds
// since the Unix epoch.
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
func TimevalToNsec(tv Timeval) int64 { return tv.Nano() }
// NsecToTimeval takes a number of nanoseconds since the Unix epoch
// and returns the corresponding Timeval value.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment