syscall_freebsd_arm64.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2018 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 arm64,freebsd
  5. package unix
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. func setTimespec(sec, nsec int64) Timespec {
  11. return Timespec{Sec: sec, Nsec: nsec}
  12. }
  13. func setTimeval(sec, usec int64) Timeval {
  14. return Timeval{Sec: sec, Usec: usec}
  15. }
  16. func SetKevent(k *Kevent_t, fd, mode, flags int) {
  17. k.Ident = uint64(fd)
  18. k.Filter = int16(mode)
  19. k.Flags = uint16(flags)
  20. }
  21. func (iov *Iovec) SetLen(length int) {
  22. iov.Len = uint64(length)
  23. }
  24. func (msghdr *Msghdr) SetControllen(length int) {
  25. msghdr.Controllen = uint32(length)
  26. }
  27. func (msghdr *Msghdr) SetIovlen(length int) {
  28. msghdr.Iovlen = int32(length)
  29. }
  30. func (cmsg *Cmsghdr) SetLen(length int) {
  31. cmsg.Len = uint32(length)
  32. }
  33. func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  34. var writtenOut uint64 = 0
  35. _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0)
  36. written = int(writtenOut)
  37. if e1 != 0 {
  38. err = e1
  39. }
  40. return
  41. }
  42. func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)