From 0572cf1d4111d22d99dcabc1390f05af33373533 Mon Sep 17 00:00:00 2001 From: Bruno Deferrari Date: Wed, 27 Dec 2023 12:44:04 -0300 Subject: [PATCH] Expose `recover_handle_mut`, used by macros --- src/macros.rs | 2 +- src/runtime.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index d0f0788..b8e8e91 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1577,7 +1577,7 @@ macro_rules! expand_exported_function { } => { #[no_mangle] pub extern "C" fn $name( $($arg: $typ),* ) -> $crate::expand_exported_function_return!($($rtyp)*) { - let $cr = unsafe { &mut $crate::OCamlRuntime::recover_handle() }; + let $cr = unsafe { &mut $crate::OCamlRuntime::recover_handle_mut() }; $crate::expand_rooted_args_init!($cr, $($original_args)*); $crate::expand_exported_function_body!( @body $body diff --git a/src/runtime.rs b/src/runtime.rs index 5a563f1..93918a8 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -49,14 +49,15 @@ impl OCamlRuntime { panic!("Rust code that is called from an OCaml program should not try to initialize the runtime."); } + #[doc(hidden)] #[inline(always)] - pub(crate) unsafe fn recover_handle_mut() -> &'static mut Self { + pub unsafe fn recover_handle_mut() -> &'static mut Self { static mut RUNTIME: OCamlRuntime = OCamlRuntime { _private: () }; &mut RUNTIME } #[inline(always)] - pub(crate) unsafe fn recover_handle() -> &'static Self { + unsafe fn recover_handle() -> &'static Self { Self::recover_handle_mut() } @@ -132,12 +133,12 @@ impl OCamlDomainLock { } #[inline(always)] - pub(crate) fn recover_handle<'a>(&self) -> &'a OCamlRuntime { + fn recover_handle<'a>(&self) -> &'a OCamlRuntime { unsafe { OCamlRuntime::recover_handle() } } #[inline(always)] - pub(crate) fn recover_handle_mut<'a>(&self) -> &'a mut OCamlRuntime { + fn recover_handle_mut<'a>(&self) -> &'a mut OCamlRuntime { unsafe { OCamlRuntime::recover_handle_mut() } } }