summaryrefslogtreecommitdiffhomepage
path: root/rwcancel/poll_linux.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-09-26 17:15:58 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2021-09-26 17:16:38 -0600
commitfcc601dbf0f6b626ec1d47a880cbe64f9c8fe385 (patch)
treea083b5d380572f2d7ceba2b952606d48c53ac398 /rwcancel/poll_linux.go
parent217ac1016bc54b47418fb606740498fcfbcfd9e6 (diff)
rwcancel: use ppoll on Linux for Android
This is a temporary measure while we wait for https://go-review.googlesource.com/c/sys/+/352310 to land. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'rwcancel/poll_linux.go')
-rw-r--r--rwcancel/poll_linux.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/rwcancel/poll_linux.go b/rwcancel/poll_linux.go
new file mode 100644
index 0000000..d9938c5
--- /dev/null
+++ b/rwcancel/poll_linux.go
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
+ */
+
+package rwcancel
+
+import "golang.org/x/sys/unix"
+
+func poll(fds []unix.PollFd, timeout int) (n int, err error) {
+ var ts *unix.Timespec
+ if timeout >= 0 {
+ ts = new(unix.Timespec)
+ *ts = unix.NsecToTimespec(int64(timeout) * 1e6)
+ }
+ return unix.Ppoll(fds, ts, nil)
+}