Skip to content

Commit

Permalink
Define _GNU_SOURCE in liburing.h, if not already set
Browse files Browse the repository at this point in the history
Rather than require applications set it to get some of the
exported function definitions, just set it in liburing.h. At least then
we keep it as a private scope for our definitions, rather than impose
it on applications as a whole.

Fixes: 6f8b348 ("Don't set _GNU_SOURCE in pkg-config cflags")
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Sep 3, 2024
1 parent 6f8b348 commit 835ff24
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
6 changes: 0 additions & 6 deletions man/io_uring_prep_ftruncate.3
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ that should get truncated to the length indicated by the
.I len
argument.

Applications must define
.B _GNU_SOURCE
to obtain the definition of this helper, as
.I loff_t
will not be defined without it.

.SH RETURN VALUE
None
.SH ERRORS
Expand Down
6 changes: 0 additions & 6 deletions man/io_uring_register_iowq_aff.3
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ For unregistration,
.BR io_uring_unregister_iowq_aff (3)
may be called to restore CPU affinities to the default.

Applications must define
.B _GNU_SOURCE
to obtain the definition of this helper, as
.I cpu_set_t
will not be defined without it.

.SH RETURN VALUE
Returns
.B 0
Expand Down
8 changes: 4 additions & 4 deletions src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#ifndef LIB_URING_H
#define LIB_URING_H

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/uio.h>
Expand Down Expand Up @@ -232,10 +236,8 @@ int io_uring_register_restrictions(struct io_uring *ring,
unsigned int nr_res);
int io_uring_enable_rings(struct io_uring *ring);
int __io_uring_sqring_wait(struct io_uring *ring);
#ifdef _GNU_SOURCE
int io_uring_register_iowq_aff(struct io_uring *ring, size_t cpusz,
const cpu_set_t *mask);
#endif
int io_uring_unregister_iowq_aff(struct io_uring *ring);
int io_uring_register_iowq_max_workers(struct io_uring *ring,
unsigned int *values);
Expand Down Expand Up @@ -1261,13 +1263,11 @@ IOURINGINLINE void io_uring_prep_fixed_fd_install(struct io_uring_sqe *sqe,
sqe->install_fd_flags = flags;
}

#ifdef _GNU_SOURCE
IOURINGINLINE void io_uring_prep_ftruncate(struct io_uring_sqe *sqe,
int fd, loff_t len)
{
io_uring_prep_rw(IORING_OP_FTRUNCATE, sqe, fd, 0, 0, len);
}
#endif

/*
* Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in
Expand Down

0 comments on commit 835ff24

Please sign in to comment.