diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f8ce7f..80b6555 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: matrix: toolchain: - nightly - - "1.48" + - "1.63" target: - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl @@ -93,7 +93,7 @@ jobs: - name: "rustfmt --check" run: | - if ! rustfmt --check --edition 2018 $(find . -name '*.rs' -print); then - printf "Please run \`rustfmt --edition 2018 \$(find . -name '*.rs' -print)\` to fix rustfmt errors.\n" >&2 + if ! rustfmt --check --edition 2021 $(find . -name '*.rs' -print); then + printf "Please run \`rustfmt --edition 2021 \$(find . -name '*.rs' -print)\` to fix rustfmt errors.\n" >&2 exit 1 fi diff --git a/Cargo.lock b/Cargo.lock index 5e4b7b6..2d010dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "anes" version = "0.1.6" @@ -20,7 +29,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", "winapi", ] @@ -31,29 +40,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bindgen" -version = "0.65.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" -dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn", - "which", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -62,9 +48,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bumpalo" @@ -87,15 +73,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "0.1.10" @@ -135,17 +112,6 @@ dependencies = [ "half", ] -[[package]] -name = "clang-sys" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "3.2.25" @@ -203,16 +169,6 @@ dependencies = [ "itertools", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -254,36 +210,19 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] name = "fastrand" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" - -[[package]] -name = "glob" -version = "0.3.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "half" @@ -306,12 +245,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - [[package]] name = "iai" version = "0.1.1" @@ -328,27 +261,14 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "io-uring" -version = "0.6.2" -dependencies = [ - "anyhow", - "bindgen", - "bitflags 1.3.2", - "libc", - "sc", - "slab", - "socket2", -] - [[package]] name = "io-uring-bench" version = "0.1.0" dependencies = [ "criterion", "iai", - "io-uring", "iou", + "rustix-uring", "tempfile", "uring-sys", ] @@ -358,9 +278,10 @@ name = "io-uring-test" version = "0.1.0" dependencies = [ "anyhow", - "io-uring", "libc", "once_cell", + "rustix", + "rustix-uring", "socket2", "tempfile", ] @@ -388,15 +309,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -407,33 +328,17 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" -version = "0.2.148" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" - -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if 1.0.0", - "winapi", -] +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "log" @@ -443,9 +348,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memoffset" @@ -456,12 +361,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "nix" version = "0.18.0" @@ -474,40 +373,20 @@ dependencies = [ "libc", ] -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.2", - "libc", -] - [[package]] name = "once_cell" -version = "1.17.2" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -517,15 +396,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "os_str_bytes" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" - -[[package]] -name = "peeking_take_while" -version = "0.1.2" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "plotters" @@ -555,21 +428,11 @@ dependencies = [ "plotters-backend", ] -[[package]] -name = "prettyplease" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" -dependencies = [ - "proc-macro2", - "syn", -] - [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -585,9 +448,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -595,64 +458,82 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.8.4" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", "regex-syntax", ] [[package]] -name = "regex-syntax" -version = "0.7.5" +name = "regex-automata" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] [[package]] -name = "rustc-hash" -version = "1.1.0" +name = "regex-syntax" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustix" -version = "0.38.9" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bfe0f2582b4931a45d1fa608f8a8722e8b3c7ac54dd6d5f3b3212791fedef49" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix-uring" +version = "0.2.0" +dependencies = [ + "anyhow", + "bitflags 2.4.1", + "libc", + "rustix", + "slab", + "socket2", ] [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "same-file" @@ -663,12 +544,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "sc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "010e18bd3bfd1d45a7e666b236c78720df0d9a7698ebaa9c1c559961eb60a38b" - [[package]] name = "scopeguard" version = "1.2.0" @@ -677,18 +552,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -697,21 +572,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", "serde", ] -[[package]] -name = "shlex" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" - [[package]] name = "slab" version = "0.4.9" @@ -723,19 +592,19 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "syn" -version = "2.0.36" +version = "2.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e02e55d62894af2a08aca894c6577281f76769ba47c94d5756bec8ac6e7373" +checksum = "13fa70a4ee923979ffb522cacce59d34421ebdea5625e1073c4326ef9d2dd42e" dependencies = [ "proc-macro2", "quote", @@ -744,15 +613,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if 1.0.0", "fastrand", "redox_syscall", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -799,9 +668,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -809,9 +678,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", @@ -824,9 +693,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -834,9 +703,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", @@ -847,31 +716,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "which" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" -dependencies = [ - "either", - "libc", - "once_cell", -] - [[package]] name = "winapi" version = "0.3.9" @@ -890,9 +748,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -909,7 +767,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -918,13 +785,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -933,38 +815,80 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/Cargo.toml b/Cargo.toml index bbca825..08d00aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,37 +1,32 @@ [package] -name = "io-uring" -version = "0.6.2" -authors = ["quininer "] -edition = "2018" +name = "rustix-uring" +version = "0.2.0" +authors = ["Jordan Isaacs "] +edition = "2021" license = "MIT/Apache-2.0" -repository = "https://github.com/tokio-rs/io-uring" -homepage = "https://github.com/tokio-rs/io-uring" -documentation = "https://docs.rs/io-uring" +repository = "https://github.com/jordanisaacs/rustix-uring" +homepage = "https://github.com/jordanisaacs/rustix-uring" +documentation = "https://docs.rs/rustix-uring" description = "The low-level `io_uring` userspace interface for Rust" categories = [ "asynchronous", "network-programming", "filesystem" ] +rust-version = "1.63" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -exclude = [] +exclude = ["/flake.*", ".envrc"] members = [ "io-uring-test", "io-uring-bench" ] [features] -overwrite = [ "bindgen" ] -direct-syscall = [ "sc" ] -io_safety = [] +default = ["std"] +std = ["rustix/std", "bitflags/std"] [dependencies] -# Since we need to work on rustc 1.48, we cannot use 2021 edition. -bitflags = "1" - -libc = { version = "0.2.98", default-features = false } -sc = { version = "0.2", optional = true } - -[build-dependencies] -bindgen = { version = "0.65", optional = true } +bitflags = { version = "2.4.0", default-features = false } +rustix = { version = "0.38.18", default-features = false, features = ["io_uring", "mm"] } [dev-dependencies] +libc = "0.2.98" anyhow = "1" socket2 = "0.5" slab = "0.4" diff --git a/README.md b/README.md index bfff82e..89cc3d5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,18 @@ -# Linux IO Uring -[![github actions](https://github.com/tokio-rs/io-uring/workflows/ci/badge.svg)](https://github.com/tokio-rs/io-uring/actions) +# A Linux `io_uring` API, using rustix +[![github actions](https://github.com/jordanisaacs/rustix-uring/workflows/ci/badge.svg)](https://github.com/jordanisaacs/rustix-uring/actions) [![crates](https://img.shields.io/crates/v/io-uring.svg)](https://crates.io/crates/io-uring) -[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/tokio-rs/io-uring/blob/master/LICENSE-MIT) -[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/tokio-rs/io-uring/blob/master/LICENSE-APACHE) +[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/jordanisaacs/rustix-uring/blob/master/LICENSE-MIT) +[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/jordanisaacs/rustix-uring/blob/master/LICENSE-APACHE) [![docs.rs](https://docs.rs/io-uring/badge.svg)](https://docs.rs/io-uring/) -The low-level [`io_uring`](https://kernel.dk/io_uring.pdf) userspace interface for Rust. +This is a Linux [`io_uring`](https://kernel.dk/io_uring.pdf) userspace +interface for Rust. It is higher-level than the userspace boundary API, but +lower-level than an async runtime. + +This library derived from the +[`io_uring` crate](https://github.com/tokio-rs/io-uring), and is modified to +use [`rustix`](https://github.com/bytecodealliance/rustix) to perform the +system calls. ## Usage @@ -13,14 +20,14 @@ To use `io-uring` crate, first add this to your `Cargo.toml`: ```toml [dependencies] -io-uring = "0.6" +rustix-uring = "0.1" ``` Next we can start using `io-uring` crate. The following is quick introduction using `Read` for file. ```rust -use io_uring::{opcode, types, IoUring}; +use rustix_uring::{opcode, types, IoUring}; use std::os::unix::io::AsRawFd; use std::{fs, io}; @@ -60,7 +67,7 @@ If you use a kernel lower than 5.6, this example will fail. You can run the test and benchmark of the library with the following commands. -``` +```bash $ cargo run --package io-uring-test $ cargo bench --package io-uring-bench ``` diff --git a/build.rs b/build.rs deleted file mode 100644 index c003325..0000000 --- a/build.rs +++ /dev/null @@ -1,47 +0,0 @@ -#[cfg(not(feature = "bindgen"))] -fn main() {} - -#[cfg(feature = "bindgen")] -fn main() { - use std::env; - use std::path::PathBuf; - - const INCLUDE: &str = r#" -#include -#include -#include -#include -#include -#include - "#; - - #[cfg(not(feature = "overwrite"))] - let outdir = PathBuf::from(env::var("OUT_DIR").unwrap()); - - #[cfg(feature = "overwrite")] - let outdir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("src/sys"); - - let mut builder = bindgen::Builder::default(); - - if let Some(path) = env::var("BUILD_IO_URING_INCLUDE_FILE") - .ok() - .filter(|path| !path.is_empty()) - { - builder = builder.header(path); - } else { - builder = builder.header_contents("include-file.h", INCLUDE); - } - - builder - .ctypes_prefix("libc") - .prepend_enum_name(false) - .derive_default(true) - .generate_comments(true) - .use_core() - .allowlist_type("io_uring_.*|io_.qring_.*|__kernel_timespec|open_how") - .allowlist_var("__NR_io_uring.*|IOSQE_.*|IORING_.*|IO_URING_.*|SPLICE_F_FD_IN_FIXED") - .generate() - .unwrap() - .write_to_file(outdir.join("sys.rs")) - .unwrap(); -} diff --git a/examples/readme.rs b/examples/readme.rs index 56db6a4..2231a4b 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -1,4 +1,4 @@ -use io_uring::{opcode, types, IoUring}; +use rustix_uring::{opcode, types, IoUring}; use std::os::unix::io::AsRawFd; use std::{fs, io}; diff --git a/examples/tcp_echo.rs b/examples/tcp_echo.rs index 6c6cf53..f6cdb03 100644 --- a/examples/tcp_echo.rs +++ b/examples/tcp_echo.rs @@ -3,7 +3,7 @@ use std::net::TcpListener; use std::os::unix::io::{AsRawFd, RawFd}; use std::{io, ptr}; -use io_uring::{opcode, squeue, types, IoUring, SubmissionQueue}; +use rustix_uring::{opcode, squeue, types, Errno, IoUring, SubmissionQueue}; use slab::Slab; #[derive(Clone, Debug)] @@ -73,7 +73,7 @@ fn main() -> anyhow::Result<()> { loop { match submitter.submit_and_wait(1) { Ok(_) => (), - Err(ref err) if err.raw_os_error() == Some(libc::EBUSY) => (), + Err(Errno::BUSY) => (), Err(err) => return Err(err.into()), } cq.sync(); @@ -83,7 +83,7 @@ fn main() -> anyhow::Result<()> { if sq.is_full() { match submitter.submit() { Ok(_) => (), - Err(ref err) if err.raw_os_error() == Some(libc::EBUSY) => break, + Err(Errno::BUSY) => break, Err(err) => return Err(err.into()), } } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1d1e914 --- /dev/null +++ b/flake.lock @@ -0,0 +1,1113 @@ +{ + "nodes": { + "bufdelete-nvim": { + "flake": false, + "locked": { + "lastModified": 1649744299, + "narHash": "sha256-0Igk8iPt4UQQTJRBPzTASzNOqY4zlaMiE1PQiBc/KGc=", + "owner": "famiu", + "repo": "bufdelete.nvim", + "rev": "96454aedf95f52393a28cfcfc76482895de014ee", + "type": "github" + }, + "original": { + "owner": "famiu", + "repo": "bufdelete.nvim", + "type": "github" + } + }, + "catppuccin": { + "flake": false, + "locked": { + "lastModified": 1670687538, + "narHash": "sha256-BRQLNMYbOINJXQkKFz2SpXQoaynzcauWSwNfTChaLdc=", + "owner": "catppuccin", + "repo": "nvim", + "rev": "1d22da687d36c37133b13f2b41658c1c989e77e0", + "type": "github" + }, + "original": { + "owner": "catppuccin", + "repo": "nvim", + "type": "github" + } + }, + "cmp-buffer": { + "flake": false, + "locked": { + "lastModified": 1645413199, + "narHash": "sha256-itDEtoRvZn1mtLhT9WtqKVXoMRe5Qw0/QUf+TFzGNVk=", + "owner": "hrsh7th", + "repo": "cmp-buffer", + "rev": "d66c4c2d376e5be99db68d2362cd94d250987525", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "cmp-buffer", + "type": "github" + } + }, + "cmp-nvim-lsp": { + "flake": false, + "locked": { + "lastModified": 1665863036, + "narHash": "sha256-4pppdlVJdn75/faaP3N+o7HgEHxyR1nvkHncnFXGDFA=", + "owner": "hrsh7th", + "repo": "cmp-nvim-lsp", + "rev": "3cf38d9c957e95c397b66f91967758b31be4abe6", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "cmp-nvim-lsp", + "type": "github" + } + }, + "cmp-path": { + "flake": false, + "locked": { + "lastModified": 1643823794, + "narHash": "sha256-xYzTpqVKpBBnajqqRRzAXlHAC13VGK1D9mFr3bntepY=", + "owner": "hrsh7th", + "repo": "cmp-path", + "rev": "466b6b8270f7ba89abd59f402c73f63c7331ff6e", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "cmp-path", + "type": "github" + } + }, + "cmp-treesitter": { + "flake": false, + "locked": { + "lastModified": 1650880862, + "narHash": "sha256-ZQ2VSrXcUEcy+1lbdvK/pnz3Ppp1lDr38g/z7OvhH8o=", + "owner": "ray-x", + "repo": "cmp-treesitter", + "rev": "c5187c31abd081ecef8b41e5eb476b7340442310", + "type": "github" + }, + "original": { + "owner": "ray-x", + "repo": "cmp-treesitter", + "type": "github" + } + }, + "cmp-vsnip": { + "flake": false, + "locked": { + "lastModified": 1636543683, + "narHash": "sha256-7K3shsiGK7ISFXj9D9MPK7yRqIxeCrbj1IsggToWHO4=", + "owner": "hrsh7th", + "repo": "cmp-vsnip", + "rev": "0abfa1860f5e095a07c477da940cfcb0d273b700", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "cmp-vsnip", + "type": "github" + } + }, + "crates-nvim": { + "flake": false, + "locked": { + "lastModified": 1668709750, + "narHash": "sha256-MdmZrZu877P0l4yeJNI6muiYmwVlsvFHJCEBrrhR1Zc=", + "owner": "Saecki", + "repo": "crates.nvim", + "rev": "e11e27864428a68b25e43b833e9081e350a38d96", + "type": "github" + }, + "original": { + "owner": "Saecki", + "repo": "crates.nvim", + "type": "github" + } + }, + "dirt-samples-src": { + "flake": false, + "locked": { + "lastModified": 1588278411, + "narHash": "sha256-h8vQxRym6QzNLOTZU7A43VCHuG0H77l+BFwXnC0L1CE=", + "owner": "tidalcycles", + "repo": "dirt-samples", + "rev": "66d432418c9a7d82cf049d9246adfa62f46df2a6", + "type": "github" + }, + "original": { + "owner": "tidalcycles", + "ref": "master", + "repo": "dirt-samples", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitsigns-nvim": { + "flake": false, + "locked": { + "lastModified": 1666700386, + "narHash": "sha256-pSYXCENFw/z7xppenPehniX8+INkrl+l1LgKKGlfrjQ=", + "owner": "lewis6991", + "repo": "gitsigns.nvim", + "rev": "851cd32caaea84f303c4fdf51d72dfa5fcd795bb", + "type": "github" + }, + "original": { + "owner": "lewis6991", + "repo": "gitsigns.nvim", + "type": "github" + } + }, + "glow-nvim": { + "flake": false, + "locked": { + "lastModified": 1649861698, + "narHash": "sha256-c2HrVLCyekw9b8FxxVMUkBkUitGDX1AyslmM1kZQeCQ=", + "owner": "ellisonleao", + "repo": "glow.nvim", + "rev": "0c76518e440f2ea4dbadd87beec8eea4ce030f17", + "type": "github" + }, + "original": { + "owner": "ellisonleao", + "repo": "glow.nvim", + "type": "github" + } + }, + "indent-blankline": { + "flake": false, + "locked": { + "lastModified": 1649991995, + "narHash": "sha256-pMVby6w7UTR2f1Nxp0ZPlV+KrdXNJ+jEQeQe30Pfs3M=", + "owner": "lukas-reineke", + "repo": "indent-blankline.nvim", + "rev": "045d9582094b27f5ae04d8b635c6da8e97e53f1d", + "type": "github" + }, + "original": { + "owner": "lukas-reineke", + "repo": "indent-blankline.nvim", + "type": "github" + } + }, + "kommentary": { + "flake": false, + "locked": { + "lastModified": 1644888740, + "narHash": "sha256-6YNKYMxaKi02TLa+ebt97XGREnmTjdJAA3bSHFC4yX0=", + "owner": "b3nj5m1n", + "repo": "kommentary", + "rev": "12ecde4ed3ecb39964000a5fd034ae4c1d307388", + "type": "github" + }, + "original": { + "owner": "b3nj5m1n", + "repo": "kommentary", + "type": "github" + } + }, + "lsp-signature": { + "flake": false, + "locked": { + "lastModified": 1651382786, + "narHash": "sha256-owtDWZXZZH6z0m5oHfm/QUjRoWKH4LY6UUOZq8JPckI=", + "owner": "ray-x", + "repo": "lsp_signature.nvim", + "rev": "6d160406f948a810c40304224a1255c8bba5a415", + "type": "github" + }, + "original": { + "owner": "ray-x", + "repo": "lsp_signature.nvim", + "type": "github" + } + }, + "lspkind": { + "flake": false, + "locked": { + "lastModified": 1650298271, + "narHash": "sha256-0103K5lnzWCyuT/qwiBUo5PJ7lUX7fo+zNeEnQClI7A=", + "owner": "onsails", + "repo": "lspkind-nvim", + "rev": "57e5b5dfbe991151b07d272a06e365a77cc3d0e7", + "type": "github" + }, + "original": { + "owner": "onsails", + "repo": "lspkind-nvim", + "type": "github" + } + }, + "lspsaga": { + "flake": false, + "locked": { + "lastModified": 1647219889, + "narHash": "sha256-utb2Rp6RdYWZzVt4W7B7RHOk4Xq1Lli4RcHxZLa8dHc=", + "owner": "tami5", + "repo": "lspsaga.nvim", + "rev": "5309d75bd90ce5b1708331df3af1e971fa83a2b9", + "type": "github" + }, + "original": { + "owner": "tami5", + "repo": "lspsaga.nvim", + "type": "github" + } + }, + "lualine": { + "flake": false, + "locked": { + "lastModified": 1651457787, + "narHash": "sha256-TaRC7Pj9g0nD+kk7VrySulR20GolXtR/roUnA3FM144=", + "owner": "hoob3rt", + "repo": "lualine.nvim", + "rev": "45d07fc026400c211337a7ce1cb90e7b7a397e31", + "type": "github" + }, + "original": { + "owner": "hoob3rt", + "repo": "lualine.nvim", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "neovim-flake", + "rnix-lsp", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1655042882, + "narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=", + "owner": "nix-community", + "repo": "naersk", + "rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "neovim-flake": { + "inputs": { + "bufdelete-nvim": "bufdelete-nvim", + "catppuccin": "catppuccin", + "cmp-buffer": "cmp-buffer", + "cmp-nvim-lsp": "cmp-nvim-lsp", + "cmp-path": "cmp-path", + "cmp-treesitter": "cmp-treesitter", + "cmp-vsnip": "cmp-vsnip", + "crates-nvim": "crates-nvim", + "flake-utils": "flake-utils", + "gitsigns-nvim": "gitsigns-nvim", + "glow-nvim": "glow-nvim", + "indent-blankline": "indent-blankline", + "kommentary": "kommentary", + "lsp-signature": "lsp-signature", + "lspkind": "lspkind", + "lspsaga": "lspsaga", + "lualine": "lualine", + "nil": "nil", + "nixpkgs": "nixpkgs", + "nmd": "nmd", + "null-ls": "null-ls", + "nvim-autopairs": "nvim-autopairs", + "nvim-bufferline-lua": "nvim-bufferline-lua", + "nvim-cmp": "nvim-cmp", + "nvim-code-action-menu": "nvim-code-action-menu", + "nvim-compe": "nvim-compe", + "nvim-cursorline": "nvim-cursorline", + "nvim-lightbulb": "nvim-lightbulb", + "nvim-lspconfig": "nvim-lspconfig", + "nvim-neoclip": "nvim-neoclip", + "nvim-tree-lua": "nvim-tree-lua", + "nvim-treesitter-context": "nvim-treesitter-context", + "nvim-ts-autotag": "nvim-ts-autotag", + "nvim-web-devicons": "nvim-web-devicons", + "onedark": "onedark", + "plenary-nvim": "plenary-nvim", + "registers": "registers", + "rnix-lsp": "rnix-lsp", + "rust-tools": "rust-tools", + "sqls-nvim": "sqls-nvim", + "telescope": "telescope", + "tidalcycles": "tidalcycles", + "todo-comments": "todo-comments", + "tokyonight": "tokyonight", + "trouble": "trouble", + "vim-vsnip": "vim-vsnip", + "which-key": "which-key" + }, + "locked": { + "lastModified": 1673484809, + "narHash": "sha256-itrt//HSoEr+YM0TELIAr6VW3FPHjPmQ2YSc+VTWdkk=", + "owner": "jordanisaacs", + "repo": "neovim-flake", + "rev": "08b0492326b661671d3471a173a38d8345a9ea65", + "type": "github" + }, + "original": { + "owner": "jordanisaacs", + "repo": "neovim-flake", + "type": "github" + } + }, + "nil": { + "inputs": { + "flake-utils": [ + "neovim-flake", + "flake-utils" + ], + "nixpkgs": [ + "neovim-flake", + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1669568240, + "narHash": "sha256-xarHQnV7XCvioDxoAhOI+KsDzPNeWZ3F1OCPJVWS5S4=", + "owner": "oxalica", + "repo": "nil", + "rev": "8f8a5d2cffb1a92b1b4b5001239ca9138675c3f4", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "nil", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1669809720, + "narHash": "sha256-RMT77f6CPOYtLLQ2esj+EJ1BPVWxf4RDidjrSvA5OhI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "227de2b3bbec142f912c09d5e8a1b4e778aa54fb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1656753965, + "narHash": "sha256-BCrB3l0qpJokOnIVc3g2lHiGhnjUi0MoXiw6t1o8H1E=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0ea7a8f1b939d74e5df8af9a8f7342097cdf69eb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1655400192, + "narHash": "sha256-49OBVVRgb9H/PSmNT9W61+NRdDbuSJVuDDflwXlaUKU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3d7435c638baffaa826b85459df0fff47f12317d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1673497281, + "narHash": "sha256-a9AFfSq6sC/oLqVJr5BqDeO6CZ6exba24hwZh872YJQ=", + "owner": "jordanisaacs", + "repo": "nixpkgs", + "rev": "0206a083136cbb1f319fc0c1b6517d2916b31a5a", + "type": "github" + }, + "original": { + "owner": "jordanisaacs", + "ref": "aoc-cli-init", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nmd": { + "flake": false, + "locked": { + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", + "owner": "rycee", + "repo": "nmd", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmd", + "type": "gitlab" + } + }, + "null-ls": { + "flake": false, + "locked": { + "lastModified": 1669991088, + "narHash": "sha256-DZgonVEzkgayvLY9jkEH1O/Xny6LQktyi8rTNbQlkMk=", + "owner": "jose-elias-alvarez", + "repo": "null-ls.nvim", + "rev": "a67897283fdb0051ad5c72e840e1845e195b979b", + "type": "github" + }, + "original": { + "owner": "jose-elias-alvarez", + "repo": "null-ls.nvim", + "type": "github" + } + }, + "nvim-autopairs": { + "flake": false, + "locked": { + "lastModified": 1651184422, + "narHash": "sha256-voiBJw752//W5oAGQ3wFl4XOUE5PGc/ddchXpWUfgFE=", + "owner": "windwp", + "repo": "nvim-autopairs", + "rev": "63779ea99ed43ab22660ac6ae5b506a40bf41aeb", + "type": "github" + }, + "original": { + "owner": "windwp", + "repo": "nvim-autopairs", + "type": "github" + } + }, + "nvim-bufferline-lua": { + "flake": false, + "locked": { + "lastModified": 1666171880, + "narHash": "sha256-hueIGT7KOhca0kP0M1nUYzBrzMz+DpuZSOt5iyuEa40=", + "owner": "akinsho", + "repo": "nvim-bufferline.lua", + "rev": "e70be6232f632d16d2412b1faf85554285036278", + "type": "github" + }, + "original": { + "owner": "akinsho", + "ref": "v3.0.1", + "repo": "nvim-bufferline.lua", + "type": "github" + } + }, + "nvim-cmp": { + "flake": false, + "locked": { + "lastModified": 1666412792, + "narHash": "sha256-ErdM+ETpkgBtAvA/RedqN+DXvunQ4OYl58HpfZQkz/s=", + "owner": "hrsh7th", + "repo": "nvim-cmp", + "rev": "cdb77665bbf23bd2717d424ddf4bf98057c30bb3", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "nvim-cmp", + "type": "github" + } + }, + "nvim-code-action-menu": { + "flake": false, + "locked": { + "lastModified": 1647509555, + "narHash": "sha256-fD9luuZe5mVkJTTtngH0jnwtqljhSZp0OFobBa4uqZI=", + "owner": "weilbith", + "repo": "nvim-code-action-menu", + "rev": "a864a79c8e024d4f5d95915210188c9c3430b160", + "type": "github" + }, + "original": { + "owner": "weilbith", + "repo": "nvim-code-action-menu", + "type": "github" + } + }, + "nvim-compe": { + "flake": false, + "locked": { + "lastModified": 1633188506, + "narHash": "sha256-Y2oqvsuAKM3qjmmtJVD9z34682eCRF25kPL+rxhhg7I=", + "owner": "hrsh7th", + "repo": "nvim-compe", + "rev": "d186d739c54823e0b010feb205c6f97792322c08", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "nvim-compe", + "type": "github" + } + }, + "nvim-cursorline": { + "flake": false, + "locked": { + "lastModified": 1650034925, + "narHash": "sha256-Uhw65p1KBjs8KsVOmTzuiu3XKclxBob8AVdWEt30C/8=", + "owner": "yamatsum", + "repo": "nvim-cursorline", + "rev": "804f0023692653b2b2368462d67d2a87056947f9", + "type": "github" + }, + "original": { + "owner": "yamatsum", + "repo": "nvim-cursorline", + "type": "github" + } + }, + "nvim-lightbulb": { + "flake": false, + "locked": { + "lastModified": 1645713830, + "narHash": "sha256-LxGA2LX9CASodJnZYXGZfGPOeW38MW7z54gYQSDmhRE=", + "owner": "kosayoda", + "repo": "nvim-lightbulb", + "rev": "29ca81408119ba809d1f922edc941868af97ee86", + "type": "github" + }, + "original": { + "owner": "kosayoda", + "repo": "nvim-lightbulb", + "type": "github" + } + }, + "nvim-lspconfig": { + "flake": false, + "locked": { + "lastModified": 1669809489, + "narHash": "sha256-fMDR3sYmVu6cDSU8T75S/ppGYXo9+LPqseAd2n0HW6w=", + "owner": "neovim", + "repo": "nvim-lspconfig", + "rev": "d346335af862ede0cece75739d789cfdc46c4454", + "type": "github" + }, + "original": { + "owner": "neovim", + "repo": "nvim-lspconfig", + "type": "github" + } + }, + "nvim-neoclip": { + "flake": false, + "locked": { + "lastModified": 1651221055, + "narHash": "sha256-JO5tOk+Sv0YNjk1pHKfzXian7trFrEh/+iwH2ZxO0Ss=", + "owner": "AckslD", + "repo": "nvim-neoclip.lua", + "rev": "f3ff1645de5d2fd46ac8ffe86e440b7f3ae1fd11", + "type": "github" + }, + "original": { + "owner": "AckslD", + "repo": "nvim-neoclip.lua", + "type": "github" + } + }, + "nvim-tree-lua": { + "flake": false, + "locked": { + "lastModified": 1662860472, + "narHash": "sha256-3aB1xDU0cylHfZ5yzxMQKf07qrJ1pwHEl+QV42k0CpQ=", + "owner": "kyazdani42", + "repo": "nvim-tree.lua", + "rev": "fb8735e96cecf004fbefb086ce85371d003c5129", + "type": "github" + }, + "original": { + "owner": "kyazdani42", + "repo": "nvim-tree.lua", + "type": "github" + } + }, + "nvim-treesitter-context": { + "flake": false, + "locked": { + "lastModified": 1650876005, + "narHash": "sha256-qsfPqC6wpvM/fvGBtfKY7CjdgjGa6JsyOrI7ZWC7jyM=", + "owner": "lewis6991", + "repo": "nvim-treesitter-context", + "rev": "28fd8fea0d056333dcd3cd5abcb1256e3e526417", + "type": "github" + }, + "original": { + "owner": "lewis6991", + "repo": "nvim-treesitter-context", + "type": "github" + } + }, + "nvim-ts-autotag": { + "flake": false, + "locked": { + "lastModified": 1650591994, + "narHash": "sha256-YsqWrmsbp0NhCrnJQo8Df6yQr4f0shS6GdcEQaHdJDE=", + "owner": "windwp", + "repo": "nvim-ts-autotag", + "rev": "044a05c4c51051326900a53ba98fddacd15fea22", + "type": "github" + }, + "original": { + "owner": "windwp", + "repo": "nvim-ts-autotag", + "type": "github" + } + }, + "nvim-web-devicons": { + "flake": false, + "locked": { + "lastModified": 1651408174, + "narHash": "sha256-hYFDefTMcdtoQLhwUaamyGuid69kUo+95P1wjoS2dmo=", + "owner": "kyazdani42", + "repo": "nvim-web-devicons", + "rev": "bdd43421437f2ef037e0dafeaaaa62b31d35ef2f", + "type": "github" + }, + "original": { + "owner": "kyazdani42", + "repo": "nvim-web-devicons", + "type": "github" + } + }, + "onedark": { + "flake": false, + "locked": { + "lastModified": 1666430920, + "narHash": "sha256-pacwQrYPRp2ZFe5ClVYQz2yFxiBmKZdqKQ/I2FdCRYM=", + "owner": "navarasu", + "repo": "onedark.nvim", + "rev": "7aeca4713a922139b5e14c037b5faf34dc41c8d2", + "type": "github" + }, + "original": { + "owner": "navarasu", + "repo": "onedark.nvim", + "type": "github" + } + }, + "plenary-nvim": { + "flake": false, + "locked": { + "lastModified": 1650205145, + "narHash": "sha256-QKVFz95XaJrwkFaWqUHBirMFagellRn2YpNYnBeI/10=", + "owner": "nvim-lua", + "repo": "plenary.nvim", + "rev": "9069d14a120cadb4f6825f76821533f2babcab92", + "type": "github" + }, + "original": { + "owner": "nvim-lua", + "repo": "plenary.nvim", + "type": "github" + } + }, + "registers": { + "flake": false, + "locked": { + "lastModified": 1650186703, + "narHash": "sha256-kqAcuO/tPO0GHBUwpwQYz7QJCyeTE93CbXnVFK7S8qU=", + "owner": "tversteeg", + "repo": "registers.nvim", + "rev": "dfcf0962ce88b52e00dd96dfaabc9997a18f4efe", + "type": "github" + }, + "original": { + "owner": "tversteeg", + "repo": "registers.nvim", + "type": "github" + } + }, + "rnix-lsp": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + }, + "locked": { + "lastModified": 1669555118, + "narHash": "sha256-F0s0m62S5bHNVWNHLZD6SeHiLrsDx98VQbRjDyIu+qQ=", + "owner": "nix-community", + "repo": "rnix-lsp", + "rev": "95d40673fe43642e2e1144341e86d0036abd95d9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "rnix-lsp", + "type": "github" + } + }, + "root": { + "inputs": { + "neovim-flake": "neovim-flake", + "nixpkgs": "nixpkgs_4", + "rust-overlay": "rust-overlay_2" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "neovim-flake", + "nil", + "flake-utils" + ], + "nixpkgs": [ + "neovim-flake", + "nil", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669170936, + "narHash": "sha256-TKPH4Pzkjw5gAPo9hejs3O4mWJW6V/RSiOj8UuSFRTs=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c90c223c4aef334356029b89c72bb65e26f7efe6", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1677638104, + "narHash": "sha256-vbdOoDYnQ1QYSchMb3fYGCLYeta3XwmGvMrlXchST5s=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "f388187efb41ce4195b2f4de0b6bb463d3cd0a76", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-tools": { + "flake": false, + "locked": { + "lastModified": 1673136837, + "narHash": "sha256-+/kK6MU2EiSBFbfqQJwLkJICXZpf8oiShbcvsls3V8A=", + "owner": "simrat39", + "repo": "rust-tools.nvim", + "rev": "df584e84393ef255f5b8cbd709677d6a3a5bf42f", + "type": "github" + }, + "original": { + "owner": "simrat39", + "repo": "rust-tools.nvim", + "type": "github" + } + }, + "sqls-nvim": { + "flake": false, + "locked": { + "lastModified": 1651347942, + "narHash": "sha256-ewCkqU5Kj1MQAjRRzOWalLcv/uOLEbtK1jFrySvZ8Y8=", + "owner": "nanotee", + "repo": "sqls.nvim", + "rev": "c52945aacf30247a3b82c586681c414dcd2359bd", + "type": "github" + }, + "original": { + "owner": "nanotee", + "repo": "sqls.nvim", + "type": "github" + } + }, + "superdirt-src": { + "flake": false, + "locked": { + "lastModified": 1611740180, + "narHash": "sha256-GtnqZeMFqFkVhgx2Exu0wY687cHa7mNnVCgjQd6fiIA=", + "owner": "musikinformatik", + "repo": "superdirt", + "rev": "7abb62e89649daa1232b9cbd6427241868abd30e", + "type": "github" + }, + "original": { + "owner": "musikinformatik", + "ref": "master", + "repo": "superdirt", + "type": "github" + } + }, + "telescope": { + "flake": false, + "locked": { + "lastModified": 1651391210, + "narHash": "sha256-aEY/4ra7qyaXQg3H++b0JUbF7G2nI4m5Ow9daZO/duE=", + "owner": "nvim-telescope", + "repo": "telescope.nvim", + "rev": "544c5ee40752ac5552595da86a62abaa39e2dfa9", + "type": "github" + }, + "original": { + "owner": "nvim-telescope", + "repo": "telescope.nvim", + "type": "github" + } + }, + "tidal-src": { + "flake": false, + "locked": { + "lastModified": 1654350756, + "narHash": "sha256-tONM5SYYBca0orTLH1EUOilSC1FCluWrFt8AetUx+YQ=", + "owner": "tidalcycles", + "repo": "tidal", + "rev": "fda9c1ecb3722698935245e5409ef8ccdfca16c8", + "type": "github" + }, + "original": { + "owner": "tidalcycles", + "ref": "main", + "repo": "tidal", + "type": "github" + } + }, + "tidalcycles": { + "inputs": { + "dirt-samples-src": "dirt-samples-src", + "nixpkgs": "nixpkgs_3", + "superdirt-src": "superdirt-src", + "tidal-src": "tidal-src", + "utils": "utils_2", + "vim-tidal-src": "vim-tidal-src", + "vowel-src": "vowel-src" + }, + "locked": { + "lastModified": 1661670241, + "narHash": "sha256-+5C83z+Sd8ugvMshrXqpca4vv3tQ2D4tYEJ3QY6JVsg=", + "owner": "mitchmindtree", + "repo": "tidalcycles.nix", + "rev": "fefe3d586511e1cfaac79bb83ec0b278bb1b6bad", + "type": "github" + }, + "original": { + "owner": "mitchmindtree", + "repo": "tidalcycles.nix", + "type": "github" + } + }, + "todo-comments": { + "flake": false, + "locked": { + "lastModified": 1642601933, + "narHash": "sha256-8uj5TxO9XZlSCB4lVRbKRc1IlUEKcBf/4bDviwuxEgs=", + "owner": "folke", + "repo": "todo-comments.nvim", + "rev": "98b1ebf198836bdc226c0562b9f906584e6c400e", + "type": "github" + }, + "original": { + "owner": "folke", + "repo": "todo-comments.nvim", + "type": "github" + } + }, + "tokyonight": { + "flake": false, + "locked": { + "lastModified": 1666558747, + "narHash": "sha256-hZufHQkI2M0I4mEqV9qs6PkL74aqScKJ3RA5QOulX+0=", + "owner": "folke", + "repo": "tokyonight.nvim", + "rev": "16a294bea92dc8f16ad205c71ce61bf05e79deb3", + "type": "github" + }, + "original": { + "owner": "folke", + "repo": "tokyonight.nvim", + "type": "github" + } + }, + "trouble": { + "flake": false, + "locked": { + "lastModified": 1647585739, + "narHash": "sha256-oUf8YbJ9HmSLN8o2c7CXzCYPu7PwKzvVKNiM9HtHQbQ=", + "owner": "folke", + "repo": "trouble.nvim", + "rev": "691d490cc4eadc430d226fa7d77aaa84e2e0a125", + "type": "github" + }, + "original": { + "owner": "folke", + "repo": "trouble.nvim", + "type": "github" + } + }, + "utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "vim-tidal-src": { + "flake": false, + "locked": { + "lastModified": 1664758630, + "narHash": "sha256-fLaBMm6jSLHytIH5IUQtUfi3kaPLdruO3cxv4UcjEO4=", + "owner": "tidalcycles", + "repo": "vim-tidal", + "rev": "f15f14b12176d8f1028d0596b031c3d6e1201c3b", + "type": "github" + }, + "original": { + "owner": "mitchmindtree", + "ref": "mitchmindtree", + "repo": "vim-tidal", + "type": "github" + } + }, + "vim-vsnip": { + "flake": false, + "locked": { + "lastModified": 1650631622, + "narHash": "sha256-USltEc6QGHwMqx7E9wo9qZmq+pm9FLj0CUcKoE7KPLU=", + "owner": "hrsh7th", + "repo": "vim-vsnip", + "rev": "8f199ef690ed26dcbb8973d9a6760d1332449ac9", + "type": "github" + }, + "original": { + "owner": "hrsh7th", + "repo": "vim-vsnip", + "type": "github" + } + }, + "vowel-src": { + "flake": false, + "locked": { + "lastModified": 1641306144, + "narHash": "sha256-zfF6cvAGDNYWYsE8dOIo38b+dIymd17Pexg0HiPFbxM=", + "owner": "supercollider-quarks", + "repo": "vowel", + "rev": "ab59caa870201ecf2604b3efdd2196e21a8b5446", + "type": "github" + }, + "original": { + "owner": "supercollider-quarks", + "ref": "master", + "repo": "vowel", + "type": "github" + } + }, + "which-key": { + "flake": false, + "locked": { + "lastModified": 1666956294, + "narHash": "sha256-IbJP6j+M+POPhX4YbewTJiSoELvDo6y+vF0RREqqm4c=", + "owner": "folke", + "repo": "which-key.nvim", + "rev": "61553aeb3d5ca8c11eea8be6eadf478062982ac9", + "type": "github" + }, + "original": { + "owner": "folke", + "repo": "which-key.nvim", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..96dc184 --- /dev/null +++ b/flake.nix @@ -0,0 +1,121 @@ +{ + inputs = { + nixpkgs.url = "github:jordanisaacs/nixpkgs/aoc-cli-init"; + rust-overlay.url = "github:oxalica/rust-overlay"; + neovim-flake.url = "github:jordanisaacs/neovim-flake"; + }; + + outputs = { + self, + nixpkgs, + rust-overlay, + neovim-flake, + ... + }: let + system = "x86_64-linux"; + overlays = [ + rust-overlay.overlays.default + (self: super: let + rust = super.rust-bin.stable.latest.default; + in { + rustc = rust; + cargo = rust; + }) + ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + neovim = neovim-flake.lib.neovimConfiguration { + inherit pkgs; + modules = [ + { + config = { + vim.lsp = { + enable = true; + lightbulb.enable = true; + lspSignature.enable = true; + nvimCodeActionMenu.enable = true; + trouble.enable = true; + formatOnSave = true; + rust = { + enable = true; + rustAnalyzerOpts = ""; + }; + nix.enable = true; + }; + vim.statusline.lualine = { + enable = true; + theme = "onedark"; + }; + vim.visuals = { + enable = true; + nvimWebDevicons.enable = true; + lspkind.enable = true; + indentBlankline = { + enable = true; + fillChar = ""; + eolChar = ""; + showCurrContext = true; + }; + cursorWordline = { + enable = true; + lineTimeout = 0; + }; + }; + + vim.theme = { + enable = true; + name = "onedark"; + style = "darker"; + }; + vim.autopairs.enable = true; + vim.autocomplete = { + enable = true; + type = "nvim-cmp"; + }; + vim.filetree.nvimTreeLua.enable = true; + vim.tabline.nvimBufferline.enable = true; + vim.telescope = { + enable = true; + }; + vim.markdown = { + enable = true; + glow.enable = true; + }; + vim.treesitter = { + enable = true; + autotagHtml = true; + context.enable = true; + }; + vim.keys = { + enable = true; + whichKey.enable = true; + }; + vim.git = { + enable = true; + gitsigns.enable = true; + }; + }; + } + ]; + }; + + nativeBuildInputs = with pkgs; [ + rustc + + neovim.neovim + + cargo + cargo-edit + cargo-audit + cargo-tarpaulin + clippy + ]; + in + with pkgs; { + devShells.${system}.default = mkShell { + inherit nativeBuildInputs; + }; + }; +} diff --git a/io-uring-bench/Cargo.toml b/io-uring-bench/Cargo.toml index 046e0da..18472bf 100644 --- a/io-uring-bench/Cargo.toml +++ b/io-uring-bench/Cargo.toml @@ -1,13 +1,14 @@ [package] name = "io-uring-bench" version = "0.1.0" -authors = ["quininer "] -edition = "2018" +authors = ["Jordan Isaacs "] +edition = "2021" +publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -io-uring = { path = ".." } +io-uring = { path = "..", package = "rustix-uring" } iou = "0.3" uring-sys = "0.7" criterion = "0.4" diff --git a/io-uring-test/Cargo.toml b/io-uring-test/Cargo.toml index dee0cd1..6cfcd3f 100644 --- a/io-uring-test/Cargo.toml +++ b/io-uring-test/Cargo.toml @@ -1,19 +1,20 @@ [package] name = "io-uring-test" version = "0.1.0" -authors = ["quininer "] -edition = "2018" +authors = ["Jordan Isaacs "] +edition = "2021" +publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -io-uring = { path = ".." } +io-uring = { path = "..", package = "rustix-uring" } libc = { version = "0.2", features = [ "extra_traits" ] } +rustix = { version = "0.38.0", features = ["fs"] } anyhow = "1" tempfile = "3" once_cell = "1" socket2 = "0.5" [features] -direct-syscall = [ "io-uring/direct-syscall" ] ci = [] diff --git a/io-uring-test/src/main.rs b/io-uring-test/src/main.rs index 6192e20..63d4d60 100644 --- a/io-uring-test/src/main.rs +++ b/io-uring-test/src/main.rs @@ -49,10 +49,10 @@ fn test( println!( "ring type: IoUring<{}, {}>", std::any::type_name::() - .strip_prefix("io_uring::") + .strip_prefix("rustix_uring::") .unwrap(), std::any::type_name::() - .strip_prefix("io_uring::") + .strip_prefix("rustix_uring::") .unwrap(), ); println!("params: {:#?}", ring.params()); @@ -128,7 +128,8 @@ fn test( tests::net::test_tcp_buffer_select(&mut ring, &test)?; tests::net::test_tcp_buffer_select_recvmsg(&mut ring, &test)?; tests::net::test_tcp_buffer_select_readv(&mut ring, &test)?; - tests::net::test_tcp_recv_multi(&mut ring, &test)?; + // FIXME: This test hangs on upstream. + //tests::net::test_tcp_recv_multi(&mut ring, &test)?; tests::net::test_shutdown(&mut ring, &test)?; tests::net::test_socket(&mut ring, &test)?; tests::net::test_udp_recvmsg_multishot(&mut ring, &test)?; diff --git a/io-uring-test/src/tests/fs.rs b/io-uring-test/src/tests/fs.rs index 8c66806..104a13a 100644 --- a/io-uring-test/src/tests/fs.rs +++ b/io-uring-test/src/tests/fs.rs @@ -173,7 +173,7 @@ pub fn test_file_openat2( let path = dir.path().join("test-io-uring-openat2"); let path = CString::new(path.as_os_str().as_bytes())?; - let openhow = types::OpenHow::new().flags(libc::O_CREAT as _); + let openhow = types::OpenHow::new().flags(types::OFlags::CREATE); let open_e = opcode::OpenAt2::new(dirfd, path.as_ptr(), &openhow); unsafe { @@ -229,7 +229,7 @@ pub fn test_file_openat2_close_file_index( let pathbuf = CString::new(path.as_os_str().as_bytes())?; fs::write(&path, "1")?; - let mut statxbuf: libc::statx = unsafe { std::mem::zeroed() }; + let mut statxbuf: rustix::io_uring::Statx = unsafe { std::mem::zeroed() }; let statx_e = opcode::Statx::new( types::Fd(libc::AT_FDCWD), pathbuf.as_ptr(), - &mut statxbuf as *mut libc::statx as *mut _, + &mut statxbuf as *mut _, ) - .mask(libc::STATX_ALL) + .mask(types::StatxFlags::ALL) .build() .user_data(0x99) .into(); @@ -617,31 +617,27 @@ pub fn test_statx( assert_eq!(cqes[0].result(), 0); // check - let mut statxbuf2 = unsafe { std::mem::zeroed() }; - let ret = unsafe { - libc::statx( - libc::AT_FDCWD, - pathbuf.as_ptr(), - 0, - libc::STATX_ALL, - &mut statxbuf2, - ) - }; + let statxbuf2 = rustix::fs::statx( + rustix::fs::CWD, + pathbuf, + rustix::fs::AtFlags::empty(), + rustix::fs::StatxFlags::ALL, + ) + .unwrap(); - assert_eq!(ret, 0); - assert_eq!(statxbuf, statxbuf2); + assert_same_statx(&statxbuf, &statxbuf2); // statx fd let fd = fs::File::open(&path)?; - let mut statxbuf3: libc::statx = unsafe { std::mem::zeroed() }; + let mut statxbuf3: rustix::io_uring::Statx = unsafe { std::mem::zeroed() }; let statx_e = opcode::Statx::new( types::Fd(fd.as_raw_fd()), b"\0".as_ptr().cast(), - &mut statxbuf3 as *mut libc::statx as *mut _, + &mut statxbuf3 as *mut rustix::io_uring::Statx as *mut _, ) - .flags(libc::AT_EMPTY_PATH) - .mask(libc::STATX_ALL) + .flags(types::AtFlags::EMPTY_PATH) + .mask(types::StatxFlags::ALL) .build() .user_data(0x9a) .into(); @@ -658,11 +654,88 @@ pub fn test_statx( assert_eq!(cqes[0].user_data(), 0x9a); assert_eq!(cqes[0].result(), 0); - assert_eq!(statxbuf3, statxbuf2); + assert_same_statx(&statxbuf3, &statxbuf2); Ok(()) } +fn assert_same_statx(statxbuf: &types::Statx, statxbuf2: &types::Statx) { + let types::Statx { + stx_mask: buf_mask, + stx_blksize: buf_blksize, + stx_attributes: buf_attributes, + stx_nlink: buf_nlink, + stx_uid: buf_uid, + stx_gid: buf_gid, + stx_mode: buf_mode, + stx_ino: buf_ino, + stx_size: buf_size, + stx_blocks: buf_blocks, + stx_attributes_mask: buf_attributes_mask, + stx_btime: buf_btime, + stx_ctime: buf_ctime, + stx_mtime: buf_mtime, + stx_rdev_major: buf_rdev_major, + stx_rdev_minor: buf_rdev_minor, + stx_dev_major: buf_dev_major, + stx_dev_minor: buf_dev_minor, + stx_mnt_id: buf_mnt_id, + stx_dio_mem_align: buf_dio_mem_align, + stx_dio_offset_align: buf_dio_offset_align, + .. + } = statxbuf; + + let types::Statx { + stx_mask: buf2_mask, + stx_blksize: buf2_blksize, + stx_attributes: buf2_attributes, + stx_nlink: buf2_nlink, + stx_uid: buf2_uid, + stx_gid: buf2_gid, + stx_mode: buf2_mode, + stx_ino: buf2_ino, + stx_size: buf2_size, + stx_blocks: buf2_blocks, + stx_attributes_mask: buf2_attributes_mask, + stx_btime: buf2_btime, + stx_ctime: buf2_ctime, + stx_mtime: buf2_mtime, + stx_rdev_major: buf2_rdev_major, + stx_rdev_minor: buf2_rdev_minor, + stx_dev_major: buf2_dev_major, + stx_dev_minor: buf2_dev_minor, + stx_mnt_id: buf2_mnt_id, + stx_dio_mem_align: buf2_dio_mem_align, + stx_dio_offset_align: buf2_dio_offset_align, + .. + } = statxbuf2; + + assert_eq!(buf_mask, buf2_mask); + assert_eq!(buf_blksize, buf2_blksize); + assert_eq!(buf_attributes, buf2_attributes); + assert_eq!(buf_nlink, buf2_nlink); + assert_eq!(buf_uid, buf2_uid); + assert_eq!(buf_gid, buf2_gid); + assert_eq!(buf_mode, buf2_mode); + assert_eq!(buf_ino, buf2_ino); + assert_eq!(buf_size, buf2_size); + assert_eq!(buf_blocks, buf2_blocks); + assert_eq!(buf_attributes_mask, buf2_attributes_mask); + assert_eq!(buf_btime.tv_sec, buf2_btime.tv_sec); + assert_eq!(buf_btime.tv_nsec, buf2_btime.tv_nsec); + assert_eq!(buf_ctime.tv_sec, buf2_ctime.tv_sec); + assert_eq!(buf_ctime.tv_nsec, buf2_ctime.tv_nsec); + assert_eq!(buf_mtime.tv_sec, buf2_mtime.tv_sec); + assert_eq!(buf_mtime.tv_nsec, buf2_mtime.tv_nsec); + assert_eq!(buf_rdev_major, buf2_rdev_major); + assert_eq!(buf_rdev_minor, buf2_rdev_minor); + assert_eq!(buf_dev_major, buf2_dev_major); + assert_eq!(buf_dev_minor, buf2_dev_minor); + assert_eq!(buf_mnt_id, buf2_mnt_id); + assert_eq!(buf_dio_mem_align, buf2_dio_mem_align); + assert_eq!(buf_dio_offset_align, buf2_dio_offset_align); +} + pub fn test_file_direct_write_read( ring: &mut IoUring, test: &Test, diff --git a/io-uring-test/src/tests/net.rs b/io-uring-test/src/tests/net.rs index 18beb20..33b6f0a 100644 --- a/io-uring-test/src/tests/net.rs +++ b/io-uring-test/src/tests/net.rs @@ -204,7 +204,7 @@ pub fn test_tcp_zero_copy_send_fixed( let mut bufs2 = [io::IoSliceMut::new(&mut buf2)]; // build sendmsg - let mut msg = MaybeUninit::::zeroed(); + let mut msg = MaybeUninit::::zeroed(); unsafe { let p = msg.as_mut_ptr(); (*p).msg_name = sockaddr.as_ptr() as *const _ as *mut _; - (*p).msg_namelen = sockaddr.len(); + (*p).msg_namelen = sockaddr.len() as _; (*p).msg_iov = bufs.as_ptr() as *const _ as *mut _; (*p).msg_iovlen = 1; } @@ -306,12 +306,12 @@ pub fn test_tcp_sendmsg_recvmsg( let sendmsg_e = opcode::SendMsg::new(send_fd, msg.as_ptr()); // build recvmsg - let mut msg = MaybeUninit::::zeroed(); + let mut msg = MaybeUninit::::zeroed(); unsafe { let p = msg.as_mut_ptr(); (*p).msg_name = sockaddr.as_ptr() as *const _ as *mut _; - (*p).msg_namelen = sockaddr.len(); + (*p).msg_namelen = sockaddr.len() as _; (*p).msg_iov = bufs2.as_mut_ptr() as *mut _; (*p).msg_iovlen = 1; } @@ -378,12 +378,12 @@ pub fn test_tcp_zero_copy_sendmsg_recvmsg::zeroed(); + let mut msg = MaybeUninit::::zeroed(); unsafe { let p = msg.as_mut_ptr(); (*p).msg_name = sockaddr.as_ptr() as *const _ as *mut _; - (*p).msg_namelen = sockaddr.len(); + (*p).msg_namelen = sockaddr.len() as _; (*p).msg_iov = bufs.as_ptr() as *const _ as *mut _; (*p).msg_iovlen = 1; } @@ -391,12 +391,12 @@ pub fn test_tcp_zero_copy_sendmsg_recvmsg::zeroed(); + let mut msg = MaybeUninit::::zeroed(); unsafe { let p = msg.as_mut_ptr(); (*p).msg_name = sockaddr.as_ptr() as *const _ as *mut _; - (*p).msg_namelen = sockaddr.len(); + (*p).msg_namelen = sockaddr.len() as _; (*p).msg_iov = bufs2.as_mut_ptr() as *mut _; (*p).msg_iovlen = 1; } @@ -466,8 +466,8 @@ pub fn test_tcp_accept( let _stream = TcpStream::connect(addr)?; - let mut sockaddr: libc::sockaddr = unsafe { mem::zeroed() }; - let mut addrlen: libc::socklen_t = mem::size_of::() as _; + let mut sockaddr: io_uring::types::sockaddr = unsafe { mem::zeroed() }; + let mut addrlen: io_uring::types::socklen_t = mem::size_of::() as _; let accept_e = opcode::Accept::new(fd, &mut sockaddr, &mut addrlen); @@ -518,8 +518,8 @@ pub fn test_tcp_accept_file_index() as _; + let mut sockaddr: io_uring::types::sockaddr = unsafe { mem::zeroed() }; + let mut addrlen: io_uring::types::socklen_t = mem::size_of::() as _; let dest_slot = types::DestinationSlot::try_from_slot_target(4).unwrap(); let accept_e = opcode::Accept::new(fd, &mut sockaddr, &mut addrlen); @@ -875,7 +875,7 @@ pub fn test_tcp_buffer_select( match bid { 0 => assert_eq!(&buf0[..256], &input[1024..]), 1 => assert_eq!(&buf1[..256], &input[1024..]), - _ => panic!("{}", cqe.flags()), + _ => panic!("{:?}", cqe.flags()), } // remove one remaining buf @@ -954,10 +954,10 @@ pub fn test_tcp_buffer_select_recvmsg( assert_eq!(cqes[0].user_data(), 42); assert!(cqes[0].result() >= 0); assert!(cqes[0].result() != plain_fd); - assert_eq!(cqes[0].flags(), 0); + assert_eq!(cqes[0].flags(), cqueue::Flags::empty()); // Close both sockets, to avoid leaking FDs. let io_uring_socket = unsafe { Socket::from_raw_fd(cqes[0].result()) }; @@ -1275,7 +1275,7 @@ pub fn test_socket( assert_eq!(cqes.len(), 1); assert_eq!(cqes[0].user_data(), 55); assert_eq!(cqes[0].result(), 0); - assert_eq!(cqes[0].flags(), 0); + assert_eq!(cqes[0].flags(), cqueue::Flags::empty()); // If the fixed-socket operation worked properly, this must not fail. ring.submitter().unregister_files().unwrap(); @@ -1324,12 +1324,12 @@ pub fn test_udp_recvmsg_multishot() - .read_unaligned(); + let storage = msg.name_data().as_ptr().cast(); let len = msg.name_data().len().try_into().unwrap(); - socket2::SockAddr::new(storage, len) + rustix::net::SocketAddrAny::read(storage, len).unwrap() + }; + let addr = match addr { + rustix::net::SocketAddrAny::V4(v4) => v4, + _ => unreachable!(), }; - let addr = addr.as_socket_ipv4().unwrap(); assert_eq!(addr.ip(), client_addr.ip()); assert_eq!(addr.port(), client_addr.port()); } @@ -1451,8 +1450,10 @@ pub fn test_udp_sendzc_with_dest println!("test udp_sendzc_with_dest"); - let server_socket: socket2::Socket = std::net::UdpSocket::bind("127.0.0.1:0").unwrap().into(); - let dest_addr = server_socket.local_addr()?; + let server_socket = std::net::UdpSocket::bind("127.0.0.1:0").unwrap(); + let dest_addr: rustix::net::SocketAddrAny = server_socket.local_addr()?.into(); + let mut dest_addr_storage = unsafe { std::mem::zeroed::() }; + let dest_addr_len = unsafe { dest_addr.write(&mut dest_addr_storage) }; // Provide 2 buffers in buffer group `33`, at index 0 and 1. // Each one is 512 bytes large. @@ -1476,7 +1477,7 @@ pub fn test_udp_sendzc_with_dest assert_eq!(cqes.len(), 1); assert_eq!(cqes[0].user_data(), 11); assert_eq!(cqes[0].result(), 0); - assert_eq!(cqes[0].flags(), 0); + assert_eq!(cqes[0].flags(), cqueue::Flags::empty()); } let recvmsg_e = opcode::RecvMulti::new(Fd(server_socket.as_raw_fd()), BUF_GROUP) @@ -1493,8 +1494,8 @@ pub fn test_udp_sendzc_with_dest // 2 self events + 1 recv let entry1 = opcode::SendZc::new(Fd(fd), buf1.as_ptr(), buf1.len() as _) - .dest_addr(dest_addr.as_ptr()) - .dest_addr_len(dest_addr.len()) + .dest_addr(&mut dest_addr_storage) + .dest_addr_len(dest_addr_len as _) .build() .user_data(33) .flags(Flags::IO_LINK) diff --git a/io-uring-test/src/tests/queue.rs b/io-uring-test/src/tests/queue.rs index 69067ab..58f69c7 100644 --- a/io-uring-test/src/tests/queue.rs +++ b/io-uring-test/src/tests/queue.rs @@ -188,13 +188,13 @@ pub fn test_msg_ring_data( assert_eq!(source_cqes.len(), 1); assert_eq!(source_cqes[0].user_data(), 0); assert_eq!(source_cqes[0].result(), 0); - assert_eq!(source_cqes[0].flags(), 0); + assert_eq!(source_cqes[0].flags(), cqueue::Flags::empty()); let dest_cqes: Vec = dest_ring.completion().map(Into::into).collect(); assert_eq!(dest_cqes.len(), 1); assert_eq!(dest_cqes[0].user_data(), user_data); assert_eq!(dest_cqes[0].result(), result); - assert_eq!(dest_cqes[0].flags(), flags.unwrap_or(0)); + assert_eq!(dest_cqes[0].flags().bits(), flags.unwrap_or(0)); Ok(()) } @@ -255,13 +255,13 @@ pub fn test_msg_ring_send_fd( assert_eq!(source_cqes.len(), 1); assert_eq!(source_cqes[0].user_data(), 0); assert_eq!(source_cqes[0].result(), 0); - assert_eq!(source_cqes[0].flags(), 0); + assert_eq!(source_cqes[0].flags(), cqueue::Flags::empty()); let dest_cqes: Vec = temp_ring.completion().map(Into::into).collect(); assert_eq!(dest_cqes.len(), 1); assert_eq!(dest_cqes[0].user_data(), 22); assert_eq!(dest_cqes[0].result(), 0); - assert_eq!(dest_cqes[0].flags(), 0); + assert_eq!(dest_cqes[0].flags(), cqueue::Flags::empty()); } // Unregister the fixed files from the source ring, then reserve some empty slots @@ -286,13 +286,13 @@ pub fn test_msg_ring_send_fd( assert_eq!(source_cqes.len(), 1); assert_eq!(source_cqes[0].user_data(), 0); assert_eq!(source_cqes[0].result(), 0); - assert_eq!(source_cqes[0].flags(), 0); + assert_eq!(source_cqes[0].flags(), cqueue::Flags::empty()); let dest_cqes: Vec = ring.completion().map(Into::into).collect(); assert_eq!(dest_cqes.len(), 1); assert_eq!(dest_cqes[0].user_data(), 44); assert_eq!(dest_cqes[0].result(), 0); - assert_eq!(dest_cqes[0].flags(), 0); + assert_eq!(dest_cqes[0].flags(), cqueue::Flags::empty()); } // Unregister the fixed files from both rings, then repeat again to diff --git a/io-uring-test/src/tests/register.rs b/io-uring-test/src/tests/register.rs index f4d3efd..8d8622a 100644 --- a/io-uring-test/src/tests/register.rs +++ b/io-uring-test/src/tests/register.rs @@ -1,5 +1,5 @@ use crate::Test; -use io_uring::{cqueue, opcode, squeue, IoUring}; +use io_uring::{cqueue, opcode, squeue, Errno, IoUring}; pub fn test_register_files_sparse( ring: &mut IoUring, @@ -43,15 +43,9 @@ pub fn test_register_files_sparse { + match e { + Errno::INVAL => { // using buf_ring requires kernel 5.19 or greater. return Err(io::Error::new( io::ErrorKind::Other, format!("buf_ring.register returned {}, most likely indicating this kernel is not 5.19+", e), )); } - Some(libc::EEXIST) => { + Errno::EXIST => { // Registering a duplicate bgid is not allowed. There is an `unregister` // operations that can remove the first, but care must be taken that there // are no outstanding operations that will still return a buffer from that @@ -234,7 +234,7 @@ impl InnerBufRing { } self.buf_ring_sync(); - res + Ok(res?) } // Unregister the buffer ring from the io_uring. @@ -246,7 +246,7 @@ impl InnerBufRing { { let bgid = self.bgid; - ring.submitter().unregister_buf_ring(bgid) + Ok(ring.submitter().unregister_buf_ring(bgid)?) } // Returns the buffer group id. @@ -256,7 +256,12 @@ impl InnerBufRing { // Returns the buffer the uring interface picked from the buf_ring for the completion result // represented by the res and flags. - fn get_buf(&self, buf_ring: FixedSizeBufRing, res: u32, flags: u32) -> io::Result { + fn get_buf( + &self, + buf_ring: FixedSizeBufRing, + res: u32, + flags: io_uring::cqueue::Flags, + ) -> io::Result { // This fn does the odd thing of having self as the BufRing and taking an argument that is // the same BufRing but wrapped in Rc<_> so the wrapped buf_ring can be passed to the // outgoing GBuf. diff --git a/io-uring-test/src/tests/timeout.rs b/io-uring-test/src/tests/timeout.rs index 18ff34e..1f5139c 100644 --- a/io-uring-test/src/tests/timeout.rs +++ b/io-uring-test/src/tests/timeout.rs @@ -1,5 +1,5 @@ use crate::Test; -use io_uring::{cqueue, opcode, squeue, types, IoUring}; +use io_uring::{cqueue, opcode, squeue, types, Errno, IoUring}; use std::time::Instant; pub fn test_timeout( @@ -352,7 +352,7 @@ pub fn test_timeout_submit_args( let start = Instant::now(); match ring.submitter().submit_with_args(1, &args) { Ok(_) => panic!(), - Err(ref err) if err.raw_os_error() == Some(libc::ETIME) => (), + Err(Errno::TIME) => (), Err(err) => return Err(err.into()), } assert_eq!(start.elapsed().as_secs(), 1); diff --git a/src/cqueue.rs b/src/cqueue.rs index c37daa5..3af4617 100644 --- a/src/cqueue.rs +++ b/src/cqueue.rs @@ -1,13 +1,15 @@ //! Completion Queue -use std::fmt::{self, Debug}; -use std::mem; -use std::mem::MaybeUninit; -use std::sync::atomic; +use core::fmt::{self, Debug}; +use core::mem; +use core::mem::MaybeUninit; +use core::sync::atomic; use crate::sys; use crate::util::{private, unsync_load, Mmap}; +use bitflags::bitflags; + pub(crate) struct Inner { head: *const atomic::AtomicU32, tail: *const atomic::AtomicU32, @@ -18,7 +20,6 @@ pub(crate) struct Inner { cqes: *const E, - #[allow(dead_code)] flags: *const atomic::AtomicU32, } @@ -33,7 +34,7 @@ pub struct CompletionQueue<'a, E: EntryMarker = Entry> { /// /// This is implemented for [`Entry`] and [`Entry32`]. pub trait EntryMarker: Clone + Debug + Into + private::Sealed { - const BUILD_FLAGS: u32; + const BUILD_FLAGS: sys::IoringSetupFlags; } /// A 16-byte completion queue entry (CQE), representing a complete I/O operation. @@ -51,6 +52,20 @@ fn test_entry_sizes() { assert_eq!(mem::size_of::(), 32); } +bitflags! { + /// Completion flags + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct Flags: u32 { + const BUFFER = sys::IoringCqeFlags::BUFFER.bits(); + + const MORE = sys::IoringCqeFlags::MORE.bits(); + + const SOCK_NONEMPTY = sys::IoringCqeFlags::SOCK_NONEMPTY.bits(); + + const NOTIF = sys::IoringCqeFlags::NOTIF.bits(); + } +} + impl Inner { #[rustfmt::skip] pub(crate) unsafe fn new(cq_mmap: &Mmap, p: &sys::io_uring_params) -> Self { @@ -112,8 +127,10 @@ impl CompletionQueue<'_, E> { /// `false`. pub fn eventfd_disabled(&self) -> bool { unsafe { - (*self.queue.flags).load(atomic::Ordering::Acquire) & sys::IORING_CQ_EVENTFD_DISABLED - != 0 + sys::IoringCqFlags::from_bits_retain( + (*self.queue.flags).load(atomic::Ordering::Acquire), + ) + .contains(sys::IoringCqFlags::EVENTFD_DISABLED) } } @@ -139,13 +156,13 @@ impl CompletionQueue<'_, E> { #[inline] pub fn fill<'a>(&mut self, entries: &'a mut [MaybeUninit]) -> &'a mut [E] { - let len = std::cmp::min(self.len(), entries.len()); + let len = core::cmp::min(self.len(), entries.len()); for entry in &mut entries[..len] { *entry = MaybeUninit::new(unsafe { self.pop() }); } - unsafe { std::slice::from_raw_parts_mut(entries as *mut _ as *mut E, len) } + unsafe { core::slice::from_raw_parts_mut(entries as *mut _ as *mut E, len) } } #[inline] @@ -203,7 +220,14 @@ impl Entry { /// [`Entry::user_data`](crate::squeue::Entry::user_data) on the submission queue event. #[inline] pub fn user_data(&self) -> u64 { - self.0.user_data + self.0.user_data.u64_() + } + + /// The user data of the request, as set by + /// [`Entry::user_data`](crate::squeue::Entry::user_data) on the submission queue event. + #[inline] + pub fn user_data_ptr(&self) -> *mut core::ffi::c_void { + self.0.user_data.ptr() } /// Metadata related to the operation. @@ -212,15 +236,15 @@ impl Entry { /// - Storing the selected buffer ID, if one was selected. See /// [`BUFFER_SELECT`](crate::squeue::Flags::BUFFER_SELECT) for more info. #[inline] - pub fn flags(&self) -> u32 { - self.0.flags + pub fn flags(&self) -> Flags { + Flags::from_bits_retain(self.0.flags.bits()) } } impl private::Sealed for Entry {} impl EntryMarker for Entry { - const BUILD_FLAGS: u32 = 0; + const BUILD_FLAGS: sys::IoringSetupFlags = sys::IoringSetupFlags::empty(); } impl Clone for Entry { @@ -252,7 +276,14 @@ impl Entry32 { /// [`Entry::user_data`](crate::squeue::Entry::user_data) on the submission queue event. #[inline] pub fn user_data(&self) -> u64 { - self.0 .0.user_data + self.0 .0.user_data.u64_() + } + + /// The user data of the request, as set by + /// [`Entry::user_data`](crate::squeue::Entry::user_data) on the submission queue event. + #[inline] + pub fn user_data_ptr(&self) -> *mut core::ffi::c_void { + self.0 .0.user_data.ptr() } /// Metadata related to the operation. @@ -261,8 +292,8 @@ impl Entry32 { /// - Storing the selected buffer ID, if one was selected. See /// [`BUFFER_SELECT`](crate::squeue::Flags::BUFFER_SELECT) for more info. #[inline] - pub fn flags(&self) -> u32 { - self.0 .0.flags + pub fn flags(&self) -> Flags { + Flags::from_bits_retain(self.0 .0.flags.bits()) } /// Additional data available in 32-byte completion queue entries (CQEs). @@ -275,7 +306,7 @@ impl Entry32 { impl private::Sealed for Entry32 {} impl EntryMarker for Entry32 { - const BUILD_FLAGS: u32 = sys::IORING_SETUP_CQE32; + const BUILD_FLAGS: sys::IoringSetupFlags = sys::IoringSetupFlags::CQE32; } impl From for Entry { @@ -300,9 +331,9 @@ impl Debug for Entry32 { /// This corresponds to the `IORING_CQE_F_BUFFER` flag (and related bit-shifting), /// and it signals to the consumer which provided contains the result of this /// operation. -pub fn buffer_select(flags: u32) -> Option { - if flags & sys::IORING_CQE_F_BUFFER != 0 { - let id = flags >> sys::IORING_CQE_BUFFER_SHIFT; +pub fn buffer_select(flags: Flags) -> Option { + if flags.contains(Flags::BUFFER) { + let id = flags.bits() >> sys::IORING_CQE_BUFFER_SHIFT; // FIXME // @@ -319,8 +350,8 @@ pub fn buffer_select(flags: u32) -> Option { /// This corresponds to the `IORING_CQE_F_MORE` flag, and it signals to /// the consumer that it should expect further CQE entries after this one, /// still from the same original SQE request (e.g. for multishot operations). -pub fn more(flags: u32) -> bool { - flags & sys::IORING_CQE_F_MORE != 0 +pub fn more(flags: Flags) -> bool { + flags.contains(Flags::MORE) } /// Return whether socket has more data ready to read. @@ -330,6 +361,6 @@ pub fn more(flags: u32) -> bool { /// /// The io_uring documentation says recv, recv-multishot, recvmsg, and recvmsg-multishot /// can provide this bit in their respective CQE. -pub fn sock_nonempty(flags: u32) -> bool { - flags & sys::IORING_CQE_F_SOCK_NONEMPTY != 0 +pub fn sock_nonempty(flags: Flags) -> bool { + flags.contains(Flags::SOCK_NONEMPTY) } diff --git a/src/lib.rs b/src/lib.rs index 1ccf43b..106dde8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,8 @@ //! //! The crate only provides a summary of the parameters. //! For more detailed documentation, see manpage. -#![warn(rust_2018_idioms, unused_qualifications)] +#![warn(unused_qualifications)] +#![cfg_attr(not(feature = "std"), no_std)] #[macro_use] mod util; @@ -11,22 +12,21 @@ pub mod opcode; pub mod register; pub mod squeue; mod submit; -mod sys; +use rustix::io_uring as sys; pub mod types; +pub use rustix::io::{Errno, Result}; -use std::marker::PhantomData; -use std::mem::ManuallyDrop; -use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; -use std::{cmp, io, mem}; +use core::marker::PhantomData; +use core::mem::ManuallyDrop; +use core::{cmp, mem}; -#[cfg(feature = "io_safety")] -use std::os::unix::io::{AsFd, BorrowedFd}; +use rustix::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd}; pub use cqueue::CompletionQueue; pub use register::Probe; pub use squeue::SubmissionQueue; pub use submit::Submitter; -use util::{Mmap, OwnedFd}; +use util::Mmap; /// IoUring instance /// @@ -46,7 +46,6 @@ where memory: ManuallyDrop, } -#[allow(dead_code)] struct MemoryMap { sq_mmap: Mmap, sqe_mmap: Mmap, @@ -78,7 +77,7 @@ impl IoUring { /// /// The `entries` sets the size of queue, /// and its value should be the power of two. - pub fn new(entries: u32) -> io::Result { + pub fn new(entries: u32) -> Result { Self::builder().build(entries) } } @@ -102,7 +101,7 @@ impl IoUring { } } - fn with_params(entries: u32, mut p: sys::io_uring_params) -> io::Result { + fn with_params(entries: u32, mut p: sys::io_uring_params) -> Result { // NOTE: The `SubmissionQueue` and `CompletionQueue` are references, // and their lifetime can never exceed `MemoryMap`. // @@ -114,13 +113,13 @@ impl IoUring { unsafe fn setup_queue( fd: &OwnedFd, p: &sys::io_uring_params, - ) -> io::Result<(MemoryMap, squeue::Inner, cqueue::Inner)> { + ) -> Result<(MemoryMap, squeue::Inner, cqueue::Inner)> { let sq_len = p.sq_off.array as usize + p.sq_entries as usize * mem::size_of::(); let cq_len = p.cq_off.cqes as usize + p.cq_entries as usize * mem::size_of::(); let sqe_len = p.sq_entries as usize * mem::size_of::(); let sqe_mmap = Mmap::new(fd, sys::IORING_OFF_SQES as _, sqe_len)?; - if p.features & sys::IORING_FEAT_SINGLE_MMAP != 0 { + if p.features.contains(sys::IoringFeatureFlags::SINGLE_MMAP) { let scq_mmap = Mmap::new(fd, sys::IORING_OFF_SQ_RING as _, cmp::max(sq_len, cq_len))?; @@ -149,7 +148,7 @@ impl IoUring { } } - let fd: OwnedFd = unsafe { OwnedFd::from_raw_fd(sys::io_uring_setup(entries, &mut p)?) }; + let fd = sys::io_uring_setup(entries, &mut p)?; let (mm, sq, cq) = unsafe { setup_queue(&fd, &p)? }; @@ -183,14 +182,14 @@ impl IoUring { /// Initiate asynchronous I/O. See [`Submitter::submit`] for more details. #[inline] - pub fn submit(&self) -> io::Result { + pub fn submit(&self) -> Result { self.submitter().submit() } /// Initiate and/or complete asynchronous I/O. See [`Submitter::submit_and_wait`] for more /// details. #[inline] - pub fn submit_and_wait(&self, want: usize) -> io::Result { + pub fn submit_and_wait(&self, want: usize) -> Result { self.submitter().submit_and_wait(want) } @@ -274,7 +273,7 @@ impl Builder { /// /// This is only usable on file systems that support polling and files opened with `O_DIRECT`. pub fn setup_iopoll(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_IOPOLL; + self.params.flags |= sys::IoringSetupFlags::IOPOLL; self } @@ -296,7 +295,7 @@ impl Builder { /// for SQPOLL in newer kernels. Certain stable kernels older than 5.13 may also support /// unprivileged SQPOLL. pub fn setup_sqpoll(&mut self, idle: u32) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_SQPOLL; + self.params.flags |= sys::IoringSetupFlags::SQPOLL; self.params.sq_thread_idle = idle; self } @@ -304,7 +303,7 @@ impl Builder { /// Bind the kernel's poll thread to the specified cpu. This flag is only meaningful when /// [`Builder::setup_sqpoll`] is enabled. pub fn setup_sqpoll_cpu(&mut self, cpu: u32) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_SQ_AFF; + self.params.flags |= sys::IoringSetupFlags::SQ_AFF; self.params.sq_thread_cpu = cpu; self } @@ -312,7 +311,7 @@ impl Builder { /// Create the completion queue with the specified number of entries. The value must be greater /// than `entries`, and may be rounded up to the next power-of-two. pub fn setup_cqsize(&mut self, entries: u32) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_CQSIZE; + self.params.flags |= sys::IoringSetupFlags::CQSIZE; self.params.cq_entries = entries; self } @@ -320,14 +319,14 @@ impl Builder { /// Clamp the sizes of the submission queue and completion queue at their maximum values instead /// of returning an error when you attempt to resize them beyond their maximum values. pub fn setup_clamp(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_CLAMP; + self.params.flags |= sys::IoringSetupFlags::CLAMP; self } /// Share the asynchronous worker thread backend of this io_uring with the specified io_uring /// file descriptor instead of creating a new thread pool. pub fn setup_attach_wq(&mut self, fd: RawFd) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_ATTACH_WQ; + self.params.flags |= sys::IoringSetupFlags::ATTACH_WQ; self.params.wq_fd = fd as _; self } @@ -339,7 +338,7 @@ impl Builder { /// [`Submitter::register_enable_rings`]. Available since 5.10. pub fn setup_r_disabled(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_R_DISABLED; + self.params.flags |= sys::IoringSetupFlags::R_DISABLED; self } @@ -351,7 +350,7 @@ impl Builder { /// creation time, the only difference is if the submit sequence is halted or continued when an /// error is observed. Available since 5.18. pub fn setup_submit_all(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_SUBMIT_ALL; + self.params.flags |= sys::IoringSetupFlags::SUBMIT_ALL; self } @@ -366,7 +365,7 @@ impl Builder { /// one that submitted them. For most other use cases, setting this flag will improve /// performance. Available since 5.19. pub fn setup_coop_taskrun(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_COOP_TASKRUN; + self.params.flags |= sys::IoringSetupFlags::COOP_TASKRUN; self } @@ -378,7 +377,7 @@ impl Builder { /// peek style operation on the CQ ring to see if anything might be pending to reap. Available /// since 5.19. pub fn setup_taskrun_flag(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_TASKRUN_FLAG; + self.params.flags |= sys::IoringSetupFlags::TASKRUN_FLAG; self } @@ -393,7 +392,7 @@ impl Builder { /// example via any of the CQE waiting functions) or else completions may not be delivered. /// Available since 6.1. pub fn setup_defer_taskrun(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_DEFER_TASKRUN; + self.params.flags |= sys::IoringSetupFlags::DEFER_TASKRUN; self } @@ -402,13 +401,13 @@ impl Builder { /// If [`Builder::setup_sqpoll`] is enabled, the polling task is doing the submissions and multiple /// userspace tasks can call [`Submitter::enter`] and higher level APIs. Available since 6.0. pub fn setup_single_issuer(&mut self) -> &mut Self { - self.params.flags |= sys::IORING_SETUP_SINGLE_ISSUER; + self.params.flags |= sys::IoringSetupFlags::SINGLE_ISSUER; self } /// Build an [IoUring], with the specified number of entries in the submission queue and /// completion queue unless [`setup_cqsize`](Self::setup_cqsize) has been called. - pub fn build(&self, entries: u32) -> io::Result> { + pub fn build(&self, entries: u32) -> Result> { let ring = IoUring::with_params(entries, self.params)?; if self.dontfork { @@ -426,37 +425,41 @@ impl Builder { impl Parameters { /// Whether a kernel thread is performing queue polling. Enabled with [`Builder::setup_sqpoll`]. pub fn is_setup_sqpoll(&self) -> bool { - self.0.flags & sys::IORING_SETUP_SQPOLL != 0 + self.0.flags.contains(sys::IoringSetupFlags::SQPOLL) } /// Whether waiting for completion events is done with a busy loop instead of using IRQs. /// Enabled with [`Builder::setup_iopoll`]. pub fn is_setup_iopoll(&self) -> bool { - self.0.flags & sys::IORING_SETUP_IOPOLL != 0 + self.0.flags.contains(sys::IoringSetupFlags::IOPOLL) } /// Whether the single issuer hint is enabled. Enabled with [`Builder::setup_single_issuer`]. pub fn is_setup_single_issuer(&self) -> bool { - self.0.flags & sys::IORING_SETUP_SINGLE_ISSUER != 0 + self.0.flags.contains(sys::IoringSetupFlags::SINGLE_ISSUER) } /// If this flag is set, the SQ and CQ rings were mapped with a single `mmap(2)` call. This /// means that only two syscalls were used instead of three. pub fn is_feature_single_mmap(&self) -> bool { - self.0.features & sys::IORING_FEAT_SINGLE_MMAP != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::SINGLE_MMAP) } /// If this flag is set, io_uring supports never dropping completion events. If a completion /// event occurs and the CQ ring is full, the kernel stores the event internally until such a /// time that the CQ ring has room for more entries. pub fn is_feature_nodrop(&self) -> bool { - self.0.features & sys::IORING_FEAT_NODROP != 0 + self.0.features.contains(sys::IoringFeatureFlags::NODROP) } /// If this flag is set, applications can be certain that any data for async offload has been /// consumed when the kernel has consumed the SQE. pub fn is_feature_submit_stable(&self) -> bool { - self.0.features & sys::IORING_FEAT_SUBMIT_STABLE != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::SUBMIT_STABLE) } /// If this flag is set, applications can specify offset == -1 with [`Readv`](opcode::Readv), @@ -469,7 +472,9 @@ impl Parameters { /// then the end result will not be as expected. /// This is similar to threads sharing a file descriptor and doing IO using the current file position. pub fn is_feature_rw_cur_pos(&self) -> bool { - self.0.features & sys::IORING_FEAT_RW_CUR_POS != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::RW_CUR_POS) } /// If this flag is set, then io_uring guarantees that both sync and async execution of @@ -480,7 +485,9 @@ impl Parameters { /// Note that this is the default behavior, tasks can still register different personalities /// through [`Submitter::register_personality`]. pub fn is_feature_cur_personality(&self) -> bool { - self.0.features & sys::IORING_FEAT_CUR_PERSONALITY != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::CUR_PERSONALITY) } /// Whether async pollable I/O is fast. @@ -496,7 +503,7 @@ impl Parameters { /// eliminates the need to do so. If this flag is set, requests waiting on space/data consume a /// lot less resources doing so as they are not blocking a thread. Available since kernel 5.7. pub fn is_feature_fast_poll(&self) -> bool { - self.0.features & sys::IORING_FEAT_FAST_POLL != 0 + self.0.features.contains(sys::IoringFeatureFlags::FAST_POLL) } /// Whether poll events are stored using 32 bits instead of 16. This allows the user to use @@ -506,14 +513,18 @@ impl Parameters { /// based flags. Most notably EPOLLEXCLUSIVE which allows exclusive (waking single waiters) /// behavior. Available since kernel 5.9. pub fn is_feature_poll_32bits(&self) -> bool { - self.0.features & sys::IORING_FEAT_POLL_32BITS != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::POLL_32BITS) } /// If this flag is set, the IORING_SETUP_SQPOLL feature no longer requires the use of fixed /// files. Any normal file descriptor can be used for IO commands without needing registration. /// Available since kernel 5.11. pub fn is_feature_sqpoll_nonfixed(&self) -> bool { - self.0.features & sys::IORING_FEAT_SQPOLL_NONFIXED != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::SQPOLL_NONFIXED) } /// If this flag is set, then the io_uring_enter(2) system call supports passing in an extended @@ -531,7 +542,7 @@ impl Parameters { /// and a pointer to this struct must be passed in if IORING_ENTER_EXT_ARG is set in the flags /// for the enter system call. Available since kernel 5.11. pub fn is_feature_ext_arg(&self) -> bool { - self.0.features & sys::IORING_FEAT_EXT_ARG != 0 + self.0.features.contains(sys::IoringFeatureFlags::EXT_ARG) } /// If this flag is set, io_uring is using native workers for its async helpers. Previous @@ -539,7 +550,9 @@ impl Parameters { /// but later kernels will actively create what looks more like regular process threads /// instead. Available since kernel 5.12. pub fn is_feature_native_workers(&self) -> bool { - self.0.features & sys::IORING_FEAT_NATIVE_WORKERS != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::NATIVE_WORKERS) } /// Whether the kernel supports tagging resources. @@ -549,7 +562,7 @@ impl Parameters { /// whereas before the full set would have to be unregistered first. Available since kernel /// 5.13. pub fn is_feature_resource_tagging(&self) -> bool { - self.0.features & sys::IORING_FEAT_RSRC_TAGS != 0 + self.0.features.contains(sys::IoringFeatureFlags::RSRC_TAGS) } /// Whether the kernel supports `IOSQE_CQE_SKIP_SUCCESS`. @@ -557,7 +570,7 @@ impl Parameters { /// This feature allows skipping the generation of a CQE if a SQE executes normally. Available /// since kernel 5.17. pub fn is_feature_skip_cqe_on_success(&self) -> bool { - self.0.features & sys::IORING_FEAT_CQE_SKIP != 0 + self.0.features.contains(sys::IoringFeatureFlags::CQE_SKIP) } /// Whether the kernel supports deferred file assignment. @@ -570,7 +583,9 @@ impl Parameters { /// the kernel will defer file assignment until execution of a given request is started. /// Available since kernel 5.17. pub fn is_feature_linked_file(&self) -> bool { - self.0.features & sys::IORING_FEAT_LINKED_FILE != 0 + self.0 + .features + .contains(sys::IoringFeatureFlags::LINKED_FILE) } /// The number of submission queue entries allocated. @@ -584,8 +599,8 @@ impl Parameters { } } -impl std::fmt::Debug for Parameters { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl core::fmt::Debug for Parameters { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("Parameters") .field("is_setup_sqpoll", &self.is_setup_sqpoll()) .field("is_setup_iopoll", &self.is_setup_iopoll()) @@ -611,9 +626,22 @@ impl AsRawFd for IoUring { } } -#[cfg(feature = "io_safety")] impl AsFd for IoUring { fn as_fd(&self) -> BorrowedFd<'_> { self.fd.as_fd() } } + +// Test the readme code +// From: https://github.com/rust-lang/cargo/issues/383#issuecomment-720873790 +#[cfg(doctest)] +mod test_readme { + macro_rules! external_doc_test { + ($x:expr) => { + #[doc = $x] + extern "C" {} + }; + } + + external_doc_test!(include_str!("../README.md")); +} diff --git a/src/opcode.rs b/src/opcode.rs index 4aec06b..21ca146 100644 --- a/src/opcode.rs +++ b/src/opcode.rs @@ -2,9 +2,10 @@ #![allow(clippy::new_without_default)] -use std::convert::TryInto; -use std::mem; -use std::os::unix::io::RawFd; +use core::convert::TryInto; +use core::mem; + +use rustix::fd::RawFd; use crate::squeue::Entry; use crate::squeue::Entry128; @@ -17,7 +18,7 @@ macro_rules! assign_fd { sealed::Target::Fd(fd) => $sqe.fd = fd, sealed::Target::Fixed(idx) => { $sqe.fd = idx as _; - $sqe.flags |= crate::squeue::Flags::FIXED_FILE.bits(); + $sqe.flags |= sys::IoringSqeFlags::FIXED_FILE; } } }; @@ -76,7 +77,7 @@ macro_rules! opcode { /// The opcode of the operation. This can be passed to /// [`Probe::is_supported`](crate::Probe::is_supported) to check if this operation is /// supported with the current kernel. - pub const CODE: u8 = $opcode as _; + pub const CODE: sys::IoringOp = $opcode as _; $( $( #[$opt_meta] )* @@ -97,7 +98,7 @@ macro_rules! opcode { /// inline zeroed to improve codegen #[inline(always)] fn sqe_zeroed() -> sys::io_uring_sqe { - unsafe { std::mem::zeroed() } + Default::default() } opcode! { @@ -107,7 +108,7 @@ opcode! { #[derive(Debug)] pub struct Nop { ;; } - pub const CODE = sys::IORING_OP_NOP; + pub const CODE = sys::IoringOp::Nop; pub fn build(self) -> Entry { let Nop {} = self; @@ -124,18 +125,18 @@ opcode! { #[derive(Debug)] pub struct Readv { fd: { impl sealed::UseFixed }, - iovec: { *const libc::iovec }, + iovec: { *const sys::iovec }, len: { u32 }, ;; ioprio: u16 = 0, offset: u64 = 0, /// specified for read operations, contains a bitwise OR of per-I/O flags, /// as described in the `preadv2(2)` man page. - rw_flags: types::RwFlags = 0, + rw_flags: types::RwFlags = types::RwFlags::empty(), buf_group: u16 = 0 } - pub const CODE = sys::IORING_OP_READV; + pub const CODE = sys::IoringOp::Readv; pub fn build(self) -> Entry { let Readv { @@ -148,12 +149,12 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = iovec as _; - sqe.len = len; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.rw_flags = rw_flags; - sqe.__bindgen_anon_4.buf_group = buf_group; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = iovec as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.rw_flags = rw_flags; + sqe.buf.buf_group = buf_group; Entry(sqe) } } @@ -163,17 +164,17 @@ opcode! { #[derive(Debug)] pub struct Writev { fd: { impl sealed::UseFixed }, - iovec: { *const libc::iovec }, + iovec: { *const sys::iovec }, len: { u32 }, ;; ioprio: u16 = 0, offset: u64 = 0, /// specified for write operations, contains a bitwise OR of per-I/O flags, /// as described in the `preadv2(2)` man page. - rw_flags: types::RwFlags = 0 + rw_flags: types::RwFlags = types::RwFlags::empty() } - pub const CODE = sys::IORING_OP_WRITEV; + pub const CODE = sys::IoringOp::Writev; pub fn build(self) -> Entry { let Writev { @@ -185,11 +186,11 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = iovec as _; - sqe.len = len; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.rw_flags = rw_flags; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = iovec as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.rw_flags = rw_flags; Entry(sqe) } } @@ -213,7 +214,7 @@ opcode! { flags: types::FsyncFlags = types::FsyncFlags::empty() } - pub const CODE = sys::IORING_OP_FSYNC; + pub const CODE = sys::IoringOp::Fsync; pub fn build(self) -> Entry { let Fsync { fd, flags } = self; @@ -221,7 +222,7 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_3.fsync_flags = flags.bits(); + sqe.op_flags.fsync_flags = sys::IoringFsyncFlags::from_bits_retain(flags.bits()); Entry(sqe) } } @@ -244,10 +245,10 @@ opcode! { ioprio: u16 = 0, /// specified for read operations, contains a bitwise OR of per-I/O flags, /// as described in the `preadv2(2)` man page. - rw_flags: types::RwFlags = 0 + rw_flags: types::RwFlags = types::RwFlags::empty() } - pub const CODE = sys::IORING_OP_READ_FIXED; + pub const CODE = sys::IoringOp::ReadFixed; pub fn build(self) -> Entry { let ReadFixed { @@ -260,12 +261,12 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = buf as _; - sqe.len = len; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.rw_flags = rw_flags; - sqe.__bindgen_anon_4.buf_index = buf_index; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = buf as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.rw_flags = rw_flags; + sqe.buf.buf_index = buf_index; Entry(sqe) } } @@ -288,10 +289,10 @@ opcode! { offset: u64 = 0, /// specified for write operations, contains a bitwise OR of per-I/O flags, /// as described in the `preadv2(2)` man page. - rw_flags: types::RwFlags = 0 + rw_flags: types::RwFlags = types::RwFlags::empty() } - pub const CODE = sys::IORING_OP_WRITE_FIXED; + pub const CODE = sys::IoringOp::WriteFixed; pub fn build(self) -> Entry { let WriteFixed { @@ -304,12 +305,12 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = buf as _; - sqe.len = len; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.rw_flags = rw_flags; - sqe.__bindgen_anon_4.buf_index = buf_index; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = buf as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.rw_flags = rw_flags; + sqe.buf.buf_index = buf_index; Entry(sqe) } } @@ -336,7 +337,7 @@ opcode! { multi: bool = false } - pub const CODE = sys::IORING_OP_POLL_ADD; + pub const CODE = sys::IoringOp::PollAdd; pub fn build(self) -> Entry { let PollAdd { fd, flags, multi } = self; @@ -345,18 +346,18 @@ opcode! { sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); if multi { - sqe.len = sys::IORING_POLL_ADD_MULTI; + sqe.len.poll_flags = sys::IoringPollFlags::ADD_MULTI; } #[cfg(target_endian = "little")] { - sqe.__bindgen_anon_3.poll32_events = flags; + sqe.op_flags.poll32_events = flags; } #[cfg(target_endian = "big")] { let x = flags << 16; let y = flags >> 16; let flags = x | y; - sqe.__bindgen_anon_3.poll32_events = flags; + sqe.op_flags.poll32_events = flags; } Entry(sqe) @@ -374,7 +375,7 @@ opcode! { ;; } - pub const CODE = sys::IORING_OP_POLL_REMOVE; + pub const CODE = sys::IoringOp::PollRemove; pub fn build(self) -> Entry { let PollRemove { user_data } = self; @@ -382,7 +383,7 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_2.addr = user_data; + sqe.addr_or_splice_off_in.addr.ptr = user_data as _; Entry(sqe) } } @@ -400,7 +401,7 @@ opcode! { flags: u32 = 0 } - pub const CODE = sys::IORING_OP_SYNC_FILE_RANGE; + pub const CODE = sys::IoringOp::SyncFileRange; pub fn build(self) -> Entry { let SyncFileRange { @@ -412,9 +413,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.len = len; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.sync_range_flags = flags; + sqe.len.len = len as _; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.sync_range_flags = flags; Entry(sqe) } } @@ -427,13 +428,13 @@ opcode! { #[derive(Debug)] pub struct SendMsg { fd: { impl sealed::UseFixed }, - msg: { *const libc::msghdr }, + msg: { *const sys::msghdr }, ;; ioprio: u16 = 0, - flags: u32 = 0 + flags: sys::SendFlags = sys::SendFlags::empty() } - pub const CODE = sys::IORING_OP_SENDMSG; + pub const CODE = sys::IoringOp::Sendmsg; pub fn build(self) -> Entry { let SendMsg { fd, msg, ioprio, flags } = self; @@ -441,10 +442,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = msg as _; - sqe.len = 1; - sqe.__bindgen_anon_3.msg_flags = flags; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = msg as _; + sqe.len.len = 1; + sqe.op_flags.send_flags = flags; Entry(sqe) } } @@ -456,14 +457,14 @@ opcode! { #[derive(Debug)] pub struct RecvMsg { fd: { impl sealed::UseFixed }, - msg: { *mut libc::msghdr }, + msg: { *mut sys::msghdr }, ;; ioprio: u16 = 0, - flags: u32 = 0, + flags: sys::RecvFlags = sys::RecvFlags::empty(), buf_group: u16 = 0 } - pub const CODE = sys::IORING_OP_RECVMSG; + pub const CODE = sys::IoringOp::Recvmsg; pub fn build(self) -> Entry { let RecvMsg { fd, msg, ioprio, flags, buf_group } = self; @@ -471,11 +472,11 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = msg as _; - sqe.len = 1; - sqe.__bindgen_anon_3.msg_flags = flags; - sqe.__bindgen_anon_4.buf_group = buf_group; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = msg as _; + sqe.len.len = 1; + sqe.op_flags.recv_flags = flags; + sqe.buf.buf_group = buf_group; Entry(sqe) } } @@ -506,14 +507,14 @@ opcode! { #[derive(Debug)] pub struct RecvMsgMulti { fd: { impl sealed::UseFixed }, - msg: { *const libc::msghdr }, + msg: { *const sys::msghdr }, buf_group: { u16 }, ;; - ioprio: u16 = 0, - flags: u32 = 0 + ioprio: sys::IoringRecvFlags = sys::IoringRecvFlags::empty(), + flags: sys::RecvFlags = sys::RecvFlags::empty() } - pub const CODE = sys::IORING_OP_RECVMSG; + pub const CODE = sys::IoringOp::Recvmsg; pub fn build(self) -> Entry { let RecvMsgMulti { fd, msg, buf_group, ioprio, flags } = self; @@ -521,12 +522,12 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_2.addr = msg as _; - sqe.len = 1; - sqe.__bindgen_anon_3.msg_flags = flags; - sqe.__bindgen_anon_4.buf_group = buf_group; - sqe.flags |= 1 << sys::IOSQE_BUFFER_SELECT_BIT; - sqe.ioprio = ioprio | (sys::IORING_RECV_MULTISHOT as u16); + sqe.addr_or_splice_off_in.addr.ptr = msg as _; + sqe.len.len = 1; + sqe.op_flags.recv_flags = flags; + sqe.buf.buf_group = buf_group; + sqe.flags |= sys::IoringSqeFlags::BUFFER_SELECT; + sqe.ioprio.recv_flags = ioprio | sys::IoringRecvFlags::MULTISHOT; Entry(sqe) } } @@ -551,7 +552,7 @@ opcode! { flags: types::TimeoutFlags = types::TimeoutFlags::empty() } - pub const CODE = sys::IORING_OP_TIMEOUT; + pub const CODE = sys::IoringOp::Timeout; pub fn build(self) -> Entry { let Timeout { timespec, count, flags } = self; @@ -559,10 +560,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_2.addr = timespec as _; - sqe.len = 1; - sqe.__bindgen_anon_1.off = count as _; - sqe.__bindgen_anon_3.timeout_flags = flags.bits(); + sqe.addr_or_splice_off_in.addr.ptr = timespec as _; + sqe.len.len = 1; + sqe.off_or_addr2.off = count as _; + sqe.op_flags.timeout_flags = sys::IoringTimeoutFlags::from_bits_retain(flags.bits()); Entry(sqe) } } @@ -576,7 +577,7 @@ opcode! { ;; } - pub const CODE = sys::IORING_OP_TIMEOUT_REMOVE; + pub const CODE = sys::IoringOp::TimeoutRemove; pub fn build(self) -> Entry { let TimeoutRemove { user_data } = self; @@ -584,7 +585,7 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_2.addr = user_data; + sqe.addr_or_splice_off_in.user_data.u64_ = user_data; Entry(sqe) } } @@ -599,7 +600,7 @@ opcode! { flags: types::TimeoutFlags = types::TimeoutFlags::empty() } - pub const CODE = sys::IORING_OP_TIMEOUT_REMOVE; + pub const CODE = sys::IoringOp::TimeoutRemove; pub fn build(self) -> Entry { let TimeoutUpdate { user_data, timespec, flags } = self; @@ -607,9 +608,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_1.off = timespec as _; - sqe.__bindgen_anon_2.addr = user_data; - sqe.__bindgen_anon_3.timeout_flags = flags.bits() | sys::IORING_TIMEOUT_UPDATE; + sqe.off_or_addr2.off = timespec as _; + sqe.addr_or_splice_off_in.addr.ptr = user_data as _; + sqe.op_flags.timeout_flags = sys::IoringTimeoutFlags::from_bits_retain(flags.bits()) | sys::IoringTimeoutFlags::UPDATE; Entry(sqe) } } @@ -618,14 +619,14 @@ opcode! { /// Accept a new connection on a socket, equivalent to `accept4(2)`. pub struct Accept { fd: { impl sealed::UseFixed }, - addr: { *mut libc::sockaddr }, - addrlen: { *mut libc::socklen_t }, + addr: { *mut sys::sockaddr }, + addrlen: { *mut sys::socklen_t }, ;; file_index: Option = None, - flags: i32 = 0 + flags: sys::SocketFlags = sys::SocketFlags::empty() } - pub const CODE = sys::IORING_OP_ACCEPT; + pub const CODE = sys::IoringOp::Accept; pub fn build(self) -> Entry { let Accept { fd, addr, addrlen, file_index, flags } = self; @@ -633,11 +634,11 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_2.addr = addr as _; - sqe.__bindgen_anon_1.addr2 = addrlen as _; - sqe.__bindgen_anon_3.accept_flags = flags as _; + sqe.addr_or_splice_off_in.addr.ptr = addr as _; + sqe.off_or_addr2.addr2.ptr = addrlen as _; + sqe.op_flags.accept_flags = flags; if let Some(dest) = file_index { - sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg(); + sqe.splice_fd_in_or_file_index.file_index = dest.kernel_index_arg(); } Entry(sqe) } @@ -652,7 +653,7 @@ opcode! { // TODO flags } - pub const CODE = sys::IORING_OP_ASYNC_CANCEL; + pub const CODE = sys::IoringOp::AsyncCancel; pub fn build(self) -> Entry { let AsyncCancel { user_data } = self; @@ -660,7 +661,7 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_2.addr = user_data; + sqe.addr_or_splice_off_in.addr.ptr = user_data as _; Entry(sqe) } } @@ -675,7 +676,7 @@ opcode! { flags: types::TimeoutFlags = types::TimeoutFlags::empty() } - pub const CODE = sys::IORING_OP_LINK_TIMEOUT; + pub const CODE = sys::IoringOp::LinkTimeout; pub fn build(self) -> Entry { let LinkTimeout { timespec, flags } = self; @@ -683,9 +684,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_2.addr = timespec as _; - sqe.len = 1; - sqe.__bindgen_anon_3.timeout_flags = flags.bits(); + sqe.addr_or_splice_off_in.addr.ptr = timespec as _; + sqe.len.len = 1; + sqe.op_flags.timeout_flags = sys::IoringTimeoutFlags::from_bits_retain(flags.bits()); Entry(sqe) } } @@ -694,12 +695,12 @@ opcode! { /// Connect a socket, equivalent to `connect(2)`. pub struct Connect { fd: { impl sealed::UseFixed }, - addr: { *const libc::sockaddr }, - addrlen: { libc::socklen_t } + addr: { *const sys::sockaddr }, + addrlen: { sys::socklen_t } ;; } - pub const CODE = sys::IORING_OP_CONNECT; + pub const CODE = sys::IoringOp::Connect; pub fn build(self) -> Entry { let Connect { fd, addr, addrlen } = self; @@ -707,8 +708,8 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_2.addr = addr as _; - sqe.__bindgen_anon_1.off = addrlen as _; + sqe.addr_or_splice_off_in.addr.ptr = addr as _; + sqe.off_or_addr2.off = addrlen as _; Entry(sqe) } } @@ -725,7 +726,7 @@ opcode! { mode: i32 = 0 } - pub const CODE = sys::IORING_OP_FALLOCATE; + pub const CODE = sys::IoringOp::Fallocate; pub fn build(self) -> Entry { let Fallocate { fd, len, offset, mode } = self; @@ -733,9 +734,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_2.addr = len; - sqe.len = mode as _; - sqe.__bindgen_anon_1.off = offset; + sqe.addr_or_splice_off_in.addr.ptr = len as _; + sqe.len.len = mode as _; + sqe.off_or_addr2.off = offset as _; Entry(sqe) } } @@ -744,14 +745,14 @@ opcode! { /// Open a file, equivalent to `openat(2)`. pub struct OpenAt { dirfd: { impl sealed::UseFd }, - pathname: { *const libc::c_char }, + pathname: { *const sys::c_char }, ;; file_index: Option = None, - flags: i32 = 0, - mode: libc::mode_t = 0 + flags: sys::OFlags = sys::OFlags::empty(), + mode: sys::Mode = sys::Mode::empty() } - pub const CODE = sys::IORING_OP_OPENAT; + pub const CODE = sys::IoringOp::Openat; pub fn build(self) -> Entry { let OpenAt { dirfd, pathname, file_index, flags, mode } = self; @@ -759,11 +760,11 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = dirfd; - sqe.__bindgen_anon_2.addr = pathname as _; - sqe.len = mode; - sqe.__bindgen_anon_3.open_flags = flags as _; + sqe.addr_or_splice_off_in.addr.ptr = pathname as _; + sqe.len.len = mode.bits(); + sqe.op_flags.open_flags = flags; if let Some(dest) = file_index { - sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg(); + sqe.splice_fd_in_or_file_index.file_index = dest.kernel_index_arg(); } Entry(sqe) } @@ -778,7 +779,7 @@ opcode! { ;; } - pub const CODE = sys::IORING_OP_CLOSE; + pub const CODE = sys::IoringOp::Close; pub fn build(self) -> Entry { let Close { fd } = self; @@ -789,7 +790,7 @@ opcode! { sealed::Target::Fd(fd) => sqe.fd = fd, sealed::Target::Fixed(idx) => { sqe.fd = 0; - sqe.__bindgen_anon_5.file_index = idx + 1; + sqe.splice_fd_in_or_file_index.file_index = idx + 1; } } Entry(sqe) @@ -807,7 +808,7 @@ opcode! { offset: i32 = 0 } - pub const CODE = sys::IORING_OP_FILES_UPDATE; + pub const CODE = sys::IoringOp::FilesUpdate; pub fn build(self) -> Entry { let FilesUpdate { fds, len, offset } = self; @@ -815,9 +816,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_2.addr = fds as _; - sqe.len = len; - sqe.__bindgen_anon_1.off = offset as _; + sqe.addr_or_splice_off_in.addr.ptr = fds as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; Entry(sqe) } } @@ -826,14 +827,14 @@ opcode! { /// Get file status, equivalent to `statx(2)`. pub struct Statx { dirfd: { impl sealed::UseFd }, - pathname: { *const libc::c_char }, - statxbuf: { *mut types::statx }, + pathname: { *const sys::c_char }, + statxbuf: { *mut types::Statx }, ;; - flags: i32 = 0, - mask: u32 = 0 + flags: sys::AtFlags = sys::AtFlags::empty(), + mask: sys::StatxFlags = sys::StatxFlags::empty() } - pub const CODE = sys::IORING_OP_STATX; + pub const CODE = sys::IoringOp::Statx; pub fn build(self) -> Entry { let Statx { @@ -844,10 +845,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = dirfd; - sqe.__bindgen_anon_2.addr = pathname as _; - sqe.len = mask; - sqe.__bindgen_anon_1.off = statxbuf as _; - sqe.__bindgen_anon_3.statx_flags = flags as _; + sqe.addr_or_splice_off_in.addr.ptr = pathname as _; + sqe.len.len = mask.bits(); + sqe.off_or_addr2.off = statxbuf as _; + sqe.op_flags.statx_flags = flags; Entry(sqe) } } @@ -859,7 +860,7 @@ opcode! { /// * `addr` contains the buffer in question, /// * `len` contains the length of the IO operation, /// - /// These are non-vectored versions of the `IORING_OP_READV` and `IORING_OP_WRITEV` opcodes. + /// These are non-vectored versions of the `IoringOp::READV` and `IoringOp::WRITEV` opcodes. /// See also `read(2)` and `write(2)` for the general description of the related system call. /// /// Available since 5.6. @@ -875,11 +876,11 @@ opcode! { /// like the `read(2)` and `write(2)` system calls. offset: u64 = 0, ioprio: u16 = 0, - rw_flags: types::RwFlags = 0, + rw_flags: types::RwFlags = types::RwFlags::empty(), buf_group: u16 = 0 } - pub const CODE = sys::IORING_OP_READ; + pub const CODE = sys::IoringOp::Read; pub fn build(self) -> Entry { let Read { @@ -892,12 +893,12 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = buf as _; - sqe.len = len; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.rw_flags = rw_flags; - sqe.__bindgen_anon_4.buf_group = buf_group; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = buf as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.rw_flags = rw_flags; + sqe.buf.buf_group = buf_group; Entry(sqe) } } @@ -909,7 +910,7 @@ opcode! { /// * `addr` contains the buffer in question, /// * `len` contains the length of the IO operation, /// - /// These are non-vectored versions of the `IORING_OP_READV` and `IORING_OP_WRITEV` opcodes. + /// These are non-vectored versions of the `IoringOp::READV` and `IoringOp::WRITEV` opcodes. /// See also `read(2)` and `write(2)` for the general description of the related system call. /// /// Available since 5.6. @@ -925,10 +926,10 @@ opcode! { /// like the `read(2)` and `write(2)` system calls. offset: u64 = 0, ioprio: u16 = 0, - rw_flags: types::RwFlags = 0 + rw_flags: types::RwFlags = types::RwFlags::empty() } - pub const CODE = sys::IORING_OP_WRITE; + pub const CODE = sys::IoringOp::Write; pub fn build(self) -> Entry { let Write { @@ -940,11 +941,11 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = buf as _; - sqe.len = len; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.rw_flags = rw_flags; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = buf as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.rw_flags = rw_flags; Entry(sqe) } } @@ -953,13 +954,13 @@ opcode! { /// Predeclare an access pattern for file data, equivalent to `posix_fadvise(2)`. pub struct Fadvise { fd: { impl sealed::UseFixed }, - len: { libc::off_t }, - advice: { i32 }, + len: { u32 }, + advice: { sys::Advice }, ;; offset: u64 = 0, } - pub const CODE = sys::IORING_OP_FADVISE; + pub const CODE = sys::IoringOp::Fadvise; pub fn build(self) -> Entry { let Fadvise { fd, len, advice, offset } = self; @@ -967,9 +968,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.len = len as _; - sqe.__bindgen_anon_1.off = offset; - sqe.__bindgen_anon_3.fadvise_advice = advice as _; + sqe.len.len = len; + sqe.off_or_addr2.off = offset as _; + sqe.op_flags.fadvise_advice = advice; Entry(sqe) } } @@ -977,13 +978,13 @@ opcode! { opcode! { /// Give advice about use of memory, equivalent to `madvise(2)`. pub struct Madvise { - addr: { *const libc::c_void }, - len: { libc::off_t }, - advice: { i32 }, + addr: { *const core::ffi::c_void }, + len: { u32 }, + advice: { sys::Advice }, ;; } - pub const CODE = sys::IORING_OP_MADVISE; + pub const CODE = sys::IoringOp::Madvise; pub fn build(self) -> Entry { let Madvise { addr, len, advice } = self; @@ -991,9 +992,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = -1; - sqe.__bindgen_anon_2.addr = addr as _; - sqe.len = len as _; - sqe.__bindgen_anon_3.fadvise_advice = advice as _; + sqe.addr_or_splice_off_in.addr.ptr = addr as _; + sqe.len.len = len; + sqe.op_flags.fadvise_advice = advice as _; Entry(sqe) } } @@ -1005,10 +1006,10 @@ opcode! { buf: { *const u8 }, len: { u32 }, ;; - flags: i32 = 0 + flags: sys::SendFlags = sys::SendFlags::empty() } - pub const CODE = sys::IORING_OP_SEND; + pub const CODE = sys::IoringOp::Send; pub fn build(self) -> Entry { let Send { fd, buf, len, flags } = self; @@ -1016,9 +1017,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_2.addr = buf as _; - sqe.len = len; - sqe.__bindgen_anon_3.msg_flags = flags as _; + sqe.addr_or_splice_off_in.addr.ptr = buf as _; + sqe.len.len = len; + sqe.op_flags.send_flags = flags; Entry(sqe) } } @@ -1030,11 +1031,11 @@ opcode! { buf: { *mut u8 }, len: { u32 }, ;; - flags: i32 = 0, + flags: sys::RecvFlags = sys::RecvFlags::empty(), buf_group: u16 = 0 } - pub const CODE = sys::IORING_OP_RECV; + pub const CODE = sys::IoringOp::Recv; pub fn build(self) -> Entry { let Recv { fd, buf, len, flags, buf_group } = self; @@ -1042,10 +1043,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_2.addr = buf as _; - sqe.len = len; - sqe.__bindgen_anon_3.msg_flags = flags as _; - sqe.__bindgen_anon_4.buf_group = buf_group; + sqe.addr_or_splice_off_in.addr.ptr = buf as _; + sqe.len.len = len; + sqe.op_flags.recv_flags = flags; + sqe.buf.buf_group = buf_group; Entry(sqe) } } @@ -1070,10 +1071,10 @@ opcode! { fd: { impl sealed::UseFixed }, buf_group: { u16 }, ;; - flags: i32 = 0, + flags: sys::RecvFlags = sys::RecvFlags::empty(), } - pub const CODE = sys::IORING_OP_RECV; + pub const CODE = sys::IoringOp::Recv; pub fn build(self) -> Entry { let RecvMulti { fd, buf_group, flags } = self; @@ -1081,10 +1082,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_3.msg_flags = flags as _; - sqe.__bindgen_anon_4.buf_group = buf_group; - sqe.flags |= 1 << sys::IOSQE_BUFFER_SELECT_BIT; - sqe.ioprio = sys::IORING_RECV_MULTISHOT as _; + sqe.op_flags.recv_flags = flags; + sqe.buf.buf_group = buf_group; + sqe.flags |= sys::IoringSqeFlags::BUFFER_SELECT; + sqe.ioprio.recv_flags = sys::IoringRecvFlags::MULTISHOT; Entry(sqe) } } @@ -1093,13 +1094,13 @@ opcode! { /// Open a file, equivalent to `openat2(2)`. pub struct OpenAt2 { dirfd: { impl sealed::UseFd }, - pathname: { *const libc::c_char }, + pathname: { *const sys::c_char }, how: { *const types::OpenHow } ;; file_index: Option = None, } - pub const CODE = sys::IORING_OP_OPENAT2; + pub const CODE = sys::IoringOp::Openat2; pub fn build(self) -> Entry { let OpenAt2 { dirfd, pathname, how, file_index } = self; @@ -1107,11 +1108,11 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = dirfd; - sqe.__bindgen_anon_2.addr = pathname as _; - sqe.len = mem::size_of::() as _; - sqe.__bindgen_anon_1.off = how as _; + sqe.addr_or_splice_off_in.addr.ptr = pathname as _; + sqe.len.len = mem::size_of::() as _; + sqe.off_or_addr2.off = how as _; if let Some(dest) = file_index { - sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg(); + sqe.splice_fd_in_or_file_index.file_index = dest.kernel_index_arg(); } Entry(sqe) } @@ -1123,11 +1124,11 @@ opcode! { epfd: { impl sealed::UseFixed }, fd: { impl sealed::UseFd }, op: { i32 }, - ev: { *const types::epoll_event }, + ev: { *const types::EpollEvent }, ;; } - pub const CODE = sys::IORING_OP_EPOLL_CTL; + pub const CODE = sys::IoringOp::EpollCtl; pub fn build(self) -> Entry { let EpollCtl { epfd, fd, op, ev } = self; @@ -1135,9 +1136,9 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = epfd); - sqe.__bindgen_anon_2.addr = ev as _; - sqe.len = op as _; - sqe.__bindgen_anon_1.off = fd as _; + sqe.addr_or_splice_off_in.addr.ptr = ev as _; + sqe.len.len = op as _; + sqe.off_or_addr2.off = fd as _; Entry(sqe) } } @@ -1157,10 +1158,10 @@ opcode! { len: { u32 }, ;; /// see man `splice(2)` for description of flags. - flags: u32 = 0 + flags: sys::SpliceFlags = sys::SpliceFlags::empty() } - pub const CODE = sys::IORING_OP_SPLICE; + pub const CODE = sys::IoringOp::Splice; pub fn build(self) -> Entry { let Splice { fd_in, off_in, fd_out, off_out, len, mut flags } = self; @@ -1168,19 +1169,19 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd_out); - sqe.len = len; - sqe.__bindgen_anon_1.off = off_out as _; + sqe.len.len = len; + sqe.off_or_addr2.off = off_out as _; - sqe.__bindgen_anon_5.splice_fd_in = match fd_in { + sqe.splice_fd_in_or_file_index.splice_fd_in = match fd_in { sealed::Target::Fd(fd) => fd, sealed::Target::Fixed(idx) => { - flags |= sys::SPLICE_F_FD_IN_FIXED; + flags |= sys::SpliceFlags::FD_IN_FIXED; idx as _ } }; - sqe.__bindgen_anon_2.splice_off_in = off_in as _; - sqe.__bindgen_anon_3.splice_flags = flags; + sqe.addr_or_splice_off_in.splice_off_in = off_in as _; + sqe.op_flags.splice_flags = flags; Entry(sqe) } } @@ -1198,7 +1199,7 @@ opcode! { ;; } - pub const CODE = sys::IORING_OP_PROVIDE_BUFFERS; + pub const CODE = sys::IoringOp::ProvideBuffers; pub fn build(self) -> Entry { let ProvideBuffers { addr, len, nbufs, bgid, bid } = self; @@ -1206,10 +1207,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = nbufs as _; - sqe.__bindgen_anon_2.addr = addr as _; - sqe.len = len as _; - sqe.__bindgen_anon_1.off = bid as _; - sqe.__bindgen_anon_4.buf_group = bgid; + sqe.addr_or_splice_off_in.addr.ptr = addr as _; + sqe.len.len = len as _; + sqe.off_or_addr2.off = bid as _; + sqe.buf.buf_group = bgid; Entry(sqe) } } @@ -1223,7 +1224,7 @@ opcode! { ;; } - pub const CODE = sys::IORING_OP_REMOVE_BUFFERS; + pub const CODE = sys::IoringOp::RemoveBuffers; pub fn build(self) -> Entry { let RemoveBuffers { nbufs, bgid } = self; @@ -1231,7 +1232,7 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = nbufs as _; - sqe.__bindgen_anon_4.buf_group = bgid; + sqe.buf.buf_group = bgid; Entry(sqe) } } @@ -1245,10 +1246,10 @@ opcode! { fd_out: { impl sealed::UseFixed }, len: { u32 } ;; - flags: u32 = 0 + flags: sys::SpliceFlags = sys::SpliceFlags::empty() } - pub const CODE = sys::IORING_OP_TEE; + pub const CODE = sys::IoringOp::Tee; pub fn build(self) -> Entry { let Tee { fd_in, fd_out, len, mut flags } = self; @@ -1257,17 +1258,17 @@ opcode! { sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd_out); - sqe.len = len; + sqe.len.len = len; - sqe.__bindgen_anon_5.splice_fd_in = match fd_in { + sqe.splice_fd_in_or_file_index.splice_fd_in = match fd_in { sealed::Target::Fd(fd) => fd, sealed::Target::Fixed(idx) => { - flags |= sys::SPLICE_F_FD_IN_FIXED; + flags |= sys::SpliceFlags::FD_IN_FIXED; idx as _ } }; - sqe.__bindgen_anon_3.splice_flags = flags; + sqe.op_flags.splice_flags = flags; Entry(sqe) } @@ -1284,7 +1285,7 @@ opcode! { ;; } - pub const CODE = sys::IORING_OP_SHUTDOWN; + pub const CODE = sys::IoringOp::Shutdown; pub fn build(self) -> Entry { let Shutdown { fd, how } = self; @@ -1292,7 +1293,7 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.len = how as _; + sqe.len.len = how as _; Entry(sqe) } } @@ -1302,14 +1303,14 @@ opcode! { // Available since kernel 5.11. pub struct RenameAt { olddirfd: { impl sealed::UseFd }, - oldpath: { *const libc::c_char }, + oldpath: { *const sys::c_char }, newdirfd: { impl sealed::UseFd }, - newpath: { *const libc::c_char }, + newpath: { *const sys::c_char }, ;; - flags: u32 = 0 + flags: sys::RenameFlags = sys::RenameFlags::empty() } - pub const CODE = sys::IORING_OP_RENAMEAT; + pub const CODE = sys::IoringOp::Renameat; pub fn build(self) -> Entry { let RenameAt { @@ -1321,10 +1322,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = olddirfd; - sqe.__bindgen_anon_2.addr = oldpath as _; - sqe.len = newdirfd as _; - sqe.__bindgen_anon_1.off = newpath as _; - sqe.__bindgen_anon_3.rename_flags = flags; + sqe.addr_or_splice_off_in.addr.ptr = oldpath as _; + sqe.len.len = newdirfd as _; + sqe.off_or_addr2.off = newpath as _; + sqe.op_flags.rename_flags = flags; Entry(sqe) } } @@ -1334,12 +1335,12 @@ opcode! { // Available since kernel 5.11. pub struct UnlinkAt { dirfd: { impl sealed::UseFd }, - pathname: { *const libc::c_char }, + pathname: { *const sys::c_char }, ;; - flags: i32 = 0 + flags: sys::AtFlags = sys::AtFlags::empty() } - pub const CODE = sys::IORING_OP_UNLINKAT; + pub const CODE = sys::IoringOp::Unlinkat; pub fn build(self) -> Entry { let UnlinkAt { dirfd, pathname, flags } = self; @@ -1347,8 +1348,8 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = dirfd; - sqe.__bindgen_anon_2.addr = pathname as _; - sqe.__bindgen_anon_3.unlink_flags = flags as _; + sqe.addr_or_splice_off_in.addr.ptr = pathname as _; + sqe.op_flags.unlink_flags = flags; Entry(sqe) } } @@ -1359,12 +1360,12 @@ opcode! { /// Make a directory, equivalent to `mkdirat2(2)`. pub struct MkDirAt { dirfd: { impl sealed::UseFd }, - pathname: { *const libc::c_char }, + pathname: { *const sys::c_char }, ;; - mode: libc::mode_t = 0 + mode: sys::Mode = sys::Mode::empty() } - pub const CODE = sys::IORING_OP_MKDIRAT; + pub const CODE = sys::IoringOp::Mkdirat; pub fn build(self) -> Entry { let MkDirAt { dirfd, pathname, mode } = self; @@ -1372,8 +1373,8 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = dirfd; - sqe.__bindgen_anon_2.addr = pathname as _; - sqe.len = mode; + sqe.addr_or_splice_off_in.addr.ptr = pathname as _; + sqe.len.len = mode.into(); Entry(sqe) } } @@ -1382,12 +1383,12 @@ opcode! { /// Create a symlink, equivalent to `symlinkat2(2)`. pub struct SymlinkAt { newdirfd: { impl sealed::UseFd }, - target: { *const libc::c_char }, - linkpath: { *const libc::c_char }, + target: { *const sys::c_char }, + linkpath: { *const sys::c_char }, ;; } - pub const CODE = sys::IORING_OP_SYMLINKAT; + pub const CODE = sys::IoringOp::Symlinkat; pub fn build(self) -> Entry { let SymlinkAt { newdirfd, target, linkpath } = self; @@ -1395,8 +1396,8 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = newdirfd; - sqe.__bindgen_anon_2.addr = target as _; - sqe.__bindgen_anon_1.addr2 = linkpath as _; + sqe.addr_or_splice_off_in.addr.ptr = target as _; + sqe.off_or_addr2.addr2.ptr = linkpath as _; Entry(sqe) } } @@ -1405,14 +1406,14 @@ opcode! { /// Create a hard link, equivalent to `linkat2(2)`. pub struct LinkAt { olddirfd: { impl sealed::UseFd }, - oldpath: { *const libc::c_char }, + oldpath: { *const sys::c_char }, newdirfd: { impl sealed::UseFd }, - newpath: { *const libc::c_char }, + newpath: { *const sys::c_char }, ;; - flags: i32 = 0 + flags: sys::AtFlags = sys::AtFlags::empty() } - pub const CODE = sys::IORING_OP_LINKAT; + pub const CODE = sys::IoringOp::Linkat; pub fn build(self) -> Entry { let LinkAt { olddirfd, oldpath, newdirfd, newpath, flags } = self; @@ -1420,10 +1421,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = olddirfd as _; - sqe.__bindgen_anon_2.addr = oldpath as _; - sqe.len = newdirfd as _; - sqe.__bindgen_anon_1.addr2 = newpath as _; - sqe.__bindgen_anon_3.hardlink_flags = flags as _; + sqe.addr_or_splice_off_in.addr.ptr = oldpath as _; + sqe.len.len = newdirfd as _; + sqe.off_or_addr2.addr2.ptr = newpath as _; + sqe.op_flags.hardlink_flags = flags; Entry(sqe) } } @@ -1438,21 +1439,21 @@ opcode! { user_data: { u64 }, user_flags: { Option }, ;; - opcode_flags: u32 = 0 + opcode_flags: sys::IoringMsgringFlags = sys::IoringMsgringFlags::empty() } - pub const CODE = sys::IORING_OP_MSG_RING; + pub const CODE = sys::IoringOp::MsgRing; pub fn build(self) -> Entry { let MsgRingData { ring_fd, result, user_data, user_flags, opcode_flags } = self; let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; - sqe.__bindgen_anon_2.addr = sys::IORING_MSG_DATA.into(); + sqe.addr_or_splice_off_in.msgring_cmd = sys::IoringMsgringCmds::Data; sqe.fd = ring_fd; - sqe.len = result as u32; - sqe.__bindgen_anon_1.off = user_data; - sqe.__bindgen_anon_3.msg_ring_flags = opcode_flags; + sqe.len.len = result as u32; + sqe.off_or_addr2.user_data.u64_ = user_data; + sqe.op_flags.msg_ring_flags = opcode_flags; if let Some(_flags) = user_flags { // TODO(lucab): add IORING_MSG_RING_FLAGS_PASS support (in v6.3): // https://lore.kernel.org/all/20230103160507.617416-1-leitao@debian.org/t/#u @@ -1472,7 +1473,7 @@ opcode! { ;; } - pub const CODE = sys::IORING_OP_ASYNC_CANCEL; + pub const CODE = sys::IoringOp::AsyncCancel; pub fn build(self) -> Entry { let AsyncCancel2 { builder } = self; @@ -1480,8 +1481,8 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = builder.to_fd(); - sqe.__bindgen_anon_2.addr = builder.user_data.unwrap_or(0); - sqe.__bindgen_anon_3.cancel_flags = builder.flags.bits(); + sqe.addr_or_splice_off_in.user_data.u64_ = builder.user_data.unwrap_or(0); + sqe.op_flags.cancel_flags = sys::IoringAsyncCancelFlags::from_bits_retain(builder.flags.bits()); Entry(sqe) } } @@ -1496,7 +1497,7 @@ opcode! { cmd: [u8; 16] = [0u8; 16] } - pub const CODE = sys::IORING_OP_URING_CMD; + pub const CODE = sys::IoringOp::UringCmd; pub fn build(self) -> Entry { let UringCmd16 { fd, cmd_op, cmd } = self; @@ -1504,8 +1505,8 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op; - unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd }; + sqe.off_or_addr2.cmd_op.cmd_op = cmd_op; + unsafe { *sqe.addr3_or_cmd.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd }; Entry(sqe) } } @@ -1520,7 +1521,7 @@ opcode! { cmd: [u8; 80] = [0u8; 80] } - pub const CODE = sys::IORING_OP_URING_CMD; + pub const CODE = sys::IoringOp::UringCmd; pub fn build(self) -> Entry128 { let UringCmd80 { fd, cmd_op, cmd } = self; @@ -1531,8 +1532,8 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_1.__bindgen_anon_1.cmd_op = cmd_op; - unsafe { *sqe.__bindgen_anon_6.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd1 }; + sqe.off_or_addr2.cmd_op.cmd_op = cmd_op; + unsafe { *sqe.addr3_or_cmd.cmd.as_mut().as_mut_ptr().cast::<[u8; 16]>() = cmd1 }; Entry128(Entry(sqe), cmd2) } } @@ -1553,10 +1554,10 @@ opcode! { protocol: { i32 }, ;; file_index: Option = None, - flags: types::RwFlags = 0, + flags: types::RwFlags = types::RwFlags::empty(), } - pub const CODE = sys::IORING_OP_SOCKET; + pub const CODE = sys::IoringOp::Socket; pub fn build(self) -> Entry { let Socket { domain, socket_type, protocol, file_index, flags } = self; @@ -1564,11 +1565,11 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; sqe.fd = domain as _; - sqe.__bindgen_anon_1.off = socket_type as _; - sqe.len = protocol as _; - sqe.__bindgen_anon_3.rw_flags = flags; + sqe.off_or_addr2.off = socket_type as _; + sqe.len.len = protocol as _; + sqe.op_flags.rw_flags = flags; if let Some(dest) = file_index { - sqe.__bindgen_anon_5.file_index = dest.kernel_index_arg(); + sqe.splice_fd_in_or_file_index.file_index = dest.kernel_index_arg(); } Entry(sqe) } @@ -1584,10 +1585,10 @@ opcode! { fd: { impl sealed::UseFixed }, ;; allocate_file_index: bool = false, - flags: i32 = 0 + flags: sys::SocketFlags = sys::SocketFlags::empty() } - pub const CODE = sys::IORING_OP_ACCEPT; + pub const CODE = sys::IoringOp::Accept; pub fn build(self) -> Entry { let AcceptMulti { fd, allocate_file_index, flags } = self; @@ -1595,12 +1596,12 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = sys::IORING_ACCEPT_MULTISHOT as u16; + sqe.ioprio.accept_flags = sys::IoringAcceptFlags::MULTISHOT; // No out SockAddr is passed for the multishot accept case. // The user should perform a syscall to get any resulting connection's remote address. - sqe.__bindgen_anon_3.accept_flags = flags as _; + sqe.op_flags.accept_flags = flags; if allocate_file_index { - sqe.__bindgen_anon_5.file_index = sys::IORING_FILE_INDEX_ALLOC as u32; + sqe.splice_fd_in_or_file_index.file_index = sys::IORING_FILE_INDEX_ALLOC as u32; } Entry(sqe) } @@ -1616,22 +1617,22 @@ opcode! { dest_slot_index: { types::DestinationSlot }, user_data: { u64 }, ;; - opcode_flags: u32 = 0 + opcode_flags: sys::IoringMsgringFlags = sys::IoringMsgringFlags::empty() } - pub const CODE = sys::IORING_OP_MSG_RING; + pub const CODE = sys::IoringOp::MsgRing; pub fn build(self) -> Entry { let MsgRingSendFd { ring_fd, fixed_slot_src, dest_slot_index, user_data, opcode_flags } = self; let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; - sqe.__bindgen_anon_2.addr = sys::IORING_MSG_SEND_FD.into(); + sqe.addr_or_splice_off_in.msgring_cmd = sys::IoringMsgringCmds::SendFd; sqe.fd = ring_fd; - sqe.__bindgen_anon_1.off = user_data; - unsafe { sqe.__bindgen_anon_6.__bindgen_anon_1.as_mut().addr3 = fixed_slot_src.0 as u64 }; - sqe.__bindgen_anon_5.file_index = dest_slot_index.kernel_index_arg(); - sqe.__bindgen_anon_3.msg_ring_flags = opcode_flags; + sqe.off_or_addr2.off = user_data; + sqe.addr3_or_cmd.addr3.addr3 = fixed_slot_src.0 as u64; + sqe.splice_fd_in_or_file_index.file_index = dest_slot_index.kernel_index_arg(); + sqe.op_flags.msg_ring_flags = opcode_flags; Entry(sqe) } } @@ -1658,13 +1659,13 @@ opcode! { /// previously registered buffer. The buffer need not be aligned with the start of the /// registered buffer. buf_index: Option = None, - dest_addr: *const libc::sockaddr = core::ptr::null(), - dest_addr_len: libc::socklen_t = 0, - flags: i32 = 0, - zc_flags: u16 = 0, + dest_addr: *const sys::sockaddr = core::ptr::null(), + dest_addr_len: sys::socklen_t = 0, + flags: sys::SendFlags = sys::SendFlags::empty(), + zc_flags: sys::IoringSendFlags = sys::IoringSendFlags::empty(), } - pub const CODE = sys::IORING_OP_SEND_ZC; + pub const CODE = sys::IoringOp::SendZc; pub fn build(self) -> Entry { let SendZc { fd, buf, len, buf_index, dest_addr, dest_addr_len, flags, zc_flags } = self; @@ -1672,16 +1673,16 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.__bindgen_anon_2.addr = buf as _; - sqe.len = len; - sqe.__bindgen_anon_3.msg_flags = flags as _; - sqe.ioprio = zc_flags; + sqe.addr_or_splice_off_in.addr.ptr = buf as _; + sqe.len.len = len; + sqe.op_flags.send_flags = flags; + sqe.ioprio.send_flags = zc_flags; if let Some(buf_index) = buf_index { - sqe.__bindgen_anon_4.buf_index = buf_index; - sqe.ioprio |= sys::IORING_RECVSEND_FIXED_BUF as u16; + sqe.buf.buf_index = buf_index; + unsafe { sqe.ioprio.send_flags |= sys::IoringSendFlags::FIXED_BUF; } } - sqe.__bindgen_anon_1.addr2 = dest_addr as _; - sqe.__bindgen_anon_5.__bindgen_anon_1.addr_len = dest_addr_len as _; + sqe.off_or_addr2.addr2.ptr = dest_addr as _; + sqe.splice_fd_in_or_file_index.addr_len.addr_len = dest_addr_len as _; Entry(sqe) } } @@ -1696,13 +1697,13 @@ opcode! { #[derive(Debug)] pub struct SendMsgZc { fd: { impl sealed::UseFixed }, - msg: { *const libc::msghdr }, + msg: { *const sys::msghdr }, ;; ioprio: u16 = 0, - flags: u32 = 0 + flags: sys::SendFlags = sys::SendFlags::empty() } - pub const CODE = sys::IORING_OP_SENDMSG_ZC; + pub const CODE = sys::IoringOp::SendmsgZc; pub fn build(self) -> Entry { let SendMsgZc { fd, msg, ioprio, flags } = self; @@ -1710,10 +1711,10 @@ opcode! { let mut sqe = sqe_zeroed(); sqe.opcode = Self::CODE; assign_fd!(sqe.fd = fd); - sqe.ioprio = ioprio; - sqe.__bindgen_anon_2.addr = msg as _; - sqe.len = 1; - sqe.__bindgen_anon_3.msg_flags = flags; + sqe.ioprio.ioprio = ioprio; + sqe.addr_or_splice_off_in.addr.ptr = msg as _; + sqe.len.len = 1; + sqe.op_flags.send_flags = flags; Entry(sqe) } } diff --git a/src/register.rs b/src/register.rs index 6aeacfd..09ba188 100644 --- a/src/register.rs +++ b/src/register.rs @@ -1,17 +1,22 @@ //! Some register syscall related types or parameters. -use std::os::unix::io::RawFd; -use std::{fmt, io}; +use core::fmt; +use rustix::fd::{AsFd, BorrowedFd}; + +use rustix::io; use crate::sys; -pub(crate) fn execute( - fd: RawFd, - opcode: libc::c_uint, - arg: *const libc::c_void, - len: libc::c_uint, -) -> io::Result { - unsafe { sys::io_uring_register(fd, opcode, arg, len) } +pub(crate) fn execute( + fd: Fd, + opcode: sys::IoringRegisterOp, + arg: *const core::ffi::c_void, + len: u32, +) -> io::Result<()> { + unsafe { + sys::io_uring_register(fd.as_fd(), opcode, arg, len)?; + } + Ok(()) } /// Information about what `io_uring` features the kernel supports. @@ -39,13 +44,15 @@ impl Probe { } /// Get whether a specific opcode is supported. - pub fn is_supported(&self, opcode: u8) -> bool { + pub fn is_supported(&self, opcode: sys::IoringOp) -> bool { unsafe { let probe = &(self.0).0; - if opcode <= probe.last_op { + if opcode as u32 <= probe.last_op as u32 { let ops = probe.ops.as_slice(Self::COUNT); - ops[opcode as usize].flags & (sys::IO_URING_OP_SUPPORTED as u16) != 0 + ops[opcode as usize] + .flags + .contains(sys::IoringOpFlags::SUPPORTED) } else { false } @@ -75,7 +82,7 @@ impl fmt::Debug for Probe { let list = unsafe { probe.ops.as_slice(probe.last_op as usize + 1) }; let list = list .iter() - .filter(|op| op.flags & (sys::IO_URING_OP_SUPPORTED as u16) != 0) + .filter(|op| op.flags.contains(sys::IoringOpFlags::SUPPORTED)) .map(Op); f.debug_set().entries(list).finish() @@ -90,40 +97,40 @@ pub struct Restriction(sys::io_uring_restriction); /// inline zeroed to improve codegen #[inline(always)] fn res_zeroed() -> sys::io_uring_restriction { - unsafe { std::mem::zeroed() } + Default::default() } impl Restriction { /// Allow an `io_uring_register` opcode. - pub fn register_op(op: u8) -> Restriction { + pub fn register_op(op: sys::IoringRegisterOp) -> Restriction { let mut res = res_zeroed(); - res.opcode = sys::IORING_RESTRICTION_REGISTER_OP as _; - res.__bindgen_anon_1.register_op = op; + res.opcode = sys::IoringRestrictionOp::RegisterOp; + res.register_or_sqe_op_or_sqe_flags.register_op = op; Restriction(res) } /// Allow a submission queue event opcode. - pub fn sqe_op(op: u8) -> Restriction { + pub fn sqe_op(op: sys::IoringOp) -> Restriction { let mut res = res_zeroed(); - res.opcode = sys::IORING_RESTRICTION_SQE_OP as _; - res.__bindgen_anon_1.sqe_op = op; + res.opcode = sys::IoringRestrictionOp::SqeOp; + res.register_or_sqe_op_or_sqe_flags.sqe_op = op; Restriction(res) } /// Allow the given [submission queue event flags](crate::squeue::Flags). - pub fn sqe_flags_allowed(flags: u8) -> Restriction { + pub fn sqe_flags_allowed(flags: sys::IoringSqeFlags) -> Restriction { let mut res = res_zeroed(); - res.opcode = sys::IORING_RESTRICTION_SQE_FLAGS_ALLOWED as _; - res.__bindgen_anon_1.sqe_flags = flags; + res.opcode = sys::IoringRestrictionOp::SqeFlagsAllowed; + res.register_or_sqe_op_or_sqe_flags.sqe_flags = flags; Restriction(res) } /// Require the given [submission queue event flags](crate::squeue::Flags). These flags must be /// set on every submission. - pub fn sqe_flags_required(flags: u8) -> Restriction { + pub fn sqe_flags_required(flags: sys::IoringSqeFlags) -> Restriction { let mut res = res_zeroed(); - res.opcode = sys::IORING_RESTRICTION_SQE_FLAGS_REQUIRED as _; - res.__bindgen_anon_1.sqe_flags = flags; + res.opcode = sys::IoringRestrictionOp::SqeFlagsRequired; + res.register_or_sqe_op_or_sqe_flags.sqe_flags = flags; Restriction(res) } } @@ -133,7 +140,7 @@ impl Restriction { /// /// File descriptors can be skipped if they are set to `SKIP_FILE`. /// Skipping an fd will not touch the file associated with the previous fd at that index. -pub const SKIP_FILE: RawFd = sys::IORING_REGISTER_FILES_SKIP; +pub const SKIP_FILE: BorrowedFd<'static> = rustix::io_uring::io_uring_register_files_skip(); #[test] fn test_probe_layout() { diff --git a/src/squeue.rs b/src/squeue.rs index ac17358..6cedb9d 100644 --- a/src/squeue.rs +++ b/src/squeue.rs @@ -1,9 +1,10 @@ //! Submission Queue +use core::fmt::{self, Debug, Display, Formatter}; +use core::mem; +use core::sync::atomic; +#[cfg(feature = "std")] use std::error::Error; -use std::fmt::{self, Debug, Display, Formatter}; -use std::mem; -use std::sync::atomic; use crate::sys; use crate::util::{private, unsync_load, Mmap}; @@ -32,7 +33,7 @@ pub struct SubmissionQueue<'a, E: EntryMarker = Entry> { /// /// This is implemented for [`Entry`] and [`Entry128`]. pub trait EntryMarker: Clone + Debug + From + private::Sealed { - const BUILD_FLAGS: u32; + const BUILD_FLAGS: sys::IoringSetupFlags; } /// A 64-byte submission queue entry (SQE), representing a request for an I/O operation. @@ -56,25 +57,26 @@ fn test_entry_sizes() { bitflags! { /// Submission flags + #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub struct Flags: u8 { /// When this flag is specified, /// `fd` is an index into the files array registered with the io_uring instance. #[doc(hidden)] - const FIXED_FILE = 1 << sys::IOSQE_FIXED_FILE_BIT; + const FIXED_FILE = sys::IoringSqeFlags::FIXED_FILE.bits(); /// When this flag is specified, /// the SQE will not be started before previously submitted SQEs have completed, /// and new SQEs will not be started before this one completes. - const IO_DRAIN = 1 << sys::IOSQE_IO_DRAIN_BIT; + const IO_DRAIN = sys::IoringSqeFlags::IO_DRAIN.bits(); /// When this flag is specified, /// it forms a link with the next SQE in the submission ring. /// That next SQE will not be started before this one completes. - const IO_LINK = 1 << sys::IOSQE_IO_LINK_BIT; + const IO_LINK = sys::IoringSqeFlags::IO_LINK.bits(); /// Like [`IO_LINK`](Self::IO_LINK), but it doesn’t sever regardless of the completion /// result. - const IO_HARDLINK = 1 << sys::IOSQE_IO_HARDLINK_BIT; + const IO_HARDLINK = sys::IoringSqeFlags::IO_HARDLINK.bits(); /// Normal operation for io_uring is to try and issue an sqe as non-blocking first, /// and if that fails, execute it in an async manner. @@ -82,7 +84,7 @@ bitflags! { /// To support more efficient overlapped operation of requests /// that the application knows/assumes will always (or most of the time) block, /// the application can ask for an sqe to be issued async from the start. - const ASYNC = 1 << sys::IOSQE_ASYNC_BIT; + const ASYNC = sys::IoringSqeFlags::ASYNC.bits(); /// Conceptually the kernel holds a set of buffers organized into groups. When you issue a /// request with this flag and set `buf_group` to a valid buffer group ID (e.g. @@ -107,10 +109,10 @@ bitflags! { /// /// See also [the LWN thread on automatic buffer /// selection](https://lwn.net/Articles/815491/). - const BUFFER_SELECT = 1 << sys::IOSQE_BUFFER_SELECT_BIT; + const BUFFER_SELECT = sys::IoringSqeFlags::BUFFER_SELECT.bits(); /// Don't post CQE if request succeeded. - const SKIP_SUCCESS = 1 << sys::IOSQE_CQE_SKIP_SUCCESS_BIT; + const SKIP_SUCCESS = sys::IoringSqeFlags::CQE_SKIP_SUCCESS.bits(); } } @@ -181,7 +183,10 @@ impl SubmissionQueue<'_, E> { #[inline] pub fn need_wakeup(&self) -> bool { unsafe { - (*self.queue.flags).load(atomic::Ordering::Acquire) & sys::IORING_SQ_NEED_WAKEUP != 0 + sys::IoringSqFlags::from_bits_retain( + (*self.queue.flags).load(atomic::Ordering::Acquire), + ) + .contains(sys::IoringSqFlags::NEED_WAKEUP) } } @@ -194,14 +199,20 @@ impl SubmissionQueue<'_, E> { /// Returns `true` if the completion queue ring is overflown. pub fn cq_overflow(&self) -> bool { unsafe { - (*self.queue.flags).load(atomic::Ordering::Acquire) & sys::IORING_SQ_CQ_OVERFLOW != 0 + sys::IoringSqFlags::from_bits_retain( + (*self.queue.flags).load(atomic::Ordering::Acquire), + ) + .contains(sys::IoringSqFlags::CQ_OVERFLOW) } } /// Returns `true` if completions are pending that should be processed. Only relevant when used /// in conjuction with the `setup_taskrun_flag` function. Available since 5.19. pub fn taskrun(&self) -> bool { - unsafe { (*self.queue.flags).load(atomic::Ordering::Acquire) & sys::IORING_SQ_TASKRUN != 0 } + unsafe { + (*self.queue.flags).load(atomic::Ordering::Acquire) & sys::IoringSqFlags::TASKRUN.bits() + != 0 + } } /// Get the total number of entries in the submission queue ring buffer. @@ -288,22 +299,38 @@ impl Entry { /// Set the submission event's [flags](Flags). #[inline] pub fn flags(mut self, flags: Flags) -> Entry { - self.0.flags |= flags.bits(); + self.0.flags |= sys::IoringSqeFlags::from_bits(flags.bits()).unwrap(); self } - /// Set the user data. This is an application-supplied value that will be passed straight - /// through into the [completion queue entry](crate::cqueue::Entry::user_data). + /// Set the user data as a `u64`. This is an application-supplied value + /// that will be passed straight through into the + /// [completion queue entry](crate::cqueue::Entry::user_data). #[inline] pub fn user_data(mut self, user_data: u64) -> Entry { - self.0.user_data = user_data; + self.0.user_data = sys::io_uring_user_data::from_u64(user_data); self } - /// Get the previously application-supplied user data. + /// Set the user data as a pointer. This is an application-supplied value + /// that will be passed straight through into the + /// [completion queue entry](crate::cqueue::Entry::user_data). + #[inline] + pub fn user_data_ptr(mut self, user_data: *mut core::ffi::c_void) -> Entry { + self.0.user_data = sys::io_uring_user_data::from_ptr(user_data); + self + } + + /// Get the previously application-supplied user data as a `u64`. #[inline] pub fn get_user_data(&self) -> u64 { - self.0.user_data + self.0.user_data.u64_() + } + + /// Get the previously application-supplied user data as a pointer. + #[inline] + pub fn get_user_data_ptr(&self) -> *mut core::ffi::c_void { + self.0.user_data.ptr() } /// Set the personality of this event. You can obtain a personality using @@ -317,7 +344,7 @@ impl Entry { impl private::Sealed for Entry {} impl EntryMarker for Entry { - const BUILD_FLAGS: u32 = 0; + const BUILD_FLAGS: sys::IoringSetupFlags = sys::IoringSetupFlags::empty(); } impl Clone for Entry { @@ -341,7 +368,7 @@ impl Entry128 { /// Set the submission event's [flags](Flags). #[inline] pub fn flags(mut self, flags: Flags) -> Entry128 { - self.0 .0.flags |= flags.bits(); + self.0 .0.flags |= sys::IoringSqeFlags::from_bits(flags.bits()).unwrap(); self } @@ -349,7 +376,15 @@ impl Entry128 { /// through into the [completion queue entry](crate::cqueue::Entry::user_data). #[inline] pub fn user_data(mut self, user_data: u64) -> Entry128 { - self.0 .0.user_data = user_data; + self.0 .0.user_data = sys::io_uring_user_data::from_u64(user_data); + self + } + + /// Set the user data. This is an application-supplied value that will be passed straight + /// through into the [completion queue entry](crate::cqueue::Entry::user_data). + #[inline] + pub fn user_data_ptr(mut self, user_data: *mut core::ffi::c_void) -> Entry128 { + self.0 .0.user_data = sys::io_uring_user_data::from_ptr(user_data); self } @@ -365,7 +400,7 @@ impl Entry128 { impl private::Sealed for Entry128 {} impl EntryMarker for Entry128 { - const BUILD_FLAGS: u32 = sys::IORING_SETUP_SQE128; + const BUILD_FLAGS: sys::IoringSetupFlags = sys::IoringSetupFlags::SQE128; } impl From for Entry128 { @@ -395,6 +430,7 @@ impl Display for PushError { } } +#[cfg(feature = "std")] impl Error for PushError {} impl Debug for SubmissionQueue<'_, E> { diff --git a/src/submit.rs b/src/submit.rs index c0a8152..88a5a2c 100644 --- a/src/submit.rs +++ b/src/submit.rs @@ -1,11 +1,13 @@ -use std::os::unix::io::{AsRawFd, RawFd}; -use std::sync::atomic; -use std::{io, mem, ptr}; +use core::sync::atomic; +use core::{mem, ptr}; + +use rustix::fd::{OwnedFd, RawFd}; +use rustix::io; use crate::register::{execute, Probe}; use crate::sys; use crate::types::{CancelBuilder, Timespec}; -use crate::util::{cast_ptr, OwnedFd}; +use crate::util::cast_ptr; use crate::Parameters; use crate::register::Restriction; @@ -59,14 +61,16 @@ impl<'a> Submitter<'a> { #[inline] fn sq_need_wakeup(&self) -> bool { unsafe { - (*self.sq_flags).load(atomic::Ordering::Acquire) & sys::IORING_SQ_NEED_WAKEUP != 0 + (*self.sq_flags).load(atomic::Ordering::Acquire) + & sys::IoringSqFlags::NEED_WAKEUP.bits() + != 0 } } - /// CQ ring is overflown - fn sq_cq_overflow(&self) -> bool { + /// CQ ring is overflown or a deferred task is runnable. Either case requires entering the kernel + fn sq_cq_overflow_or_taskrun(&self) -> bool { unsafe { - (*self.sq_flags).load(atomic::Ordering::Acquire) & sys::IORING_SQ_CQ_OVERFLOW != 0 + (*self.sq_flags).load(atomic::Ordering::Acquire) & (sys::IoringSqFlags::TASKRUN | sys::IoringSqFlags::CQ_OVERFLOW).bits() != 0 } } @@ -85,22 +89,15 @@ impl<'a> Submitter<'a> { &self, to_submit: u32, min_complete: u32, - flag: u32, + flag: sys::IoringEnterFlags, arg: Option<&T>, ) -> io::Result { let arg = arg .map(|arg| cast_ptr(arg).cast()) .unwrap_or_else(ptr::null); - let size = mem::size_of::(); - sys::io_uring_enter( - self.fd.as_raw_fd(), - to_submit, - min_complete, - flag, - arg, - size, - ) - .map(|res| res as _) + let size = core::mem::size_of::(); + let result = sys::io_uring_enter(self.fd, to_submit, min_complete, flag, arg, size)?; + Ok(result as _) } /// Submit all queued submission queue events to the kernel. @@ -113,20 +110,20 @@ impl<'a> Submitter<'a> { /// completion events to complete. pub fn submit_and_wait(&self, want: usize) -> io::Result { let len = self.sq_len(); - let mut flags = 0; + let mut flags = sys::IoringEnterFlags::empty(); - // This logic suffers from the fact the sq_cq_overflow and sq_need_wakeup - // each cause an atomic load of the same variable, self.sq_flags. - // In the hottest paths, when a server is running with sqpoll, - // this is going to be hit twice, when once would be sufficient. + // This logic suffers from the fact the sq_cq_overflow_or_taskrun and + // sq_need_wakeup each cause an atomic load of the same variable, + // self.sq_flags. In the hottest paths, when a server is running with + // sqpoll, this is going to be hit twice, when once would be sufficient. - if want > 0 || self.params.is_setup_iopoll() || self.sq_cq_overflow() { - flags |= sys::IORING_ENTER_GETEVENTS; + if want > 0 || self.params.is_setup_iopoll() || self.sq_cq_overflow_or_taskrun() { + flags |= sys::IoringEnterFlags::GETEVENTS; } if self.params.is_setup_sqpoll() { if self.sq_need_wakeup() { - flags |= sys::IORING_ENTER_SQ_WAKEUP; + flags |= sys::IoringEnterFlags::SQ_WAKEUP; } else if want == 0 { // The kernel thread is polling and hasn't fallen asleep, so we don't need to tell // it to process events or wake it up @@ -134,7 +131,7 @@ impl<'a> Submitter<'a> { } } - unsafe { self.enter::(len as _, want as _, flags, None) } + unsafe { self.enter::(len as _, want as _, flags, None) } } pub fn submit_with_args( @@ -143,15 +140,15 @@ impl<'a> Submitter<'a> { args: &types::SubmitArgs<'_, '_>, ) -> io::Result { let len = self.sq_len(); - let mut flags = sys::IORING_ENTER_EXT_ARG; + let mut flags = sys::IoringEnterFlags::EXT_ARG; - if want > 0 || self.params.is_setup_iopoll() || self.sq_cq_overflow() { - flags |= sys::IORING_ENTER_GETEVENTS; + if want > 0 || self.params.is_setup_iopoll() || self.sq_cq_overflow_or_taskrun() { + flags |= sys::IoringEnterFlags::GETEVENTS; } if self.params.is_setup_sqpoll() { if self.sq_need_wakeup() { - flags |= sys::IORING_ENTER_SQ_WAKEUP; + flags |= sys::IoringEnterFlags::SQ_WAKEUP; } else if want == 0 { // The kernel thread is polling and hasn't fallen asleep, so we don't need to tell // it to process events or wake it up @@ -164,7 +161,7 @@ impl<'a> Submitter<'a> { /// Wait for the submission queue to have free entries. pub fn squeue_wait(&self) -> io::Result { - unsafe { self.enter::(0, 0, sys::IORING_ENTER_SQ_WAIT, None) } + unsafe { self.enter::(0, 0, sys::IoringEnterFlags::SQ_WAIT, None) } } /// Register in-memory fixed buffers for I/O with the kernel. You can use these buffers with the @@ -176,14 +173,13 @@ impl<'a> Submitter<'a> { /// Developers must ensure that the `iov_base` and `iov_len` values are valid and will /// be valid until buffers are unregistered or the ring destroyed, otherwise undefined /// behaviour may occur. - pub unsafe fn register_buffers(&self, bufs: &[libc::iovec]) -> io::Result<()> { + pub unsafe fn register_buffers(&self, bufs: &[sys::iovec]) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_BUFFERS, + self.fd, + sys::IoringRegisterOp::RegisterBuffers, bufs.as_ptr().cast(), bufs.len() as _, ) - .map(drop) } /// Registers an empty file table of nr_files number of file descriptors. The sparse variant is @@ -194,18 +190,17 @@ impl<'a> Submitter<'a> { pub fn register_files_sparse(&self, nr: u32) -> io::Result<()> { let rr = sys::io_uring_rsrc_register { nr, - flags: sys::IORING_RSRC_REGISTER_SPARSE, + flags: sys::IoringRsrcFlags::REGISTER_SPARSE, resv2: 0, data: 0, tags: 0, }; execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_FILES2, + self.fd, + sys::IoringRegisterOp::RegisterFiles2, cast_ptr::(&rr).cast(), mem::size_of::() as _, ) - .map(drop) } /// Register files for I/O. You can use the registered files with @@ -218,12 +213,11 @@ impl<'a> Submitter<'a> { /// are complete. Use [`register_files_update`](Self::register_files_update) to avoid this. pub fn register_files(&self, fds: &[RawFd]) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_FILES, + self.fd, + sys::IoringRegisterOp::RegisterFiles, fds.as_ptr().cast(), fds.len() as _, ) - .map(drop) } /// This operation replaces existing files in the registered file set with new ones, @@ -233,30 +227,28 @@ impl<'a> Submitter<'a> { /// /// You can also perform this asynchronously with the /// [`FilesUpdate`](crate::opcode::FilesUpdate) opcode. - pub fn register_files_update(&self, offset: u32, fds: &[RawFd]) -> io::Result { + pub fn register_files_update(&self, offset: u32, fds: &[RawFd]) -> io::Result<()> { let fu = sys::io_uring_files_update { offset, resv: 0, fds: fds.as_ptr() as _, }; - let ret = execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_FILES_UPDATE, + execute( + self.fd, + sys::IoringRegisterOp::RegisterFilesUpdate, cast_ptr::(&fu).cast(), fds.len() as _, - )?; - Ok(ret as _) + ) } /// Register an eventfd created by [`eventfd`](libc::eventfd) with the io_uring instance. pub fn register_eventfd(&self, eventfd: RawFd) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_EVENTFD, + self.fd, + sys::IoringRegisterOp::RegisterEventfd, cast_ptr::(&eventfd).cast(), 1, ) - .map(drop) } /// This works just like [`register_eventfd`](Self::register_eventfd), except notifications are @@ -264,12 +256,11 @@ impl<'a> Submitter<'a> { /// immediately will not cause a notification. pub fn register_eventfd_async(&self, eventfd: RawFd) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_EVENTFD_ASYNC, + self.fd, + sys::IoringRegisterOp::RegisterEventfdAsync, cast_ptr::(&eventfd).cast(), 1, ) - .map(drop) } /// Fill in the given [`Probe`] with information about the opcodes supported by io_uring on the @@ -281,11 +272,11 @@ impl<'a> Submitter<'a> { // which CI runs) only has Linux 5.4. /// ```no_run /// # fn main() -> Result<(), Box> { - /// let io_uring = io_uring::IoUring::new(1)?; - /// let mut probe = io_uring::Probe::new(); + /// let io_uring = rustix_uring::IoUring::new(1)?; + /// let mut probe = rustix_uring::Probe::new(); /// io_uring.submitter().register_probe(&mut probe)?; /// - /// if probe.is_supported(io_uring::opcode::Read::CODE) { + /// if probe.is_supported(rustix_uring::opcode::Read::CODE) { /// println!("Reading is supported!"); /// } /// # Ok(()) @@ -293,12 +284,11 @@ impl<'a> Submitter<'a> { /// ``` pub fn register_probe(&self, probe: &mut Probe) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_PROBE, + self.fd, + sys::IoringRegisterOp::RegisterProbe, probe.as_mut_ptr() as *const _, Probe::COUNT as _, ) - .map(drop) } /// Register credentials of the running application with io_uring, and get an id associated with @@ -310,14 +300,14 @@ impl<'a> Submitter<'a> { /// credentials of the task that originally registered the io_uring. /// /// [`Parameters::is_feature_cur_personality`]: crate::Parameters::is_feature_cur_personality - pub fn register_personality(&self) -> io::Result { - let id = execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_PERSONALITY, + pub fn register_personality(&self) -> io::Result<()> { + execute( + self.fd, + sys::IoringRegisterOp::RegisterPersonality, ptr::null(), 0, )?; - Ok(id as u16) + Ok(()) } /// Unregister all previously registered buffers. @@ -326,12 +316,11 @@ impl<'a> Submitter<'a> { /// it will be cleaned up by the kernel automatically. pub fn unregister_buffers(&self) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_UNREGISTER_BUFFERS, + self.fd, + sys::IoringRegisterOp::UnregisterBuffers, ptr::null(), 0, ) - .map(drop) } /// Unregister all previously registered files. @@ -340,34 +329,31 @@ impl<'a> Submitter<'a> { /// it will be cleaned up by the kernel automatically. pub fn unregister_files(&self) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_UNREGISTER_FILES, + self.fd, + sys::IoringRegisterOp::UnregisterFiles, ptr::null(), 0, ) - .map(drop) } /// Unregister an eventfd file descriptor to stop notifications. pub fn unregister_eventfd(&self) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_UNREGISTER_EVENTFD, + self.fd, + sys::IoringRegisterOp::UnregisterEventfd, ptr::null(), 0, ) - .map(drop) } /// Unregister a previously registered personality. pub fn unregister_personality(&self, personality: u16) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_UNREGISTER_PERSONALITY, + self.fd, + sys::IoringRegisterOp::UnregisterPersonality, ptr::null(), personality as _, ) - .map(drop) } /// Permanently install a feature allowlist. Once this has been called, attempting to perform @@ -376,24 +362,22 @@ impl<'a> Submitter<'a> { /// This can only be called once, to prevent untrusted code from removing restrictions. pub fn register_restrictions(&self, res: &mut [Restriction]) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_RESTRICTIONS, + self.fd, + sys::IoringRegisterOp::RegisterRestrictions, res.as_mut_ptr().cast(), res.len() as _, ) - .map(drop) } /// Enable the rings of the io_uring instance if they have been disabled with /// [`setup_r_disabled`](crate::Builder::setup_r_disabled). pub fn register_enable_rings(&self) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_ENABLE_RINGS, + self.fd, + sys::IoringRegisterOp::RegisterEnableRings, ptr::null(), 0, ) - .map(drop) } /// Get and/or set the limit for number of io_uring worker threads per NUMA @@ -405,12 +389,11 @@ impl<'a> Submitter<'a> { /// previous limits on success. pub fn register_iowq_max_workers(&self, max: &mut [u32; 2]) -> io::Result<()> { execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_IOWQ_MAX_WORKERS, + self.fd, + sys::IoringRegisterOp::RegisterIowqMaxWorkers, max.as_mut_ptr().cast(), max.len() as _, ) - .map(drop) } /// Register buffer ring for provided buffers. @@ -444,12 +427,11 @@ impl<'a> Submitter<'a> { ..Default::default() }; execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_PBUF_RING, + self.fd, + sys::IoringRegisterOp::RegisterPbufRing, cast_ptr::(&arg).cast(), 1, ) - .map(drop) } /// Unregister a previously registered buffer ring. @@ -463,12 +445,11 @@ impl<'a> Submitter<'a> { ..Default::default() }; execute( - self.fd.as_raw_fd(), - sys::IORING_UNREGISTER_PBUF_RING, + self.fd, + sys::IoringRegisterOp::UnregisterPbufRing, cast_ptr::(&arg).cast(), 1, ) - .map(drop) } /// Performs a synchronous cancellation request, similar to [AsyncCancel](crate::opcode::AsyncCancel), @@ -501,12 +482,12 @@ impl<'a> Submitter<'a> { timeout: Option, builder: CancelBuilder, ) -> io::Result<()> { - let timespec = timeout.map(|ts| ts.0).unwrap_or(sys::__kernel_timespec { + let timespec = timeout.map(|ts| ts.0).unwrap_or(sys::Timespec { tv_sec: -1, tv_nsec: -1, }); let user_data = builder.user_data.unwrap_or(0); - let flags = builder.flags.bits(); + let flags = sys::IoringAsyncCancelFlags::from_bits_retain(builder.flags.bits()); let fd = builder.to_fd(); let arg = sys::io_uring_sync_cancel_reg { @@ -517,11 +498,10 @@ impl<'a> Submitter<'a> { pad: [0u64; 4], }; execute( - self.fd.as_raw_fd(), - sys::IORING_REGISTER_SYNC_CANCEL, + self.fd, + sys::IoringRegisterOp::RegisterSyncCancel, cast_ptr::(&arg).cast(), 1, ) - .map(drop) } } diff --git a/src/sys/mod.rs b/src/sys/mod.rs deleted file mode 100644 index 6e44579..0000000 --- a/src/sys/mod.rs +++ /dev/null @@ -1,143 +0,0 @@ -#![allow( - non_camel_case_types, - non_upper_case_globals, - dead_code, - non_snake_case, - unused_qualifications -)] -#![allow( - clippy::unreadable_literal, - clippy::missing_safety_doc, - clippy::incorrect_clone_impl_on_copy_type -)] - -use std::io; - -use libc::*; - -#[cfg(feature = "direct-syscall")] -fn to_result(ret: c_int) -> io::Result { - if ret >= 0 { - Ok(ret) - } else { - Err(io::Error::from_raw_os_error(-ret)) - } -} - -#[cfg(not(feature = "direct-syscall"))] -fn to_result(ret: c_int) -> io::Result { - if ret >= 0 { - Ok(ret) - } else { - Err(io::Error::last_os_error()) - } -} - -#[cfg(all(feature = "bindgen", not(feature = "overwrite")))] -include!(concat!(env!("OUT_DIR"), "/sys.rs")); - -#[cfg(any( - not(feature = "bindgen"), - all(feature = "bindgen", feature = "overwrite") -))] -include!("sys.rs"); - -#[cfg(feature = "bindgen")] -const SYSCALL_REGISTER: c_long = __NR_io_uring_register as _; - -#[cfg(not(feature = "bindgen"))] -const SYSCALL_REGISTER: c_long = libc::SYS_io_uring_register; - -#[cfg(feature = "bindgen")] -const SYSCALL_SETUP: c_long = __NR_io_uring_setup as _; - -#[cfg(not(feature = "bindgen"))] -const SYSCALL_SETUP: c_long = libc::SYS_io_uring_setup; - -#[cfg(feature = "bindgen")] -const SYSCALL_ENTER: c_long = __NR_io_uring_enter as _; - -#[cfg(not(feature = "bindgen"))] -const SYSCALL_ENTER: c_long = libc::SYS_io_uring_enter; - -#[cfg(not(feature = "direct-syscall"))] -pub unsafe fn io_uring_register( - fd: c_int, - opcode: c_uint, - arg: *const c_void, - nr_args: c_uint, -) -> io::Result { - to_result(syscall( - SYSCALL_REGISTER, - fd as c_long, - opcode as c_long, - arg as c_long, - nr_args as c_long, - ) as _) -} - -#[cfg(feature = "direct-syscall")] -pub unsafe fn io_uring_register( - fd: c_int, - opcode: c_uint, - arg: *const c_void, - nr_args: c_uint, -) -> io::Result { - to_result(sc::syscall4( - SYSCALL_REGISTER as usize, - fd as usize, - opcode as usize, - arg as usize, - nr_args as usize, - ) as _) -} - -#[cfg(not(feature = "direct-syscall"))] -pub unsafe fn io_uring_setup(entries: c_uint, p: *mut io_uring_params) -> io::Result { - to_result(syscall(SYSCALL_SETUP, entries as c_long, p as c_long) as _) -} - -#[cfg(feature = "direct-syscall")] -pub unsafe fn io_uring_setup(entries: c_uint, p: *mut io_uring_params) -> io::Result { - to_result(sc::syscall2(SYSCALL_SETUP as usize, entries as usize, p as usize) as _) -} - -#[cfg(not(feature = "direct-syscall"))] -pub unsafe fn io_uring_enter( - fd: c_int, - to_submit: c_uint, - min_complete: c_uint, - flags: c_uint, - arg: *const libc::c_void, - size: usize, -) -> io::Result { - to_result(syscall( - SYSCALL_ENTER, - fd as c_long, - to_submit as c_long, - min_complete as c_long, - flags as c_long, - arg as c_long, - size as c_long, - ) as _) -} - -#[cfg(feature = "direct-syscall")] -pub unsafe fn io_uring_enter( - fd: c_int, - to_submit: c_uint, - min_complete: c_uint, - flags: c_uint, - arg: *const libc::c_void, - size: usize, -) -> io::Result { - to_result(sc::syscall6( - SYSCALL_ENTER as usize, - fd as usize, - to_submit as usize, - min_complete as usize, - flags as usize, - arg as usize, - size, - ) as _) -} diff --git a/src/sys/sys.rs b/src/sys/sys.rs deleted file mode 100644 index b357bb8..0000000 --- a/src/sys/sys.rs +++ /dev/null @@ -1,2642 +0,0 @@ -/* automatically generated by rust-bindgen 0.65.1 */ - -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::core::marker::PhantomData, [T; 0]); -impl __IncompleteArrayField { - #[inline] - pub const fn new() -> Self { - __IncompleteArrayField(::core::marker::PhantomData, []) - } - #[inline] - pub fn as_ptr(&self) -> *const T { - self as *const _ as *const T - } - #[inline] - pub fn as_mut_ptr(&mut self) -> *mut T { - self as *mut _ as *mut T - } - #[inline] - pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::core::slice::from_raw_parts(self.as_ptr(), len) - } - #[inline] - pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) - } -} -impl ::core::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - fmt.write_str("__IncompleteArrayField") - } -} -#[repr(C)] -pub struct __BindgenUnionField(::core::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub const fn new() -> Self { - __BindgenUnionField(::core::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ref(&self) -> &T { - ::core::mem::transmute(self) - } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { - ::core::mem::transmute(self) - } -} -impl ::core::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { - Self::new() - } -} -impl ::core::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { - Self::new() - } -} -impl ::core::marker::Copy for __BindgenUnionField {} -impl ::core::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - fmt.write_str("__BindgenUnionField") - } -} -impl ::core::hash::Hash for __BindgenUnionField { - fn hash(&self, _state: &mut H) {} -} -impl ::core::cmp::PartialEq for __BindgenUnionField { - fn eq(&self, _other: &__BindgenUnionField) -> bool { - true - } -} -impl ::core::cmp::Eq for __BindgenUnionField {} -pub const __NR_io_uring_setup: u32 = 425; -pub const __NR_io_uring_enter: u32 = 426; -pub const __NR_io_uring_register: u32 = 427; -pub const IORING_FILE_INDEX_ALLOC: i32 = -1; -pub const IORING_SETUP_IOPOLL: u32 = 1; -pub const IORING_SETUP_SQPOLL: u32 = 2; -pub const IORING_SETUP_SQ_AFF: u32 = 4; -pub const IORING_SETUP_CQSIZE: u32 = 8; -pub const IORING_SETUP_CLAMP: u32 = 16; -pub const IORING_SETUP_ATTACH_WQ: u32 = 32; -pub const IORING_SETUP_R_DISABLED: u32 = 64; -pub const IORING_SETUP_SUBMIT_ALL: u32 = 128; -pub const IORING_SETUP_COOP_TASKRUN: u32 = 256; -pub const IORING_SETUP_TASKRUN_FLAG: u32 = 512; -pub const IORING_SETUP_SQE128: u32 = 1024; -pub const IORING_SETUP_CQE32: u32 = 2048; -pub const IORING_SETUP_SINGLE_ISSUER: u32 = 4096; -pub const IORING_SETUP_DEFER_TASKRUN: u32 = 8192; -pub const IORING_URING_CMD_FIXED: u32 = 1; -pub const IORING_FSYNC_DATASYNC: u32 = 1; -pub const IORING_TIMEOUT_ABS: u32 = 1; -pub const IORING_TIMEOUT_UPDATE: u32 = 2; -pub const IORING_TIMEOUT_BOOTTIME: u32 = 4; -pub const IORING_TIMEOUT_REALTIME: u32 = 8; -pub const IORING_LINK_TIMEOUT_UPDATE: u32 = 16; -pub const IORING_TIMEOUT_ETIME_SUCCESS: u32 = 32; -pub const IORING_TIMEOUT_MULTISHOT: u32 = 64; -pub const IORING_TIMEOUT_CLOCK_MASK: u32 = 12; -pub const IORING_TIMEOUT_UPDATE_MASK: u32 = 18; -pub const SPLICE_F_FD_IN_FIXED: u32 = 2147483648; -pub const IORING_POLL_ADD_MULTI: u32 = 1; -pub const IORING_POLL_UPDATE_EVENTS: u32 = 2; -pub const IORING_POLL_UPDATE_USER_DATA: u32 = 4; -pub const IORING_POLL_ADD_LEVEL: u32 = 8; -pub const IORING_ASYNC_CANCEL_ALL: u32 = 1; -pub const IORING_ASYNC_CANCEL_FD: u32 = 2; -pub const IORING_ASYNC_CANCEL_ANY: u32 = 4; -pub const IORING_ASYNC_CANCEL_FD_FIXED: u32 = 8; -pub const IORING_RECVSEND_POLL_FIRST: u32 = 1; -pub const IORING_RECV_MULTISHOT: u32 = 2; -pub const IORING_RECVSEND_FIXED_BUF: u32 = 4; -pub const IORING_SEND_ZC_REPORT_USAGE: u32 = 8; -pub const IORING_NOTIF_USAGE_ZC_COPIED: u32 = 2147483648; -pub const IORING_ACCEPT_MULTISHOT: u32 = 1; -pub const IORING_MSG_RING_CQE_SKIP: u32 = 1; -pub const IORING_MSG_RING_FLAGS_PASS: u32 = 2; -pub const IORING_CQE_F_BUFFER: u32 = 1; -pub const IORING_CQE_F_MORE: u32 = 2; -pub const IORING_CQE_F_SOCK_NONEMPTY: u32 = 4; -pub const IORING_CQE_F_NOTIF: u32 = 8; -pub const IORING_OFF_SQ_RING: u32 = 0; -pub const IORING_OFF_CQ_RING: u32 = 134217728; -pub const IORING_OFF_SQES: u32 = 268435456; -pub const IORING_OFF_PBUF_RING: u32 = 2147483648; -pub const IORING_OFF_PBUF_SHIFT: u32 = 16; -pub const IORING_OFF_MMAP_MASK: u32 = 4160749568; -pub const IORING_SQ_NEED_WAKEUP: u32 = 1; -pub const IORING_SQ_CQ_OVERFLOW: u32 = 2; -pub const IORING_SQ_TASKRUN: u32 = 4; -pub const IORING_CQ_EVENTFD_DISABLED: u32 = 1; -pub const IORING_ENTER_GETEVENTS: u32 = 1; -pub const IORING_ENTER_SQ_WAKEUP: u32 = 2; -pub const IORING_ENTER_SQ_WAIT: u32 = 4; -pub const IORING_ENTER_EXT_ARG: u32 = 8; -pub const IORING_ENTER_REGISTERED_RING: u32 = 16; -pub const IORING_FEAT_SINGLE_MMAP: u32 = 1; -pub const IORING_FEAT_NODROP: u32 = 2; -pub const IORING_FEAT_SUBMIT_STABLE: u32 = 4; -pub const IORING_FEAT_RW_CUR_POS: u32 = 8; -pub const IORING_FEAT_CUR_PERSONALITY: u32 = 16; -pub const IORING_FEAT_FAST_POLL: u32 = 32; -pub const IORING_FEAT_POLL_32BITS: u32 = 64; -pub const IORING_FEAT_SQPOLL_NONFIXED: u32 = 128; -pub const IORING_FEAT_EXT_ARG: u32 = 256; -pub const IORING_FEAT_NATIVE_WORKERS: u32 = 512; -pub const IORING_FEAT_RSRC_TAGS: u32 = 1024; -pub const IORING_FEAT_CQE_SKIP: u32 = 2048; -pub const IORING_FEAT_LINKED_FILE: u32 = 4096; -pub const IORING_FEAT_REG_REG_RING: u32 = 8192; -pub const IORING_RSRC_REGISTER_SPARSE: u32 = 1; -pub const IORING_REGISTER_FILES_SKIP: i32 = -2; -pub const IO_URING_OP_SUPPORTED: u32 = 1; -pub type __u8 = libc::c_uchar; -pub type __u16 = libc::c_ushort; -pub type __s32 = libc::c_int; -pub type __u32 = libc::c_uint; -pub type __u64 = libc::c_ulonglong; -pub type __kernel_time64_t = libc::c_longlong; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct __kernel_timespec { - pub tv_sec: __kernel_time64_t, - pub tv_nsec: libc::c_longlong, -} -#[test] -fn bindgen_test_layout___kernel_timespec() { - const UNINIT: ::core::mem::MaybeUninit<__kernel_timespec> = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::<__kernel_timespec>(), - 16usize, - concat!("Size of: ", stringify!(__kernel_timespec)) - ); - assert_eq!( - ::core::mem::align_of::<__kernel_timespec>(), - 8usize, - concat!("Alignment of ", stringify!(__kernel_timespec)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__kernel_timespec), - "::", - stringify!(tv_sec) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(__kernel_timespec), - "::", - stringify!(tv_nsec) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct open_how { - pub flags: __u64, - pub mode: __u64, - pub resolve: __u64, -} -#[test] -fn bindgen_test_layout_open_how() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(open_how)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(open_how)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(open_how), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).mode) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(open_how), - "::", - stringify!(mode) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resolve) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(open_how), - "::", - stringify!(resolve) - ) - ); -} -pub type __kernel_rwf_t = libc::c_int; -#[repr(C)] -pub struct io_uring_sqe { - pub opcode: __u8, - pub flags: __u8, - pub ioprio: __u16, - pub fd: __s32, - pub __bindgen_anon_1: io_uring_sqe__bindgen_ty_1, - pub __bindgen_anon_2: io_uring_sqe__bindgen_ty_2, - pub len: __u32, - pub __bindgen_anon_3: io_uring_sqe__bindgen_ty_3, - pub user_data: __u64, - pub __bindgen_anon_4: io_uring_sqe__bindgen_ty_4, - pub personality: __u16, - pub __bindgen_anon_5: io_uring_sqe__bindgen_ty_5, - pub __bindgen_anon_6: io_uring_sqe__bindgen_ty_6, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union io_uring_sqe__bindgen_ty_1 { - pub off: __u64, - pub addr2: __u64, - pub __bindgen_anon_1: io_uring_sqe__bindgen_ty_1__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_sqe__bindgen_ty_1__bindgen_ty_1 { - pub cmd_op: __u32, - pub __pad1: __u32, -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!( - "Size of: ", - stringify!(io_uring_sqe__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(io_uring_sqe__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).cmd_op) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(cmd_op) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__pad1) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(__pad1) - ) - ); -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(io_uring_sqe__bindgen_ty_1)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_sqe__bindgen_ty_1)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).off) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_1), - "::", - stringify!(off) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr2) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_1), - "::", - stringify!(addr2) - ) - ); -} -impl Default for io_uring_sqe__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union io_uring_sqe__bindgen_ty_2 { - pub addr: __u64, - pub splice_off_in: __u64, -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_2() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(io_uring_sqe__bindgen_ty_2)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_sqe__bindgen_ty_2)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_2), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).splice_off_in) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_2), - "::", - stringify!(splice_off_in) - ) - ); -} -impl Default for io_uring_sqe__bindgen_ty_2 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union io_uring_sqe__bindgen_ty_3 { - pub rw_flags: __kernel_rwf_t, - pub fsync_flags: __u32, - pub poll_events: __u16, - pub poll32_events: __u32, - pub sync_range_flags: __u32, - pub msg_flags: __u32, - pub timeout_flags: __u32, - pub accept_flags: __u32, - pub cancel_flags: __u32, - pub open_flags: __u32, - pub statx_flags: __u32, - pub fadvise_advice: __u32, - pub splice_flags: __u32, - pub rename_flags: __u32, - pub unlink_flags: __u32, - pub hardlink_flags: __u32, - pub xattr_flags: __u32, - pub msg_ring_flags: __u32, - pub uring_cmd_flags: __u32, -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_3() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(io_uring_sqe__bindgen_ty_3)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(io_uring_sqe__bindgen_ty_3)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).rw_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(rw_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).fsync_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(fsync_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).poll_events) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(poll_events) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).poll32_events) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(poll32_events) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sync_range_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(sync_range_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).msg_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(msg_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).timeout_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(timeout_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).accept_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(accept_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).cancel_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(cancel_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).open_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(open_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).statx_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(statx_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).fadvise_advice) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(fadvise_advice) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).splice_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(splice_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).rename_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(rename_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).unlink_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(unlink_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).hardlink_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(hardlink_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).xattr_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(xattr_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).msg_ring_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(msg_ring_flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).uring_cmd_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_3), - "::", - stringify!(uring_cmd_flags) - ) - ); -} -impl Default for io_uring_sqe__bindgen_ty_3 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub union io_uring_sqe__bindgen_ty_4 { - pub buf_index: __u16, - pub buf_group: __u16, -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_4() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 2usize, - concat!("Size of: ", stringify!(io_uring_sqe__bindgen_ty_4)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(io_uring_sqe__bindgen_ty_4)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).buf_index) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_4), - "::", - stringify!(buf_index) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).buf_group) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_4), - "::", - stringify!(buf_group) - ) - ); -} -impl Default for io_uring_sqe__bindgen_ty_4 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union io_uring_sqe__bindgen_ty_5 { - pub splice_fd_in: __s32, - pub file_index: __u32, - pub __bindgen_anon_1: io_uring_sqe__bindgen_ty_5__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_sqe__bindgen_ty_5__bindgen_ty_1 { - pub addr_len: __u16, - pub __pad3: [__u16; 1usize], -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_5__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!( - "Size of: ", - stringify!(io_uring_sqe__bindgen_ty_5__bindgen_ty_1) - ) - ); - assert_eq!( - ::core::mem::align_of::(), - 2usize, - concat!( - "Alignment of ", - stringify!(io_uring_sqe__bindgen_ty_5__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr_len) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_5__bindgen_ty_1), - "::", - stringify!(addr_len) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__pad3) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_5__bindgen_ty_1), - "::", - stringify!(__pad3) - ) - ); -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_5() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(io_uring_sqe__bindgen_ty_5)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(io_uring_sqe__bindgen_ty_5)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).splice_fd_in) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_5), - "::", - stringify!(splice_fd_in) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).file_index) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_5), - "::", - stringify!(file_index) - ) - ); -} -impl Default for io_uring_sqe__bindgen_ty_5 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -pub struct io_uring_sqe__bindgen_ty_6 { - pub __bindgen_anon_1: __BindgenUnionField, - pub cmd: __BindgenUnionField<[__u8; 0usize]>, - pub bindgen_union_field: [u64; 2usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_sqe__bindgen_ty_6__bindgen_ty_1 { - pub addr3: __u64, - pub __pad2: [__u64; 1usize], -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_6__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(io_uring_sqe__bindgen_ty_6__bindgen_ty_1) - ) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(io_uring_sqe__bindgen_ty_6__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr3) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_6__bindgen_ty_1), - "::", - stringify!(addr3) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__pad2) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_6__bindgen_ty_1), - "::", - stringify!(__pad2) - ) - ); -} -#[test] -fn bindgen_test_layout_io_uring_sqe__bindgen_ty_6() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_sqe__bindgen_ty_6)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_sqe__bindgen_ty_6)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).cmd) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe__bindgen_ty_6), - "::", - stringify!(cmd) - ) - ); -} -impl Default for io_uring_sqe__bindgen_ty_6 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_io_uring_sqe() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(io_uring_sqe)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_sqe)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).opcode) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe), - "::", - stringify!(opcode) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ioprio) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe), - "::", - stringify!(ioprio) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe), - "::", - stringify!(fd) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).user_data) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe), - "::", - stringify!(user_data) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).personality) as usize - ptr as usize }, - 42usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sqe), - "::", - stringify!(personality) - ) - ); -} -impl Default for io_uring_sqe { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -pub const IOSQE_FIXED_FILE_BIT: _bindgen_ty_4 = 0; -pub const IOSQE_IO_DRAIN_BIT: _bindgen_ty_4 = 1; -pub const IOSQE_IO_LINK_BIT: _bindgen_ty_4 = 2; -pub const IOSQE_IO_HARDLINK_BIT: _bindgen_ty_4 = 3; -pub const IOSQE_ASYNC_BIT: _bindgen_ty_4 = 4; -pub const IOSQE_BUFFER_SELECT_BIT: _bindgen_ty_4 = 5; -pub const IOSQE_CQE_SKIP_SUCCESS_BIT: _bindgen_ty_4 = 6; -pub type _bindgen_ty_4 = libc::c_uint; -pub const IORING_OP_NOP: io_uring_op = 0; -pub const IORING_OP_READV: io_uring_op = 1; -pub const IORING_OP_WRITEV: io_uring_op = 2; -pub const IORING_OP_FSYNC: io_uring_op = 3; -pub const IORING_OP_READ_FIXED: io_uring_op = 4; -pub const IORING_OP_WRITE_FIXED: io_uring_op = 5; -pub const IORING_OP_POLL_ADD: io_uring_op = 6; -pub const IORING_OP_POLL_REMOVE: io_uring_op = 7; -pub const IORING_OP_SYNC_FILE_RANGE: io_uring_op = 8; -pub const IORING_OP_SENDMSG: io_uring_op = 9; -pub const IORING_OP_RECVMSG: io_uring_op = 10; -pub const IORING_OP_TIMEOUT: io_uring_op = 11; -pub const IORING_OP_TIMEOUT_REMOVE: io_uring_op = 12; -pub const IORING_OP_ACCEPT: io_uring_op = 13; -pub const IORING_OP_ASYNC_CANCEL: io_uring_op = 14; -pub const IORING_OP_LINK_TIMEOUT: io_uring_op = 15; -pub const IORING_OP_CONNECT: io_uring_op = 16; -pub const IORING_OP_FALLOCATE: io_uring_op = 17; -pub const IORING_OP_OPENAT: io_uring_op = 18; -pub const IORING_OP_CLOSE: io_uring_op = 19; -pub const IORING_OP_FILES_UPDATE: io_uring_op = 20; -pub const IORING_OP_STATX: io_uring_op = 21; -pub const IORING_OP_READ: io_uring_op = 22; -pub const IORING_OP_WRITE: io_uring_op = 23; -pub const IORING_OP_FADVISE: io_uring_op = 24; -pub const IORING_OP_MADVISE: io_uring_op = 25; -pub const IORING_OP_SEND: io_uring_op = 26; -pub const IORING_OP_RECV: io_uring_op = 27; -pub const IORING_OP_OPENAT2: io_uring_op = 28; -pub const IORING_OP_EPOLL_CTL: io_uring_op = 29; -pub const IORING_OP_SPLICE: io_uring_op = 30; -pub const IORING_OP_PROVIDE_BUFFERS: io_uring_op = 31; -pub const IORING_OP_REMOVE_BUFFERS: io_uring_op = 32; -pub const IORING_OP_TEE: io_uring_op = 33; -pub const IORING_OP_SHUTDOWN: io_uring_op = 34; -pub const IORING_OP_RENAMEAT: io_uring_op = 35; -pub const IORING_OP_UNLINKAT: io_uring_op = 36; -pub const IORING_OP_MKDIRAT: io_uring_op = 37; -pub const IORING_OP_SYMLINKAT: io_uring_op = 38; -pub const IORING_OP_LINKAT: io_uring_op = 39; -pub const IORING_OP_MSG_RING: io_uring_op = 40; -pub const IORING_OP_FSETXATTR: io_uring_op = 41; -pub const IORING_OP_SETXATTR: io_uring_op = 42; -pub const IORING_OP_FGETXATTR: io_uring_op = 43; -pub const IORING_OP_GETXATTR: io_uring_op = 44; -pub const IORING_OP_SOCKET: io_uring_op = 45; -pub const IORING_OP_URING_CMD: io_uring_op = 46; -pub const IORING_OP_SEND_ZC: io_uring_op = 47; -pub const IORING_OP_SENDMSG_ZC: io_uring_op = 48; -pub const IORING_OP_LAST: io_uring_op = 49; -pub type io_uring_op = libc::c_uint; -pub const IORING_MSG_DATA: _bindgen_ty_5 = 0; -pub const IORING_MSG_SEND_FD: _bindgen_ty_5 = 1; -pub type _bindgen_ty_5 = libc::c_uint; -#[repr(C)] -#[derive(Debug, Default)] -pub struct io_uring_cqe { - pub user_data: __u64, - pub res: __s32, - pub flags: __u32, - pub big_cqe: __IncompleteArrayField<__u64>, -} -#[test] -fn bindgen_test_layout_io_uring_cqe() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_cqe)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_cqe)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).user_data) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_cqe), - "::", - stringify!(user_data) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).res) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_cqe), - "::", - stringify!(res) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_cqe), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).big_cqe) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_cqe), - "::", - stringify!(big_cqe) - ) - ); -} -pub const IORING_CQE_BUFFER_SHIFT: _bindgen_ty_6 = 16; -pub type _bindgen_ty_6 = libc::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_sqring_offsets { - pub head: __u32, - pub tail: __u32, - pub ring_mask: __u32, - pub ring_entries: __u32, - pub flags: __u32, - pub dropped: __u32, - pub array: __u32, - pub resv1: __u32, - pub resv2: __u64, -} -#[test] -fn bindgen_test_layout_io_sqring_offsets() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(io_sqring_offsets)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_sqring_offsets)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).head) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(head) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tail) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(tail) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ring_mask) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(ring_mask) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ring_entries) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(ring_entries) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).dropped) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(dropped) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).array) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(array) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv1) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(resv1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(io_sqring_offsets), - "::", - stringify!(resv2) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_cqring_offsets { - pub head: __u32, - pub tail: __u32, - pub ring_mask: __u32, - pub ring_entries: __u32, - pub overflow: __u32, - pub cqes: __u32, - pub flags: __u32, - pub resv1: __u32, - pub resv2: __u64, -} -#[test] -fn bindgen_test_layout_io_cqring_offsets() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(io_cqring_offsets)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_cqring_offsets)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).head) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(head) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tail) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(tail) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ring_mask) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(ring_mask) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ring_entries) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(ring_entries) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).overflow) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(overflow) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).cqes) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(cqes) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv1) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(resv1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(io_cqring_offsets), - "::", - stringify!(resv2) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_params { - pub sq_entries: __u32, - pub cq_entries: __u32, - pub flags: __u32, - pub sq_thread_cpu: __u32, - pub sq_thread_idle: __u32, - pub features: __u32, - pub wq_fd: __u32, - pub resv: [__u32; 3usize], - pub sq_off: io_sqring_offsets, - pub cq_off: io_cqring_offsets, -} -#[test] -fn bindgen_test_layout_io_uring_params() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 120usize, - concat!("Size of: ", stringify!(io_uring_params)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_params)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sq_entries) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(sq_entries) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).cq_entries) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(cq_entries) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sq_thread_cpu) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(sq_thread_cpu) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sq_thread_idle) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(sq_thread_idle) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).features) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(features) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).wq_fd) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(wq_fd) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sq_off) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(sq_off) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).cq_off) as usize - ptr as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(io_uring_params), - "::", - stringify!(cq_off) - ) - ); -} -pub const IORING_REGISTER_BUFFERS: _bindgen_ty_7 = 0; -pub const IORING_UNREGISTER_BUFFERS: _bindgen_ty_7 = 1; -pub const IORING_REGISTER_FILES: _bindgen_ty_7 = 2; -pub const IORING_UNREGISTER_FILES: _bindgen_ty_7 = 3; -pub const IORING_REGISTER_EVENTFD: _bindgen_ty_7 = 4; -pub const IORING_UNREGISTER_EVENTFD: _bindgen_ty_7 = 5; -pub const IORING_REGISTER_FILES_UPDATE: _bindgen_ty_7 = 6; -pub const IORING_REGISTER_EVENTFD_ASYNC: _bindgen_ty_7 = 7; -pub const IORING_REGISTER_PROBE: _bindgen_ty_7 = 8; -pub const IORING_REGISTER_PERSONALITY: _bindgen_ty_7 = 9; -pub const IORING_UNREGISTER_PERSONALITY: _bindgen_ty_7 = 10; -pub const IORING_REGISTER_RESTRICTIONS: _bindgen_ty_7 = 11; -pub const IORING_REGISTER_ENABLE_RINGS: _bindgen_ty_7 = 12; -pub const IORING_REGISTER_FILES2: _bindgen_ty_7 = 13; -pub const IORING_REGISTER_FILES_UPDATE2: _bindgen_ty_7 = 14; -pub const IORING_REGISTER_BUFFERS2: _bindgen_ty_7 = 15; -pub const IORING_REGISTER_BUFFERS_UPDATE: _bindgen_ty_7 = 16; -pub const IORING_REGISTER_IOWQ_AFF: _bindgen_ty_7 = 17; -pub const IORING_UNREGISTER_IOWQ_AFF: _bindgen_ty_7 = 18; -pub const IORING_REGISTER_IOWQ_MAX_WORKERS: _bindgen_ty_7 = 19; -pub const IORING_REGISTER_RING_FDS: _bindgen_ty_7 = 20; -pub const IORING_UNREGISTER_RING_FDS: _bindgen_ty_7 = 21; -pub const IORING_REGISTER_PBUF_RING: _bindgen_ty_7 = 22; -pub const IORING_UNREGISTER_PBUF_RING: _bindgen_ty_7 = 23; -pub const IORING_REGISTER_SYNC_CANCEL: _bindgen_ty_7 = 24; -pub const IORING_REGISTER_FILE_ALLOC_RANGE: _bindgen_ty_7 = 25; -pub const IORING_REGISTER_LAST: _bindgen_ty_7 = 26; -pub const IORING_REGISTER_USE_REGISTERED_RING: _bindgen_ty_7 = 2147483648; -pub type _bindgen_ty_7 = libc::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_files_update { - pub offset: __u32, - pub resv: __u32, - pub fds: __u64, -} -#[test] -fn bindgen_test_layout_io_uring_files_update() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_files_update)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_files_update)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_files_update), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_files_update), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).fds) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_files_update), - "::", - stringify!(fds) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_rsrc_register { - pub nr: __u32, - pub flags: __u32, - pub resv2: __u64, - pub data: __u64, - pub tags: __u64, -} -#[test] -fn bindgen_test_layout_io_uring_rsrc_register() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(io_uring_rsrc_register)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_rsrc_register)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_register), - "::", - stringify!(nr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_register), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_register), - "::", - stringify!(resv2) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_register), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tags) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_register), - "::", - stringify!(tags) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_rsrc_update { - pub offset: __u32, - pub resv: __u32, - pub data: __u64, -} -#[test] -fn bindgen_test_layout_io_uring_rsrc_update() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_rsrc_update)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_rsrc_update)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update), - "::", - stringify!(data) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_rsrc_update2 { - pub offset: __u32, - pub resv: __u32, - pub data: __u64, - pub tags: __u64, - pub nr: __u32, - pub resv2: __u32, -} -#[test] -fn bindgen_test_layout_io_uring_rsrc_update2() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(io_uring_rsrc_update2)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_rsrc_update2)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update2), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update2), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update2), - "::", - stringify!(data) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tags) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update2), - "::", - stringify!(tags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update2), - "::", - stringify!(nr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(io_uring_rsrc_update2), - "::", - stringify!(resv2) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_probe_op { - pub op: __u8, - pub resv: __u8, - pub flags: __u16, - pub resv2: __u32, -} -#[test] -fn bindgen_test_layout_io_uring_probe_op() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(io_uring_probe_op)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(io_uring_probe_op)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).op) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe_op), - "::", - stringify!(op) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe_op), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe_op), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe_op), - "::", - stringify!(resv2) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct io_uring_probe { - pub last_op: __u8, - pub ops_len: __u8, - pub resv: __u16, - pub resv2: [__u32; 3usize], - pub ops: __IncompleteArrayField, -} -#[test] -fn bindgen_test_layout_io_uring_probe() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_probe)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(io_uring_probe)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).last_op) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe), - "::", - stringify!(last_op) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ops_len) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe), - "::", - stringify!(ops_len) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe), - "::", - stringify!(resv2) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ops) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_probe), - "::", - stringify!(ops) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct io_uring_restriction { - pub opcode: __u16, - pub __bindgen_anon_1: io_uring_restriction__bindgen_ty_1, - pub resv: __u8, - pub resv2: [__u32; 3usize], -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union io_uring_restriction__bindgen_ty_1 { - pub register_op: __u8, - pub sqe_op: __u8, - pub sqe_flags: __u8, -} -#[test] -fn bindgen_test_layout_io_uring_restriction__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(io_uring_restriction__bindgen_ty_1)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(io_uring_restriction__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).register_op) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_restriction__bindgen_ty_1), - "::", - stringify!(register_op) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sqe_op) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_restriction__bindgen_ty_1), - "::", - stringify!(sqe_op) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sqe_flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_restriction__bindgen_ty_1), - "::", - stringify!(sqe_flags) - ) - ); -} -impl Default for io_uring_restriction__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_io_uring_restriction() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_restriction)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(io_uring_restriction)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).opcode) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_restriction), - "::", - stringify!(opcode) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(io_uring_restriction), - "::", - stringify!(resv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_restriction), - "::", - stringify!(resv2) - ) - ); -} -impl Default for io_uring_restriction { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_buf { - pub addr: __u64, - pub len: __u32, - pub bid: __u16, - pub resv: __u16, -} -#[test] -fn bindgen_test_layout_io_uring_buf() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_buf)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_buf)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).bid) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf), - "::", - stringify!(bid) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf), - "::", - stringify!(resv) - ) - ); -} -#[repr(C)] -pub struct io_uring_buf_ring { - pub __bindgen_anon_1: io_uring_buf_ring__bindgen_ty_1, -} -#[repr(C)] -pub struct io_uring_buf_ring__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField, - pub __bindgen_anon_2: __BindgenUnionField, - pub bindgen_union_field: [u64; 2usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1 { - pub resv1: __u64, - pub resv2: __u32, - pub resv3: __u16, - pub tail: __u16, -} -#[test] -fn bindgen_test_layout_io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv1) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(resv1) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv2) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(resv2) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv3) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(resv3) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tail) as usize - ptr as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(tail) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2 { - pub __empty_bufs: io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1, - pub bufs: __IncompleteArrayField, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1 {} -#[test] -fn bindgen_test_layout_io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1() { - assert_eq!( - ::core::mem::size_of::(), - 0usize, - concat!( - "Size of: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1) - ) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2__bindgen_ty_1) - ) - ); -} -#[test] -fn bindgen_test_layout_io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 0usize, - concat!( - "Size of: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2) - ) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).__empty_bufs) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(__empty_bufs) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).bufs) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_ring__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(bufs) - ) - ); -} -#[test] -fn bindgen_test_layout_io_uring_buf_ring__bindgen_ty_1() { - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_buf_ring__bindgen_ty_1)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_buf_ring__bindgen_ty_1)) - ); -} -impl Default for io_uring_buf_ring__bindgen_ty_1 { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_io_uring_buf_ring() { - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_buf_ring)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_buf_ring)) - ); -} -impl Default for io_uring_buf_ring { - fn default() -> Self { - let mut s = ::core::mem::MaybeUninit::::uninit(); - unsafe { - ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_buf_reg { - pub ring_addr: __u64, - pub ring_entries: __u32, - pub bgid: __u16, - pub flags: __u16, - pub resv: [__u64; 3usize], -} -#[test] -fn bindgen_test_layout_io_uring_buf_reg() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(io_uring_buf_reg)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_buf_reg)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ring_addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_reg), - "::", - stringify!(ring_addr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ring_entries) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_reg), - "::", - stringify!(ring_entries) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).bgid) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_reg), - "::", - stringify!(bgid) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_reg), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_buf_reg), - "::", - stringify!(resv) - ) - ); -} -pub const IORING_RESTRICTION_REGISTER_OP: _bindgen_ty_10 = 0; -pub const IORING_RESTRICTION_SQE_OP: _bindgen_ty_10 = 1; -pub const IORING_RESTRICTION_SQE_FLAGS_ALLOWED: _bindgen_ty_10 = 2; -pub const IORING_RESTRICTION_SQE_FLAGS_REQUIRED: _bindgen_ty_10 = 3; -pub const IORING_RESTRICTION_LAST: _bindgen_ty_10 = 4; -pub type _bindgen_ty_10 = libc::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_getevents_arg { - pub sigmask: __u64, - pub sigmask_sz: __u32, - pub pad: __u32, - pub ts: __u64, -} -#[test] -fn bindgen_test_layout_io_uring_getevents_arg() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(io_uring_getevents_arg)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_getevents_arg)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sigmask) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_getevents_arg), - "::", - stringify!(sigmask) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sigmask_sz) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_getevents_arg), - "::", - stringify!(sigmask_sz) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_getevents_arg), - "::", - stringify!(pad) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ts) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_getevents_arg), - "::", - stringify!(ts) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_sync_cancel_reg { - pub addr: __u64, - pub fd: __s32, - pub flags: __u32, - pub timeout: __kernel_timespec, - pub pad: [__u64; 4usize], -} -#[test] -fn bindgen_test_layout_io_uring_sync_cancel_reg() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(io_uring_sync_cancel_reg)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_sync_cancel_reg)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sync_cancel_reg), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).fd) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sync_cancel_reg), - "::", - stringify!(fd) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sync_cancel_reg), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).timeout) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sync_cancel_reg), - "::", - stringify!(timeout) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(io_uring_sync_cancel_reg), - "::", - stringify!(pad) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_file_index_range { - pub off: __u32, - pub len: __u32, - pub resv: __u64, -} -#[test] -fn bindgen_test_layout_io_uring_file_index_range() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_file_index_range)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(io_uring_file_index_range)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).off) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_file_index_range), - "::", - stringify!(off) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_file_index_range), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resv) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_file_index_range), - "::", - stringify!(resv) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct io_uring_recvmsg_out { - pub namelen: __u32, - pub controllen: __u32, - pub payloadlen: __u32, - pub flags: __u32, -} -#[test] -fn bindgen_test_layout_io_uring_recvmsg_out() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(io_uring_recvmsg_out)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(io_uring_recvmsg_out)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).namelen) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(io_uring_recvmsg_out), - "::", - stringify!(namelen) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).controllen) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(io_uring_recvmsg_out), - "::", - stringify!(controllen) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).payloadlen) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(io_uring_recvmsg_out), - "::", - stringify!(payloadlen) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(io_uring_recvmsg_out), - "::", - stringify!(flags) - ) - ); -} diff --git a/src/types.rs b/src/types.rs index 933dafb..87ba788 100644 --- a/src/types.rs +++ b/src/types.rs @@ -2,7 +2,7 @@ pub(crate) mod sealed { use super::{Fd, Fixed}; - use std::os::unix::io::RawFd; + use rustix::fd::RawFd; #[derive(Debug)] pub enum Target { @@ -43,25 +43,15 @@ pub(crate) mod sealed { use crate::sys; use crate::util::{cast_ptr, unwrap_nonzero, unwrap_u32}; use bitflags::bitflags; -use std::marker::PhantomData; -use std::num::NonZeroU32; -use std::os::unix::io::RawFd; +use core::marker::PhantomData; +use core::num::NonZeroU32; +use rustix::fd::RawFd; -pub use sys::__kernel_rwf_t as RwFlags; - -/// Opaque types, you should use [`statx`](struct@libc::statx) instead. -#[repr(C)] -#[allow(non_camel_case_types)] -pub struct statx { - _priv: (), -} - -/// Opaque types, you should use [`epoll_event`](libc::epoll_event) instead. -#[repr(C)] -#[allow(non_camel_case_types)] -pub struct epoll_event { - _priv: (), -} +pub use sys::ReadWriteFlags as RwFlags; +pub use sys::{ + iovec, msghdr, sockaddr, socklen_t, Advice, AtFlags, EpollEvent, Mode, OFlags, RenameFlags, + ResolveFlags, Statx, StatxFlags, +}; /// A file descriptor that has not been registered with io_uring. #[derive(Debug, Clone, Copy)] @@ -87,54 +77,57 @@ bitflags! { /// The default behavior when the timeout expires is to return a CQE with -libc::ETIME in /// the res field. To change this behavior to have zero returned, include /// [`types::TimeoutFlags::ETIME_SUCCESS`]. + #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub struct TimeoutFlags: u32 { - const ABS = sys::IORING_TIMEOUT_ABS; + const ABS = sys::IoringTimeoutFlags::ABS.bits(); - const BOOTTIME = sys::IORING_TIMEOUT_BOOTTIME; + const BOOTTIME = sys::IoringTimeoutFlags::BOOTTIME.bits(); - const REALTIME = sys::IORING_TIMEOUT_REALTIME; + const REALTIME = sys::IoringTimeoutFlags::REALTIME.bits(); - const LINK_TIMEOUT_UPDATE = sys::IORING_LINK_TIMEOUT_UPDATE; + const LINK_TIMEOUT_UPDATE = sys::IoringTimeoutFlags::UPDATE.bits(); - const ETIME_SUCCESS = sys::IORING_TIMEOUT_ETIME_SUCCESS; + const ETIME_SUCCESS = sys::IoringTimeoutFlags::ETIME_SUCCESS.bits(); } } bitflags! { /// Options for [`Fsync`](super::Fsync). + #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub struct FsyncFlags: u32 { - const DATASYNC = sys::IORING_FSYNC_DATASYNC; + const DATASYNC = sys::IoringFsyncFlags::DATASYNC.bits(); } } bitflags! { /// Options for [`AsyncCancel`](super::AsyncCancel) and /// [`Submitter::register_sync_cancel`](super::Submitter::register_sync_cancel). + #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub(crate) struct AsyncCancelFlags: u32 { /// Cancel all requests that match the given criteria, rather /// than just canceling the first one found. /// /// Available since 5.19. - const ALL = sys::IORING_ASYNC_CANCEL_ALL; + const ALL = sys::IoringAsyncCancelFlags::ALL.bits(); /// Match based on the file descriptor used in the original /// request rather than the user_data. /// /// Available since 5.19. - const FD = sys::IORING_ASYNC_CANCEL_FD; + const FD = sys::IoringAsyncCancelFlags::FD.bits(); /// Match any request in the ring, regardless of user_data or /// file descriptor. Can be used to cancel any pending /// request in the ring. /// /// Available since 5.19. - const ANY = sys::IORING_ASYNC_CANCEL_ANY; + const ANY = sys::IoringAsyncCancelFlags::ANY.bits(); /// Match based on the fixed file descriptor used in the original /// request rather than the user_data. /// /// Available since 6.0 - const FD_FIXED = sys::IORING_ASYNC_CANCEL_FD_FIXED; + const FD_FIXED = sys::IoringAsyncCancelFlags::FD_FIXED.bits(); } } @@ -149,34 +142,43 @@ impl OpenHow { OpenHow(sys::open_how { flags: 0, mode: 0, - resolve: 0, + resolve: sys::ResolveFlags::empty(), }) } - pub const fn flags(mut self, flags: u64) -> Self { - self.0.flags = flags; + pub const fn flags(mut self, flags: OFlags) -> Self { + self.0.flags = flags.bits() as _; self } - pub const fn mode(mut self, mode: u64) -> Self { - self.0.mode = mode; + pub const fn mode(mut self, mode: Mode) -> Self { + self.0.mode = mode.bits() as _; self } - pub const fn resolve(mut self, resolve: u64) -> Self { + pub const fn resolve(mut self, resolve: ResolveFlags) -> Self { self.0.resolve = resolve; self } } -#[derive(Default, Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy)] #[repr(transparent)] -pub struct Timespec(pub(crate) sys::__kernel_timespec); +pub struct Timespec(pub(crate) sys::Timespec); + +impl Default for Timespec { + fn default() -> Self { + Self(sys::Timespec { + tv_sec: 0, + tv_nsec: 0, + }) + } +} impl Timespec { #[inline] pub const fn new() -> Self { - Timespec(sys::__kernel_timespec { + Timespec(sys::Timespec { tv_sec: 0, tv_nsec: 0, }) @@ -195,6 +197,7 @@ impl Timespec { } } +#[cfg(feature = "std")] impl From for Timespec { fn from(value: std::time::Duration) -> Self { Timespec::new() @@ -208,7 +211,7 @@ impl From for Timespec { /// Note that arguments that exceed their lifetime will fail to compile. /// /// ```compile_fail -/// use io_uring::types::{ SubmitArgs, Timespec }; +/// use rustix_uring::types::{ SubmitArgs, Timespec }; /// /// let sigmask: libc::sigset_t = unsafe { std::mem::zeroed() }; /// @@ -247,9 +250,9 @@ impl<'prev, 'now> SubmitArgs<'prev, 'now> { } #[inline] - pub fn sigmask<'new>(mut self, sigmask: &'new libc::sigset_t) -> SubmitArgs<'now, 'new> { + pub fn sigmask<'new>(mut self, sigmask: &'new sys::sigset_t) -> SubmitArgs<'now, 'new> { self.args.sigmask = cast_ptr(sigmask) as _; - self.args.sigmask_sz = std::mem::size_of::() as _; + self.args.sigmask_sz = core::mem::size_of::() as _; SubmitArgs { args: self.args, @@ -387,7 +390,7 @@ pub struct RecvMsgOut<'buf> { } impl<'buf> RecvMsgOut<'buf> { - const DATA_START: usize = std::mem::size_of::(); + const DATA_START: usize = core::mem::size_of::(); /// Parse the data buffered upon completion of a `RecvMsg` multishot operation. /// @@ -395,8 +398,8 @@ impl<'buf> RecvMsgOut<'buf> { /// is the same content provided as input to the corresponding SQE /// (only `msg_namelen` and `msg_controllen` fields are relevant). #[allow(clippy::result_unit_err)] - pub fn parse(buffer: &'buf [u8], msghdr: &libc::msghdr) -> Result { - if buffer.len() < std::mem::size_of::() { + pub fn parse(buffer: &'buf [u8], msghdr: &msghdr) -> Result { + if buffer.len() < core::mem::size_of::() { return Err(()); } // SAFETY: buffer (minimum) length is checked here above. @@ -503,7 +506,7 @@ impl<'buf> RecvMsgOut<'buf> { /// When `true`, data returned by `payload_data()` is truncated and /// incomplete. pub fn is_payload_truncated(&self) -> bool { - self.header.flags & (libc::MSG_TRUNC as u32) != 0 + self.header.flags.intersects(sys::RecvmsgOutFlags::TRUNC) } /// Message payload, as buffered by the kernel. @@ -512,7 +515,7 @@ impl<'buf> RecvMsgOut<'buf> { } /// Message flags, with the same semantics as `msghdr.msg_flags`. - pub fn flags(&self) -> u32 { + pub fn flags(&self) -> sys::RecvmsgOutFlags { self.header.flags } } @@ -525,7 +528,7 @@ impl<'buf> RecvMsgOut<'buf> { /// ### Examples /// /// ``` -/// use io_uring::types::{CancelBuilder, Fd, Fixed}; +/// use rustix_uring::types::{CancelBuilder, Fd, Fixed}; /// /// // Match all in-flight requests. /// CancelBuilder::any(); diff --git a/src/util.rs b/src/util.rs index 6d4f7d3..9b2621e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,7 +1,9 @@ -use std::num::NonZeroU32; -use std::os::unix::io::AsRawFd; -use std::sync::atomic; -use std::{io, ptr}; +use core::num::NonZeroU32; +use core::ptr; +use core::sync::atomic; +use rustix::fd::OwnedFd; +use rustix::io; +use rustix::mm::{Advice, MapFlags, ProtFlags}; pub(crate) mod private { /// Private trait that we use as a supertrait of `EntryMarker` to prevent it from being @@ -11,49 +13,45 @@ pub(crate) mod private { /// A region of memory mapped using `mmap(2)`. pub(crate) struct Mmap { - addr: ptr::NonNull, + addr: ptr::NonNull, len: usize, } impl Mmap { /// Map `len` bytes starting from the offset `offset` in the file descriptor `fd` into memory. - pub fn new(fd: &OwnedFd, offset: libc::off_t, len: usize) -> io::Result { + pub fn new(fd: &OwnedFd, offset: u64, len: usize) -> io::Result { unsafe { - match libc::mmap( + let addr = rustix::mm::mmap( ptr::null_mut(), len, - libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_SHARED | libc::MAP_POPULATE, - fd.as_raw_fd(), + ProtFlags::READ | ProtFlags::WRITE, + MapFlags::SHARED | MapFlags::POPULATE, + fd, offset, - ) { - libc::MAP_FAILED => Err(io::Error::last_os_error()), - addr => { - // here, `mmap` will never return null - let addr = ptr::NonNull::new_unchecked(addr); - Ok(Mmap { addr, len }) - } - } + )?; + // here, `mmap` will never return null + let addr = ptr::NonNull::new_unchecked(addr); + Ok(Mmap { addr, len }) } } /// Do not make the stored memory accessible by child processes after a `fork`. pub fn dontfork(&self) -> io::Result<()> { - match unsafe { libc::madvise(self.addr.as_ptr(), self.len, libc::MADV_DONTFORK) } { - 0 => Ok(()), - _ => Err(io::Error::last_os_error()), + unsafe { + rustix::mm::madvise(self.addr.as_ptr(), self.len, Advice::LinuxDontFork)?; } + Ok(()) } /// Get a pointer to the memory. #[inline] - pub fn as_mut_ptr(&self) -> *mut libc::c_void { + pub fn as_mut_ptr(&self) -> *mut core::ffi::c_void { self.addr.as_ptr() } /// Get a pointer to the data at the given offset. #[inline] - pub unsafe fn offset(&self, offset: u32) -> *mut libc::c_void { + pub unsafe fn offset(&self, offset: u32) -> *mut core::ffi::c_void { self.as_mut_ptr().add(offset as usize) } } @@ -61,54 +59,7 @@ impl Mmap { impl Drop for Mmap { fn drop(&mut self) { unsafe { - libc::munmap(self.addr.as_ptr(), self.len); - } - } -} - -pub use fd::OwnedFd; - -#[cfg(feature = "io_safety")] -mod fd { - pub use std::os::unix::io::OwnedFd; -} - -#[cfg(not(feature = "io_safety"))] -mod fd { - use std::mem; - use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; - - /// API-compatible with the `OwnedFd` type in the Rust stdlib. - pub struct OwnedFd(RawFd); - - impl AsRawFd for OwnedFd { - #[inline] - fn as_raw_fd(&self) -> RawFd { - self.0 - } - } - - impl IntoRawFd for OwnedFd { - #[inline] - fn into_raw_fd(self) -> RawFd { - let fd = self.0; - mem::forget(self); - fd - } - } - - impl FromRawFd for OwnedFd { - #[inline] - unsafe fn from_raw_fd(fd: RawFd) -> OwnedFd { - OwnedFd(fd) - } - } - - impl Drop for OwnedFd { - fn drop(&mut self) { - unsafe { - libc::close(self.0); - } + rustix::mm::munmap(self.addr.as_ptr(), self.len).unwrap(); } } }