syscall_freebsd_arm.go 1.2 KB

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