From owner-svn-ports-all@freebsd.org Sun Mar 26 06:22:54 2017 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 138F0D1DE59; Sun, 26 Mar 2017 06:22:54 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD5F41B47; Sun, 26 Mar 2017 06:22:53 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2Q6MqY2016811; Sun, 26 Mar 2017 06:22:52 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2Q6MqvW016810; Sun, 26 Mar 2017 06:22:52 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201703260622.v2Q6MqvW016810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Sun, 26 Mar 2017 06:22:52 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r436939 - head/lang/go/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Mar 2017 06:22:54 -0000 Author: glebius (src committer) Date: Sun Mar 26 06:22:52 2017 New Revision: 436939 URL: https://svnweb.freebsd.org/changeset/ports/436939 Log: Use pipe2() syscall. It is available on all supported FreeBSD versions. This makes lang/go not depending on pipe() syscall, this not depending on COMPAT_FREEBSD10 kernel. This is adjusted version of 0ebaca6ba27534add5930a95acffa9acff182e2b from the official Go repo. Approved by: jlaffaye Added: head/lang/go/files/ head/lang/go/files/patch-pipe2 (contents, props changed) Added: head/lang/go/files/patch-pipe2 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/go/files/patch-pipe2 Sun Mar 26 06:22:52 2017 (r436939) @@ -0,0 +1,162 @@ +--- src/os/pipe_bsd.go ++++ 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 freebsd nacl netbsd openbsd solaris ++// +build darwin dragonfly nacl netbsd openbsd solaris + + package os + +--- /dev/null ++++ src/os/pipe_freebsd.go +@@ -0,0 +1,20 @@ ++// Copyright 2017 The Go Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style ++// license that can be found in the LICENSE file. ++ ++package os ++ ++import "syscall" ++ ++// Pipe returns a connected pair of Files; reads from r return bytes written to w. ++// It returns the files and an error, if any. ++func Pipe() (r *File, w *File, err error) { ++ var p [2]int ++ ++ e := syscall.Pipe2(p[0:], syscall.O_CLOEXEC) ++ if e != nil { ++ return nil, nil, NewSyscallError("pipe", e) ++ } ++ ++ return NewFile(uintptr(p[0]), "|0"), NewFile(uintptr(p[1]), "|1"), nil ++} +--- src/syscall/exec_bsd.go ++++ src/syscall/exec_bsd.go +@@ -256,17 +256,3 @@ childerror: + RawSyscall(SYS_EXIT, 253, 0, 0) + } + } +- +-// Try to open a pipe with O_CLOEXEC set on both file descriptors. +-func forkExecPipe(p []int) error { +- err := Pipe(p) +- if err != nil { +- return err +- } +- _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC) +- if err != nil { +- return err +- } +- _, err = fcntl(p[1], F_SETFD, FD_CLOEXEC) +- return err +-} +--- /dev/null ++++ src/syscall/exec_freebsd.go +@@ -0,0 +1,9 @@ ++// Copyright 2017 The Go Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style ++// license that can be found in the LICENSE file. ++ ++package syscall ++ ++func forkExecPipe(p []int) error { ++ return Pipe2(p, O_CLOEXEC) ++} +--- /dev/null ++++ src/syscall/forkpipe_bsd.go +@@ -0,0 +1,20 @@ ++// Copyright 2011 The Go Authors. All rights reserved. ++// 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 ++ ++package syscall ++ ++func forkExecPipe(p []int) error { ++ err := Pipe(p) ++ if err != nil { ++ return err ++ } ++ _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC) ++ if err != nil { ++ return err ++ } ++ _, err = fcntl(p[1], F_SETFD, FD_CLOEXEC) ++ return err ++} +--- src/syscall/syscall_freebsd.go ++++ src/syscall/syscall_freebsd.go +@@ -66,14 +66,21 @@ func direntNamlen(buf []byte) (uint64, bool) { + return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen)) + } + +-//sysnb pipe() (r int, w int, err error) ++func Pipe(p []int) error { ++ return Pipe2(p, 0) ++} ++ ++//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +-func Pipe(p []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) { +--- src/syscall/zsyscall_freebsd_386.go ++++ src/syscall/zsyscall_freebsd_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() (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) + } +--- src/syscall/zsyscall_freebsd_amd64.go ++++ src/syscall/zsyscall_freebsd_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() (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) + } +--- src/syscall/zsyscall_freebsd_arm.go ++++ src/syscall/zsyscall_freebsd_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() (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) + }