mirror of
https://github.com/golang/go
synced 2024-11-17 21:04:43 -07:00
syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe
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>
This commit is contained in:
parent
666ad85df4
commit
76c0003cd5
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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); }
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user