Browse Source

unix: implement pipe() on linux/mips

Change the Pipe() function to use the pipe() syscall (which has a unique
calling convention on linux/mips) instead of using pipe2(). This allows
it to work on kernels <2.6.27 when pipe2() was introduced.

Change-Id: I088886e66b594232869d8b88c6e1a630c76188a3
Reviewed-on: https://go-review.googlesource.com/126176
Reviewed-by: Vladimir Stefanovic <vladimir.stefanovic@mips.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
David Wimmer 7 years ago
parent
commit
c4d1ff19d3
3 changed files with 27 additions and 4 deletions
  1. 3 4
      unix/syscall_linux_mipsx.go
  2. 12 0
      unix/zsyscall_linux_mips.go
  3. 12 0
      unix/zsyscall_linux_mipsle.go

+ 3 - 4
unix/syscall_linux_mipsx.go

@@ -124,14 +124,13 @@ func Pipe2(p []int, flags int) (err error) {
 	return
 	return
 }
 }
 
 
+//sysnb pipe() (p1 int, p2 int, err error)
+
 func Pipe(p []int) (err error) {
 func Pipe(p []int) (err error) {
 	if len(p) != 2 {
 	if len(p) != 2 {
 		return EINVAL
 		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
 	return
 }
 }
 
 

+ 12 - 0
unix/zsyscall_linux_mips.go

@@ -2137,6 +2137,18 @@ func pipe2(p *[2]_C_int, flags int) (err error) {
 
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 
+func pipe() (p1 int, p2 int, err error) {
+	r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+	p1 = int(r0)
+	p2 = int(r1)
+	if e1 != 0 {
+		err = errnoErr(e1)
+	}
+	return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
 func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
 	r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
 	r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
 	xaddr = uintptr(r0)
 	xaddr = uintptr(r0)

+ 12 - 0
unix/zsyscall_linux_mipsle.go

@@ -2137,6 +2137,18 @@ func pipe2(p *[2]_C_int, flags int) (err error) {
 
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 
+func pipe() (p1 int, p2 int, err error) {
+	r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+	p1 = int(r0)
+	p2 = int(r1)
+	if e1 != 0 {
+		err = errnoErr(e1)
+	}
+	return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
 func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
 	r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
 	r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
 	xaddr = uintptr(r0)
 	xaddr = uintptr(r0)