diff mbox series

[liburing] io_uring.h: Avoid anonymous enums

Message ID 20240328001653.31124-1-krisman@suse.de (mailing list archive)
State New
Headers show
Series [liburing] io_uring.h: Avoid anonymous enums | expand

Commit Message

Gabriel Krisman Bertazi March 28, 2024, 12:16 a.m. UTC
anonymous enums, while valid, confuses Cython (Python to C translator),
as reported by Ritesh (YoSTEALTH) .  Since people are using this, just
name the existing enums.

See https://github.com/cython/cython/issues/3240.

Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>

---
Do we want to sync with the kernel header?
---
 src/include/liburing/io_uring.h | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Jens Axboe March 28, 2024, 1:45 p.m. UTC | #1
On 3/27/24 6:16 PM, Gabriel Krisman Bertazi wrote:
> anonymous enums, while valid, confuses Cython (Python to C translator),
> as reported by Ritesh (YoSTEALTH) .  Since people are using this, just
> name the existing enums.
> 
> See https://github.com/cython/cython/issues/3240.
> 
> Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
> 
> ---
> Do we want to sync with the kernel header?

Yeah, usually the kernel side gets updates, and then liburing syncs it.
That's how it needs to be done as the kernel side is driving
improvements or new features. So I think we'd want to do this on the
kernel side first, then sync it back to liburing afterwards as a follow
up patch.
diff mbox series

Patch

diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index bde1199..efa3b78 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -115,7 +115,7 @@  struct io_uring_sqe {
  */
 #define IORING_FILE_INDEX_ALLOC		(~0U)
 
-enum {
+enum io_uring_sqe_flag_bit {
 	IOSQE_FIXED_FILE_BIT,
 	IOSQE_IO_DRAIN_BIT,
 	IOSQE_IO_LINK_BIT,
@@ -369,7 +369,7 @@  enum io_uring_op {
 /*
  * IORING_OP_MSG_RING command types, stored in sqe->addr
  */
-enum {
+enum io_uring_msg_ring_flags {
 	IORING_MSG_DATA,	/* pass sqe->len as 'res' and off as user_data */
 	IORING_MSG_SEND_FD,	/* send a registered fd to another ring */
 };
@@ -420,9 +420,7 @@  struct io_uring_cqe {
 #define IORING_CQE_F_SOCK_NONEMPTY	(1U << 2)
 #define IORING_CQE_F_NOTIF		(1U << 3)
 
-enum {
-	IORING_CQE_BUFFER_SHIFT		= 16,
-};
+#define IORING_CQE_BUFFER_SHIFT 16
 
 /*
  * Magic offsets for the application to mmap the data it needs
@@ -521,7 +519,7 @@  struct io_uring_params {
 /*
  * io_uring_register(2) opcodes and arguments
  */
-enum {
+enum io_uring_register_op {
 	IORING_REGISTER_BUFFERS			= 0,
 	IORING_UNREGISTER_BUFFERS		= 1,
 	IORING_REGISTER_FILES			= 2,
@@ -578,7 +576,7 @@  enum {
 };
 
 /* io-wq worker categories */
-enum {
+enum io_wq_type {
 	IO_WQ_BOUND,
 	IO_WQ_UNBOUND,
 };
@@ -683,7 +681,7 @@  struct io_uring_buf_ring {
  *			IORING_OFF_PBUF_RING | (bgid << IORING_OFF_PBUF_SHIFT)
  *			to get a virtual mapping for the ring.
  */
-enum {
+enum io_uring_register_pbuf_ring_flags {
 	IOU_PBUF_RING_MMAP	= 1,
 };
 
@@ -714,7 +712,7 @@  struct io_uring_napi {
 /*
  * io_uring_restriction->opcode values
  */
-enum {
+enum io_uring_register_restrictions {
 	/* Allow an io_uring_register(2) opcode */
 	IORING_RESTRICTION_REGISTER_OP		= 0,
 
@@ -768,7 +766,7 @@  struct io_uring_recvmsg_out {
 /*
  * Argument for IORING_OP_URING_CMD when file is a socket
  */
-enum {
+enum io_uring_socket_op {
 	SOCKET_URING_OP_SIOCINQ		= 0,
 	SOCKET_URING_OP_SIOCOUTQ,
 	SOCKET_URING_OP_GETSOCKOPT,