diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2021-02-23 14:58:32 +0100 |
---|---|---|
committer | Tobias Klauser <tobias.klauser@gmail.com> | 2021-02-25 09:20:03 +0000 |
commit | 76c0003cd5645078e342c1d24c98b3ce5ae42eb4 (patch) | |
tree | 9e07285c7cedd7a94b95a3b9acafeef9ba77bcb4 | |
parent | 666ad85df450e3a54a77954f97423980b6ac064f (diff) | |
download | go-76c0003cd5645078e342c1d24c98b3ce5ae42eb4.tar.gz go-76c0003cd5645078e342c1d24c98b3ce5ae42eb4.zip |
syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe
Follow the implementation used by the other BSDs and account for the
intricacy of having to pass the fds array even though the file
descriptors are returned.
Re-submit of CL 130996 with corrected pipe2 wrapper.
Change-Id: Ie36d8214cba60c4fdb579f18bfc1c1ab3ead3ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/295372
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/os/pipe2_bsd.go | 4 | ||||
-rw-r--r-- | src/os/pipe_bsd.go | 4 | ||||
-rw-r--r-- | src/syscall/forkpipe.go | 4 | ||||
-rw-r--r-- | src/syscall/forkpipe2.go | 4 | ||||
-rw-r--r-- | src/syscall/syscall_dragonfly.go | 13 | ||||
-rw-r--r-- | src/syscall/zsyscall_dragonfly_amd64.go | 12 | ||||
-rw-r--r-- | src/syscall/zsysnum_dragonfly_amd64.go | 1 |
7 files changed, 34 insertions, 8 deletions
diff --git a/src/os/pipe2_bsd.go b/src/os/pipe2_bsd.go index 0af8019525..bf6d081db5 100644 --- a/src/os/pipe2_bsd.go +++ b/src/os/pipe2_bsd.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build freebsd || netbsd || openbsd -// +build freebsd netbsd openbsd +//go:build dragonfly || freebsd || netbsd || openbsd +// +build dragonfly freebsd netbsd openbsd package os diff --git a/src/os/pipe_bsd.go b/src/os/pipe_bsd.go index 57959a2ea4..097b32e7eb 100644 --- a/src/os/pipe_bsd.go +++ b/src/os/pipe_bsd.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build aix || darwin || dragonfly || (js && wasm) || (solaris && !illumos) -// +build aix darwin dragonfly js,wasm solaris,!illumos +//go:build aix || darwin || (js && wasm) || (solaris && !illumos) +// +build aix darwin js,wasm solaris,!illumos package os diff --git a/src/syscall/forkpipe.go b/src/syscall/forkpipe.go index c7ddcf26ab..79cbdf4150 100644 --- a/src/syscall/forkpipe.go +++ b/src/syscall/forkpipe.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build aix || darwin || dragonfly || solaris -// +build aix darwin dragonfly solaris +//go:build aix || darwin || solaris +// +build aix darwin solaris package syscall diff --git a/src/syscall/forkpipe2.go b/src/syscall/forkpipe2.go index cd98779ac9..e57240c156 100644 --- a/src/syscall/forkpipe2.go +++ b/src/syscall/forkpipe2.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build freebsd || netbsd || openbsd -// +build freebsd netbsd openbsd +//go:build dragonfly || freebsd || netbsd || openbsd +// +build dragonfly freebsd netbsd openbsd package syscall diff --git a/src/syscall/syscall_dragonfly.go b/src/syscall/syscall_dragonfly.go index 0988fe4608..b01a4ada67 100644 --- a/src/syscall/syscall_dragonfly.go +++ b/src/syscall/syscall_dragonfly.go @@ -100,6 +100,19 @@ func Pipe(p []int) (err error) { return } +//sysnb pipe2(p *[2]_C_int, flags int) (r int, w int, err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + // pipe2 on dragonfly takes an fds array as an argument, but still + // returns the file descriptors. + p[0], p[1], err = pipe2(&pp, flags) + return err +} + //sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error) func Pread(fd int, p []byte, offset int64) (n int, err error) { return extpread(fd, p, 0, offset) diff --git a/src/syscall/zsyscall_dragonfly_amd64.go b/src/syscall/zsyscall_dragonfly_amd64.go index 4799d1dcb0..aa327c0010 100644 --- a/src/syscall/zsyscall_dragonfly_amd64.go +++ b/src/syscall/zsyscall_dragonfly_amd64.go @@ -274,6 +274,18 @@ func pipe() (r int, w int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func extpread(fd int, p []byte, flags int, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { diff --git a/src/syscall/zsysnum_dragonfly_amd64.go b/src/syscall/zsysnum_dragonfly_amd64.go index 855188f045..ae504a5f0c 100644 --- a/src/syscall/zsysnum_dragonfly_amd64.go +++ b/src/syscall/zsysnum_dragonfly_amd64.go @@ -302,6 +302,7 @@ const ( SYS_LPATHCONF = 533 // { int lpathconf(char *path, int name); } SYS_VMM_GUEST_CTL = 534 // { int vmm_guest_ctl(int op, struct vmm_guest_options *options); } SYS_VMM_GUEST_SYNC_ADDR = 535 // { int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); } + SYS_PIPE2 = 538 // { int pipe2(int *fildes, int flags); } SYS_UTIMENSAT = 539 // { int utimensat(int fd, const char *path, const struct timespec *ts, int flags); } SYS_ACCEPT4 = 541 // { int accept4(int s, caddr_t name, int *anamelen, int flags); } ) |