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

Exposing IBV_LINK_LAYER_.* unnamed enum variants in bindings #40

Closed
crazyboycjr opened this issue Dec 19, 2024 · 3 comments · Fixed by #42
Closed

Exposing IBV_LINK_LAYER_.* unnamed enum variants in bindings #40

crazyboycjr opened this issue Dec 19, 2024 · 3 comments · Fixed by #42

Comments

@crazyboycjr
Copy link

.allowlist_type("ibv_.*")

Hey @jonhoo, would you mind adding a one line change so that the ffi exposes three more variants as below? This will be useful for determining the default gid_index based on the link layer types (IB: no gid; ETH: default to 0).

The proposed one line change:

diff --git a/ibverbs-sys/build.rs b/ibverbs-sys/build.rs
index cfd50f5..17d771f 100644
--- a/ibverbs-sys/build.rs
+++ b/ibverbs-sys/build.rs
@@ -41,6 +41,7 @@ fn main() {
         .clang_arg(format!("-I{built_in}/include/"))
         .allowlist_function("ibv_.*")
         .allowlist_type("ibv_.*")
+        .allowlist_var("IBV_LINK_LAYER_.*")
         .bitfield_enum("ibv_access_flags")
         .bitfield_enum("ibv_qp_attr_mask")
         .bitfield_enum("ibv_wc_flags")

The changes to the generated bindings:

$ diff target/debug/build/ibverbs-sys-ae96b897be5a9fe2/out/bindings.rs target/debug/build/ibverbs-sys-5db836f0aefb9cb9/out/bindings.rs --color
2363a2364,2367
> pub const IBV_LINK_LAYER_UNSPECIFIED: _bindgen_ty_13 = 0;
> pub const IBV_LINK_LAYER_INFINIBAND: _bindgen_ty_13 = 1;
> pub const IBV_LINK_LAYER_ETHERNET: _bindgen_ty_13 = 2;
> pub type _bindgen_ty_13 = ::std::os::raw::c_uint;
jonhoo added a commit that referenced this issue Dec 27, 2024
These are useful for matching against and providing some known constant
numeric values with meaningful names.

Fixes #40.
@jonhoo
Copy link
Owner

jonhoo commented Dec 27, 2024

Consider it done!
#42

@jonhoo
Copy link
Owner

jonhoo commented Dec 27, 2024

btw, both ibverbs-sys and ibverbs are now documented on docs.rs! 🎉

@crazyboycjr
Copy link
Author

crazyboycjr commented Dec 27, 2024

btw, both ibverbs-sys and ibverbs are now documented on docs.rs! 🎉

Thank you so much for the great effort! 🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants