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

[RFC] GUID byte-order #15

Open
planetA opened this issue Aug 21, 2021 · 2 comments
Open

[RFC] GUID byte-order #15

planetA opened this issue Aug 21, 2021 · 2 comments

Comments

@planetA
Copy link
Contributor

planetA commented Aug 21, 2021

Hello,

ibv_get_device_guid returns GUID in "network byte order" [1], which means big endian.

On another hand, the Rust counterpart returns u64, which I expect to be in the host byte order, which is little endian on my system. I would suggest to convert the result of the C version into host order. What would be your thoughts?

  1. https://linux.die.net/man/3/ibv_get_device_guid
@jonhoo
Copy link
Owner

jonhoo commented Aug 21, 2021

Ah, good catch! I think we should do the same thing that we ended up doing for Gid in #7. See the code there to handle the endianness. Would you be willing to submit a PR along those lines?

@planetA
Copy link
Contributor Author

planetA commented Aug 22, 2021

Hi, I created a pull request, which unfortunately does not work yet.

I tried to make a __be64 type as a tuple, so that it will not be convertible from u64 automatically. Unfortunately, it breaks ibv_gid type with the following error message

warning: build failed, waiting for other jobs to finish...
error[E0308]: mismatched types
   --> src/lib.rs:895:27
    |
895 |             raw: unsafe { gid.raw },
    |                           ^^^^^^^ expected array `[u8; 16]`, found struct `__BindgenUnionField`
    |
    = note: expected array `[u8; 16]`
              found struct `__BindgenUnionField<[u8; 16]>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

I'm still a newbie with Rust. Could you have a look at #16 to say if I'm moving in the right direction?

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

No branches or pull requests

2 participants