You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

syscall_illumos.go 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // illumos system calls not present on Solaris.
  5. // +build amd64,illumos
  6. package unix
  7. import "unsafe"
  8. func bytes2iovec(bs [][]byte) []Iovec {
  9. iovecs := make([]Iovec, len(bs))
  10. for i, b := range bs {
  11. iovecs[i].SetLen(len(b))
  12. if len(b) > 0 {
  13. // somehow Iovec.Base on illumos is (*int8), not (*byte)
  14. iovecs[i].Base = (*int8)(unsafe.Pointer(&b[0]))
  15. } else {
  16. iovecs[i].Base = (*int8)(unsafe.Pointer(&_zero))
  17. }
  18. }
  19. return iovecs
  20. }
  21. //sys readv(fd int, iovs []Iovec) (n int, err error)
  22. func Readv(fd int, iovs [][]byte) (n int, err error) {
  23. iovecs := bytes2iovec(iovs)
  24. n, err = readv(fd, iovecs)
  25. return n, err
  26. }
  27. //sys preadv(fd int, iovs []Iovec, off int64) (n int, err error)
  28. func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
  29. iovecs := bytes2iovec(iovs)
  30. n, err = preadv(fd, iovecs, off)
  31. return n, err
  32. }
  33. //sys writev(fd int, iovs []Iovec) (n int, err error)
  34. func Writev(fd int, iovs [][]byte) (n int, err error) {
  35. iovecs := bytes2iovec(iovs)
  36. n, err = writev(fd, iovecs)
  37. return n, err
  38. }
  39. //sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
  40. func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
  41. iovecs := bytes2iovec(iovs)
  42. n, err = pwritev(fd, iovecs, off)
  43. return n, err
  44. }