| // Copyright 2016 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris |
| // +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris |
| // TimespecToNSec returns the time stored in ts as nanoseconds. |
| func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } |
| // NsecToTimespec converts a number of nanoseconds into a Timespec. |
| func NsecToTimespec(nsec int64) Timespec { |
| return setTimespec(sec, nsec) |
| // TimevalToNsec returns the time stored in tv as nanoseconds. |
| func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } |
| // NsecToTimeval converts a number of nanoseconds into a Timeval. |
| func NsecToTimeval(nsec int64) Timeval { |
| nsec += 999 // round up to microsecond |
| return setTimeval(sec, usec) |