Skip to content

Commit

Permalink
feat(liburing) update to 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Sep 19, 2024
1 parent 326ad3d commit fce4851
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 46 deletions.
1 change: 1 addition & 0 deletions doc/notes/3.3.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This build includes the following changes:
#### Bindings

- libdivide: Updated to 5.1 (up from 5.0)
- liburing: Updated to 2.7 (up from 2.6)
- NativeFileDialog: Update to 1.2.1 (up from 1.2.0)
- OpenXR: Updated to 1.1.40 (up from 1.0.38)
- stb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,19 @@ JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_
io_uring_prep_connect(sqe, fd, addr, (socklen_t)addrlen);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1bind(JNIEnv *__env, jclass clazz, jlong sqeAddress, jint fd, jlong addrAddress, jint addrlen) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
struct sockaddr *addr = (struct sockaddr *)(uintptr_t)addrAddress;
UNUSED_PARAMS(__env, clazz)
io_uring_prep_bind(sqe, fd, addr, (socklen_t)addrlen);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1listen(JNIEnv *__env, jclass clazz, jlong sqeAddress, jint fd, jint backlog) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
UNUSED_PARAMS(__env, clazz)
io_uring_prep_listen(sqe, fd, backlog);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1files_1update(JNIEnv *__env, jclass clazz, jlong sqeAddress, jlong fdsAddress, jint nr_fds, jint offset) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
int *fds = (int *)(uintptr_t)fdsAddress;
Expand Down Expand Up @@ -690,17 +703,30 @@ JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_
io_uring_prep_statx(sqe, dfd, path, flags, (unsigned int)mask, statxbuf);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1fadvise(JNIEnv *__env, jclass clazz, jlong sqeAddress, jint fd, jint offset, jlong len, jint advice) {
JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1fadvise(JNIEnv *__env, jclass clazz, jlong sqeAddress, jint fd, jlong offset, jint len, jint advice) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
UNUSED_PARAMS(__env, clazz)
io_uring_prep_fadvise(sqe, fd, (__u64)offset, (__u32)len, advice);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1madvise(JNIEnv *__env, jclass clazz, jlong sqeAddress, jlong addrAddress, jint length, jint advice) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
void *addr = (void *)(uintptr_t)addrAddress;
UNUSED_PARAMS(__env, clazz)
io_uring_prep_fadvise(sqe, fd, offset, (off_t)len, advice);
io_uring_prep_madvise(sqe, addr, (__u32)length, advice);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1madvise(JNIEnv *__env, jclass clazz, jlong sqeAddress, jlong addrAddress, jlong length, jint advice) {
JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1fadvise64(JNIEnv *__env, jclass clazz, jlong sqeAddress, jint fd, jlong offset, jint len, jint advice) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
UNUSED_PARAMS(__env, clazz)
io_uring_prep_fadvise64(sqe, fd, (__u64)offset, (__u32)len, advice);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1madvise64(JNIEnv *__env, jclass clazz, jlong sqeAddress, jlong addrAddress, jlong length, jint advice) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
void *addr = (void *)(uintptr_t)addrAddress;
UNUSED_PARAMS(__env, clazz)
io_uring_prep_madvise(sqe, addr, (off_t)length, advice);
io_uring_prep_madvise64(sqe, addr, (off_t)length, advice);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1send(JNIEnv *__env, jclass clazz, jlong sqeAddress, jint sockfd, jlong bufAddress, jlong len, jint flags) {
Expand All @@ -710,6 +736,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_
io_uring_prep_send(sqe, sockfd, buf, (size_t)len, flags);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1send_1bundle(JNIEnv *__env, jclass clazz, jlong sqeAddress, jint sockfd, jlong len, jint flags) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
UNUSED_PARAMS(__env, clazz)
io_uring_prep_send_bundle(sqe, sockfd, (size_t)len, flags);
}

JNIEXPORT void JNICALL Java_org_lwjgl_system_linux_liburing_LibURing_nio_1uring_1prep_1send_1set_1addr(JNIEnv *__env, jclass clazz, jlong sqeAddress, jlong dest_addrAddress, jshort addr_len) {
struct io_uring_sqe *sqe = (struct io_uring_sqe *)(uintptr_t)sqeAddress;
struct sockaddr const *dest_addr = (struct sockaddr const *)(uintptr_t)dest_addrAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public IOURingParams(ByteBuffer container) {
/** @return the value of the {@code sq_thread_idle} field. */
@NativeType("__u32")
public int sq_thread_idle() { return nsq_thread_idle(address()); }
/** filled in by the kernel, which specifies various features supported by current kernel version. One or more of:<br><table><tr><td>{@link LibIOURing#IORING_FEAT_SINGLE_MMAP FEAT_SINGLE_MMAP}</td><td>{@link LibIOURing#IORING_FEAT_NODROP FEAT_NODROP}</td><td>{@link LibIOURing#IORING_FEAT_SUBMIT_STABLE FEAT_SUBMIT_STABLE}</td><td>{@link LibIOURing#IORING_FEAT_RW_CUR_POS FEAT_RW_CUR_POS}</td><td>{@link LibIOURing#IORING_FEAT_CUR_PERSONALITY FEAT_CUR_PERSONALITY}</td></tr><tr><td>{@link LibIOURing#IORING_FEAT_FAST_POLL FEAT_FAST_POLL}</td><td>{@link LibIOURing#IORING_FEAT_POLL_32BITS FEAT_POLL_32BITS}</td><td>{@link LibIOURing#IORING_FEAT_SQPOLL_NONFIXED FEAT_SQPOLL_NONFIXED}</td><td>{@link LibIOURing#IORING_FEAT_EXT_ARG FEAT_EXT_ARG}</td><td>{@link LibIOURing#IORING_FEAT_NATIVE_WORKERS FEAT_NATIVE_WORKERS}</td></tr><tr><td>{@link LibIOURing#IORING_FEAT_RSRC_TAGS FEAT_RSRC_TAGS}</td><td>{@link LibIOURing#IORING_FEAT_CQE_SKIP FEAT_CQE_SKIP}</td><td>{@link LibIOURing#IORING_FEAT_LINKED_FILE FEAT_LINKED_FILE}</td><td>{@link LibIOURing#IORING_FEAT_REG_REG_RING FEAT_REG_REG_RING}</td></tr></table> */
/** filled in by the kernel, which specifies various features supported by current kernel version. One or more of:<br><table><tr><td>{@link LibIOURing#IORING_FEAT_SINGLE_MMAP FEAT_SINGLE_MMAP}</td><td>{@link LibIOURing#IORING_FEAT_NODROP FEAT_NODROP}</td><td>{@link LibIOURing#IORING_FEAT_SUBMIT_STABLE FEAT_SUBMIT_STABLE}</td><td>{@link LibIOURing#IORING_FEAT_RW_CUR_POS FEAT_RW_CUR_POS}</td><td>{@link LibIOURing#IORING_FEAT_CUR_PERSONALITY FEAT_CUR_PERSONALITY}</td></tr><tr><td>{@link LibIOURing#IORING_FEAT_FAST_POLL FEAT_FAST_POLL}</td><td>{@link LibIOURing#IORING_FEAT_POLL_32BITS FEAT_POLL_32BITS}</td><td>{@link LibIOURing#IORING_FEAT_SQPOLL_NONFIXED FEAT_SQPOLL_NONFIXED}</td><td>{@link LibIOURing#IORING_FEAT_EXT_ARG FEAT_EXT_ARG}</td><td>{@link LibIOURing#IORING_FEAT_NATIVE_WORKERS FEAT_NATIVE_WORKERS}</td></tr><tr><td>{@link LibIOURing#IORING_FEAT_RSRC_TAGS FEAT_RSRC_TAGS}</td><td>{@link LibIOURing#IORING_FEAT_CQE_SKIP FEAT_CQE_SKIP}</td><td>{@link LibIOURing#IORING_FEAT_LINKED_FILE FEAT_LINKED_FILE}</td><td>{@link LibIOURing#IORING_FEAT_REG_REG_RING FEAT_REG_REG_RING}</td><td>{@link LibIOURing#IORING_FEAT_RECVSEND_BUNDLE FEAT_RECVSEND_BUNDLE}</td></tr></table> */
@NativeType("__u32")
public int features() { return nfeatures(address()); }
/** @return the value of the {@code wq_fd} field. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
* __u32 waitid_flags;
* __u32 futex_flags;
* __u32 install_fd_flags;
* __u32 nop_flags;
* };
* __u64 {@link #user_data};
* union {
Expand Down Expand Up @@ -142,6 +143,7 @@ public class IOURingSQE extends Struct<IOURingSQE> implements NativeResource {
WAITID_FLAGS,
FUTEX_FLAGS,
INSTALL_FD_FLAGS,
NOP_FLAGS,
USER_DATA,
BUF_INDEX,
BUF_GROUP,
Expand Down Expand Up @@ -201,6 +203,7 @@ public class IOURingSQE extends Struct<IOURingSQE> implements NativeResource {
__member(4),
__member(4),
__member(4),
__member(4),
__member(4)
),
__member(8),
Expand Down Expand Up @@ -266,19 +269,20 @@ public class IOURingSQE extends Struct<IOURingSQE> implements NativeResource {
WAITID_FLAGS = layout.offsetof(37);
FUTEX_FLAGS = layout.offsetof(38);
INSTALL_FD_FLAGS = layout.offsetof(39);
USER_DATA = layout.offsetof(40);
BUF_INDEX = layout.offsetof(42);
BUF_GROUP = layout.offsetof(43);
PERSONALITY = layout.offsetof(44);
SPLICE_FD_IN = layout.offsetof(46);
FILE_INDEX = layout.offsetof(47);
OPTLEN = layout.offsetof(48);
ADDR_LEN = layout.offsetof(50);
__PAD3 = layout.offsetof(51);
ADDR3 = layout.offsetof(54);
__PAD2 = layout.offsetof(55);
OPTVAL = layout.offsetof(56);
CMD = layout.offsetof(57);
NOP_FLAGS = layout.offsetof(40);
USER_DATA = layout.offsetof(41);
BUF_INDEX = layout.offsetof(43);
BUF_GROUP = layout.offsetof(44);
PERSONALITY = layout.offsetof(45);
SPLICE_FD_IN = layout.offsetof(47);
FILE_INDEX = layout.offsetof(48);
OPTLEN = layout.offsetof(49);
ADDR_LEN = layout.offsetof(51);
__PAD3 = layout.offsetof(52);
ADDR3 = layout.offsetof(55);
__PAD2 = layout.offsetof(56);
OPTVAL = layout.offsetof(57);
CMD = layout.offsetof(58);
}

protected IOURingSQE(long address, @Nullable ByteBuffer container) {
Expand Down Expand Up @@ -412,6 +416,9 @@ public IOURingSQE(ByteBuffer container) {
/** @return the value of the {@code install_fd_flags} field. */
@NativeType("__u32")
public int install_fd_flags() { return ninstall_fd_flags(address()); }
/** @return the value of the {@code nop_flags} field. */
@NativeType("__u32")
public int nop_flags() { return nnop_flags(address()); }
/** an application-supplied value that will be copied into the completion queue entry */
@NativeType("__u64")
public long user_data() { return nuser_data(address()); }
Expand Down Expand Up @@ -535,6 +542,8 @@ public IOURingSQE(ByteBuffer container) {
public IOURingSQE futex_flags(@NativeType("__u32") int value) { nfutex_flags(address(), value); return this; }
/** Sets the specified value to the {@code install_fd_flags} field. */
public IOURingSQE install_fd_flags(@NativeType("__u32") int value) { ninstall_fd_flags(address(), value); return this; }
/** Sets the specified value to the {@code nop_flags} field. */
public IOURingSQE nop_flags(@NativeType("__u32") int value) { nnop_flags(address(), value); return this; }
/** Sets the specified value to the {@link #user_data} field. */
public IOURingSQE user_data(@NativeType("__u64") long value) { nuser_data(address(), value); return this; }
/** Sets the specified value to the {@link #buf_index} field. */
Expand Down Expand Up @@ -762,6 +771,8 @@ public static IOURingSQE.Buffer calloc(int capacity, MemoryStack stack) {
public static int nfutex_flags(long struct) { return UNSAFE.getInt(null, struct + IOURingSQE.FUTEX_FLAGS); }
/** Unsafe version of {@link #install_fd_flags}. */
public static int ninstall_fd_flags(long struct) { return UNSAFE.getInt(null, struct + IOURingSQE.INSTALL_FD_FLAGS); }
/** Unsafe version of {@link #nop_flags}. */
public static int nnop_flags(long struct) { return UNSAFE.getInt(null, struct + IOURingSQE.NOP_FLAGS); }
/** Unsafe version of {@link #user_data}. */
public static long nuser_data(long struct) { return UNSAFE.getLong(null, struct + IOURingSQE.USER_DATA); }
/** Unsafe version of {@link #buf_index}. */
Expand Down Expand Up @@ -866,6 +877,8 @@ public static byte ncmd(long struct, int index) {
public static void nfutex_flags(long struct, int value) { UNSAFE.putInt(null, struct + IOURingSQE.FUTEX_FLAGS, value); }
/** Unsafe version of {@link #install_fd_flags(int) install_fd_flags}. */
public static void ninstall_fd_flags(long struct, int value) { UNSAFE.putInt(null, struct + IOURingSQE.INSTALL_FD_FLAGS, value); }
/** Unsafe version of {@link #nop_flags(int) nop_flags}. */
public static void nnop_flags(long struct, int value) { UNSAFE.putInt(null, struct + IOURingSQE.NOP_FLAGS, value); }
/** Unsafe version of {@link #user_data(long) user_data}. */
public static void nuser_data(long struct, long value) { UNSAFE.putLong(null, struct + IOURingSQE.USER_DATA, value); }
/** Unsafe version of {@link #buf_index(short) buf_index}. */
Expand Down Expand Up @@ -1053,6 +1066,9 @@ protected IOURingSQE getElementFactory() {
/** @return the value of the {@code install_fd_flags} field. */
@NativeType("__u32")
public int install_fd_flags() { return IOURingSQE.ninstall_fd_flags(address()); }
/** @return the value of the {@code nop_flags} field. */
@NativeType("__u32")
public int nop_flags() { return IOURingSQE.nnop_flags(address()); }
/** @return the value of the {@link IOURingSQE#user_data} field. */
@NativeType("__u64")
public long user_data() { return IOURingSQE.nuser_data(address()); }
Expand Down Expand Up @@ -1172,6 +1188,8 @@ protected IOURingSQE getElementFactory() {
public IOURingSQE.Buffer futex_flags(@NativeType("__u32") int value) { IOURingSQE.nfutex_flags(address(), value); return this; }
/** Sets the specified value to the {@code install_fd_flags} field. */
public IOURingSQE.Buffer install_fd_flags(@NativeType("__u32") int value) { IOURingSQE.ninstall_fd_flags(address(), value); return this; }
/** Sets the specified value to the {@code nop_flags} field. */
public IOURingSQE.Buffer nop_flags(@NativeType("__u32") int value) { IOURingSQE.nnop_flags(address(), value); return this; }
/** Sets the specified value to the {@link IOURingSQE#user_data} field. */
public IOURingSQE.Buffer user_data(@NativeType("__u64") long value) { IOURingSQE.nuser_data(address(), value); return this; }
/** Sets the specified value to the {@link IOURingSQE#buf_index} field. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ public class LibIOURing {
* <li>{@link #IORING_OP_FUTEX_WAITV OP_FUTEX_WAITV}</li>
* <li>{@link #IORING_OP_FIXED_FD_INSTALL OP_FIXED_FD_INSTALL}</li>
* <li>{@link #IORING_OP_FTRUNCATE OP_FTRUNCATE}</li>
* <li>{@link #IORING_OP_BIND OP_BIND}</li>
* <li>{@link #IORING_OP_LISTEN OP_LISTEN}</li>
* <li>{@link #IORING_OP_LAST OP_LAST}</li>
* </ul>
*/
Expand Down Expand Up @@ -946,7 +948,9 @@ public class LibIOURing {
IORING_OP_FUTEX_WAITV = 53,
IORING_OP_FIXED_FD_INSTALL = 54,
IORING_OP_FTRUNCATE = 55,
IORING_OP_LAST = 56;
IORING_OP_BIND = 56,
IORING_OP_LISTEN = 57,
IORING_OP_LAST = 58;

public static final int IORING_URING_CMD_FIXED = 1 << 0;

Expand Down Expand Up @@ -1065,19 +1069,44 @@ public class LibIOURing {
* <p>Sets {@link #IORING_CQE_F_MORE CQE_F_MORE} if the handler will continue to report CQEs on behalf of the same SQE.</p>
* </li>
* <li>{@link #IORING_RECVSEND_FIXED_BUF RECVSEND_FIXED_BUF} - Use registered buffers, the index is stored in the {@code buf_index} field.</li>
* <li>{@link #IORING_SEND_ZC_REPORT_USAGE SEND_ZC_REPORT_USAGE}</li>
* <li>{@link #IORING_SEND_ZC_REPORT_USAGE SEND_ZC_REPORT_USAGE} -
* If set, {@code SEND[MSG]_ZC} should report the zerocopy usage in {@code cqe.res} for the {@link #IORING_CQE_F_NOTIF CQE_F_NOTIF} cqe.
*
* <p>0 is reported if zerocopy was actually possible. {@link #IORING_NOTIF_USAGE_ZC_COPIED NOTIF_USAGE_ZC_COPIED} if data was copied (at least partially).</p>
* </li>
* <li>{@link #IORING_RECVSEND_BUNDLE RECVSEND_BUNDLE} -
* Used with {@link #IOSQE_BUFFER_SELECT}.
*
* <p>If set, send wil grab as many buffers from the buffer group ID given and send them all. The completion result will be the number of buffers send,
* with the starting buffer ID in {@code cqe->flags} as per usual for provided buffer usage. The buffers will be contigious from the starting buffer
* ID.</p>
* </li>
* </ul>
*/
public static final int
IORING_RECVSEND_POLL_FIRST = 1 << 0,
IORING_RECV_MULTISHOT = 1 << 1,
IORING_RECVSEND_FIXED_BUF = 1 << 2,
IORING_SEND_ZC_REPORT_USAGE = 1 << 3;
IORING_SEND_ZC_REPORT_USAGE = 1 << 3,
IORING_RECVSEND_BUNDLE = 1 << 4;

public static final int IORING_NOTIF_USAGE_ZC_COPIED = 1 << 31;

/** Accept flags stored in {@code sqe->ioprio} */
public static final int IORING_ACCEPT_MULTISHOT = 1 << 0;
/**
* Accept flags stored in {@code sqe->ioprio}
*
* <h5>Enum values:</h5>
*
* <ul>
* <li>{@link #IORING_ACCEPT_MULTISHOT ACCEPT_MULTISHOT}</li>
* <li>{@link #IORING_ACCEPT_DONTWAIT ACCEPT_DONTWAIT}</li>
* <li>{@link #IORING_ACCEPT_POLL_FIRST ACCEPT_POLL_FIRST}</li>
* </ul>
*/
public static final int
IORING_ACCEPT_MULTISHOT = 1 << 0,
IORING_ACCEPT_DONTWAIT = 1 << 1,
IORING_ACCEPT_POLL_FIRST = 1 << 2;

/**
* {@link #IORING_OP_MSG_RING OP_MSG_RING} command types, stored in {@code sqe->addr}
Expand Down Expand Up @@ -1118,6 +1147,17 @@ public class LibIOURing {
*/
public static final int IORING_FIXED_FD_NO_CLOEXEC = 1 << 0;

/**
* {@link #IORING_OP_NOP OP_NOP} flags ({@code sqe->nop_flags})
*
* <h5>Enum values:</h5>
*
* <ul>
* <li>{@link #IORING_NOP_INJECT_RESULT NOP_INJECT_RESULT} - Inject result from {@code sqe->result}.</li>
* </ul>
*/
public static final int IORING_NOP_INJECT_RESULT = 1 << 0;

/**
* {@code cqe->flags}
*
Expand Down Expand Up @@ -1331,6 +1371,7 @@ public class LibIOURing {
* <p>Available since kernel 5.17.</p>
* </li>
* <li>{@link #IORING_FEAT_REG_REG_RING FEAT_REG_REG_RING}</li>
* <li>{@link #IORING_FEAT_RECVSEND_BUNDLE FEAT_RECVSEND_BUNDLE}</li>
* </ul>
*/
public static final int
Expand All @@ -1347,7 +1388,8 @@ public class LibIOURing {
IORING_FEAT_RSRC_TAGS = 1 << 10,
IORING_FEAT_CQE_SKIP = 1 << 11,
IORING_FEAT_LINKED_FILE = 1 << 12,
IORING_FEAT_REG_REG_RING = 1 << 13;
IORING_FEAT_REG_REG_RING = 1 << 13,
IORING_FEAT_RECVSEND_BUNDLE = 1 << 14;

/**
* {@link #io_uring_register register} {@code opcodes} and arguments
Expand Down
Loading

0 comments on commit fce4851

Please sign in to comment.