-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iovec read/writes (readv, writev, preadv, pwritev) are present on illumos, but they weren't added to the package. This commit adds those missing features. Updates golang/go#36201 Change-Id: Iecf2bab7ef846f5ca5d693e833491d819618c15d GitHub-Last-Rev: 81a479f GitHub-Pull-Request: #64 Reviewed-on: https://go-review.googlesource.com/c/sys/+/224238 Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Tobias Klauser <[email protected]>
- Loading branch information
Showing
4 changed files
with
167 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2009 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// illumos system calls not present on Solaris. | ||
|
||
// +build amd64,illumos | ||
|
||
package unix | ||
|
||
import "unsafe" | ||
|
||
func bytes2iovec(bs [][]byte) []Iovec { | ||
iovecs := make([]Iovec, len(bs)) | ||
for i, b := range bs { | ||
iovecs[i].SetLen(len(b)) | ||
if len(b) > 0 { | ||
// somehow Iovec.Base on illumos is (*int8), not (*byte) | ||
iovecs[i].Base = (*int8)(unsafe.Pointer(&b[0])) | ||
} else { | ||
iovecs[i].Base = (*int8)(unsafe.Pointer(&_zero)) | ||
} | ||
} | ||
return iovecs | ||
} | ||
|
||
//sys readv(fd int, iovs []Iovec) (n int, err error) | ||
|
||
func Readv(fd int, iovs [][]byte) (n int, err error) { | ||
iovecs := bytes2iovec(iovs) | ||
n, err = readv(fd, iovecs) | ||
return n, err | ||
} | ||
|
||
//sys preadv(fd int, iovs []Iovec, off int64) (n int, err error) | ||
|
||
func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) { | ||
iovecs := bytes2iovec(iovs) | ||
n, err = preadv(fd, iovecs, off) | ||
return n, err | ||
} | ||
|
||
//sys writev(fd int, iovs []Iovec) (n int, err error) | ||
|
||
func Writev(fd int, iovs [][]byte) (n int, err error) { | ||
iovecs := bytes2iovec(iovs) | ||
n, err = writev(fd, iovecs) | ||
return n, err | ||
} | ||
|
||
//sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error) | ||
|
||
func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) { | ||
iovecs := bytes2iovec(iovs) | ||
n, err = pwritev(fd, iovecs, off) | ||
return n, err | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.