From 9fbb57f87de9ccfe3a99d4e3270ce8a926ebba4f Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 24 Jan 2020 09:31:26 -0700 Subject: [PATCH] unix: use pipe2 syscall on OpenBSD pipe2 has been available on OpenBSD for some time, all currently supported versions of OpenBSD have an implementataion of it. Change-Id: I740da07139541084f99a4fa4efcf67a591eed9e5 Reviewed-on: https://go-review.googlesource.com/c/sys/+/216244 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- unix/syscall_openbsd.go | 10 +++++++--- unix/zsyscall_openbsd_386.go | 4 ++-- unix/zsyscall_openbsd_amd64.go | 4 ++-- unix/zsyscall_openbsd_arm.go | 4 ++-- unix/zsyscall_openbsd_arm64.go | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/unix/syscall_openbsd.go b/unix/syscall_openbsd.go index 2629a326..a266e92a 100644 --- a/unix/syscall_openbsd.go +++ b/unix/syscall_openbsd.go @@ -72,16 +72,20 @@ func SysctlUvmexp(name string) (*Uvmexp, error) { return &u, nil } -//sysnb pipe(p *[2]_C_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 } var pp [2]_C_int - err = pipe(&pp) + err := pipe2(&pp, flags) p[0] = int(pp[0]) p[1] = int(pp[1]) - return + return err } //sys Getdents(fd int, buf []byte) (n int, err error) diff --git a/unix/zsyscall_openbsd_386.go b/unix/zsyscall_openbsd_386.go index aad7b9c8..b44b31ae 100644 --- a/unix/zsyscall_openbsd_386.go +++ b/unix/zsyscall_openbsd_386.go @@ -350,8 +350,8 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) +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/unix/zsyscall_openbsd_amd64.go b/unix/zsyscall_openbsd_amd64.go index 365b33d2..67f93ee7 100644 --- a/unix/zsyscall_openbsd_amd64.go +++ b/unix/zsyscall_openbsd_amd64.go @@ -350,8 +350,8 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) +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/unix/zsyscall_openbsd_arm.go b/unix/zsyscall_openbsd_arm.go index 07cba965..d7c878b1 100644 --- a/unix/zsyscall_openbsd_arm.go +++ b/unix/zsyscall_openbsd_arm.go @@ -350,8 +350,8 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) +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/unix/zsyscall_openbsd_arm64.go b/unix/zsyscall_openbsd_arm64.go index 78951abf..8facd695 100644 --- a/unix/zsyscall_openbsd_arm64.go +++ b/unix/zsyscall_openbsd_arm64.go @@ -350,8 +350,8 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) +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) }