From 9555bcde0c6a6cd260623a1a1a5b49442543af2c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 17 Feb 2021 14:07:18 +0100 Subject: [PATCH] unix: add Pipe2 on netbsd Re-submit after CL 283593 broke the dragonfly builders. Change-Id: Ifdeb7642be32f5d3d3862aacdff90a0da4886365 Reviewed-on: https://go-review.googlesource.com/c/sys/+/283599 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- unix/pipe2_test.go | 2 +- unix/syscall_netbsd.go | 13 +++++++++++++ unix/zsyscall_netbsd_386.go | 10 ++++++++++ unix/zsyscall_netbsd_amd64.go | 10 ++++++++++ unix/zsyscall_netbsd_arm.go | 10 ++++++++++ unix/zsyscall_netbsd_arm64.go | 10 ++++++++++ 6 files changed, 54 insertions(+), 1 deletion(-) diff --git a/unix/pipe2_test.go b/unix/pipe2_test.go index 3e1c01fe..3cd3bbde 100644 --- a/unix/pipe2_test.go +++ b/unix/pipe2_test.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 dragonfly freebsd linux openbsd solaris +// +build dragonfly freebsd linux netbsd openbsd solaris package unix_test diff --git a/unix/syscall_netbsd.go b/unix/syscall_netbsd.go index 9b150709..853d5f0f 100644 --- a/unix/syscall_netbsd.go +++ b/unix/syscall_netbsd.go @@ -120,6 +120,19 @@ func Pipe(p []int) (err error) { return } +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) error { + if len(p) != 2 { + return EINVAL + } + 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) func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { diff --git a/unix/zsyscall_netbsd_386.go b/unix/zsyscall_netbsd_386.go index 3bbd9e39..1d6f71d9 100644 --- a/unix/zsyscall_netbsd_386.go +++ b/unix/zsyscall_netbsd_386.go @@ -362,6 +362,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +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) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { diff --git a/unix/zsyscall_netbsd_amd64.go b/unix/zsyscall_netbsd_amd64.go index d8cf5012..82f50506 100644 --- a/unix/zsyscall_netbsd_amd64.go +++ b/unix/zsyscall_netbsd_amd64.go @@ -362,6 +362,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +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) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { diff --git a/unix/zsyscall_netbsd_arm.go b/unix/zsyscall_netbsd_arm.go index 1153fe69..b4db55a0 100644 --- a/unix/zsyscall_netbsd_arm.go +++ b/unix/zsyscall_netbsd_arm.go @@ -362,6 +362,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +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) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { diff --git a/unix/zsyscall_netbsd_arm64.go b/unix/zsyscall_netbsd_arm64.go index 24b4ebb4..e9f6d797 100644 --- a/unix/zsyscall_netbsd_arm64.go +++ b/unix/zsyscall_netbsd_arm64.go @@ -362,6 +362,16 @@ func pipe() (fd1 int, fd2 int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +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) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 {