1#![cfg(target_os = "linux")]
2mod ring;
3mod slab;
4use {
5 io_uring::IoUring,
6 std::{io, sync::Once},
7};
8pub use {ring::*, slab::FixedSlab};
9
10pub fn io_uring_supported() -> bool {
11 static mut IO_URING_SUPPORTED: bool = false;
12 static IO_URING_SUPPORTED_ONCE: Once = Once::new();
13 IO_URING_SUPPORTED_ONCE.call_once(|| {
14 fn check() -> io::Result<()> {
15 let ring = IoUring::new(1)?;
16 if !ring.params().is_feature_nodrop() {
17 return Err(io::Error::other("no IORING_FEAT_NODROP"));
18 }
19 if !ring.params().is_feature_sqpoll_nonfixed() {
20 return Err(io::Error::other("no IORING_FEAT_SQPOLL_NONFIXED"));
21 }
22 Ok(())
23 }
24 unsafe {
25 IO_URING_SUPPORTED = match check() {
26 Ok(_) => {
27 log::info!("io_uring supported");
28 true
29 }
30 Err(e) => {
31 log::info!("io_uring NOT supported: {}", e);
32 false
33 }
34 };
35 }
36 });
37 unsafe { IO_URING_SUPPORTED }
38}