From: Tobias Klauser Date: Tue, 4 Oct 2022 11:53:46 +0000 (+0200) Subject: internal/poll, internal/syscall/unix, syscall: move writev definition for solaris X-Git-Tag: go1.20rc1~711 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5ca0cd3f1824f189b6c5edf59b669f22a393e2e1;p=gostls13.git internal/poll, internal/syscall/unix, syscall: move writev definition for solaris Move the writev definition for solaris from package internal/syscall/unix to package syscall. This corresponds to where writev is defined on aix, darwin and openbsd as well and is go:linkname'ed from internal/poll. This also allows updating the generated wrappers more easily if needed. Change-Id: I671ed8232d25319f8e63f549f786d77a17602148 Reviewed-on: https://go-review.googlesource.com/c/go/+/436597 Run-TryBot: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Carlos Amedee Reviewed-by: Ian Lance Taylor Auto-Submit: Tobias Klauser --- diff --git a/src/internal/poll/fd_writev_libc.go b/src/internal/poll/fd_writev_libc.go index 7d59e6b641..0a60473b3e 100644 --- a/src/internal/poll/fd_writev_libc.go +++ b/src/internal/poll/fd_writev_libc.go @@ -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 aix || darwin || (openbsd && !mips64) +//go:build aix || darwin || (openbsd && !mips64) || solaris package poll diff --git a/src/internal/poll/fd_writev_solaris.go b/src/internal/poll/fd_writev_solaris.go deleted file mode 100644 index d20f20114e..0000000000 --- a/src/internal/poll/fd_writev_solaris.go +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -package poll - -import ( - "internal/syscall/unix" - "syscall" -) - -func writev(fd int, iovecs []syscall.Iovec) (uintptr, error) { - return unix.Writev(fd, iovecs) -} diff --git a/src/internal/syscall/unix/writev_solaris.go b/src/internal/syscall/unix/writev_solaris.go deleted file mode 100644 index d4895eef9e..0000000000 --- a/src/internal/syscall/unix/writev_solaris.go +++ /dev/null @@ -1,28 +0,0 @@ -// 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. - -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 -} diff --git a/src/syscall/syscall_solaris.go b/src/syscall/syscall_solaris.go index fce0b058fc..2d042acdc9 100644 --- a/src/syscall/syscall_solaris.go +++ b/src/syscall/syscall_solaris.go @@ -495,6 +495,7 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i //sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.__xnet_socket //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.__xnet_socketpair //sys write(fd int, p []byte) (n int, err error) +//sys writev(fd int, iovecs []Iovec) (n uintptr, err error) //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.__xnet_getsockopt //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername //sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname diff --git a/src/syscall/zsyscall_solaris_amd64.go b/src/syscall/zsyscall_solaris_amd64.go index a2bbeed844..19e5ec1fcd 100644 --- a/src/syscall/zsyscall_solaris_amd64.go +++ b/src/syscall/zsyscall_solaris_amd64.go @@ -85,6 +85,7 @@ import "unsafe" //go:cgo_import_dynamic libc___xnet_socket __xnet_socket "libsocket.so" //go:cgo_import_dynamic libc___xnet_socketpair __xnet_socketpair "libsocket.so" //go:cgo_import_dynamic libc_write write "libc.so" +//go:cgo_import_dynamic libc_writev writev "libc.so" //go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so" //go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so" //go:cgo_import_dynamic libc_getsockname getsockname "libsocket.so" @@ -172,6 +173,7 @@ import "unsafe" //go:linkname libc___xnet_socket libc___xnet_socket //go:linkname libc___xnet_socketpair libc___xnet_socketpair //go:linkname libc_write libc_write +//go:linkname libc_writev libc_writev //go:linkname libc___xnet_getsockopt libc___xnet_getsockopt //go:linkname libc_getpeername libc_getpeername //go:linkname libc_getsockname libc_getsockname @@ -262,6 +264,7 @@ var ( libc___xnet_socket, libc___xnet_socketpair, libc_write, + libc_writev, libc___xnet_getsockopt, libc_getpeername, libc_getsockname, @@ -1209,6 +1212,21 @@ func write(fd int, p []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func writev(fd int, iovecs []Iovec) (n uintptr, err error) { + var _p0 *Iovec + if len(iovecs) > 0 { + _p0 = &iovecs[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_writev)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(iovecs)), 0, 0, 0) + n = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc___xnet_getsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) if e1 != 0 {