Add explicit Miri support to libpanic_unwind
This commit is contained in:
@@ -1348,6 +1348,11 @@ extern "rust-intrinsic" {
|
|||||||
/// See documentation of `<*const T>::offset_from` for details.
|
/// See documentation of `<*const T>::offset_from` for details.
|
||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;
|
pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;
|
||||||
|
|
||||||
|
/// Internal hook used by Miri to implement unwinding.
|
||||||
|
/// Perma-unstable: do not use
|
||||||
|
#[cfg(not(bootstrap))]
|
||||||
|
pub fn miri_start_panic(data: *mut (dyn crate::any::Any + Send)) -> !;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some functions are defined here because they accidentally got made
|
// Some functions are defined here because they accidentally got made
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ use core::raw;
|
|||||||
use core::panic::BoxMeUp;
|
use core::panic::BoxMeUp;
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_os = "emscripten")] {
|
if #[cfg(miri)] {
|
||||||
|
#[path = "miri.rs"]
|
||||||
|
mod imp;
|
||||||
|
} else if #[cfg(target_os = "emscripten")] {
|
||||||
#[path = "emcc.rs"]
|
#[path = "emcc.rs"]
|
||||||
mod imp;
|
mod imp;
|
||||||
} else if #[cfg(target_arch = "wasm32")] {
|
} else if #[cfg(target_arch = "wasm32")] {
|
||||||
|
|||||||
12
src/libpanic_unwind/miri.rs
Normal file
12
src/libpanic_unwind/miri.rs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
pub fn payload() -> *mut u8 {
|
||||||
|
core::ptr::null_mut()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
|
||||||
|
core::intrinsics::miri_start_panic(Box::into_raw(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
|
||||||
|
Box::from_raw(ptr)
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user