mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-19 11:02:02 +00:00
feat(core/rust): improve catch_exception, make use of Rust 1.55
This commit is contained in:
parent
9dd97c77e3
commit
806beb77d2
@ -71,7 +71,7 @@ mp_obj_t trezor_obj_call_protected(void (*func)(void *), void *arg) {
|
|||||||
if (nlr_push(&nlr) == 0) {
|
if (nlr_push(&nlr) == 0) {
|
||||||
(*func)(arg);
|
(*func)(arg);
|
||||||
nlr_pop();
|
nlr_pop();
|
||||||
return mp_const_none;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
return MP_OBJ_FROM_PTR(nlr.ret_val);
|
return MP_OBJ_FROM_PTR(nlr.ret_val);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use core::mem::MaybeUninit;
|
|||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use super::{ffi, obj::Obj};
|
use super::ffi;
|
||||||
|
|
||||||
/// Raise a micropython exception via NLR jump.
|
/// Raise a micropython exception via NLR jump.
|
||||||
/// Jumps directly out of the context without running any destructors,
|
/// Jumps directly out of the context without running any destructors,
|
||||||
@ -34,7 +34,7 @@ where
|
|||||||
// boundary, so we assign it explicitly in `wrapper`.
|
// boundary, so we assign it explicitly in `wrapper`.
|
||||||
let mut result = MaybeUninit::zeroed();
|
let mut result = MaybeUninit::zeroed();
|
||||||
let mut wrapper = || {
|
let mut wrapper = || {
|
||||||
result = MaybeUninit::new(func());
|
result.write(func());
|
||||||
};
|
};
|
||||||
// `wrapper` is a closure, and to pass it over the FFI, we split it into a
|
// `wrapper` is a closure, and to pass it over the FFI, we split it into a
|
||||||
// function pointer, and a user-data pointer.
|
// function pointer, and a user-data pointer.
|
||||||
@ -42,7 +42,7 @@ where
|
|||||||
// `argument`.
|
// `argument`.
|
||||||
let (callback, argument) = split_func_into_callback_and_argument(&mut wrapper);
|
let (callback, argument) = split_func_into_callback_and_argument(&mut wrapper);
|
||||||
let exception = ffi::trezor_obj_call_protected(Some(callback), argument);
|
let exception = ffi::trezor_obj_call_protected(Some(callback), argument);
|
||||||
if exception == Obj::const_none() {
|
if exception.is_null() {
|
||||||
Ok(result.assume_init())
|
Ok(result.assume_init())
|
||||||
} else {
|
} else {
|
||||||
Err(Error::CaughtException(exception))
|
Err(Error::CaughtException(exception))
|
||||||
|
@ -54,7 +54,7 @@ brew install scons sdl2 sdl2_image pkg-config llvm
|
|||||||
|
|
||||||
## Rust
|
## Rust
|
||||||
|
|
||||||
You will require Rust and Cargo. The currently supported version is 1.52 stable.
|
You will require Rust and Cargo. The currently supported version is 1.55 stable.
|
||||||
The recommended way to install both is with [`rustup`](https://rustup.rs/). If you
|
The recommended way to install both is with [`rustup`](https://rustup.rs/). If you
|
||||||
are installing `rustup` for the first time, the stable toolchain will be installed
|
are installing `rustup` for the first time, the stable toolchain will be installed
|
||||||
for you automatically. Otherwise, make sure you are up to date:
|
for you automatically. Otherwise, make sure you are up to date:
|
||||||
|
Loading…
Reference in New Issue
Block a user