2016-03-01 22:57:46 +00:00
|
|
|
// Copyright 2014 The Go Authors. All rights reserved.
|
2014-07-10 15:15:06 -04:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package syscall
|
|
|
|
|
|
|
|
|
|
type Timespec struct {
|
|
|
|
|
Sec int64
|
|
|
|
|
Nsec int32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Timeval struct {
|
|
|
|
|
Sec int64
|
|
|
|
|
Usec int32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NsecToTimespec(nsec int64) (ts Timespec) {
|
|
|
|
|
ts.Sec = int64(nsec / 1e9)
|
|
|
|
|
ts.Nsec = int32(nsec % 1e9)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NsecToTimeval(nsec int64) (tv Timeval) {
|
|
|
|
|
nsec += 999 // round up to microsecond
|
|
|
|
|
tv.Usec = int32(nsec % 1e9 / 1e3)
|
|
|
|
|
tv.Sec = int64(nsec / 1e9)
|
|
|
|
|
return
|
|
|
|
|
}
|