]> Cypherpunks repositories - gostls13.git/commitdiff
os, syscall: use pipe2 instead of pipe syscall on OpenBSD
authorTobias Klauser <tklauser@distanz.ch>
Tue, 27 Feb 2018 07:14:53 +0000 (08:14 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Tue, 27 Feb 2018 18:37:36 +0000 (18:37 +0000)
The pipe2 syscall is part of OpenBSD since version 5.7 and thus exists in
all officially supported versions.

Follows CL 38426 and CL 94035

Change-Id: I8f93ecbc89664241f1b6b0d069e948776941b1d0
Reviewed-on: https://go-review.googlesource.com/97356
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/pipe2_bsd.go
src/os/pipe_bsd.go
src/syscall/forkpipe.go
src/syscall/forkpipe2.go
src/syscall/syscall_openbsd.go
src/syscall/zsyscall_openbsd_386.go
src/syscall/zsyscall_openbsd_amd64.go
src/syscall/zsyscall_openbsd_arm.go
src/syscall/zsysnum_openbsd_386.go
src/syscall/zsysnum_openbsd_amd64.go

index 1615067b4125b73f6ee9a33719f188786960353a..0ef894b476bed9386dbdc837042b3c4b869b3bd7 100644 (file)
@@ -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 freebsd netbsd
+// +build freebsd netbsd openbsd
 
 package os
 
index 04eaf83791364761cc1b0ba3d6d044e786cf4b74..5260ceea94f95fdb1e9297e0e1454b143cf97c7d 100644 (file)
@@ -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 openbsd solaris
+// +build darwin dragonfly nacl solaris
 
 package os
 
index 5d9eb4d5f220e71944211dc549a3f68d5c912451..71890a29badcca66b15911e2c888ff7e944a0a80 100644 (file)
@@ -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 openbsd solaris
+// +build darwin dragonfly solaris
 
 package syscall
 
index 2bf4757133cdc4dcd8f5a9bfb03330a4a18d660b..c9a0c4996e3bbbdffca63a36987ad1c50214ad35 100644 (file)
@@ -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 freebsd netbsd
+// +build freebsd netbsd openbsd
 
 package syscall
 
index db1e9a057f83c0860f60efce7068e146b730bea9..d2f58e67d7610a41de680f9e8f69cc8672c5b525 100644 (file)
@@ -62,16 +62,20 @@ func direntNamlen(buf []byte) (uint64, bool) {
        return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
 }
 
-//sysnb pipe(p *[2]_C_int) (err error)
-func Pipe(p []int) (err error) {
+func Pipe(p []int) 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  accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
index 2e619472d977388b33971799f1fedc8b38ac26ad..8fc96e0b68fc32c1a2ef19b66d37743d3be81c2f 100644 (file)
@@ -261,8 +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(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)
        }
index b749b88d90b79c3c892a8fa670826f36b438c655..50bd41083b7021715c781ae3f739ceb8ef487a2c 100644 (file)
@@ -261,8 +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(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)
        }
index 69f4823e16265c57edd2589cffafd669b77e8e5c..99be8d4e93e84429351edcb3cbcce6f686069abb 100644 (file)
@@ -261,8 +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(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)
        }
index f9331fc57bae42c0366e99c38b0b2ef778063f91..8262ec5f5343e4c14ddfe4bf2c15b1d0704ef43d 100644 (file)
@@ -102,6 +102,7 @@ const (
        SYS_CONNECT        = 98  // { int sys_connect(int s, const struct sockaddr *name, \
        SYS_GETDENTS       = 99  // { int sys_getdents(int fd, void *buf, size_t buflen); }
        SYS_GETPRIORITY    = 100 // { int sys_getpriority(int which, id_t who); }
+       SYS_PIPE2          = 101 // { int sys_pipe2(int *fdp, int flags); }
        SYS_SIGRETURN      = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); }
        SYS_BIND           = 104 // { int sys_bind(int s, const struct sockaddr *name, \
        SYS_SETSOCKOPT     = 105 // { int sys_setsockopt(int s, int level, int name, \
index 3ebb1c4e8262b9d6bd68c28725294bccb2a343d0..1b0a52750c7de37e11d3ebe44edea0ffe4d510b2 100644 (file)
@@ -102,6 +102,7 @@ const (
        SYS_CONNECT        = 98  // { int sys_connect(int s, const struct sockaddr *name, \
        SYS_GETDENTS       = 99  // { int sys_getdents(int fd, void *buf, size_t buflen); }
        SYS_GETPRIORITY    = 100 // { int sys_getpriority(int which, id_t who); }
+       SYS_PIPE2          = 101 // { int sys_pipe2(int *fdp, int flags); }
        SYS_SIGRETURN      = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); }
        SYS_BIND           = 104 // { int sys_bind(int s, const struct sockaddr *name, \
        SYS_SETSOCKOPT     = 105 // { int sys_setsockopt(int s, int level, int name, \