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

Fix up some mutability warts on datasec skeleton accessors #611

Closed
wants to merge 5 commits into from
Closed

Fix up some mutability warts on datasec skeleton accessors #611

wants to merge 5 commits into from

Conversation

danielocfb
Copy link
Collaborator

Please see individual commits for descriptions

It's not particularly user friendly to only have exclusive shared
datasec accessor variants available, as that can lead to unnecessary
borrow conflicts.
With this change we revamp the generation logic to generate shared and
exclusive accessors when possible.

Refs: #606

Signed-off-by: Daniel Müller <[email protected]>
@danielocfb danielocfb requested a review from anakryiko November 20, 2023 22:38
When we create a skeleton with a getter for an immutable map, we should
be able to use a non-exclusive receiver (&self) instead of an exclusive
one (&mut self). Using the latter unconditionally can be the cause of
unnecessary borrow conflicts.

Refs: #606

Signed-off-by: Daniel Müller <[email protected]>
There is not too much of a point in passing in the desired mutability to
gen_skel_prog_getter() when all call sites invoke it with both true and
false.
Move the logic for dealing with mutability into the function itself to
shield callers from the need to care.

Signed-off-by: Daniel Müller <[email protected]>
There is not too much of a point in passing in the desired mutability to
gen_skel_map_getters() when all call sites invoke it with both true and
false.
Move the logic for dealing with mutability into the function itself to
shield callers from the need to care.

Signed-off-by: Daniel Müller <[email protected]>
There is not too much of a point in passing in the desired mutability to
gen_skel_map_defs() when all call sites invoke it with both true and
false.
Move the logic for dealing with mutability into the function itself to
shield callers from the need to care.

Signed-off-by: Daniel Müller <[email protected]>
unsafe {{
std::mem::transmute::<*mut std::ffi::c_void, &'_ {mutability} {struct_name}>(
std::mem::transmute::<*mut std::ffi::c_void, &{mutability} {struct_name}>(
Copy link
Member

Choose a reason for hiding this comment

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

is it intentional that we transmute to *mut c_void for both mutabilities?

Copy link
Collaborator Author

@danielocfb danielocfb Nov 21, 2023

Choose a reason for hiding this comment

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

Not sure which commit you looked at/commented on, but in the end mutability would be just the empty string for the "shared" accessor. So yeah, it's intentional.

Copy link
Member

Choose a reason for hiding this comment

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

ah, I commented on commit #2 ("Use non-exclusive receiver for immutable datasec getters"), and it will later be replaced with {ptr_suffix}, never mind.

@danielocfb
Copy link
Collaborator Author

Uhm...I can't rebase and resolve the conflict for , so I am going to recreate the pull request with updated changes and then merge. Thanks for the review.

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 this pull request may close these issues.

3 participants