mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-10 14:26:26 -05:00
c78ee5aac7
* ⬆ Update to Go 1.17 * 🏗 Update workflows and add windows-arm64 * 💾 Update generated files * 📛 Update not-so-friendly filenames
38 lines
561 B
Go
38 lines
561 B
Go
//go:build illumos
|
|
// +build illumos
|
|
|
|
package buf
|
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
type unixReader struct {
|
|
iovs [][]byte
|
|
}
|
|
|
|
func (r *unixReader) Init(bs []*Buffer) {
|
|
iovs := r.iovs
|
|
if iovs == nil {
|
|
iovs = make([][]byte, 0, len(bs))
|
|
}
|
|
for _, b := range bs {
|
|
iovs = append(iovs, b.v)
|
|
}
|
|
r.iovs = iovs
|
|
}
|
|
|
|
func (r *unixReader) Read(fd uintptr) int32 {
|
|
n, e := unix.Readv(int(fd), r.iovs)
|
|
if e != nil {
|
|
return -1
|
|
}
|
|
return int32(n)
|
|
}
|
|
|
|
func (r *unixReader) Clear() {
|
|
r.iovs = r.iovs[:0]
|
|
}
|
|
|
|
func newMultiReader() multiReader {
|
|
return &unixReader{}
|
|
}
|