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

Derive zerocopy::{AsBytes, FromBytes} for all structs #65

Open
smmalis37 opened this issue Oct 20, 2022 · 6 comments
Open

Derive zerocopy::{AsBytes, FromBytes} for all structs #65

smmalis37 opened this issue Oct 20, 2022 · 6 comments

Comments

@smmalis37
Copy link

It would be very helpful, and allow us to reduce the amount of unsafe code we have, if more structs could derive AsBytes and FromBytes, specifically those in https://github.com/rust-vmm/mshv/blob/main/mshv-bindings/src/bindings.rs and https://github.com/rust-vmm/mshv/blob/main/mshv-bindings/src/regs.rs.

@liuw
Copy link
Member

liuw commented Oct 20, 2022

CC @russell-islam

@liuw
Copy link
Member

liuw commented Oct 20, 2022

@smmalis37 I've gone through regs.rs and added those where I can. However bindings.rs is generated by bindgen. I'm a bit hesitant to modify it by hand and only to be overwritten later.

@liuw
Copy link
Member

liuw commented Oct 20, 2022

This looks interesting rust-lang/rust-bindgen#2059 but there is no CLI option exposed in bindgen.

@smmalis37
Copy link
Author

There's also rust-lang/rust-bindgen#2168

@russell-islam
Copy link
Collaborator

For generating bindings we need to have the support to derive these fields. We can not manually do it every time.

@liuw
Copy link
Member

liuw commented Oct 25, 2022

It looks like the issue on bindgen's side is progressing. I'm going to leave this issue open for now.

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

3 participants