From: Tobias Klauser Date: Wed, 14 Feb 2018 14:56:39 +0000 (+0000) Subject: syscall, os: use pipe2 syscall on NetBSD instead of pipe X-Git-Tag: go1.11beta1~1651 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=eab06e65f7c4a1e3acafc220d0e9b8eca50f0311;p=gostls13.git syscall, os: use pipe2 syscall on NetBSD instead of pipe The pipe2 syscall is part of NetBSD since version 6.0 and thus exists in all officially supported versions (6.0 through 6.1 and 7.0+). Follows CL 38426 Change-Id: I7b62b507300c3dfbcc6ae56408a7d7088ddccc77 Reviewed-on: https://go-review.googlesource.com/94035 Run-TryBot: Tobias Klauser Reviewed-by: Brad Fitzpatrick Reviewed-by: Benny Siegert TryBot-Result: Gobot Gobot --- diff --git a/src/os/pipe_freebsd.go b/src/os/pipe2_bsd.go similarity index 95% rename from src/os/pipe_freebsd.go rename to src/os/pipe2_bsd.go index 93bd869afd..1615067b41 100644 --- a/src/os/pipe_freebsd.go +++ b/src/os/pipe2_bsd.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build freebsd netbsd + package os import "syscall" diff --git a/src/os/pipe_bsd.go b/src/os/pipe_bsd.go index d16c2a6c0b..04eaf83791 100644 --- a/src/os/pipe_bsd.go +++ b/src/os/pipe_bsd.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. -// +build darwin dragonfly nacl netbsd openbsd solaris +// +build darwin dragonfly nacl openbsd solaris package os diff --git a/src/syscall/forkpipe.go b/src/syscall/forkpipe.go index fa799eb5b9..5d9eb4d5f2 100644 --- a/src/syscall/forkpipe.go +++ b/src/syscall/forkpipe.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. -// +build darwin dragonfly netbsd openbsd solaris +// +build darwin dragonfly openbsd solaris package syscall diff --git a/src/syscall/exec_freebsd.go b/src/syscall/forkpipe2.go similarity index 90% rename from src/syscall/exec_freebsd.go rename to src/syscall/forkpipe2.go index 1654b4ba2a..2bf4757133 100644 --- a/src/syscall/exec_freebsd.go +++ b/src/syscall/forkpipe2.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build freebsd netbsd + package syscall func forkExecPipe(p []int) error { diff --git a/src/syscall/syscall_netbsd.go b/src/syscall/syscall_netbsd.go index d9eddc18cf..90837e01f9 100644 --- a/src/syscall/syscall_netbsd.go +++ b/src/syscall/syscall_netbsd.go @@ -102,13 +102,20 @@ func direntNamlen(buf []byte) (uint64, bool) { return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen)) } -//sysnb pipe() (fd1 int, fd2 int, err error) func Pipe(p []int) (err error) { + return Pipe2(p, 0) +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) +func Pipe2(p []int, flags int) error { if len(p) != 2 { return EINVAL } - p[0], p[1], err = pipe() - return + var pp [2]_C_int + err := pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return err } //sys getdents(fd int, buf []byte) (n int, err error) diff --git a/src/syscall/zsyscall_netbsd_386.go b/src/syscall/zsyscall_netbsd_386.go index 9102465948..156292a84e 100644 --- a/src/syscall/zsyscall_netbsd_386.go +++ b/src/syscall/zsyscall_netbsd_386.go @@ -261,10 +261,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (fd1 int, fd2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - fd1 = int(r0) - fd2 = int(r1) +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } diff --git a/src/syscall/zsyscall_netbsd_amd64.go b/src/syscall/zsyscall_netbsd_amd64.go index f4a46c19a2..1af62b715e 100644 --- a/src/syscall/zsyscall_netbsd_amd64.go +++ b/src/syscall/zsyscall_netbsd_amd64.go @@ -261,10 +261,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (fd1 int, fd2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - fd1 = int(r0) - fd2 = int(r1) +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } diff --git a/src/syscall/zsyscall_netbsd_arm.go b/src/syscall/zsyscall_netbsd_arm.go index b07e7775c1..b03b19169e 100644 --- a/src/syscall/zsyscall_netbsd_arm.go +++ b/src/syscall/zsyscall_netbsd_arm.go @@ -261,10 +261,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (fd1 int, fd2 int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - fd1 = int(r0) - fd2 = int(r1) +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) }