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

Rust: remove direct dependency on the libc crate #5654

Closed
wants to merge 1 commit into from

Conversation

mkrasnitski
Copy link
Contributor

Almost all uses of the libc crate were to import types that the standard library already provides, e.g. c_void, c_char, etc. We can import those from std::ffi. In some places they were being imported from std::os::raw, so I changed those imports as well, as they are just type aliases for the definitions in std::ffi anyways.

One nontrivial case where libc was being used was inside cb_{free_}flag_conditions_for_semantic_flag_group, which used libc::{malloc, free}. This was changed to use std::alloc::{alloc, dealloc} and required some hacky layout calculations in order to smuggle the length of the allocated array across the FFI boundary.

Getting rid of this hack would require for the Core API to change such that a count: usize parameter is passed to cb_free_flag_conditions_for_semantic_flag_group (and ideally also to cb_free_register_list) so that no smuggling would be required and we could just call Box::from_raw(ptr::slice_from_raw_parts_mut(conds, count)) and be done. I'll open a separate issue for that.

@mkrasnitski
Copy link
Contributor Author

Rebased on the newest dev, and ready for re-review.

@mkrasnitski
Copy link
Contributor Author

Before I resolve the new conflicts, I'd love for #5764 to be merged so I could rebase on top.

@emesare emesare self-assigned this Jul 29, 2024
@emesare emesare self-requested a review July 29, 2024 11:21
@emesare
Copy link
Member

emesare commented Aug 24, 2024

This PR is superseded by rust_break_everything.

Specifically ec43516 and ce5995c (Warning: this branch will rewrite history, these commits may not be accurate later)

@emesare emesare closed this Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Rust API Issue needs changes to the Rust API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants