libcall_bsd_sendfile.go 664 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2015 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 darwin dragonfly freebsd openbsd solaris
  5. // BSD sendfile support.
  6. package syscall
  7. import (
  8. "internal/race"
  9. "unsafe"
  10. )
  11. func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  12. if race.Enabled {
  13. race.ReleaseMerge(unsafe.Pointer(&ioSync))
  14. }
  15. var soff Offset_t
  16. var psoff *Offset_t
  17. if offset != nil {
  18. soff = Offset_t(*offset)
  19. psoff = &soff
  20. }
  21. written, err = sendfile(outfd, infd, psoff, count)
  22. if offset != nil {
  23. *offset = int64(soff)
  24. }
  25. return
  26. }