Skip to content

Commit

Permalink
Add 'flags' to futex prep helpers
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Jul 25, 2023
1 parent e79f0e4 commit 1a29af7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -1130,30 +1130,30 @@ IOURINGINLINE void io_uring_prep_socket_direct_alloc(struct io_uring_sqe *sqe,

IOURINGINLINE void io_uring_prep_futex_wake(struct io_uring_sqe *sqe,
uint32_t *futex, uint64_t val,
uint64_t mask)
uint64_t mask, uint32_t flags)
{
io_uring_prep_rw(IORING_OP_FUTEX_WAKE, sqe, 0, futex, 0, val);
sqe->futex_flags = 2; /* FLAGS_SIZE_32 */
sqe->futex_flags = flags | 2; /* FLAGS_SIZE_32 */
sqe->addr3 = mask;
}

IOURINGINLINE void io_uring_prep_futex_wait(struct io_uring_sqe *sqe,
uint32_t *futex, uint64_t val,
uint64_t mask)
uint64_t mask, uint32_t flags)
{
io_uring_prep_rw(IORING_OP_FUTEX_WAIT, sqe, 0, futex, 0, val);
sqe->futex_flags = 2; /* FLAGS_SIZE_32 */
sqe->futex_flags = flags | 2; /* FLAGS_SIZE_32 */
sqe->addr3 = mask;
}

struct futex_waitv;
IOURINGINLINE void io_uring_prep_futex_waitv(struct io_uring_sqe *sqe,
struct futex_waitv *futex,
uint32_t nr_futex, uint64_t val,
uint64_t mask)
uint64_t mask, uint32_t flags)
{
io_uring_prep_rw(IORING_OP_FUTEX_WAITV, sqe, 0, futex, nr_futex, val);
sqe->futex_flags = 2; /* FLAGS_SIZE_32 */
sqe->futex_flags = flags | 2; /* FLAGS_SIZE_32 */
sqe->addr3 = mask;
}

Expand Down
26 changes: 13 additions & 13 deletions test/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void *fwake(void *data)

*futex = 1;
sqe = io_uring_get_sqe(&ring);
io_uring_prep_futex_wake(sqe, futex, 1, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wake(sqe, futex, 1, FUTEX_BITSET_MATCH_ANY, 0);
sqe->user_data = 3;

io_uring_submit(&ring);
Expand Down Expand Up @@ -74,9 +74,9 @@ static int __test(struct io_uring *ring, int vectored, int async,

sqe = io_uring_get_sqe(ring);
if (vectored)
io_uring_prep_futex_waitv(sqe, fw, nfutex, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_waitv(sqe, fw, nfutex, 0, FUTEX_BITSET_MATCH_ANY, 0);
else
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY, 0);
if (async)
sqe->flags |= IOSQE_ASYNC;
sqe->user_data = 1;
Expand Down Expand Up @@ -165,16 +165,16 @@ static int test_order(int vectored, int async)
*/
sqe = io_uring_get_sqe(&ring);
if (!vectored)
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY, 0);
else
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY, 0);
sqe->user_data = 1;

sqe = io_uring_get_sqe(&ring);
if (!vectored)
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY, 0);
else
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY, 0);
sqe->user_data = 2;

io_uring_submit(&ring);
Expand All @@ -184,7 +184,7 @@ static int test_order(int vectored, int async)
*/
*futex = 1;
sqe = io_uring_get_sqe(&ring);
io_uring_prep_futex_wake(sqe, futex, 1, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wake(sqe, futex, 1, FUTEX_BITSET_MATCH_ANY, 0);
sqe->user_data = 100;
if (async)
sqe->flags |= IOSQE_ASYNC;
Expand Down Expand Up @@ -245,16 +245,16 @@ static int test_multi_wake(int vectored)
*/
sqe = io_uring_get_sqe(&ring);
if (!vectored)
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY, 0);
else
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY, 0);
sqe->user_data = 1;

sqe = io_uring_get_sqe(&ring);
if (!vectored)
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wait(sqe, futex, 0, FUTEX_BITSET_MATCH_ANY, 0);
else
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_waitv(sqe, &fw, 1, 0, FUTEX_BITSET_MATCH_ANY, 0);
sqe->user_data = 2;

io_uring_submit(&ring);
Expand All @@ -264,7 +264,7 @@ static int test_multi_wake(int vectored)
*/
*futex = 1;
sqe = io_uring_get_sqe(&ring);
io_uring_prep_futex_wake(sqe, futex, 2, FUTEX_BITSET_MATCH_ANY);
io_uring_prep_futex_wake(sqe, futex, 2, FUTEX_BITSET_MATCH_ANY, 0);
sqe->user_data = 100;

io_uring_submit(&ring);
Expand Down

0 comments on commit 1a29af7

Please sign in to comment.