]> Cypherpunks repositories - gostls13.git/commitdiff
syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe
authorTobias Klauser <tklauser@distanz.ch>
Tue, 23 Feb 2021 13:58:32 +0000 (14:58 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Thu, 25 Feb 2021 09:20:03 +0000 (09:20 +0000)
Follow the implementation used by the other BSDs and account for the
intricacy of having to pass the fds array even though the file
descriptors are returned.

Re-submit of CL 130996 with corrected pipe2 wrapper.

Change-Id: Ie36d8214cba60c4fdb579f18bfc1c1ab3ead3ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/295372
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
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_dragonfly.go
src/syscall/zsyscall_dragonfly_amd64.go
src/syscall/zsysnum_dragonfly_amd64.go

index 0af80195256d59d3330796ed22400a469d57159e..bf6d081db5b83c9cfe8e47d392fba4db71fd4eaa 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build freebsd || netbsd || openbsd
-// +build freebsd netbsd openbsd
+//go:build dragonfly || freebsd || netbsd || openbsd
+// +build dragonfly freebsd netbsd openbsd
 
 package os
 
index 57959a2ea43b756c14fff7e425cf2ef8c230b6ca..097b32e7eb33cf0414a28209c681b399449e07ba 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build aix || darwin || dragonfly || (js && wasm) || (solaris && !illumos)
-// +build aix darwin dragonfly js,wasm solaris,!illumos
+//go:build aix || darwin || (js && wasm) || (solaris && !illumos)
+// +build aix darwin js,wasm solaris,!illumos
 
 package os
 
index c7ddcf26ab7c44af25c7ebdeeb2ada5b643659ee..79cbdf4150f5354fb3ccb913019ded8a656ace5e 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build aix || darwin || dragonfly || solaris
-// +build aix darwin dragonfly solaris
+//go:build aix || darwin || solaris
+// +build aix darwin solaris
 
 package syscall
 
index cd98779ac9edd5137e9e6d467093915ad69214e7..e57240c156157a033e4211157049c467c17b84b6 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build freebsd || netbsd || openbsd
-// +build freebsd netbsd openbsd
+//go:build dragonfly || freebsd || netbsd || openbsd
+// +build dragonfly freebsd netbsd openbsd
 
 package syscall
 
index 0988fe46088a8818b70ac3b82ce7ca987d5248ed..b01a4ada67525e356195c6a1314a70bdeff50098 100644 (file)
@@ -100,6 +100,19 @@ func Pipe(p []int) (err error) {
        return
 }
 
+//sysnb        pipe2(p *[2]_C_int, flags int) (r int, w int, err error)
+
+func Pipe2(p []int, flags int) (err error) {
+       if len(p) != 2 {
+               return EINVAL
+       }
+       var pp [2]_C_int
+       // pipe2 on dragonfly takes an fds array as an argument, but still
+       // returns the file descriptors.
+       p[0], p[1], err = pipe2(&pp, flags)
+       return err
+}
+
 //sys  extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
 func Pread(fd int, p []byte, offset int64) (n int, err error) {
        return extpread(fd, p, 0, offset)
index 4799d1dcb01132472487870f6aafe521662338e6..aa327c001095362fa7fd81f9716e28c51d78aeb8 100644 (file)
@@ -274,6 +274,18 @@ func pipe() (r int, w int, err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func pipe2(p *[2]_C_int, flags int) (r int, w int, err error) {
+       r0, r1, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
+       r = int(r0)
+       w = int(r1)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func extpread(fd int, p []byte, flags int, offset int64) (n int, err error) {
        var _p0 unsafe.Pointer
        if len(p) > 0 {
index 855188f045cb8379be6feddd177d4afe8e91ee02..ae504a5f0c2658087dc21024fda991ddf2dd9958 100644 (file)
@@ -302,6 +302,7 @@ const (
        SYS_LPATHCONF              = 533 // { int lpathconf(char *path, int name); }
        SYS_VMM_GUEST_CTL          = 534 // { int vmm_guest_ctl(int op, struct vmm_guest_options *options); }
        SYS_VMM_GUEST_SYNC_ADDR    = 535 // { int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); }
+       SYS_PIPE2                  = 538 // { int pipe2(int *fildes, int flags); }
        SYS_UTIMENSAT              = 539 // { int utimensat(int fd, const char *path, const struct timespec *ts, int flags); }
        SYS_ACCEPT4                = 541 // { int accept4(int s, caddr_t name, int *anamelen, int flags); }
 )