syscall_openbsd_amd64.go 886 B

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