timestruct.go 606 B

123456789101112131415
  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package unix
  6. // TimespecToNsec converts a Timespec value into a number of
  7. // nanoseconds since the Unix epoch.
  8. func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
  9. // TimevalToNsec converts a Timeval value into a number of nanoseconds
  10. // since the Unix epoch.
  11. func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }