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