]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll, internal/syscall/unix, net: enable writev on solaris
authorTobias Klauser <tklauser@distanz.ch>
Mon, 5 Sep 2022 13:38:18 +0000 (15:38 +0200)
committerTobias Klauser <tobias.klauser@gmail.com>
Tue, 6 Sep 2022 18:06:02 +0000 (18:06 +0000)
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 <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/internal/poll/fd_writev_solaris.go [moved from src/internal/poll/fd_writev_illumos.go with 94% similarity]
src/internal/poll/iovec_solaris.go [moved from src/internal/poll/iovec_illumos.go with 94% similarity]
src/internal/poll/writev.go
src/internal/syscall/unix/writev_solaris.go [moved from src/internal/syscall/unix/writev_illumos.go with 96% similarity]
src/net/writev_test.go
src/net/writev_unix.go

similarity index 94%
rename from src/internal/poll/fd_writev_illumos.go
rename to src/internal/poll/fd_writev_solaris.go
index 79190c2f6398a69da014eddb3aa3cb177a609ed5..d20f20114e161677aa2ba3ea3fbc93bc27a50cb7 100644 (file)
@@ -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 (
similarity index 94%
rename from src/internal/poll/iovec_illumos.go
rename to src/internal/poll/iovec_solaris.go
index 00a65d7995b9b3954c92b1bfb5d86a643f82b34c..e68f833d2d5e02db1c530d46169c6ba8da160562 100644 (file)
@@ -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 (
index cd600b63d7d61e8d97fa1a72328bd120d4cc6cf3..4086c705fdfa2bbfc9ed7abd5081b239328cbb5f 100644 (file)
@@ -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"
 )
 
@@ -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
similarity index 96%
rename from src/internal/syscall/unix/writev_illumos.go
rename to src/internal/syscall/unix/writev_solaris.go
index ee31be1302e5321f630c6d8406cd51b784f15735..d4895eef9e7408ef89d97a186fc660729c3dc3f9 100644 (file)
@@ -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 (
index 18795a457ac1f6a4066fc6b72a827f282c43820d..81b14774f9535d147bce92788d31e6e3e3152472 100644 (file)
@@ -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
index 51ab29dc312a170e9a14ff68db882af615f134a3..3318fc5f6f9b041a112bacb2f4b159f0a776c4f3 100644 (file)
@@ -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