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