| 1 |
//! Linux [io_uring]. |
| 2 |
//! |
| 3 |
//! This API is very low-level. The main adaptations it makes from the raw |
| 4 |
//! Linux io_uring API are the use of appropriately-sized `bitflags`, `enum`, |
| 5 |
//! `Result`, `OwnedFd`, `AsFd`, `RawFd`, and `*mut c_void` in place of plain |
| 6 |
//! integers. |
| 7 |
//! |
| 8 |
//! For a higher-level API built on top of this, see the [rustix-uring] crate. |
| 9 |
//! |
| 10 |
//! # Safety |
| 11 |
//! |
| 12 |
//! io_uring operates on raw pointers and raw file descriptors. Rustix does not |
| 13 |
//! attempt to provide a safe API for these, because the abstraction level is |
| 14 |
//! too low for this to be practical. Safety should be introduced in |
| 15 |
//! higher-level abstraction layers. |
| 16 |
//! |
| 17 |
//! # References |
| 18 |
//! - [Linux] |
| 19 |
//! - [io_uring header] |
| 20 |
//! |
| 21 |
//! [Linux]: https://man.archlinux.org/man/io_uring.7.en |
| 22 |
//! [io_uring]: https://en.wikipedia.org/wiki/Io_uring |
| 23 |
//! [io_uring header]: https://github.com/torvalds/linux/blob/master/include/uapi/linux/io_uring.h |
| 24 |
//! [rustix-uring]: https://crates.io/crates/rustix-uring |
| 25 |
#![allow(unsafe_code)] |
| 26 |
|
| 27 |
use crate::fd::{AsFd, BorrowedFd, OwnedFd, RawFd}; |
| 28 |
use crate::{backend, io}; |
| 29 |
use core::ffi::c_void; |
| 30 |
use core::mem::MaybeUninit; |
| 31 |
use core::ptr::{null_mut, write_bytes}; |
| 32 |
use linux_raw_sys::net; |
| 33 |
|
| 34 |
// Export types used in io_uring APIs. |
| 35 |
pub use crate::event::epoll::{ |
| 36 |
Event as EpollEvent, EventData as EpollEventData, EventFlags as EpollEventFlags, |
| 37 |
}; |
| 38 |
pub use crate::fs::{Advice, AtFlags, Mode, OFlags, RenameFlags, ResolveFlags, Statx, StatxFlags}; |
| 39 |
pub use crate::io::ReadWriteFlags; |
| 40 |
pub use crate::net::{RecvFlags, SendFlags, SocketFlags}; |
| 41 |
pub use crate::timespec::Timespec; |
| 42 |
pub use linux_raw_sys::general::sigset_t; |
| 43 |
|
| 44 |
pub use net::{__kernel_sockaddr_storage as sockaddr_storage, msghdr, sockaddr, socklen_t}; |
| 45 |
|
| 46 |
// Declare the `c_char` type for use with entries that take pointers |
| 47 |
// to C strings. Define it as unsigned or signed according to the platform |
| 48 |
// so that we match what Rust's `CStr` uses. |
| 49 |
// |
| 50 |
// When we can update to linux-raw-sys 0.5, we can remove this, as its |
| 51 |
// `c_char` type will declare this. |
| 52 |
/// The C `char` type. |
| 53 |
#[cfg(any( |
| 54 |
target_arch = "aarch64", |
| 55 |
target_arch = "arm", |
| 56 |
target_arch = "msp430", |
| 57 |
target_arch = "powerpc", |
| 58 |
target_arch = "powerpc64", |
| 59 |
target_arch = "riscv32", |
| 60 |
target_arch = "riscv64", |
| 61 |
target_arch = "s390x", |
| 62 |
))] |
| 63 |
#[allow(non_camel_case_types)] |
| 64 |
pub type c_char = u8; |
| 65 |
/// The C `char` type. |
| 66 |
#[cfg(any( |
| 67 |
target_arch = "mips", |
| 68 |
target_arch = "mips64", |
| 69 |
target_arch = "sparc64", |
| 70 |
target_arch = "x86", |
| 71 |
target_arch = "x86_64", |
| 72 |
target_arch = "xtensa", |
| 73 |
))] |
| 74 |
#[allow(non_camel_case_types)] |
| 75 |
pub type c_char = i8; |
| 76 |
|
| 77 |
mod sys { |
| 78 |
pub(super) use linux_raw_sys::io_uring::*; |
| 79 |
#[cfg(test)] |
| 80 |
pub(super) use {crate::backend::c::iovec, linux_raw_sys::general::open_how}; |
| 81 |
} |
| 82 |
|
| 83 |
/// `io_uring_setup(entries, params)`—Setup a context for performing |
| 84 |
/// asynchronous I/O. |
| 85 |
/// |
| 86 |
/// # References |
| 87 |
/// - [Linux] |
| 88 |
/// |
| 89 |
/// [Linux]: https://man.archlinux.org/man/io_uring_setup.2.en |
| 90 |
#[inline] |
| 91 |
pub fn io_uring_setup(entries: u32, params: &mut io_uring_params) -> io::Result<OwnedFd> { |
| 92 |
backend::io_uring::syscalls::io_uring_setup(entries, params) |
| 93 |
} |
| 94 |
|
| 95 |
/// `io_uring_register(fd, opcode, arg, nr_args)`—Register files or user |
| 96 |
/// buffers for asynchronous I/O. |
| 97 |
/// |
| 98 |
/// # Safety |
| 99 |
/// |
| 100 |
/// io_uring operates on raw pointers and raw file descriptors. Users are |
| 101 |
/// responsible for ensuring that memory and resources are only accessed in |
| 102 |
/// valid ways. |
| 103 |
/// |
| 104 |
/// # References |
| 105 |
/// - [Linux] |
| 106 |
/// |
| 107 |
/// [Linux]: https://man.archlinux.org/man/io_uring_register.2.en |
| 108 |
#[inline] |
| 109 |
pub unsafe fn io_uring_register<Fd: AsFd>( |
| 110 |
fd: Fd, |
| 111 |
opcode: IoringRegisterOp, |
| 112 |
arg: *const c_void, |
| 113 |
nr_args: u32, |
| 114 |
) -> io::Result<u32> { |
| 115 |
backend::io_uring::syscalls::io_uring_register(fd.as_fd(), opcode, arg, nr_args) |
| 116 |
} |
| 117 |
|
| 118 |
/// `io_uring_enter(fd, to_submit, min_complete, flags, arg, size)`—Initiate |
| 119 |
/// and/or complete asynchronous I/O. |
| 120 |
/// |
| 121 |
/// # Safety |
| 122 |
/// |
| 123 |
/// io_uring operates on raw pointers and raw file descriptors. Users are |
| 124 |
/// responsible for ensuring that memory and resources are only accessed in |
| 125 |
/// valid ways. |
| 126 |
/// |
| 127 |
/// # References |
| 128 |
/// - [Linux] |
| 129 |
/// |
| 130 |
/// [Linux]: https://man.archlinux.org/man/io_uring_enter.2.en |
| 131 |
#[inline] |
| 132 |
pub unsafe fn io_uring_enter<Fd: AsFd>( |
| 133 |
fd: Fd, |
| 134 |
to_submit: u32, |
| 135 |
min_complete: u32, |
| 136 |
flags: IoringEnterFlags, |
| 137 |
arg: *const c_void, |
| 138 |
size: usize, |
| 139 |
) -> io::Result<u32> { |
| 140 |
backend::io_uring::syscalls::io_uring_enter( |
| 141 |
fd.as_fd(), |
| 142 |
to_submit, |
| 143 |
min_complete, |
| 144 |
flags, |
| 145 |
arg, |
| 146 |
size, |
| 147 |
) |
| 148 |
} |
| 149 |
|
| 150 |
bitflags::bitflags! { |
| 151 |
/// `IORING_ENTER_*` flags for use with [`io_uring_enter`]. |
| 152 |
#[repr(transparent)] |
| 153 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 154 |
pub struct IoringEnterFlags: u32 { |
| 155 |
/// `IORING_ENTER_GETEVENTS` |
| 156 |
const GETEVENTS = sys::IORING_ENTER_GETEVENTS; |
| 157 |
|
| 158 |
/// `IORING_ENTER_SQ_WAKEUP` |
| 159 |
const SQ_WAKEUP = sys::IORING_ENTER_SQ_WAKEUP; |
| 160 |
|
| 161 |
/// `IORING_ENTER_SQ_WAIT` |
| 162 |
const SQ_WAIT = sys::IORING_ENTER_SQ_WAIT; |
| 163 |
|
| 164 |
/// `IORING_ENTER_EXT_ARG` |
| 165 |
const EXT_ARG = sys::IORING_ENTER_EXT_ARG; |
| 166 |
|
| 167 |
/// `IORING_ENTER_REGISTERED_RING` |
| 168 |
const REGISTERED_RING = sys::IORING_ENTER_REGISTERED_RING; |
| 169 |
|
| 170 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 171 |
const _ = !0; |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
/// `IORING_REGISTER_*` and `IORING_UNREGISTER_*` constants for use with |
| 176 |
/// [`io_uring_register`]. |
| 177 |
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] |
| 178 |
#[repr(u8)] |
| 179 |
#[non_exhaustive] |
| 180 |
pub enum IoringRegisterOp { |
| 181 |
/// `IORING_REGISTER_BUFFERS` |
| 182 |
RegisterBuffers = sys::IORING_REGISTER_BUFFERS as _, |
| 183 |
|
| 184 |
/// `IORING_UNREGISTER_BUFFERS` |
| 185 |
UnregisterBuffers = sys::IORING_UNREGISTER_BUFFERS as _, |
| 186 |
|
| 187 |
/// `IORING_REGISTER_FILES` |
| 188 |
RegisterFiles = sys::IORING_REGISTER_FILES as _, |
| 189 |
|
| 190 |
/// `IORING_UNREGISTER_FILES` |
| 191 |
UnregisterFiles = sys::IORING_UNREGISTER_FILES as _, |
| 192 |
|
| 193 |
/// `IORING_REGISTER_EVENTFD` |
| 194 |
RegisterEventfd = sys::IORING_REGISTER_EVENTFD as _, |
| 195 |
|
| 196 |
/// `IORING_UNREGISTER_EVENTFD` |
| 197 |
UnregisterEventfd = sys::IORING_UNREGISTER_EVENTFD as _, |
| 198 |
|
| 199 |
/// `IORING_REGISTER_FILES_UPDATE` |
| 200 |
RegisterFilesUpdate = sys::IORING_REGISTER_FILES_UPDATE as _, |
| 201 |
|
| 202 |
/// `IORING_REGISTER_EVENTFD_ASYNC` |
| 203 |
RegisterEventfdAsync = sys::IORING_REGISTER_EVENTFD_ASYNC as _, |
| 204 |
|
| 205 |
/// `IORING_REGISTER_PROBE` |
| 206 |
RegisterProbe = sys::IORING_REGISTER_PROBE as _, |
| 207 |
|
| 208 |
/// `IORING_REGISTER_PERSONALITY` |
| 209 |
RegisterPersonality = sys::IORING_REGISTER_PERSONALITY as _, |
| 210 |
|
| 211 |
/// `IORING_UNREGISTER_PERSONALITY` |
| 212 |
UnregisterPersonality = sys::IORING_UNREGISTER_PERSONALITY as _, |
| 213 |
|
| 214 |
/// `IORING_REGISTER_RESTRICTIONS` |
| 215 |
RegisterRestrictions = sys::IORING_REGISTER_RESTRICTIONS as _, |
| 216 |
|
| 217 |
/// `IORING_REGISTER_ENABLE_RINGS` |
| 218 |
RegisterEnableRings = sys::IORING_REGISTER_ENABLE_RINGS as _, |
| 219 |
|
| 220 |
/// `IORING_REGISTER_BUFFERS2` |
| 221 |
RegisterBuffers2 = sys::IORING_REGISTER_BUFFERS2 as _, |
| 222 |
|
| 223 |
/// `IORING_REGISTER_BUFFERS_UPDATE` |
| 224 |
RegisterBuffersUpdate = sys::IORING_REGISTER_BUFFERS_UPDATE as _, |
| 225 |
|
| 226 |
/// `IORING_REGISTER_FILES2` |
| 227 |
RegisterFiles2 = sys::IORING_REGISTER_FILES2 as _, |
| 228 |
|
| 229 |
/// `IORING_REGISTER_FILES_SKIP` |
| 230 |
RegisterFilesSkip = sys::IORING_REGISTER_FILES_SKIP as _, |
| 231 |
|
| 232 |
/// `IORING_REGISTER_FILES_UPDATE2` |
| 233 |
RegisterFilesUpdate2 = sys::IORING_REGISTER_FILES_UPDATE2 as _, |
| 234 |
|
| 235 |
/// `IORING_REGISTER_IOWQ_AFF` |
| 236 |
RegisterIowqAff = sys::IORING_REGISTER_IOWQ_AFF as _, |
| 237 |
|
| 238 |
/// `IORING_UNREGISTER_IOWQ_AFF` |
| 239 |
UnregisterIowqAff = sys::IORING_UNREGISTER_IOWQ_AFF as _, |
| 240 |
|
| 241 |
/// `IORING_REGISTER_IOWQ_MAX_WORKERS` |
| 242 |
RegisterIowqMaxWorkers = sys::IORING_REGISTER_IOWQ_MAX_WORKERS as _, |
| 243 |
|
| 244 |
/// `IORING_REGISTER_RING_FDS` |
| 245 |
RegisterRingFds = sys::IORING_REGISTER_RING_FDS as _, |
| 246 |
|
| 247 |
/// `IORING_UNREGISTER_RING_FDS` |
| 248 |
UnregisterRingFds = sys::IORING_UNREGISTER_RING_FDS as _, |
| 249 |
|
| 250 |
/// `IORING_REGISTER_PBUF_RING` |
| 251 |
RegisterPbufRing = sys::IORING_REGISTER_PBUF_RING as _, |
| 252 |
|
| 253 |
/// `IORING_UNREGISTER_PBUF_RING` |
| 254 |
UnregisterPbufRing = sys::IORING_UNREGISTER_PBUF_RING as _, |
| 255 |
|
| 256 |
/// `IORING_REGISTER_SYNC_CANCEL` |
| 257 |
RegisterSyncCancel = sys::IORING_REGISTER_SYNC_CANCEL as _, |
| 258 |
|
| 259 |
/// `IORING_REGISTER_FILE_ALLOC_RANGE` |
| 260 |
RegisterFileAllocRange = sys::IORING_REGISTER_FILE_ALLOC_RANGE as _, |
| 261 |
} |
| 262 |
|
| 263 |
/// `IORING_OP_*` constants for use with [`io_uring_sqe`]. |
| 264 |
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] |
| 265 |
#[repr(u8)] |
| 266 |
#[non_exhaustive] |
| 267 |
pub enum IoringOp { |
| 268 |
/// `IORING_OP_NOP` |
| 269 |
Nop = sys::io_uring_op::IORING_OP_NOP as _, |
| 270 |
|
| 271 |
/// `IORING_OP_ACCEPT` |
| 272 |
Accept = sys::io_uring_op::IORING_OP_ACCEPT as _, |
| 273 |
|
| 274 |
/// `IORING_OP_ASYNC_CANCEL` |
| 275 |
AsyncCancel = sys::io_uring_op::IORING_OP_ASYNC_CANCEL as _, |
| 276 |
|
| 277 |
/// `IORING_OP_CLOSE` |
| 278 |
Close = sys::io_uring_op::IORING_OP_CLOSE as _, |
| 279 |
|
| 280 |
/// `IORING_OP_CONNECT` |
| 281 |
Connect = sys::io_uring_op::IORING_OP_CONNECT as _, |
| 282 |
|
| 283 |
/// `IORING_OP_EPOLL_CTL` |
| 284 |
EpollCtl = sys::io_uring_op::IORING_OP_EPOLL_CTL as _, |
| 285 |
|
| 286 |
/// `IORING_OP_FADVISE` |
| 287 |
Fadvise = sys::io_uring_op::IORING_OP_FADVISE as _, |
| 288 |
|
| 289 |
/// `IORING_OP_FALLOCATE` |
| 290 |
Fallocate = sys::io_uring_op::IORING_OP_FALLOCATE as _, |
| 291 |
|
| 292 |
/// `IORING_OP_FILES_UPDATE` |
| 293 |
FilesUpdate = sys::io_uring_op::IORING_OP_FILES_UPDATE as _, |
| 294 |
|
| 295 |
/// `IORING_OP_FSYNC` |
| 296 |
Fsync = sys::io_uring_op::IORING_OP_FSYNC as _, |
| 297 |
|
| 298 |
/// `IORING_OP_LINKAT` |
| 299 |
Linkat = sys::io_uring_op::IORING_OP_LINKAT as _, |
| 300 |
|
| 301 |
/// `IORING_OP_LINK_TIMEOUT` |
| 302 |
LinkTimeout = sys::io_uring_op::IORING_OP_LINK_TIMEOUT as _, |
| 303 |
|
| 304 |
/// `IORING_OP_MADVISE` |
| 305 |
Madvise = sys::io_uring_op::IORING_OP_MADVISE as _, |
| 306 |
|
| 307 |
/// `IORING_OP_MKDIRAT` |
| 308 |
Mkdirat = sys::io_uring_op::IORING_OP_MKDIRAT as _, |
| 309 |
|
| 310 |
/// `IORING_OP_OPENAT` |
| 311 |
Openat = sys::io_uring_op::IORING_OP_OPENAT as _, |
| 312 |
|
| 313 |
/// `IORING_OP_OPENAT2` |
| 314 |
Openat2 = sys::io_uring_op::IORING_OP_OPENAT2 as _, |
| 315 |
|
| 316 |
/// `IORING_OP_POLL_ADD` |
| 317 |
PollAdd = sys::io_uring_op::IORING_OP_POLL_ADD as _, |
| 318 |
|
| 319 |
/// `IORING_OP_POLL_REMOVE` |
| 320 |
PollRemove = sys::io_uring_op::IORING_OP_POLL_REMOVE as _, |
| 321 |
|
| 322 |
/// `IORING_OP_PROVIDE_BUFFERS` |
| 323 |
ProvideBuffers = sys::io_uring_op::IORING_OP_PROVIDE_BUFFERS as _, |
| 324 |
|
| 325 |
/// `IORING_OP_READ` |
| 326 |
Read = sys::io_uring_op::IORING_OP_READ as _, |
| 327 |
|
| 328 |
/// `IORING_OP_READV` |
| 329 |
Readv = sys::io_uring_op::IORING_OP_READV as _, |
| 330 |
|
| 331 |
/// `IORING_OP_READ_FIXED` |
| 332 |
ReadFixed = sys::io_uring_op::IORING_OP_READ_FIXED as _, |
| 333 |
|
| 334 |
/// `IORING_OP_RECV` |
| 335 |
Recv = sys::io_uring_op::IORING_OP_RECV as _, |
| 336 |
|
| 337 |
/// `IORING_OP_RECVMSG` |
| 338 |
Recvmsg = sys::io_uring_op::IORING_OP_RECVMSG as _, |
| 339 |
|
| 340 |
/// `IORING_OP_REMOVE_BUFFERS` |
| 341 |
RemoveBuffers = sys::io_uring_op::IORING_OP_REMOVE_BUFFERS as _, |
| 342 |
|
| 343 |
/// `IORING_OP_RENAMEAT` |
| 344 |
Renameat = sys::io_uring_op::IORING_OP_RENAMEAT as _, |
| 345 |
|
| 346 |
/// `IORING_OP_SEND` |
| 347 |
Send = sys::io_uring_op::IORING_OP_SEND as _, |
| 348 |
|
| 349 |
/// `IORING_OP_SENDMSG` |
| 350 |
Sendmsg = sys::io_uring_op::IORING_OP_SENDMSG as _, |
| 351 |
|
| 352 |
/// `IORING_OP_SHUTDOWN` |
| 353 |
Shutdown = sys::io_uring_op::IORING_OP_SHUTDOWN as _, |
| 354 |
|
| 355 |
/// `IORING_OP_SPLICE` |
| 356 |
Splice = sys::io_uring_op::IORING_OP_SPLICE as _, |
| 357 |
|
| 358 |
/// `IORING_OP_STATX` |
| 359 |
Statx = sys::io_uring_op::IORING_OP_STATX as _, |
| 360 |
|
| 361 |
/// `IORING_OP_SYMLINKAT` |
| 362 |
Symlinkat = sys::io_uring_op::IORING_OP_SYMLINKAT as _, |
| 363 |
|
| 364 |
/// `IORING_OP_SYNC_FILE_RANGE` |
| 365 |
SyncFileRange = sys::io_uring_op::IORING_OP_SYNC_FILE_RANGE as _, |
| 366 |
|
| 367 |
/// `IORING_OP_TEE` |
| 368 |
Tee = sys::io_uring_op::IORING_OP_TEE as _, |
| 369 |
|
| 370 |
/// `IORING_OP_TIMEOUT` |
| 371 |
Timeout = sys::io_uring_op::IORING_OP_TIMEOUT as _, |
| 372 |
|
| 373 |
/// `IORING_OP_TIMEOUT_REMOVE` |
| 374 |
TimeoutRemove = sys::io_uring_op::IORING_OP_TIMEOUT_REMOVE as _, |
| 375 |
|
| 376 |
/// `IORING_OP_UNLINKAT` |
| 377 |
Unlinkat = sys::io_uring_op::IORING_OP_UNLINKAT as _, |
| 378 |
|
| 379 |
/// `IORING_OP_WRITE` |
| 380 |
Write = sys::io_uring_op::IORING_OP_WRITE as _, |
| 381 |
|
| 382 |
/// `IORING_OP_WRITEV` |
| 383 |
Writev = sys::io_uring_op::IORING_OP_WRITEV as _, |
| 384 |
|
| 385 |
/// `IORING_OP_WRITE_FIXED` |
| 386 |
WriteFixed = sys::io_uring_op::IORING_OP_WRITE_FIXED as _, |
| 387 |
|
| 388 |
/// `IORING_OP_MSG_RING` |
| 389 |
MsgRing = sys::io_uring_op::IORING_OP_MSG_RING as _, |
| 390 |
|
| 391 |
/// `IORING_OP_FSETXATTR` |
| 392 |
Fsetxattr = sys::io_uring_op::IORING_OP_FSETXATTR as _, |
| 393 |
|
| 394 |
/// `IORING_OP_SETXATTR` |
| 395 |
Setxattr = sys::io_uring_op::IORING_OP_SETXATTR as _, |
| 396 |
|
| 397 |
/// `IORING_OP_FGETXATTR` |
| 398 |
Fgetxattr = sys::io_uring_op::IORING_OP_FGETXATTR as _, |
| 399 |
|
| 400 |
/// `IORING_OP_GETXATTR` |
| 401 |
Getxattr = sys::io_uring_op::IORING_OP_GETXATTR as _, |
| 402 |
|
| 403 |
/// `IORING_OP_SOCKET` |
| 404 |
Socket = sys::io_uring_op::IORING_OP_SOCKET as _, |
| 405 |
|
| 406 |
/// `IORING_OP_URING_CMD` |
| 407 |
UringCmd = sys::io_uring_op::IORING_OP_URING_CMD as _, |
| 408 |
|
| 409 |
/// `IORING_OP_SEND_ZC` |
| 410 |
SendZc = sys::io_uring_op::IORING_OP_SEND_ZC as _, |
| 411 |
|
| 412 |
/// `IORING_OP_SENDMSG_ZC` |
| 413 |
SendmsgZc = sys::io_uring_op::IORING_OP_SENDMSG_ZC as _, |
| 414 |
} |
| 415 |
|
| 416 |
impl Default for IoringOp { |
| 417 |
#[inline] |
| 418 |
fn default() -> Self { |
| 419 |
Self::Nop |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
/// `IORING_RESTRICTION_*` constants for use with [`io_uring_restriction`]. |
| 424 |
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] |
| 425 |
#[repr(u16)] |
| 426 |
#[non_exhaustive] |
| 427 |
pub enum IoringRestrictionOp { |
| 428 |
/// `IORING_RESTRICTION_REGISTER_OP` |
| 429 |
RegisterOp = sys::IORING_RESTRICTION_REGISTER_OP as _, |
| 430 |
|
| 431 |
/// `IORING_RESTRICTION_SQE_FLAGS_ALLOWED` |
| 432 |
SqeFlagsAllowed = sys::IORING_RESTRICTION_SQE_FLAGS_ALLOWED as _, |
| 433 |
|
| 434 |
/// `IORING_RESTRICTION_SQE_FLAGS_REQUIRED` |
| 435 |
SqeFlagsRequired = sys::IORING_RESTRICTION_SQE_FLAGS_REQUIRED as _, |
| 436 |
|
| 437 |
/// `IORING_RESTRICTION_SQE_OP` |
| 438 |
SqeOp = sys::IORING_RESTRICTION_SQE_OP as _, |
| 439 |
} |
| 440 |
|
| 441 |
impl Default for IoringRestrictionOp { |
| 442 |
#[inline] |
| 443 |
fn default() -> Self { |
| 444 |
Self::RegisterOp |
| 445 |
} |
| 446 |
} |
| 447 |
|
| 448 |
/// `IORING_MSG_*` constants which represent commands for use with |
| 449 |
/// [`IoringOp::MsgRing`], (`seq.addr`) |
| 450 |
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] |
| 451 |
#[repr(u64)] |
| 452 |
#[non_exhaustive] |
| 453 |
pub enum IoringMsgringCmds { |
| 454 |
/// `IORING_MSG_DATA` |
| 455 |
Data = sys::IORING_MSG_DATA as _, |
| 456 |
|
| 457 |
/// `IORING_MSG_SEND_FD` |
| 458 |
SendFd = sys::IORING_MSG_SEND_FD as _, |
| 459 |
} |
| 460 |
|
| 461 |
bitflags::bitflags! { |
| 462 |
/// `IORING_SETUP_*` flags for use with [`io_uring_params`]. |
| 463 |
#[repr(transparent)] |
| 464 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 465 |
pub struct IoringSetupFlags: u32 { |
| 466 |
/// `IORING_SETUP_ATTACH_WQ` |
| 467 |
const ATTACH_WQ = sys::IORING_SETUP_ATTACH_WQ; |
| 468 |
|
| 469 |
/// `IORING_SETUP_CLAMP` |
| 470 |
const CLAMP = sys::IORING_SETUP_CLAMP; |
| 471 |
|
| 472 |
/// `IORING_SETUP_CQSIZE` |
| 473 |
const CQSIZE = sys::IORING_SETUP_CQSIZE; |
| 474 |
|
| 475 |
/// `IORING_SETUP_IOPOLL` |
| 476 |
const IOPOLL = sys::IORING_SETUP_IOPOLL; |
| 477 |
|
| 478 |
/// `IORING_SETUP_R_DISABLED` |
| 479 |
const R_DISABLED = sys::IORING_SETUP_R_DISABLED; |
| 480 |
|
| 481 |
/// `IORING_SETUP_SQPOLL` |
| 482 |
const SQPOLL = sys::IORING_SETUP_SQPOLL; |
| 483 |
|
| 484 |
/// `IORING_SETUP_SQ_AFF` |
| 485 |
const SQ_AFF = sys::IORING_SETUP_SQ_AFF; |
| 486 |
|
| 487 |
/// `IORING_SETUP_SQE128` |
| 488 |
const SQE128 = sys::IORING_SETUP_SQE128; |
| 489 |
|
| 490 |
/// `IORING_SETUP_CQE32` |
| 491 |
const CQE32 = sys::IORING_SETUP_CQE32; |
| 492 |
|
| 493 |
/// `IORING_SETUP_SUBMIT_ALL` |
| 494 |
const SUBMIT_ALL = sys::IORING_SETUP_SUBMIT_ALL; |
| 495 |
|
| 496 |
/// `IORING_SETUP_COOP_TRASKRUN` |
| 497 |
const COOP_TASKRUN = sys::IORING_SETUP_COOP_TASKRUN; |
| 498 |
|
| 499 |
/// `IORING_SETUP_TASKRUN_FLAG` |
| 500 |
const TASKRUN_FLAG = sys::IORING_SETUP_TASKRUN_FLAG; |
| 501 |
|
| 502 |
/// `IORING_SETUP_SINGLE_ISSUER` |
| 503 |
const SINGLE_ISSUER = sys::IORING_SETUP_SINGLE_ISSUER; |
| 504 |
|
| 505 |
/// `IORING_SETUP_DEFER_TASKRUN` |
| 506 |
const DEFER_TASKRUN = sys::IORING_SETUP_DEFER_TASKRUN; |
| 507 |
|
| 508 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 509 |
const _ = !0; |
| 510 |
} |
| 511 |
} |
| 512 |
|
| 513 |
bitflags::bitflags! { |
| 514 |
/// `IOSQE_*` flags for use with [`io_uring_sqe`]. |
| 515 |
#[repr(transparent)] |
| 516 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 517 |
pub struct IoringSqeFlags: u8 { |
| 518 |
/// `1 << IOSQE_ASYNC_BIT` |
| 519 |
const ASYNC = 1 << sys::IOSQE_ASYNC_BIT as u8; |
| 520 |
|
| 521 |
/// `1 << IOSQE_BUFFER_SELECT_BIT` |
| 522 |
const BUFFER_SELECT = 1 << sys::IOSQE_BUFFER_SELECT_BIT as u8; |
| 523 |
|
| 524 |
/// `1 << IOSQE_FIXED_FILE_BIT` |
| 525 |
const FIXED_FILE = 1 << sys::IOSQE_FIXED_FILE_BIT as u8; |
| 526 |
|
| 527 |
/// 1 << `IOSQE_IO_DRAIN_BIT` |
| 528 |
const IO_DRAIN = 1 << sys::IOSQE_IO_DRAIN_BIT as u8; |
| 529 |
|
| 530 |
/// `1 << IOSQE_IO_HARDLINK_BIT` |
| 531 |
const IO_HARDLINK = 1 << sys::IOSQE_IO_HARDLINK_BIT as u8; |
| 532 |
|
| 533 |
/// `1 << IOSQE_IO_LINK_BIT` |
| 534 |
const IO_LINK = 1 << sys::IOSQE_IO_LINK_BIT as u8; |
| 535 |
|
| 536 |
/// `1 << IOSQE_CQE_SKIP_SUCCESS_BIT` |
| 537 |
const CQE_SKIP_SUCCESS = 1 << sys::IOSQE_CQE_SKIP_SUCCESS_BIT as u8; |
| 538 |
|
| 539 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 540 |
const _ = !0; |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
bitflags::bitflags! { |
| 545 |
/// `IORING_CQE_F_*` flags for use with [`io_uring_cqe`]. |
| 546 |
#[repr(transparent)] |
| 547 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 548 |
pub struct IoringCqeFlags: u32 { |
| 549 |
/// `IORING_CQE_F_BUFFER` |
| 550 |
const BUFFER = bitcast!(sys::IORING_CQE_F_BUFFER); |
| 551 |
|
| 552 |
/// `IORING_CQE_F_MORE` |
| 553 |
const MORE = bitcast!(sys::IORING_CQE_F_MORE); |
| 554 |
|
| 555 |
/// `IORING_CQE_F_SOCK_NONEMPTY` |
| 556 |
const SOCK_NONEMPTY = bitcast!(sys::IORING_CQE_F_SOCK_NONEMPTY); |
| 557 |
|
| 558 |
/// `IORING_CQE_F_NOTIF` |
| 559 |
const NOTIF = bitcast!(sys::IORING_CQE_F_NOTIF); |
| 560 |
|
| 561 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 562 |
const _ = !0; |
| 563 |
} |
| 564 |
} |
| 565 |
|
| 566 |
bitflags::bitflags! { |
| 567 |
/// `IORING_FSYNC_*` flags for use with [`io_uring_sqe`]. |
| 568 |
#[repr(transparent)] |
| 569 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 570 |
pub struct IoringFsyncFlags: u32 { |
| 571 |
/// `IORING_FSYNC_DATASYNC` |
| 572 |
const DATASYNC = sys::IORING_FSYNC_DATASYNC; |
| 573 |
|
| 574 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 575 |
const _ = !0; |
| 576 |
} |
| 577 |
} |
| 578 |
|
| 579 |
bitflags::bitflags! { |
| 580 |
/// `IORING_TIMEOUT_*` and `IORING_LINK_TIMEOUT_UPDATE` flags for use with |
| 581 |
/// [`io_uring_sqe`]. |
| 582 |
#[repr(transparent)] |
| 583 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 584 |
pub struct IoringTimeoutFlags: u32 { |
| 585 |
/// `IORING_TIMEOUT_ABS` |
| 586 |
const ABS = sys::IORING_TIMEOUT_ABS; |
| 587 |
|
| 588 |
/// `IORING_TIMEOUT_UPDATE` |
| 589 |
const UPDATE = sys::IORING_TIMEOUT_UPDATE; |
| 590 |
|
| 591 |
/// `IORING_TIMEOUT_BOOTTIME` |
| 592 |
const BOOTTIME = sys::IORING_TIMEOUT_BOOTTIME; |
| 593 |
|
| 594 |
/// `IORING_TIMEOUT_ETIME_SUCCESS` |
| 595 |
const ETIME_SUCCESS = sys::IORING_TIMEOUT_ETIME_SUCCESS; |
| 596 |
|
| 597 |
/// `IORING_TIMEOUT_REALTIME` |
| 598 |
const REALTIME = sys::IORING_TIMEOUT_REALTIME; |
| 599 |
|
| 600 |
/// `IORING_TIMEOUT_CLOCK_MASK` |
| 601 |
const CLOCK_MASK = sys::IORING_TIMEOUT_CLOCK_MASK; |
| 602 |
|
| 603 |
/// `IORING_TIMEOUT_UPDATE_MASK` |
| 604 |
const UPDATE_MASK = sys::IORING_TIMEOUT_UPDATE_MASK; |
| 605 |
|
| 606 |
/// `IORING_LINK_TIMEOUT_UPDATE` |
| 607 |
const LINK_TIMEOUT_UPDATE = sys::IORING_LINK_TIMEOUT_UPDATE; |
| 608 |
|
| 609 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 610 |
const _ = !0; |
| 611 |
} |
| 612 |
} |
| 613 |
|
| 614 |
bitflags::bitflags! { |
| 615 |
/// `SPLICE_F_*` flags for use with [`io_uring_sqe`]. |
| 616 |
#[repr(transparent)] |
| 617 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 618 |
pub struct SpliceFlags: u32 { |
| 619 |
/// `SPLICE_F_FD_IN_FIXED` |
| 620 |
const FD_IN_FIXED = sys::SPLICE_F_FD_IN_FIXED; |
| 621 |
|
| 622 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 623 |
const _ = !0; |
| 624 |
} |
| 625 |
} |
| 626 |
|
| 627 |
bitflags::bitflags! { |
| 628 |
/// `IORING_MSG_RING_*` flags for use with [`io_uring_sqe`]. |
| 629 |
#[repr(transparent)] |
| 630 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 631 |
pub struct IoringMsgringFlags: u32 { |
| 632 |
/// `IORING_MSG_RING_CQE_SKIP` |
| 633 |
const CQE_SKIP = sys::IORING_MSG_RING_CQE_SKIP; |
| 634 |
|
| 635 |
/// `IORING_MSG_RING_FLAGS_PASS` |
| 636 |
const FLAGS_PASS = sys::IORING_MSG_RING_FLAGS_PASS; |
| 637 |
|
| 638 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 639 |
const _ = !0; |
| 640 |
} |
| 641 |
} |
| 642 |
|
| 643 |
bitflags::bitflags! { |
| 644 |
/// `IORING_ASYNC_CANCEL_*` flags for use with [`io_uring_sqe`]. |
| 645 |
#[repr(transparent)] |
| 646 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 647 |
pub struct IoringAsyncCancelFlags: u32 { |
| 648 |
/// `IORING_ASYNC_CANCEL_ALL` |
| 649 |
const ALL = sys::IORING_ASYNC_CANCEL_ALL; |
| 650 |
|
| 651 |
/// `IORING_ASYNC_CANCEL_FD` |
| 652 |
const FD = sys::IORING_ASYNC_CANCEL_FD; |
| 653 |
|
| 654 |
/// `IORING_ASYNC_CANCEL_FD` |
| 655 |
const ANY = sys::IORING_ASYNC_CANCEL_ANY; |
| 656 |
|
| 657 |
/// `IORING_ASYNC_CANCEL_FD` |
| 658 |
const FD_FIXED = sys::IORING_ASYNC_CANCEL_FD_FIXED; |
| 659 |
|
| 660 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 661 |
const _ = !0; |
| 662 |
} |
| 663 |
} |
| 664 |
|
| 665 |
bitflags::bitflags! { |
| 666 |
/// `IORING_FEAT_*` flags for use with [`io_uring_params`]. |
| 667 |
#[repr(transparent)] |
| 668 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 669 |
pub struct IoringFeatureFlags: u32 { |
| 670 |
/// `IORING_FEAT_CQE_SKIP` |
| 671 |
const CQE_SKIP = sys::IORING_FEAT_CQE_SKIP; |
| 672 |
|
| 673 |
/// `IORING_FEAT_CUR_PERSONALITY` |
| 674 |
const CUR_PERSONALITY = sys::IORING_FEAT_CUR_PERSONALITY; |
| 675 |
|
| 676 |
/// `IORING_FEAT_EXT_ARG` |
| 677 |
const EXT_ARG = sys::IORING_FEAT_EXT_ARG; |
| 678 |
|
| 679 |
/// `IORING_FEAT_FAST_POLL` |
| 680 |
const FAST_POLL = sys::IORING_FEAT_FAST_POLL; |
| 681 |
|
| 682 |
/// `IORING_FEAT_NATIVE_WORKERS` |
| 683 |
const NATIVE_WORKERS = sys::IORING_FEAT_NATIVE_WORKERS; |
| 684 |
|
| 685 |
/// `IORING_FEAT_NODROP` |
| 686 |
const NODROP = sys::IORING_FEAT_NODROP; |
| 687 |
|
| 688 |
/// `IORING_FEAT_POLL_32BITS` |
| 689 |
const POLL_32BITS = sys::IORING_FEAT_POLL_32BITS; |
| 690 |
|
| 691 |
/// `IORING_FEAT_RSRC_TAGS` |
| 692 |
const RSRC_TAGS = sys::IORING_FEAT_RSRC_TAGS; |
| 693 |
|
| 694 |
/// `IORING_FEAT_RW_CUR_POS` |
| 695 |
const RW_CUR_POS = sys::IORING_FEAT_RW_CUR_POS; |
| 696 |
|
| 697 |
/// `IORING_FEAT_SINGLE_MMAP` |
| 698 |
const SINGLE_MMAP = sys::IORING_FEAT_SINGLE_MMAP; |
| 699 |
|
| 700 |
/// `IORING_FEAT_SQPOLL_NONFIXED` |
| 701 |
const SQPOLL_NONFIXED = sys::IORING_FEAT_SQPOLL_NONFIXED; |
| 702 |
|
| 703 |
/// `IORING_FEAT_SUBMIT_STABLE` |
| 704 |
const SUBMIT_STABLE = sys::IORING_FEAT_SUBMIT_STABLE; |
| 705 |
|
| 706 |
/// `IORING_FEAT_LINKED_FILE` |
| 707 |
const LINKED_FILE = sys::IORING_FEAT_LINKED_FILE; |
| 708 |
|
| 709 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 710 |
const _ = !0; |
| 711 |
} |
| 712 |
} |
| 713 |
|
| 714 |
bitflags::bitflags! { |
| 715 |
/// `IO_URING_OP_*` flags for use with [`io_uring_probe_op`]. |
| 716 |
#[repr(transparent)] |
| 717 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 718 |
pub struct IoringOpFlags: u16 { |
| 719 |
/// `IO_URING_OP_SUPPORTED` |
| 720 |
const SUPPORTED = sys::IO_URING_OP_SUPPORTED as _; |
| 721 |
|
| 722 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 723 |
const _ = !0; |
| 724 |
} |
| 725 |
} |
| 726 |
|
| 727 |
bitflags::bitflags! { |
| 728 |
/// `IORING_RSRC_*` flags for use with [`io_uring_rsrc_register`]. |
| 729 |
#[repr(transparent)] |
| 730 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 731 |
pub struct IoringRsrcFlags: u32 { |
| 732 |
/// `IORING_RSRC_REGISTER_SPARSE` |
| 733 |
const REGISTER_SPARSE = sys::IORING_RSRC_REGISTER_SPARSE as _; |
| 734 |
|
| 735 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 736 |
const _ = !0; |
| 737 |
} |
| 738 |
} |
| 739 |
|
| 740 |
bitflags::bitflags! { |
| 741 |
/// `IORING_SQ_*` flags. |
| 742 |
#[repr(transparent)] |
| 743 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 744 |
pub struct IoringSqFlags: u32 { |
| 745 |
/// `IORING_SQ_NEED_WAKEUP` |
| 746 |
const NEED_WAKEUP = sys::IORING_SQ_NEED_WAKEUP; |
| 747 |
|
| 748 |
/// `IORING_SQ_CQ_OVERFLOW` |
| 749 |
const CQ_OVERFLOW = sys::IORING_SQ_CQ_OVERFLOW; |
| 750 |
|
| 751 |
/// `IORING_SQ_TASKRUN` |
| 752 |
const TASKRUN = sys::IORING_SQ_TASKRUN; |
| 753 |
|
| 754 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 755 |
const _ = !0; |
| 756 |
} |
| 757 |
} |
| 758 |
|
| 759 |
bitflags::bitflags! { |
| 760 |
/// `IORING_CQ_*` flags. |
| 761 |
#[repr(transparent)] |
| 762 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 763 |
pub struct IoringCqFlags: u32 { |
| 764 |
/// `IORING_CQ_EVENTFD_DISABLED` |
| 765 |
const EVENTFD_DISABLED = sys::IORING_CQ_EVENTFD_DISABLED; |
| 766 |
|
| 767 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 768 |
const _ = !0; |
| 769 |
} |
| 770 |
} |
| 771 |
|
| 772 |
bitflags::bitflags! { |
| 773 |
/// `IORING_POLL_*` flags. |
| 774 |
#[repr(transparent)] |
| 775 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 776 |
pub struct IoringPollFlags: u32 { |
| 777 |
/// `IORING_POLL_ADD_MULTI` |
| 778 |
const ADD_MULTI = sys::IORING_POLL_ADD_MULTI; |
| 779 |
|
| 780 |
/// `IORING_POLL_UPDATE_EVENTS` |
| 781 |
const UPDATE_EVENTS = sys::IORING_POLL_UPDATE_EVENTS; |
| 782 |
|
| 783 |
/// `IORING_POLL_UPDATE_USER_DATA` |
| 784 |
const UPDATE_USER_DATA = sys::IORING_POLL_UPDATE_USER_DATA; |
| 785 |
|
| 786 |
/// `IORING_POLL_ADD_LEVEL` |
| 787 |
const ADD_LEVEL = sys::IORING_POLL_ADD_LEVEL; |
| 788 |
|
| 789 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 790 |
const _ = !0; |
| 791 |
} |
| 792 |
} |
| 793 |
|
| 794 |
bitflags::bitflags! { |
| 795 |
/// send/sendmsg flags (`sqe.ioprio`) |
| 796 |
#[repr(transparent)] |
| 797 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 798 |
pub struct IoringSendFlags: u16 { |
| 799 |
/// `IORING_RECVSEND_POLL_FIRST`. |
| 800 |
/// |
| 801 |
/// See also [`IoringRecvFlags::POLL_FIRST`]. |
| 802 |
const POLL_FIRST = sys::IORING_RECVSEND_POLL_FIRST as _; |
| 803 |
|
| 804 |
/// `IORING_RECVSEND_FIXED_BUF` |
| 805 |
/// |
| 806 |
/// See also [`IoringRecvFlags::FIXED_BUF`]. |
| 807 |
const FIXED_BUF = sys::IORING_RECVSEND_FIXED_BUF as _; |
| 808 |
|
| 809 |
/// `IORING_SEND_ZC_REPORT_USAGE` (since Linux 6.2) |
| 810 |
const ZC_REPORT_USAGE = sys::IORING_SEND_ZC_REPORT_USAGE as _; |
| 811 |
|
| 812 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 813 |
const _ = !0; |
| 814 |
} |
| 815 |
} |
| 816 |
|
| 817 |
bitflags::bitflags! { |
| 818 |
/// recv/recvmsg flags (`sqe.ioprio`) |
| 819 |
#[repr(transparent)] |
| 820 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 821 |
pub struct IoringRecvFlags: u16 { |
| 822 |
/// `IORING_RECVSEND_POLL_FIRST` |
| 823 |
/// |
| 824 |
/// See also [`IoringSendFlags::POLL_FIRST`]. |
| 825 |
const POLL_FIRST = sys::IORING_RECVSEND_POLL_FIRST as _; |
| 826 |
|
| 827 |
/// `IORING_RECV_MULTISHOT` |
| 828 |
const MULTISHOT = sys::IORING_RECV_MULTISHOT as _; |
| 829 |
|
| 830 |
/// `IORING_RECVSEND_FIXED_BUF` |
| 831 |
/// |
| 832 |
/// See also [`IoringSendFlags::FIXED_BUF`]. |
| 833 |
const FIXED_BUF = sys::IORING_RECVSEND_FIXED_BUF as _; |
| 834 |
|
| 835 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 836 |
const _ = !0; |
| 837 |
} |
| 838 |
} |
| 839 |
|
| 840 |
bitflags::bitflags! { |
| 841 |
/// accept flags (`sqe.ioprio`) |
| 842 |
#[repr(transparent)] |
| 843 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 844 |
pub struct IoringAcceptFlags: u16 { |
| 845 |
/// `IORING_ACCEPT_MULTISHOT` |
| 846 |
const MULTISHOT = sys::IORING_ACCEPT_MULTISHOT as _; |
| 847 |
|
| 848 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 849 |
const _ = !0; |
| 850 |
} |
| 851 |
} |
| 852 |
|
| 853 |
bitflags::bitflags! { |
| 854 |
/// recvmsg out flags |
| 855 |
#[repr(transparent)] |
| 856 |
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] |
| 857 |
pub struct RecvmsgOutFlags: u32 { |
| 858 |
/// `MSG_EOR` |
| 859 |
const EOR = net::MSG_EOR; |
| 860 |
|
| 861 |
/// `MSG_TRUNC` |
| 862 |
const TRUNC = net::MSG_TRUNC; |
| 863 |
|
| 864 |
/// `MSG_CTRUNC` |
| 865 |
const CTRUNC = net::MSG_CTRUNC; |
| 866 |
|
| 867 |
/// `MSG_OOB` |
| 868 |
const OOB = net::MSG_OOB; |
| 869 |
|
| 870 |
/// `MSG_ERRQUEUE` |
| 871 |
const ERRQUEUE = net::MSG_ERRQUEUE; |
| 872 |
|
| 873 |
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> |
| 874 |
const _ = !0; |
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
#[allow(missing_docs)] |
| 879 |
pub const IORING_CQE_BUFFER_SHIFT: u32 = sys::IORING_CQE_BUFFER_SHIFT as _; |
| 880 |
#[allow(missing_docs)] |
| 881 |
pub const IORING_FILE_INDEX_ALLOC: i32 = sys::IORING_FILE_INDEX_ALLOC as _; |
| 882 |
|
| 883 |
// Re-export these as `u64`, which is the `offset` type in `rustix::io::mmap`. |
| 884 |
#[allow(missing_docs)] |
| 885 |
pub const IORING_OFF_SQ_RING: u64 = sys::IORING_OFF_SQ_RING as _; |
| 886 |
#[allow(missing_docs)] |
| 887 |
pub const IORING_OFF_CQ_RING: u64 = sys::IORING_OFF_CQ_RING as _; |
| 888 |
#[allow(missing_docs)] |
| 889 |
pub const IORING_OFF_SQES: u64 = sys::IORING_OFF_SQES as _; |
| 890 |
|
| 891 |
/// `IORING_REGISTER_FILES_SKIP` |
| 892 |
#[inline] |
| 893 |
#[doc(alias = "IORING_REGISTER_FILES_SKIP")] |
| 894 |
pub const fn io_uring_register_files_skip() -> BorrowedFd<'static> { |
| 895 |
let files_skip = sys::IORING_REGISTER_FILES_SKIP as RawFd; |
| 896 |
|
| 897 |
// SAFETY: `IORING_REGISTER_FILES_SKIP` is a reserved value that is never |
| 898 |
// dynamically allocated, so it'll remain valid for the duration of |
| 899 |
// `'static`. |
| 900 |
unsafe { BorrowedFd::<'static>::borrow_raw(files_skip) } |
| 901 |
} |
| 902 |
|
| 903 |
/// `IORING_NOTIF_USAGE_ZC_COPIED` (since Linux 6.2) |
| 904 |
pub const IORING_NOTIF_USAGE_ZC_COPIED: i32 = sys::IORING_NOTIF_USAGE_ZC_COPIED as _; |
| 905 |
|
| 906 |
/// A pointer in the io_uring API. |
| 907 |
/// |
| 908 |
/// `io_uring`'s native API represents pointers as `u64` values. In order to |
| 909 |
/// preserve strict-provenance, use a `*mut c_void`. On platforms where |
| 910 |
/// pointers are narrower than 64 bits, this requires additional padding. |
| 911 |
#[repr(C)] |
| 912 |
#[derive(Copy, Clone)] |
| 913 |
pub struct io_uring_ptr { |
| 914 |
#[cfg(all(target_pointer_width = "32", target_endian = "big"))] |
| 915 |
#[doc(hidden)] |
| 916 |
pub __pad32: u32, |
| 917 |
#[cfg(all(target_pointer_width = "16", target_endian = "big"))] |
| 918 |
#[doc(hidden)] |
| 919 |
pub __pad16: u16, |
| 920 |
|
| 921 |
/// The pointer value. |
| 922 |
pub ptr: *mut c_void, |
| 923 |
|
| 924 |
#[cfg(all(target_pointer_width = "16", target_endian = "little"))] |
| 925 |
#[doc(hidden)] |
| 926 |
pub __pad16: u16, |
| 927 |
#[cfg(all(target_pointer_width = "32", target_endian = "little"))] |
| 928 |
#[doc(hidden)] |
| 929 |
pub __pad32: u32, |
| 930 |
} |
| 931 |
|
| 932 |
impl From<*mut c_void> for io_uring_ptr { |
| 933 |
#[inline] |
| 934 |
fn from(ptr: *mut c_void) -> Self { |
| 935 |
Self { |
| 936 |
ptr, |
| 937 |
|
| 938 |
#[cfg(target_pointer_width = "16")] |
| 939 |
__pad16: Default::default(), |
| 940 |
#[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))] |
| 941 |
__pad32: Default::default(), |
| 942 |
} |
| 943 |
} |
| 944 |
} |
| 945 |
|
| 946 |
impl Default for io_uring_ptr { |
| 947 |
#[inline] |
| 948 |
fn default() -> Self { |
| 949 |
Self::from(null_mut()) |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
/// User data in the io_uring API. |
| 954 |
/// |
| 955 |
/// `io_uring`'s native API represents `user_data` fields as `u64` values. In |
| 956 |
/// order to preserve strict-provenance, use a union which allows users to |
| 957 |
/// optionally store pointers. |
| 958 |
#[repr(C)] |
| 959 |
#[derive(Copy, Clone)] |
| 960 |
pub union io_uring_user_data { |
| 961 |
/// An arbitrary `u64`. |
| 962 |
pub u64_: u64, |
| 963 |
|
| 964 |
/// A pointer. |
| 965 |
pub ptr: io_uring_ptr, |
| 966 |
} |
| 967 |
|
| 968 |
impl io_uring_user_data { |
| 969 |
/// Return the `u64` value. |
| 970 |
#[inline] |
| 971 |
pub fn u64_(self) -> u64 { |
| 972 |
// SAFETY: All the fields have the same underlying representation. |
| 973 |
unsafe { self.u64_ } |
| 974 |
} |
| 975 |
|
| 976 |
/// Create a `Self` from a `u64` value. |
| 977 |
#[inline] |
| 978 |
pub fn from_u64(u64_: u64) -> Self { |
| 979 |
Self { u64_ } |
| 980 |
} |
| 981 |
|
| 982 |
/// Return the `ptr` pointer value. |
| 983 |
#[inline] |
| 984 |
pub fn ptr(self) -> *mut c_void { |
| 985 |
// SAFETY: All the fields have the same underlying representation. |
| 986 |
unsafe { self.ptr }.ptr |
| 987 |
} |
| 988 |
|
| 989 |
/// Create a `Self` from a pointer value. |
| 990 |
#[inline] |
| 991 |
pub fn from_ptr(ptr: *mut c_void) -> Self { |
| 992 |
Self { |
| 993 |
ptr: io_uring_ptr::from(ptr), |
| 994 |
} |
| 995 |
} |
| 996 |
} |
| 997 |
|
| 998 |
impl Default for io_uring_user_data { |
| 999 |
#[inline] |
| 1000 |
fn default() -> Self { |
| 1001 |
let mut s = MaybeUninit::<Self>::uninit(); |
| 1002 |
// SAFETY: All of Linux's io_uring structs may be zero-initialized. |
| 1003 |
unsafe { |
| 1004 |
write_bytes(s.as_mut_ptr(), 0, 1); |
| 1005 |
s.assume_init() |
| 1006 |
} |
| 1007 |
} |
| 1008 |
} |
| 1009 |
|
| 1010 |
impl core::fmt::Debug for io_uring_user_data { |
| 1011 |
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
| 1012 |
// SAFETY: Just format as a `u64`, since formatting doesn't preserve |
| 1013 |
// provenance, and we don't have a discriminant. |
| 1014 |
unsafe { self.u64_.fmt(fmt) } |
| 1015 |
} |
| 1016 |
} |
| 1017 |
|
| 1018 |
/// An io_uring Submission Queue Entry. |
| 1019 |
#[allow(missing_docs)] |
| 1020 |
#[repr(C)] |
| 1021 |
#[derive(Copy, Clone, Default)] |
| 1022 |
pub struct io_uring_sqe { |
| 1023 |
pub opcode: IoringOp, |
| 1024 |
pub flags: IoringSqeFlags, |
| 1025 |
pub ioprio: ioprio_union, |
| 1026 |
pub fd: RawFd, |
| 1027 |
pub off_or_addr2: off_or_addr2_union, |
| 1028 |
pub addr_or_splice_off_in: addr_or_splice_off_in_union, |
| 1029 |
pub len: len_union, |
| 1030 |
pub op_flags: op_flags_union, |
| 1031 |
pub user_data: io_uring_user_data, |
| 1032 |
pub buf: buf_union, |
| 1033 |
pub personality: u16, |
| 1034 |
pub splice_fd_in_or_file_index: splice_fd_in_or_file_index_union, |
| 1035 |
pub addr3_or_cmd: addr3_or_cmd_union, |
| 1036 |
} |
| 1037 |
|
| 1038 |
#[allow(missing_docs)] |
| 1039 |
#[repr(C)] |
| 1040 |
#[derive(Copy, Clone)] |
| 1041 |
pub union ioprio_union { |
| 1042 |
pub recv_flags: IoringRecvFlags, |
| 1043 |
pub send_flags: IoringSendFlags, |
| 1044 |
pub accept_flags: IoringAcceptFlags, |
| 1045 |
pub ioprio: u16, |
| 1046 |
} |
| 1047 |
|
| 1048 |
#[allow(missing_docs)] |
| 1049 |
#[repr(C)] |
| 1050 |
#[derive(Copy, Clone)] |
| 1051 |
pub union len_union { |
| 1052 |
pub poll_flags: IoringPollFlags, |
| 1053 |
pub len: u32, |
| 1054 |
} |
| 1055 |
|
| 1056 |
#[allow(missing_docs)] |
| 1057 |
#[repr(C)] |
| 1058 |
#[derive(Copy, Clone)] |
| 1059 |
pub union addr3_or_cmd_union { |
| 1060 |
pub addr3: addr3_struct, |
| 1061 |
pub cmd: [u8; 0], |
| 1062 |
} |
| 1063 |
|
| 1064 |
#[allow(missing_docs)] |
| 1065 |
#[repr(C)] |
| 1066 |
#[derive(Copy, Clone, Default)] |
| 1067 |
pub struct addr3_struct { |
| 1068 |
pub addr3: u64, |
| 1069 |
pub __pad2: [u64; 1], |
| 1070 |
} |
| 1071 |
|
| 1072 |
#[allow(missing_docs)] |
| 1073 |
#[repr(C)] |
| 1074 |
#[derive(Copy, Clone)] |
| 1075 |
pub union off_or_addr2_union { |
| 1076 |
pub off: u64, |
| 1077 |
pub addr2: io_uring_ptr, |
| 1078 |
pub cmd_op: cmd_op_struct, |
| 1079 |
pub user_data: io_uring_user_data, |
| 1080 |
} |
| 1081 |
|
| 1082 |
#[allow(missing_docs)] |
| 1083 |
#[repr(C)] |
| 1084 |
#[derive(Copy, Clone)] |
| 1085 |
pub struct cmd_op_struct { |
| 1086 |
pub cmd_op: u32, |
| 1087 |
pub __pad1: u32, |
| 1088 |
} |
| 1089 |
|
| 1090 |
#[allow(missing_docs)] |
| 1091 |
#[repr(C)] |
| 1092 |
#[derive(Copy, Clone)] |
| 1093 |
pub union addr_or_splice_off_in_union { |
| 1094 |
pub addr: io_uring_ptr, |
| 1095 |
pub splice_off_in: u64, |
| 1096 |
pub msgring_cmd: IoringMsgringCmds, |
| 1097 |
pub user_data: io_uring_user_data, |
| 1098 |
} |
| 1099 |
|
| 1100 |
#[allow(missing_docs)] |
| 1101 |
#[repr(C)] |
| 1102 |
#[derive(Copy, Clone)] |
| 1103 |
pub union op_flags_union { |
| 1104 |
pub rw_flags: crate::io::ReadWriteFlags, |
| 1105 |
pub fsync_flags: IoringFsyncFlags, |
| 1106 |
pub poll_events: u16, |
| 1107 |
pub poll32_events: u32, |
| 1108 |
pub sync_range_flags: u32, |
| 1109 |
/// `msg_flags` is split into `send_flags` and `recv_flags`. |
| 1110 |
#[doc(alias = "msg_flags")] |
| 1111 |
pub send_flags: SendFlags, |
| 1112 |
/// `msg_flags` is split into `send_flags` and `recv_flags`. |
| 1113 |
#[doc(alias = "msg_flags")] |
| 1114 |
pub recv_flags: RecvFlags, |
| 1115 |
pub timeout_flags: IoringTimeoutFlags, |
| 1116 |
pub accept_flags: SocketFlags, |
| 1117 |
pub cancel_flags: IoringAsyncCancelFlags, |
| 1118 |
pub open_flags: OFlags, |
| 1119 |
pub statx_flags: AtFlags, |
| 1120 |
pub fadvise_advice: Advice, |
| 1121 |
pub splice_flags: SpliceFlags, |
| 1122 |
pub rename_flags: RenameFlags, |
| 1123 |
pub unlink_flags: AtFlags, |
| 1124 |
pub hardlink_flags: AtFlags, |
| 1125 |
pub msg_ring_flags: IoringMsgringFlags, |
| 1126 |
} |
| 1127 |
|
| 1128 |
#[allow(missing_docs)] |
| 1129 |
#[repr(C, packed)] |
| 1130 |
#[derive(Copy, Clone)] |
| 1131 |
pub union buf_union { |
| 1132 |
pub buf_index: u16, |
| 1133 |
pub buf_group: u16, |
| 1134 |
} |
| 1135 |
|
| 1136 |
// TODO: Rename this to include `addr_len` when we have a semver bump? |
| 1137 |
#[allow(missing_docs)] |
| 1138 |
#[repr(C)] |
| 1139 |
#[derive(Copy, Clone)] |
| 1140 |
pub union splice_fd_in_or_file_index_union { |
| 1141 |
pub splice_fd_in: i32, |
| 1142 |
pub file_index: u32, |
| 1143 |
pub addr_len: addr_len_struct, |
| 1144 |
} |
| 1145 |
|
| 1146 |
#[allow(missing_docs)] |
| 1147 |
#[repr(C)] |
| 1148 |
#[derive(Copy, Clone)] |
| 1149 |
pub struct addr_len_struct { |
| 1150 |
pub addr_len: u16, |
| 1151 |
pub __pad3: [u16; 1], |
| 1152 |
} |
| 1153 |
|
| 1154 |
#[allow(missing_docs)] |
| 1155 |
#[repr(C)] |
| 1156 |
#[derive(Copy, Clone)] |
| 1157 |
pub struct io_uring_sync_cancel_reg { |
| 1158 |
pub addr: u64, |
| 1159 |
pub fd: i32, |
| 1160 |
pub flags: IoringAsyncCancelFlags, |
| 1161 |
pub timeout: Timespec, |
| 1162 |
pub pad: [u64; 4], |
| 1163 |
} |
| 1164 |
|
| 1165 |
impl Default for io_uring_sync_cancel_reg { |
| 1166 |
#[inline] |
| 1167 |
fn default() -> Self { |
| 1168 |
Self { |
| 1169 |
addr: Default::default(), |
| 1170 |
fd: Default::default(), |
| 1171 |
flags: Default::default(), |
| 1172 |
timeout: Timespec { |
| 1173 |
tv_sec: 0, |
| 1174 |
tv_nsec: 0, |
| 1175 |
}, |
| 1176 |
pad: Default::default(), |
| 1177 |
} |
| 1178 |
} |
| 1179 |
} |
| 1180 |
|
| 1181 |
/// An io_uring Completion Queue Entry. |
| 1182 |
/// |
| 1183 |
/// This does not derive `Copy` or `Clone` because the `big_cqe` field is not |
| 1184 |
/// automatically copyable. |
| 1185 |
#[allow(missing_docs)] |
| 1186 |
#[repr(C)] |
| 1187 |
#[derive(Debug, Default)] |
| 1188 |
pub struct io_uring_cqe { |
| 1189 |
pub user_data: io_uring_user_data, |
| 1190 |
pub res: i32, |
| 1191 |
pub flags: IoringCqeFlags, |
| 1192 |
pub big_cqe: sys::__IncompleteArrayField<u64>, |
| 1193 |
} |
| 1194 |
|
| 1195 |
#[allow(missing_docs)] |
| 1196 |
#[repr(C)] |
| 1197 |
#[derive(Copy, Clone, Default)] |
| 1198 |
pub struct io_uring_restriction { |
| 1199 |
pub opcode: IoringRestrictionOp, |
| 1200 |
pub register_or_sqe_op_or_sqe_flags: register_or_sqe_op_or_sqe_flags_union, |
| 1201 |
pub resv: u8, |
| 1202 |
pub resv2: [u32; 3], |
| 1203 |
} |
| 1204 |
|
| 1205 |
#[allow(missing_docs)] |
| 1206 |
#[repr(C)] |
| 1207 |
#[derive(Copy, Clone)] |
| 1208 |
pub union register_or_sqe_op_or_sqe_flags_union { |
| 1209 |
pub register_op: IoringRegisterOp, |
| 1210 |
pub sqe_op: IoringOp, |
| 1211 |
pub sqe_flags: IoringSqeFlags, |
| 1212 |
} |
| 1213 |
|
| 1214 |
#[allow(missing_docs)] |
| 1215 |
#[repr(C)] |
| 1216 |
#[derive(Debug, Copy, Clone, Default)] |
| 1217 |
pub struct io_uring_params { |
| 1218 |
pub sq_entries: u32, |
| 1219 |
pub cq_entries: u32, |
| 1220 |
pub flags: IoringSetupFlags, |
| 1221 |
pub sq_thread_cpu: u32, |
| 1222 |
pub sq_thread_idle: u32, |
| 1223 |
pub features: IoringFeatureFlags, |
| 1224 |
pub wq_fd: u32, |
| 1225 |
pub resv: [u32; 3], |
| 1226 |
pub sq_off: io_sqring_offsets, |
| 1227 |
pub cq_off: io_cqring_offsets, |
| 1228 |
} |
| 1229 |
|
| 1230 |
#[allow(missing_docs)] |
| 1231 |
#[repr(C)] |
| 1232 |
#[derive(Debug, Copy, Clone, Default)] |
| 1233 |
pub struct io_sqring_offsets { |
| 1234 |
pub head: u32, |
| 1235 |
pub tail: u32, |
| 1236 |
pub ring_mask: u32, |
| 1237 |
pub ring_entries: u32, |
| 1238 |
pub flags: u32, |
| 1239 |
pub dropped: u32, |
| 1240 |
pub array: u32, |
| 1241 |
pub resv1: u32, |
| 1242 |
pub resv2: u64, |
| 1243 |
} |
| 1244 |
|
| 1245 |
#[allow(missing_docs)] |
| 1246 |
#[repr(C)] |
| 1247 |
#[derive(Debug, Copy, Clone, Default)] |
| 1248 |
pub struct io_cqring_offsets { |
| 1249 |
pub head: u32, |
| 1250 |
pub tail: u32, |
| 1251 |
pub ring_mask: u32, |
| 1252 |
pub ring_entries: u32, |
| 1253 |
pub overflow: u32, |
| 1254 |
pub cqes: u32, |
| 1255 |
pub flags: u32, |
| 1256 |
pub resv1: u32, |
| 1257 |
pub resv2: u64, |
| 1258 |
} |
| 1259 |
|
| 1260 |
#[allow(missing_docs)] |
| 1261 |
#[repr(C)] |
| 1262 |
#[derive(Debug, Default)] |
| 1263 |
pub struct io_uring_probe { |
| 1264 |
pub last_op: IoringOp, |
| 1265 |
pub ops_len: u8, |
| 1266 |
pub resv: u16, |
| 1267 |
pub resv2: [u32; 3], |
| 1268 |
pub ops: sys::__IncompleteArrayField<io_uring_probe_op>, |
| 1269 |
} |
| 1270 |
|
| 1271 |
#[allow(missing_docs)] |
| 1272 |
#[repr(C)] |
| 1273 |
#[derive(Debug, Copy, Clone, Default)] |
| 1274 |
pub struct io_uring_probe_op { |
| 1275 |
pub op: IoringOp, |
| 1276 |
pub resv: u8, |
| 1277 |
pub flags: IoringOpFlags, |
| 1278 |
pub resv2: u32, |
| 1279 |
} |
| 1280 |
|
| 1281 |
#[allow(missing_docs)] |
| 1282 |
#[repr(C, align(8))] |
| 1283 |
#[derive(Debug, Copy, Clone, Default)] |
| 1284 |
pub struct io_uring_files_update { |
| 1285 |
pub offset: u32, |
| 1286 |
pub resv: u32, |
| 1287 |
pub fds: u64, |
| 1288 |
} |
| 1289 |
|
| 1290 |
#[allow(missing_docs)] |
| 1291 |
#[repr(C, align(8))] |
| 1292 |
#[derive(Debug, Copy, Clone, Default)] |
| 1293 |
pub struct io_uring_rsrc_register { |
| 1294 |
pub nr: u32, |
| 1295 |
pub flags: IoringRsrcFlags, |
| 1296 |
pub resv2: u64, |
| 1297 |
pub data: u64, |
| 1298 |
pub tags: u64, |
| 1299 |
} |
| 1300 |
|
| 1301 |
#[allow(missing_docs)] |
| 1302 |
#[repr(C, align(8))] |
| 1303 |
#[derive(Debug, Copy, Clone, Default)] |
| 1304 |
pub struct io_uring_rsrc_update { |
| 1305 |
pub offset: u32, |
| 1306 |
pub resv: u32, |
| 1307 |
pub data: u64, |
| 1308 |
} |
| 1309 |
|
| 1310 |
#[allow(missing_docs)] |
| 1311 |
#[repr(C, align(8))] |
| 1312 |
#[derive(Debug, Copy, Clone, Default)] |
| 1313 |
pub struct io_uring_rsrc_update2 { |
| 1314 |
pub offset: u32, |
| 1315 |
pub resv: u32, |
| 1316 |
pub data: u64, |
| 1317 |
pub tags: u64, |
| 1318 |
pub nr: u32, |
| 1319 |
pub resv2: u32, |
| 1320 |
} |
| 1321 |
|
| 1322 |
#[allow(missing_docs)] |
| 1323 |
#[repr(C)] |
| 1324 |
#[derive(Debug, Copy, Clone, Default)] |
| 1325 |
pub struct io_uring_getevents_arg { |
| 1326 |
pub sigmask: u64, |
| 1327 |
pub sigmask_sz: u32, |
| 1328 |
pub pad: u32, |
| 1329 |
pub ts: u64, |
| 1330 |
} |
| 1331 |
|
| 1332 |
#[allow(missing_docs)] |
| 1333 |
#[repr(C)] |
| 1334 |
#[derive(Debug, Default, Copy, Clone)] |
| 1335 |
pub struct io_uring_recvmsg_out { |
| 1336 |
pub namelen: u32, |
| 1337 |
pub controllen: u32, |
| 1338 |
pub payloadlen: u32, |
| 1339 |
pub flags: RecvmsgOutFlags, |
| 1340 |
} |
| 1341 |
|
| 1342 |
#[allow(missing_docs)] |
| 1343 |
#[repr(C)] |
| 1344 |
#[derive(Debug, Copy, Clone)] |
| 1345 |
pub struct iovec { |
| 1346 |
pub iov_base: *mut c_void, |
| 1347 |
pub iov_len: usize, |
| 1348 |
} |
| 1349 |
|
| 1350 |
#[allow(missing_docs)] |
| 1351 |
#[repr(C)] |
| 1352 |
#[derive(Debug, Copy, Clone, Default)] |
| 1353 |
pub struct open_how { |
| 1354 |
/// An [`OFlags`] value represented as a `u64`. |
| 1355 |
pub flags: u64, |
| 1356 |
|
| 1357 |
/// A [`Mode`] value represented as a `u64`. |
| 1358 |
pub mode: u64, |
| 1359 |
|
| 1360 |
pub resolve: ResolveFlags, |
| 1361 |
} |
| 1362 |
|
| 1363 |
#[allow(missing_docs)] |
| 1364 |
#[repr(C)] |
| 1365 |
#[derive(Debug, Copy, Clone, Default)] |
| 1366 |
pub struct io_uring_buf_reg { |
| 1367 |
pub ring_addr: u64, |
| 1368 |
pub ring_entries: u32, |
| 1369 |
pub bgid: u16, |
| 1370 |
pub pad: u16, |
| 1371 |
pub resv: [u64; 3_usize], |
| 1372 |
} |
| 1373 |
|
| 1374 |
#[allow(missing_docs)] |
| 1375 |
#[repr(C)] |
| 1376 |
#[derive(Debug, Copy, Clone, Default)] |
| 1377 |
pub struct io_uring_buf { |
| 1378 |
pub addr: u64, |
| 1379 |
pub len: u32, |
| 1380 |
pub bid: u16, |
| 1381 |
pub resv: u16, |
| 1382 |
} |
| 1383 |
|
| 1384 |
impl Default for ioprio_union { |
| 1385 |
#[inline] |
| 1386 |
fn default() -> Self { |
| 1387 |
default_union!(ioprio_union, ioprio) |
| 1388 |
} |
| 1389 |
} |
| 1390 |
|
| 1391 |
impl Default for len_union { |
| 1392 |
#[inline] |
| 1393 |
fn default() -> Self { |
| 1394 |
default_union!(len_union, len) |
| 1395 |
} |
| 1396 |
} |
| 1397 |
|
| 1398 |
impl Default for off_or_addr2_union { |
| 1399 |
#[inline] |
| 1400 |
fn default() -> Self { |
| 1401 |
default_union!(off_or_addr2_union, off) |
| 1402 |
} |
| 1403 |
} |
| 1404 |
|
| 1405 |
impl Default for addr_or_splice_off_in_union { |
| 1406 |
#[inline] |
| 1407 |
fn default() -> Self { |
| 1408 |
default_union!(addr_or_splice_off_in_union, splice_off_in) |
| 1409 |
} |
| 1410 |
} |
| 1411 |
|
| 1412 |
impl Default for addr3_or_cmd_union { |
| 1413 |
#[inline] |
| 1414 |
fn default() -> Self { |
| 1415 |
default_union!(addr3_or_cmd_union, addr3) |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
impl Default for op_flags_union { |
| 1420 |
#[inline] |
| 1421 |
fn default() -> Self { |
| 1422 |
default_union!(op_flags_union, sync_range_flags) |
| 1423 |
} |
| 1424 |
} |
| 1425 |
|
| 1426 |
impl Default for buf_union { |
| 1427 |
#[inline] |
| 1428 |
fn default() -> Self { |
| 1429 |
default_union!(buf_union, buf_index) |
| 1430 |
} |
| 1431 |
} |
| 1432 |
|
| 1433 |
impl Default for splice_fd_in_or_file_index_union { |
| 1434 |
#[inline] |
| 1435 |
fn default() -> Self { |
| 1436 |
default_union!(splice_fd_in_or_file_index_union, splice_fd_in) |
| 1437 |
} |
| 1438 |
} |
| 1439 |
|
| 1440 |
impl Default for register_or_sqe_op_or_sqe_flags_union { |
| 1441 |
#[inline] |
| 1442 |
fn default() -> Self { |
| 1443 |
default_union!(register_or_sqe_op_or_sqe_flags_union, sqe_flags) |
| 1444 |
} |
| 1445 |
} |
| 1446 |
|
| 1447 |
/// Check that our custom structs and unions have the same layout as the |
| 1448 |
/// kernel's versions. |
| 1449 |
#[test] |
| 1450 |
fn io_uring_layouts() { |
| 1451 |
use sys as c; |
| 1452 |
|
| 1453 |
assert_eq_size!(io_uring_ptr, u64); |
| 1454 |
|
| 1455 |
check_renamed_type!(off_or_addr2_union, io_uring_sqe__bindgen_ty_1); |
| 1456 |
check_renamed_type!(addr_or_splice_off_in_union, io_uring_sqe__bindgen_ty_2); |
| 1457 |
check_renamed_type!(addr3_or_cmd_union, io_uring_sqe__bindgen_ty_6); |
| 1458 |
check_renamed_type!(op_flags_union, io_uring_sqe__bindgen_ty_3); |
| 1459 |
check_renamed_type!(buf_union, io_uring_sqe__bindgen_ty_4); |
| 1460 |
check_renamed_type!(splice_fd_in_or_file_index_union, io_uring_sqe__bindgen_ty_5); |
| 1461 |
check_renamed_type!(addr_len_struct, io_uring_sqe__bindgen_ty_5__bindgen_ty_1); |
| 1462 |
check_renamed_type!( |
| 1463 |
register_or_sqe_op_or_sqe_flags_union, |
| 1464 |
io_uring_restriction__bindgen_ty_1 |
| 1465 |
); |
| 1466 |
|
| 1467 |
check_renamed_type!(addr3_struct, io_uring_sqe__bindgen_ty_6__bindgen_ty_1); |
| 1468 |
check_renamed_type!(cmd_op_struct, io_uring_sqe__bindgen_ty_1__bindgen_ty_1); |
| 1469 |
|
| 1470 |
check_type!(io_uring_sqe); |
| 1471 |
check_struct_field!(io_uring_sqe, opcode); |
| 1472 |
check_struct_field!(io_uring_sqe, flags); |
| 1473 |
check_struct_field!(io_uring_sqe, ioprio); |
| 1474 |
check_struct_field!(io_uring_sqe, fd); |
| 1475 |
check_struct_renamed_field!(io_uring_sqe, off_or_addr2, __bindgen_anon_1); |
| 1476 |
check_struct_renamed_field!(io_uring_sqe, addr_or_splice_off_in, __bindgen_anon_2); |
| 1477 |
check_struct_field!(io_uring_sqe, len); |
| 1478 |
check_struct_renamed_field!(io_uring_sqe, op_flags, __bindgen_anon_3); |
| 1479 |
check_struct_field!(io_uring_sqe, user_data); |
| 1480 |
check_struct_renamed_field!(io_uring_sqe, buf, __bindgen_anon_4); |
| 1481 |
check_struct_field!(io_uring_sqe, personality); |
| 1482 |
check_struct_renamed_field!(io_uring_sqe, splice_fd_in_or_file_index, __bindgen_anon_5); |
| 1483 |
check_struct_renamed_field!(io_uring_sqe, addr3_or_cmd, __bindgen_anon_6); |
| 1484 |
|
| 1485 |
check_type!(io_uring_restriction); |
| 1486 |
check_struct_field!(io_uring_restriction, opcode); |
| 1487 |
check_struct_renamed_field!( |
| 1488 |
io_uring_restriction, |
| 1489 |
register_or_sqe_op_or_sqe_flags, |
| 1490 |
__bindgen_anon_1 |
| 1491 |
); |
| 1492 |
check_struct_field!(io_uring_restriction, resv); |
| 1493 |
check_struct_field!(io_uring_restriction, resv2); |
| 1494 |
|
| 1495 |
check_struct!(io_uring_cqe, user_data, res, flags, big_cqe); |
| 1496 |
check_struct!( |
| 1497 |
io_uring_params, |
| 1498 |
sq_entries, |
| 1499 |
cq_entries, |
| 1500 |
flags, |
| 1501 |
sq_thread_cpu, |
| 1502 |
sq_thread_idle, |
| 1503 |
features, |
| 1504 |
wq_fd, |
| 1505 |
resv, |
| 1506 |
sq_off, |
| 1507 |
cq_off |
| 1508 |
); |
| 1509 |
check_struct!( |
| 1510 |
io_sqring_offsets, |
| 1511 |
head, |
| 1512 |
tail, |
| 1513 |
ring_mask, |
| 1514 |
ring_entries, |
| 1515 |
flags, |
| 1516 |
dropped, |
| 1517 |
array, |
| 1518 |
resv1, |
| 1519 |
resv2 |
| 1520 |
); |
| 1521 |
check_struct!( |
| 1522 |
io_cqring_offsets, |
| 1523 |
head, |
| 1524 |
tail, |
| 1525 |
ring_mask, |
| 1526 |
ring_entries, |
| 1527 |
overflow, |
| 1528 |
cqes, |
| 1529 |
flags, |
| 1530 |
resv1, |
| 1531 |
resv2 |
| 1532 |
); |
| 1533 |
check_struct!(io_uring_recvmsg_out, namelen, controllen, payloadlen, flags); |
| 1534 |
check_struct!(io_uring_probe, last_op, ops_len, resv, resv2, ops); |
| 1535 |
check_struct!(io_uring_probe_op, op, resv, flags, resv2); |
| 1536 |
check_struct!(io_uring_files_update, offset, resv, fds); |
| 1537 |
check_struct!(io_uring_rsrc_register, nr, flags, resv2, data, tags); |
| 1538 |
check_struct!(io_uring_rsrc_update, offset, resv, data); |
| 1539 |
check_struct!(io_uring_rsrc_update2, offset, resv, data, tags, nr, resv2); |
| 1540 |
check_struct!(io_uring_getevents_arg, sigmask, sigmask_sz, pad, ts); |
| 1541 |
check_struct!(iovec, iov_base, iov_len); |
| 1542 |
check_struct!(open_how, flags, mode, resolve); |
| 1543 |
check_struct!(io_uring_buf_reg, ring_addr, ring_entries, bgid, pad, resv); |
| 1544 |
check_struct!(io_uring_buf, addr, len, bid, resv); |
| 1545 |
check_struct!(io_uring_sync_cancel_reg, addr, fd, flags, timeout, pad); |
| 1546 |
} |