]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: on ARM GNU/Linux let Pipe fall back to pipe
authorIan Lance Taylor <iant@golang.org>
Tue, 5 Mar 2019 02:28:51 +0000 (18:28 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 5 Mar 2019 02:49:10 +0000 (02:49 +0000)
Android O seems to require Pipe to call the pipe2 system call.
But kernel version 2.6.23 only supports pipe, not pipe2.
So try pipe2 first, then fall back to pipe.

Fixes #30549

Change-Id: I3c5d86e8e945a5ec8a0ecea7853302952c0476c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/165217
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/syscall/syscall_linux_arm.go
src/syscall/zsyscall_linux_arm.go

index 65543193e15ebef0eb7b2c4bc84d3f405c94ed4b..a7acd080336422f691a494d243ccb707fcf619fc 100644 (file)
@@ -19,12 +19,18 @@ func setTimeval(sec, usec int64) Timeval {
        return Timeval{Sec: int32(sec), Usec: int32(usec)}
 }
 
+//sysnb pipe(p *[2]_C_int) (err error)
+
 func Pipe(p []int) (err error) {
        if len(p) != 2 {
                return EINVAL
        }
        var pp [2]_C_int
+       // Try pipe2 first for Android O, then try pipe for kernel 2.6.23.
        err = pipe2(&pp, 0)
+       if err == ENOSYS {
+               err = pipe(&pp)
+       }
        p[0] = int(pp[0])
        p[1] = int(pp[1])
        return
index 3d099aa16df65f3043d1e9a47289b1802a9e8675..3d01cd35d5f22a99c42a3158cca7c6bb21354f4c 100644 (file)
@@ -1138,6 +1138,16 @@ func Munlockall() (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func pipe(p *[2]_C_int) (err error) {
+       _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func pipe2(p *[2]_C_int, flags int) (err error) {
        _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
        if e1 != 0 {