From: Benny Siegert Date: Mon, 4 Jun 2012 15:29:34 +0000 (+1000) Subject: syscall: use pipe instead of pipe2 on NetBSD X-Git-Tag: go1.1rc2~3005 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=677cdb800d85025b01173e44925189c822869168;p=gostls13.git syscall: use pipe instead of pipe2 on NetBSD pipe2 is equivalent to pipe with flags set to 0. However, pipe2 was only added recently. Using pipe instead improves compatibility with NetBSD 5. R=jsing CC=golang-dev https://golang.org/cl/6268045 --- diff --git a/src/pkg/syscall/syscall_netbsd.go b/src/pkg/syscall/syscall_netbsd.go index 3534c0277b..f45801a92a 100644 --- a/src/pkg/syscall/syscall_netbsd.go +++ b/src/pkg/syscall/syscall_netbsd.go @@ -118,15 +118,12 @@ func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, return origlen - len(buf), count, names } -//sysnb pipe2(p *[2]_C_int, flags _C_int) (err error) +//sysnb pipe() (fd1 int, fd2 int, err error) func Pipe(p []int) (err error) { if len(p) != 2 { return EINVAL } - var pp [2]_C_int - err = pipe2(&pp, 0) - p[0] = int(pp[0]) - p[1] = int(pp[1]) + p[0], p[1], err = pipe() return } diff --git a/src/pkg/syscall/zsyscall_netbsd_386.go b/src/pkg/syscall/zsyscall_netbsd_386.go index 60fbe3cd53..8b00f440af 100644 --- a/src/pkg/syscall/zsyscall_netbsd_386.go +++ b/src/pkg/syscall/zsyscall_netbsd_386.go @@ -253,8 +253,10 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags _C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) +func pipe() (fd1 int, fd2 int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + fd1 = int(r0) + fd2 = int(r1) if e1 != 0 { err = e1 } diff --git a/src/pkg/syscall/zsyscall_netbsd_amd64.go b/src/pkg/syscall/zsyscall_netbsd_amd64.go index 5bf5df88ca..9501c15f9d 100644 --- a/src/pkg/syscall/zsyscall_netbsd_amd64.go +++ b/src/pkg/syscall/zsyscall_netbsd_amd64.go @@ -253,8 +253,10 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags _C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) +func pipe() (fd1 int, fd2 int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + fd1 = int(r0) + fd2 = int(r1) if e1 != 0 { err = e1 }