Skip to content

Commit ee2a45e

Browse files
committed
runtime: use pipe2 for nonblockingPipe on dragonfly
The pipe2 syscall is available since DragonflyBSD 4.2, see https://www.dragonflybsd.org/release42/ Change-Id: Ifc67c4935cc59bae29be459167e2fa765843ac03 Reviewed-on: https://go-review.googlesource.com/c/go/+/295471 Trust: Tobias Klauser <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 1f7a014 commit ee2a45e

File tree

8 files changed

+37
-10
lines changed

8 files changed

+37
-10
lines changed

src/runtime/defs_dragonfly.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const (
3232
EFAULT = C.EFAULT
3333
EBUSY = C.EBUSY
3434
EAGAIN = C.EAGAIN
35+
ENOSYS = C.ENOSYS
36+
37+
O_NONBLOCK = C.O_NONBLOCK
38+
O_CLOEXEC = C.O_CLOEXEC
3539

3640
PROT_NONE = C.PROT_NONE
3741
PROT_READ = C.PROT_READ

src/runtime/defs_dragonfly_amd64.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const (
1010
_EFAULT = 0xe
1111
_EBUSY = 0x10
1212
_EAGAIN = 0x23
13+
_ENOSYS = 0x4e
14+
15+
_O_NONBLOCK = 0x4
16+
_O_CLOEXEC = 0x20000
1317

1418
_PROT_NONE = 0x0
1519
_PROT_READ = 0x1

src/runtime/export_pipe2_test.go

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

5-
//go:build freebsd || linux || netbsd || openbsd || solaris
6-
// +build freebsd linux netbsd openbsd solaris
5+
//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
6+
// +build dragonfly freebsd linux netbsd openbsd solaris
77

88
package runtime
99

src/runtime/export_pipe_test.go

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

5-
//go:build aix || darwin || dragonfly
6-
// +build aix darwin dragonfly
5+
//go:build aix || darwin
6+
// +build aix darwin
77

88
package runtime
99

src/runtime/nbpipe_pipe.go

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

5-
//go:build aix || darwin || dragonfly
6-
// +build aix darwin dragonfly
5+
//go:build aix || darwin
6+
// +build aix darwin
77

88
package runtime
99

src/runtime/nbpipe_pipe2.go

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

5-
//go:build freebsd || linux || netbsd || openbsd || solaris
6-
// +build freebsd linux netbsd openbsd solaris
5+
//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
6+
// +build dragonfly freebsd linux netbsd openbsd solaris
77

88
package runtime
99

src/runtime/os_dragonfly.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ func kqueue() int32
6060

6161
//go:noescape
6262
func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timespec) int32
63-
func closeonexec(fd int32)
64-
func setNonblock(fd int32)
6563

6664
func pipe() (r, w int32, errno int32)
65+
func pipe2(flags int32) (r, w int32, errno int32)
66+
func closeonexec(fd int32)
67+
func setNonblock(fd int32)
6768

6869
// From DragonFly's <sys/sysctl.h>
6970
const (

src/runtime/sys_dragonfly_amd64.s

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ pipeok:
123123
MOVL $0, errno+8(FP)
124124
RET
125125

126+
// func pipe2(flags int32) (r, w int32, errno int32)
127+
TEXT runtime·pipe2(SB),NOSPLIT,$0-20
128+
MOVL $0, DI
129+
// dragonfly expects flags as the 2nd argument
130+
MOVL flags+0(FP), SI
131+
MOVL $538, AX
132+
SYSCALL
133+
JCC pipe2ok
134+
MOVL $-1,r+8(FP)
135+
MOVL $-1,w+12(FP)
136+
MOVL AX, errno+16(FP)
137+
RET
138+
pipe2ok:
139+
MOVL AX, r+8(FP)
140+
MOVL DX, w+12(FP)
141+
MOVL $0, errno+16(FP)
142+
RET
143+
126144
TEXT runtime·write1(SB),NOSPLIT,$-8
127145
MOVQ fd+0(FP), DI // arg 1 fd
128146
MOVQ p+8(FP), SI // arg 2 buf

0 commit comments

Comments
 (0)