summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/futex/include
diff options
context:
space:
mode:
authorAndré Almeida <andrealmeid@collabora.com>2021-09-23 19:11:08 +0200
committerPeter Zijlstra <peterz@infradead.org>2021-10-07 13:51:12 +0200
commit5e59c1d1c78c9cdd8834f3242db4a76f617fa4ad (patch)
tree56dc57bbddb5496600a6125d9ed81e76791698de /tools/testing/selftests/futex/include
parentfutex,arm: Wire up sys_futex_waitv() (diff)
downloadlinux-5e59c1d1c78c9cdd8834f3242db4a76f617fa4ad.tar.xz
linux-5e59c1d1c78c9cdd8834f3242db4a76f617fa4ad.zip
selftests: futex: Add sys_futex_waitv() test
Create a new file to test the waitv mechanism. Test both private and shared futexes. Wake the last futex in the array, and check if the return value from futex_waitv() is the right index. Signed-off-by: André Almeida <andrealmeid@collabora.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20210923171111.300673-20-andrealmeid@collabora.com
Diffstat (limited to 'tools/testing/selftests/futex/include')
-rw-r--r--tools/testing/selftests/futex/include/futex2test.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/testing/selftests/futex/include/futex2test.h b/tools/testing/selftests/futex/include/futex2test.h
new file mode 100644
index 000000000000..9d305520e849
--- /dev/null
+++ b/tools/testing/selftests/futex/include/futex2test.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Futex2 library addons for futex tests
+ *
+ * Copyright 2021 Collabora Ltd.
+ */
+#include <stdint.h>
+
+#define u64_to_ptr(x) ((void *)(uintptr_t)(x))
+
+/**
+ * futex_waitv - Wait at multiple futexes, wake on any
+ * @waiters: Array of waiters
+ * @nr_waiters: Length of waiters array
+ * @flags: Operation flags
+ * @timo: Optional timeout for operation
+ */
+static inline int futex_waitv(volatile struct futex_waitv *waiters, unsigned long nr_waiters,
+ unsigned long flags, struct timespec *timo, clockid_t clockid)
+{
+ return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid);
+}