Skip to content

Commit

Permalink
internal/poll, internal/syscall/unix, net: enable writev on solaris
Browse files Browse the repository at this point in the history
The writev syscall is available since at least Solaris 11.3.

Reuse the existing illumos writev wrapper on solaris to implement
internal/poll.writev for net.(*netFD).writeBuffers.

Change-Id: I23adc3bb4637740c72bfb61bfa9697b432dfe3db
Reviewed-on: https://go-review.googlesource.com/c/go/+/427714
Run-TryBot: Tobias Klauser <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
  • Loading branch information
tklauser committed Sep 6, 2022
1 parent e0e0c8f commit 00234b0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build illumos

package poll

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build illumos

package poll

import (
Expand Down
7 changes: 6 additions & 1 deletion src/internal/poll/writev.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build darwin || dragonfly || freebsd || illumos || linux || netbsd || openbsd
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris

package poll

import (
"io"
"runtime"
"syscall"
)

Expand All @@ -29,6 +30,10 @@ func (fd *FD) Writev(v *[][]byte) (int64, error) {
// 1024 and this seems conservative enough for now. Darwin's
// UIO_MAXIOV also seems to be 1024.
maxVec := 1024
if runtime.GOOS == "solaris" {
// IOV_MAX is set to XOPEN_IOV_MAX on Solaris.
maxVec = 16
}

var n int64
var err error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build illumos

package unix

import (
Expand Down
2 changes: 1 addition & 1 deletion src/net/writev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func testBuffer_writeTo(t *testing.T, chunks int, useCopy bool) {

var wantSum int
switch runtime.GOOS {
case "android", "darwin", "ios", "dragonfly", "freebsd", "illumos", "linux", "netbsd", "openbsd":
case "android", "darwin", "ios", "dragonfly", "freebsd", "illumos", "linux", "netbsd", "openbsd", "solaris":
var wantMinCalls int
wantSum = want.Len()
v := chunks
Expand Down
2 changes: 1 addition & 1 deletion src/net/writev_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build darwin || dragonfly || freebsd || illumos || linux || netbsd || openbsd
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris

package net

Expand Down

0 comments on commit 00234b0

Please sign in to comment.