Skip to content

Add from_raw and into_raw methods to RestoreState. - #64

Open
reitermarkus wants to merge 1 commit into
rust-embedded:mainfrom
reitermarkus:raw-conversion
Open

Add from_raw and into_raw methods to RestoreState.#64
reitermarkus wants to merge 1 commit into
rust-embedded:mainfrom
reitermarkus:raw-conversion

Conversation

@reitermarkus

Copy link
Copy Markdown
Member

I have a use case where I need to re-expose _critical_section_1_0_acquire/_critical_section_1_0_release to a shared library that is dynamically loaded.

Specifically, using the elf_loader crate, I need to do this:

unsafe fn _critical_section_1_0_acquire() -> RawRestoreState {
  unsafe { critical_section::acquire().into_raw() }
}

unsafe fn _critical_section_1_0_release(restore_state: RawRestoreState) {
  unsafe { critical_section::release(RestoreState::from_raw(restore_state)) };
}


 SyntheticModule::new(
  "__host",
  [
    SyntheticSymbol::function(
      "_critical_section_1_0_acquire",
      _critical_section_1_0_acquire as *const (),
    ),
    SyntheticSymbol::function(
      "_critical_section_1_0_release",
      _critical_section_1_0_release as *const (),
    ),
  ],
)

@reitermarkus
reitermarkus requested a review from a team as a code owner July 27, 2026 07:11
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.

1 participant