]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use pipe2 for nonblockingPipe on dragonfly
authorTobias Klauser <tklauser@distanz.ch>
Wed, 24 Feb 2021 08:43:59 +0000 (09:43 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Thu, 25 Feb 2021 18:43:17 +0000 (18:43 +0000)
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 <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/runtime/defs_dragonfly.go
src/runtime/defs_dragonfly_amd64.go
src/runtime/export_pipe2_test.go
src/runtime/export_pipe_test.go
src/runtime/nbpipe_pipe.go
src/runtime/nbpipe_pipe2.go
src/runtime/os_dragonfly.go
src/runtime/sys_dragonfly_amd64.s

index 225258901f1936887389edd23fef4ef86c5cb82a..aca2bf9001e82a296cffcaa0707edce29ddc7a58 100644 (file)
@@ -32,6 +32,10 @@ const (
        EFAULT = C.EFAULT
        EBUSY  = C.EBUSY
        EAGAIN = C.EAGAIN
+       ENOSYS = C.ENOSYS
+
+       O_NONBLOCK = C.O_NONBLOCK
+       O_CLOEXEC  = C.O_CLOEXEC
 
        PROT_NONE  = C.PROT_NONE
        PROT_READ  = C.PROT_READ
index 30f1b33845e612d0d6d6cfc799f9dbd9f3d17459..f3c6ecd04b7997cf5d2142d377dd8c79b5251827 100644 (file)
@@ -10,6 +10,10 @@ const (
        _EFAULT = 0xe
        _EBUSY  = 0x10
        _EAGAIN = 0x23
+       _ENOSYS = 0x4e
+
+       _O_NONBLOCK = 0x4
+       _O_CLOEXEC  = 0x20000
 
        _PROT_NONE  = 0x0
        _PROT_READ  = 0x1
index 31c8e43b3f4fcc995b30007711d4c50593fe21ff..26d8b7d185948aef22540176d5be6a0abc41961e 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 || linux || netbsd || openbsd || solaris
-// +build freebsd linux netbsd openbsd solaris
+//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
+// +build dragonfly freebsd linux netbsd openbsd solaris
 
 package runtime
 
index 82032e6bfb4ec6a6437d668c6cc95af5f8705148..a0c6c0440d8d94447157f28f762bc1587ca7ab09 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
-// +build aix darwin dragonfly
+//go:build aix || darwin
+// +build aix darwin
 
 package runtime
 
index d92cf97217b2efbfecc5c5fae094bcc2a7ca1b4b..b17257e9ec3649ba4cf5eebe671f5897648d5e88 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
-// +build aix darwin dragonfly
+//go:build aix || darwin
+// +build aix darwin
 
 package runtime
 
index f138d1f9561fbb81d4152426780ac507b3f4dcdf..f22b2b591fd592806ba7b4df5de67222464a51a2 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 || linux || netbsd || openbsd || solaris
-// +build freebsd linux netbsd openbsd solaris
+//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
+// +build dragonfly freebsd linux netbsd openbsd solaris
 
 package runtime
 
index 2e930b6e949b14bda2a666f2bf8cad229ca78765..5c688a31096a6b6aa51175a7d5b8fa702a210a62 100644 (file)
@@ -60,10 +60,11 @@ func kqueue() int32
 
 //go:noescape
 func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timespec) int32
-func closeonexec(fd int32)
-func setNonblock(fd int32)
 
 func pipe() (r, w int32, errno int32)
+func pipe2(flags int32) (r, w int32, errno int32)
+func closeonexec(fd int32)
+func setNonblock(fd int32)
 
 // From DragonFly's <sys/sysctl.h>
 const (
index 580633af559b80a42dac8543708b74e49174115a..9cb268d740114c26a4c8300c9626fa21ee38a2a1 100644 (file)
@@ -123,6 +123,24 @@ pipeok:
        MOVL    $0, errno+8(FP)
        RET
 
+// func pipe2(flags int32) (r, w int32, errno int32)
+TEXT runtime·pipe2(SB),NOSPLIT,$0-20
+       MOVL    $0, DI
+       // dragonfly expects flags as the 2nd argument
+       MOVL    flags+0(FP), SI
+       MOVL    $538, AX
+       SYSCALL
+       JCC     pipe2ok
+       MOVL    $-1,r+8(FP)
+       MOVL    $-1,w+12(FP)
+       MOVL    AX, errno+16(FP)
+       RET
+pipe2ok:
+       MOVL    AX, r+8(FP)
+       MOVL    DX, w+12(FP)
+       MOVL    $0, errno+16(FP)
+       RET
+
 TEXT runtime·write1(SB),NOSPLIT,$-8
        MOVQ    fd+0(FP), DI            // arg 1 fd
        MOVQ    p+8(FP), SI             // arg 2 buf