From 11551d06cbcc94edc80a0facaccbda56473c19c1 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 23 Aug 2018 14:12:18 +0000 Subject: [PATCH] unix: use pipe2 syscall on FreeBSD instead of pipe The pipe syscall no longer exists in FreeBSD 11 and 12. The pipe2 syscall exists in all currently supported FreeBSD versions: 10, 11 and the upcoming 12. Follow CL 38426 Change-Id: If908eecfd2662e6f32a229ac52f27d9a2ec2b9d7 Reviewed-on: https://go-review.googlesource.com/130995 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- unix/syscall_freebsd.go | 15 +++++++++++---- unix/zsyscall_freebsd_386.go | 6 ++---- unix/zsyscall_freebsd_amd64.go | 6 ++---- unix/zsyscall_freebsd_arm.go | 6 ++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/unix/syscall_freebsd.go b/unix/syscall_freebsd.go index 7bc830d0..77a634c7 100644 --- a/unix/syscall_freebsd.go +++ b/unix/syscall_freebsd.go @@ -57,14 +57,21 @@ func nametomib(name string) (mib []_C_int, err error) { return buf[0 : n/siz], nil } -//sysnb pipe() (r int, w 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 } func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) { diff --git a/unix/zsyscall_freebsd_386.go b/unix/zsyscall_freebsd_386.go index a86434a7..ad77882b 100644 --- a/unix/zsyscall_freebsd_386.go +++ b/unix/zsyscall_freebsd_386.go @@ -377,10 +377,8 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - r = int(r0) - w = 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/unix/zsyscall_freebsd_amd64.go b/unix/zsyscall_freebsd_amd64.go index 040e2f76..d3ba6c46 100644 --- a/unix/zsyscall_freebsd_amd64.go +++ b/unix/zsyscall_freebsd_amd64.go @@ -377,10 +377,8 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - r = int(r0) - w = 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/unix/zsyscall_freebsd_arm.go b/unix/zsyscall_freebsd_arm.go index cddc5e86..9dfd77b6 100644 --- a/unix/zsyscall_freebsd_arm.go +++ b/unix/zsyscall_freebsd_arm.go @@ -377,10 +377,8 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - r = int(r0) - w = 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) }