Skip to content

Commit 2013ad8

Browse files
committed
os, syscall: use pipe2 instead of pipe syscall on OpenBSD
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 8178664 commit 2013ad8

10 files changed

+20
-14
lines changed

src/os/pipe2_bsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build freebsd netbsd
5+
// +build freebsd netbsd openbsd
66

77
package os
88

src/os/pipe_bsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build darwin dragonfly nacl openbsd solaris
5+
// +build darwin dragonfly nacl solaris
66

77
package os
88

src/syscall/forkpipe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build darwin dragonfly openbsd solaris
5+
// +build darwin dragonfly solaris
66

77
package syscall
88

src/syscall/forkpipe2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build freebsd netbsd
5+
// +build freebsd netbsd openbsd
66

77
package syscall
88

src/syscall/syscall_openbsd.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,20 @@ func direntNamlen(buf []byte) (uint64, bool) {
6262
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
6363
}
6464

65-
//sysnb pipe(p *[2]_C_int) (err error)
66-
func Pipe(p []int) (err error) {
65+
func Pipe(p []int) error {
66+
return Pipe2(p, 0)
67+
}
68+
69+
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
70+
func Pipe2(p []int, flags int) error {
6771
if len(p) != 2 {
6872
return EINVAL
6973
}
7074
var pp [2]_C_int
71-
err = pipe(&pp)
75+
err := pipe2(&pp, flags)
7276
p[0] = int(pp[0])
7377
p[1] = int(pp[1])
74-
return
78+
return err
7579
}
7680

7781
//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)

src/syscall/zsyscall_openbsd_386.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
261261

262262
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
263263

264-
func pipe(p *[2]_C_int) (err error) {
265-
_, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
264+
func pipe2(p *[2]_C_int, flags int) (err error) {
265+
_, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
266266
if e1 != 0 {
267267
err = errnoErr(e1)
268268
}

src/syscall/zsyscall_openbsd_amd64.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
261261

262262
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
263263

264-
func pipe(p *[2]_C_int) (err error) {
265-
_, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
264+
func pipe2(p *[2]_C_int, flags int) (err error) {
265+
_, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
266266
if e1 != 0 {
267267
err = errnoErr(e1)
268268
}

src/syscall/zsyscall_openbsd_arm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
261261

262262
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
263263

264-
func pipe(p *[2]_C_int) (err error) {
265-
_, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
264+
func pipe2(p *[2]_C_int, flags int) (err error) {
265+
_, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
266266
if e1 != 0 {
267267
err = errnoErr(e1)
268268
}

src/syscall/zsysnum_openbsd_386.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const (
102102
SYS_CONNECT = 98 // { int sys_connect(int s, const struct sockaddr *name, \
103103
SYS_GETDENTS = 99 // { int sys_getdents(int fd, void *buf, size_t buflen); }
104104
SYS_GETPRIORITY = 100 // { int sys_getpriority(int which, id_t who); }
105+
SYS_PIPE2 = 101 // { int sys_pipe2(int *fdp, int flags); }
105106
SYS_SIGRETURN = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); }
106107
SYS_BIND = 104 // { int sys_bind(int s, const struct sockaddr *name, \
107108
SYS_SETSOCKOPT = 105 // { int sys_setsockopt(int s, int level, int name, \

src/syscall/zsysnum_openbsd_amd64.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const (
102102
SYS_CONNECT = 98 // { int sys_connect(int s, const struct sockaddr *name, \
103103
SYS_GETDENTS = 99 // { int sys_getdents(int fd, void *buf, size_t buflen); }
104104
SYS_GETPRIORITY = 100 // { int sys_getpriority(int which, id_t who); }
105+
SYS_PIPE2 = 101 // { int sys_pipe2(int *fdp, int flags); }
105106
SYS_SIGRETURN = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); }
106107
SYS_BIND = 104 // { int sys_bind(int s, const struct sockaddr *name, \
107108
SYS_SETSOCKOPT = 105 // { int sys_setsockopt(int s, int level, int name, \

0 commit comments

Comments
 (0)