diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2020-09-14 11:06:39 +0200 |
---|---|---|
committer | Tobias Klauser <tobias.klauser@gmail.com> | 2020-09-15 05:08:53 +0000 |
commit | 3b64e6b010775839f2daef4ac3fb607bf1519e05 (patch) | |
tree | d0e917f9caa9aed787f769b326c67b7f2b926fb3 /src/internal/syscall/unix/writev_illumos.go | |
parent | bae9cf651796db898b1e4bd77a1a47c5f2d7b04d (diff) | |
download | go-git-3b64e6b010775839f2daef4ac3fb607bf1519e05.tar.gz |
internal/poll, internal/syscall/unix, net: enable writev on illumos
Illumos supports iovec read/write. Add the writev wrapper to
internal/syscall/unix and use it to implement internal/poll.writev for
net.(*netFD).writeBuffers.
Change-Id: Ie256c2f96aba8e61fb21991788789a049425f792
Reviewed-on: https://go-review.googlesource.com/c/go/+/254638
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Diffstat (limited to 'src/internal/syscall/unix/writev_illumos.go')
-rw-r--r-- | src/internal/syscall/unix/writev_illumos.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/internal/syscall/unix/writev_illumos.go b/src/internal/syscall/unix/writev_illumos.go new file mode 100644 index 0000000000..eb7973d65b --- /dev/null +++ b/src/internal/syscall/unix/writev_illumos.go @@ -0,0 +1,30 @@ +// Copyright 2020 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. + +// +build illumos + +package unix + +import ( + "syscall" + "unsafe" +) + +//go:cgo_import_dynamic libc_writev writev "libc.so" + +//go:linkname procwritev libc_writev + +var procwritev uintptr + +func Writev(fd int, iovs []syscall.Iovec) (uintptr, error) { + var p *syscall.Iovec + if len(iovs) > 0 { + p = &iovs[0] + } + n, _, errno := syscall6(uintptr(unsafe.Pointer(&procwritev)), 3, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(len(iovs)), 0, 0, 0) + if errno != 0 { + return 0, errno + } + return n, nil +} |