syscall_nacl_arm.go 723 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2014 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. package unix
  5. type Timespec struct {
  6. Sec int64
  7. Nsec int32
  8. }
  9. type Timeval struct {
  10. Sec int64
  11. Usec int32
  12. }
  13. func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
  14. func NsecToTimespec(nsec int64) (ts Timespec) {
  15. ts.Sec = int64(nsec / 1e9)
  16. ts.Nsec = int32(nsec % 1e9)
  17. return
  18. }
  19. func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
  20. func NsecToTimeval(nsec int64) (tv Timeval) {
  21. nsec += 999 // round up to microsecond
  22. tv.Usec = int32(nsec % 1e9 / 1e3)
  23. tv.Sec = int64(nsec / 1e9)
  24. return
  25. }