Skip to content

Commit

Permalink
feat: Faster UDP/IO on Apple platforms
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
larseggert committed Sep 20, 2024
1 parent 43a9d76 commit aa19b97
Show file tree
Hide file tree
Showing 4 changed files with 1,630 additions and 12 deletions.
3 changes: 3 additions & 0 deletions quinn-udp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ tracing = { workspace = true, optional = true }
once_cell = { workspace = true }
windows-sys = { workspace = true }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.build-dependencies]
bindgen = "0.70.1"

[dev-dependencies]
criterion = "0.5"

Expand Down
22 changes: 22 additions & 0 deletions quinn-udp/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![cfg(any(target_os = "macos", target_os = "ios"))]

use std::env;
use std::path::PathBuf;

fn main() {
// Generate the bindings for Apple's private `recvmsg_x` from
// https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/socket.h.
let bindings = bindgen::Builder::default()
.clang_arg("-DPRIVATE=1")
.allowlist_function("recvmsg_x") // TODO: sendmsg_x
.no_copy("iovec") // msghdr_x
.header("src/bindings/socket.h")
.generate()
.expect("Unable to generate bindings");

// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}
Loading

0 comments on commit aa19b97

Please sign in to comment.