Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Faster UDP/IO on Apple platforms #1993

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bindgen is a pretty big and unstable dependency. Would it be simpler to commit the generated bindings?

.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
Loading