1*49cdfc7eSAndroid Build Coastguard Worker /* SPDX-License-Identifier: GPL-2.0-or-later */
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker * Futex2 library addons for futex tests
4*49cdfc7eSAndroid Build Coastguard Worker *
5*49cdfc7eSAndroid Build Coastguard Worker * Copyright 2021 Collabora Ltd.
6*49cdfc7eSAndroid Build Coastguard Worker * Copyright (C) 2021 SUSE LLC Andrea Cervesato <[email protected]>
7*49cdfc7eSAndroid Build Coastguard Worker */
8*49cdfc7eSAndroid Build Coastguard Worker
9*49cdfc7eSAndroid Build Coastguard Worker #ifndef FUTEX2TEST_H
10*49cdfc7eSAndroid Build Coastguard Worker #define FUTEX2TEST_H
11*49cdfc7eSAndroid Build Coastguard Worker
12*49cdfc7eSAndroid Build Coastguard Worker #include <stdint.h>
13*49cdfc7eSAndroid Build Coastguard Worker #include "lapi/syscalls.h"
14*49cdfc7eSAndroid Build Coastguard Worker #include "futextest.h"
15*49cdfc7eSAndroid Build Coastguard Worker #include "lapi/abisize.h"
16*49cdfc7eSAndroid Build Coastguard Worker
17*49cdfc7eSAndroid Build Coastguard Worker #ifdef TST_ABI32
18*49cdfc7eSAndroid Build Coastguard Worker struct timespec64 {
19*49cdfc7eSAndroid Build Coastguard Worker int64_t tv_sec;
20*49cdfc7eSAndroid Build Coastguard Worker int64_t tv_nsec;
21*49cdfc7eSAndroid Build Coastguard Worker };
22*49cdfc7eSAndroid Build Coastguard Worker #endif
23*49cdfc7eSAndroid Build Coastguard Worker
24*49cdfc7eSAndroid Build Coastguard Worker /**
25*49cdfc7eSAndroid Build Coastguard Worker * futex_waitv - Wait at multiple futexes, wake on any
26*49cdfc7eSAndroid Build Coastguard Worker * @waiters: Array of waiters
27*49cdfc7eSAndroid Build Coastguard Worker * @nr_waiters: Length of waiters array
28*49cdfc7eSAndroid Build Coastguard Worker * @flags: Operation flags
29*49cdfc7eSAndroid Build Coastguard Worker * @timo: Optional timeout for operation
30*49cdfc7eSAndroid Build Coastguard Worker */
futex_waitv(volatile struct futex_waitv * waiters,unsigned long nr_waiters,unsigned long flags,struct timespec * timo,clockid_t clockid)31*49cdfc7eSAndroid Build Coastguard Worker static inline int futex_waitv(volatile struct futex_waitv *waiters,
32*49cdfc7eSAndroid Build Coastguard Worker unsigned long nr_waiters, unsigned long flags,
33*49cdfc7eSAndroid Build Coastguard Worker struct timespec *timo, clockid_t clockid)
34*49cdfc7eSAndroid Build Coastguard Worker {
35*49cdfc7eSAndroid Build Coastguard Worker #ifdef TST_ABI32
36*49cdfc7eSAndroid Build Coastguard Worker struct timespec64 timo64 = {0};
37*49cdfc7eSAndroid Build Coastguard Worker
38*49cdfc7eSAndroid Build Coastguard Worker timo64.tv_sec = timo->tv_sec;
39*49cdfc7eSAndroid Build Coastguard Worker timo64.tv_nsec = timo->tv_nsec;
40*49cdfc7eSAndroid Build Coastguard Worker return tst_syscall(__NR_futex_waitv, waiters, nr_waiters, flags, &timo64, clockid);
41*49cdfc7eSAndroid Build Coastguard Worker #else
42*49cdfc7eSAndroid Build Coastguard Worker return tst_syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid);
43*49cdfc7eSAndroid Build Coastguard Worker
44*49cdfc7eSAndroid Build Coastguard Worker #endif
45*49cdfc7eSAndroid Build Coastguard Worker }
46*49cdfc7eSAndroid Build Coastguard Worker
47*49cdfc7eSAndroid Build Coastguard Worker #endif /* _FUTEX2TEST_H */
48