From a98ae47d97a5abb3a3e9045da36315f9f8312970 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 5 Mar 2019 07:55:27 +0100 Subject: [PATCH] unix: on ARM GNU/Linux let Pipe fall back to pipe Follow CL 165217 which did this for package syscall. 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. Updates golang/go#30549 Change-Id: Icf21433fa046ff137c0265fa96410229def482f7 Reviewed-on: https://go-review.googlesource.com/c/sys/+/165297 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- unix/syscall_linux_arm.go | 6 ++++++ unix/zsyscall_linux_arm.go | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/unix/syscall_linux_arm.go b/unix/syscall_linux_arm.go index cda35594..3a3c37b4 100644 --- a/unix/syscall_linux_arm.go +++ b/unix/syscall_linux_arm.go @@ -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 diff --git a/unix/zsyscall_linux_arm.go b/unix/zsyscall_linux_arm.go index 370b656f..ccea621d 100644 --- a/unix/zsyscall_linux_arm.go +++ b/unix/zsyscall_linux_arm.go @@ -1679,6 +1679,16 @@ func faccessat(dirfd int, path string, mode uint32) (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 {