syscall_dragonfly_amd64.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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,dragonfly
  5. package unix
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. func Getpagesize() int { return 4096 }
  11. func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
  12. func NsecToTimespec(nsec int64) (ts Timespec) {
  13. ts.Sec = nsec / 1e9
  14. ts.Nsec = nsec % 1e9
  15. return
  16. }
  17. func NsecToTimeval(nsec int64) (tv Timeval) {
  18. nsec += 999 // round up to microsecond
  19. tv.Usec = nsec % 1e9 / 1e3
  20. tv.Sec = int64(nsec / 1e9)
  21. return
  22. }
  23. func SetKevent(k *Kevent_t, fd, mode, flags int) {
  24. k.Ident = uint64(fd)
  25. k.Filter = int16(mode)
  26. k.Flags = uint16(flags)
  27. }
  28. func (iov *Iovec) SetLen(length int) {
  29. iov.Len = uint64(length)
  30. }
  31. func (msghdr *Msghdr) SetControllen(length int) {
  32. msghdr.Controllen = uint32(length)
  33. }
  34. func (cmsg *Cmsghdr) SetLen(length int) {
  35. cmsg.Len = uint32(length)
  36. }
  37. func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  38. var writtenOut uint64 = 0
  39. _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
  40. written = int(writtenOut)
  41. if e1 != 0 {
  42. err = e1
  43. }
  44. return
  45. }
  46. func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)