]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: add Pipe2 on solaris and use it for forkExecPipe
authorTobias Klauser <tklauser@distanz.ch>
Tue, 8 Mar 2022 10:13:37 +0000 (11:13 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Tue, 8 Mar 2022 21:16:30 +0000 (21:16 +0000)
Other platforms already define Pipe2, so add it for solaris as well.

Change-Id: If0d2dfc9a3613479fb4611a673a20a4aa0af0b2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/390714
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/syscall/forkpipe.go
src/syscall/forkpipe2.go
src/syscall/syscall_solaris.go
src/syscall/zsyscall_solaris_amd64.go

index 6f7d29ce67aea1597649d08e1eeed3f4506531ed..5082abc41cf140ef23d08348e236495dd0a9f075 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.
 
-//go:build aix || darwin || solaris
+//go:build aix || darwin
 
 package syscall
 
index 312244c0d8ab0c604b917c0b72c4652ebe58ef1f..6ab1391c1275fe6181ec673944bb878397c0bdc7 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.
 
-//go:build dragonfly || freebsd || netbsd || openbsd
+//go:build dragonfly || freebsd || netbsd || openbsd || solaris
 
 package syscall
 
index f44a9e25ac97bde5923eb688f9a67a2c8d11618b..3c50343d845b6b1ae71a1eec1da5a63e2007af12 100644 (file)
@@ -63,6 +63,21 @@ func Pipe(p []int) (err error) {
        return
 }
 
+//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 := pipe2(&pp, flags)
+       if err == nil {
+               p[0] = int(pp[0])
+               p[1] = int(pp[1])
+       }
+       return err
+}
+
 func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
        if sa.Port < 0 || sa.Port > 0xFFFF {
                return nil, 0, EINVAL
index 2d8cdfd280b807a0dd337ba2feab818eaad93934..dad05800273fec25fc62dc23209542a2997bdd97 100644 (file)
@@ -7,6 +7,7 @@ package syscall
 
 import "unsafe"
 
+//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
 //go:cgo_import_dynamic libc_Getcwd getcwd "libc.so"
 //go:cgo_import_dynamic libc_getgroups getgroups "libc.so"
 //go:cgo_import_dynamic libc_setgroups setgroups "libc.so"
@@ -91,6 +92,7 @@ import "unsafe"
 //go:cgo_import_dynamic libc_getexecname getexecname "libc.so"
 //go:cgo_import_dynamic libc_utimensat utimensat "libc.so"
 
+//go:linkname libc_pipe2 libc_pipe2
 //go:linkname libc_Getcwd libc_Getcwd
 //go:linkname libc_getgroups libc_getgroups
 //go:linkname libc_setgroups libc_setgroups
@@ -178,6 +180,7 @@ import "unsafe"
 type libcFunc uintptr
 
 var (
+       libc_pipe2,
        libc_Getcwd,
        libc_getgroups,
        libc_setgroups,
@@ -265,6 +268,16 @@ var (
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func pipe2(p *[2]_C_int, flags int) (err error) {
+       _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&libc_pipe2)), 2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Getcwd(buf []byte) (n int, err error) {
        var _p0 *byte
        if len(buf) > 0 {