@@ -59,7 +59,7 @@ class Crystal::System::IoUring
5959 (@@opcodes .not_nil![opcode].flags & LibC ::IO_URING_OP_SUPPORTED ) == LibC ::IO_URING_OP_SUPPORTED
6060 end
6161
62- @ fd : Int32
62+ getter fd : Int32
6363 @flags : UInt32
6464 @sq_size : UInt32
6565 @cq_size : UInt32
@@ -90,6 +90,10 @@ class Crystal::System::IoUring
9090 params.flags |= LibC ::IORING_SETUP_ATTACH_WQ
9191 end
9292
93+ # The following is boilerplate code to map the rings from kernel land to
94+ # user land, with some slight differences based on the running kernel
95+ # supported features (for example single mmap, no SQ array).
96+
9397 Crystal .trace :evloop , " io_uring_setup"
9498 @fd = Syscall .io_uring_setup(sq_entries.to_u32, pointerof (params))
9599 raise RuntimeError .from_os_error(" io_uring_setup" , Errno .new(- @fd )) if @fd < 0
@@ -278,17 +282,15 @@ class Crystal::System::IoUring
278282 # Call `io_uring_enter` syscall. Panics on EBADR (can't recover from lost
279283 # CQE), returns -EINTR or -EBUSY, and raises on other errnos, otherwise
280284 # returns the int returned by the syscall.
281- def enter (to_submit : UInt32 = 0 , min_complete : UInt32 = 0 , flags : UInt32 = 0 , timeout : Time ::Span ?) : Int32
285+ def enter (to_submit : Int = 0 , min_complete : Int = 0 , flags : UInt32 = 0 , timeout : :: Time ::Span ? = nil ) : Int32
282286 if timeout
283287 flags |= LibC ::IORING_ENTER_EXT_ARG
284288
285289 ts = uninitialized LibC ::Timespec
286290 ts.tv_sec = typeof (ts.tv_sec).new(timeout.@seconds )
287291 ts.tv_nsec = typeof (ts.tv_nsec).new(timeout.@nanoseconds )
288292
289- args = LibC ::IoUringGetEventsArg .new(
290- ts : pointerof (ts).address.to_u64!
291- )
293+ args = LibC ::IoUringGetEventsArg .new(ts: pointerof (ts).address.to_u64!)
292294 arg = pointerof (args).as(Void * )
293295 argsz = LibC ::SizeT .new(sizeof(LibC ::IoUringGetEventsArg ))
294296 else
@@ -303,7 +305,7 @@ class Crystal::System::IoUring
303305 timeout: timeout,
304306 flags: ENTERS .new(flags).to_s
305307
306- ret = Syscall .io_uring_enter(@fd , to_submit, min_complete, flags, arg, argsz)
308+ ret = Syscall .io_uring_enter(@fd , to_submit.to_u32 , min_complete.to_u32 , flags, arg, argsz)
307309 return ret if ret >= 0
308310
309311 case ret
0 commit comments