syscall_netbsd_amd64.go 828 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2009 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 amd64,netbsd
  5. package unix
  6. func NsecToTimespec(nsec int64) (ts Timespec) {
  7. ts.Sec = int64(nsec / 1e9)
  8. ts.Nsec = int64(nsec % 1e9)
  9. return
  10. }
  11. func NsecToTimeval(nsec int64) (tv Timeval) {
  12. nsec += 999 // round up to microsecond
  13. tv.Usec = int32(nsec % 1e9 / 1e3)
  14. tv.Sec = int64(nsec / 1e9)
  15. return
  16. }
  17. func SetKevent(k *Kevent_t, fd, mode, flags int) {
  18. k.Ident = uint64(fd)
  19. k.Filter = uint32(mode)
  20. k.Flags = uint32(flags)
  21. }
  22. func (iov *Iovec) SetLen(length int) {
  23. iov.Len = uint64(length)
  24. }
  25. func (msghdr *Msghdr) SetControllen(length int) {
  26. msghdr.Controllen = uint32(length)
  27. }
  28. func (cmsg *Cmsghdr) SetLen(length int) {
  29. cmsg.Len = uint32(length)
  30. }