unix: use Time{spec,val}.Nano in Time{spec,val}ToNsec

Follow what CL 188397 did in package syscall:

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

Change-Id: I50f1958c0f7bca92fc4990684f1de9c148ae5859
Reviewed-on: https://go-review.googlesource.com/c/sys/+/277253
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/unix/timestruct.go b/unix/timestruct.go
index 6b0a89a..1036042 100644
--- a/unix/timestruct.go
+++ b/unix/timestruct.go
@@ -9,7 +9,7 @@
 import "time"
 
 // TimespecToNSec returns the time stored in ts as nanoseconds.
-func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
+func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }
 
 // NsecToTimespec converts a number of nanoseconds into a Timespec.
 func NsecToTimespec(nsec int64) Timespec {
@@ -41,7 +41,7 @@
 }
 
 // TimevalToNsec returns the time stored in tv as nanoseconds.
-func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
+func TimevalToNsec(tv Timeval) int64 { return tv.Nano() }
 
 // NsecToTimeval converts a number of nanoseconds into a Timeval.
 func NsecToTimeval(nsec int64) Timeval {