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