aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-08-03 06:06:54 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-08-03 06:06:54 +0000
commitdf26fc1a301389c0c8a7cba3539d9c6252ec5dec (patch)
tree1a3355408e26bab053c26cb40b94765dc378ffe9
parentc76f2a18d982760bdd1d088b9272223af5f30e9b (diff)
parent21c205462686554d0d639834fc7d38e84608f11a (diff)
downloadcortex-m-df26fc1a301389c0c8a7cba3539d9c6252ec5dec.tar.gz
cortex-m-df26fc1a301389c0c8a7cba3539d9c6252ec5dec.tar.zst
cortex-m-df26fc1a301389c0c8a7cba3539d9c6252ec5dec.zip
Merge #78
78: Modified the entry and exception macros to accept a closure. r=japaric a=sjroe This allows: ```rust entry!(|| { let mut x = 1; loop { x = x + 1; } }); ``` as well as allowing the original usage: ```rust entry!(main); fn main() -> ! { let mut x = 1; loop { x = x + 1; } } ``` The same is true for exceptions: ```rust exception!(*, |irqn: i16| { panic!("Unhandled exception (IRQn = {})", irqn); }); ``` Co-authored-by: Stephen Roe <ste.roe@gmail.com>
-rw-r--r--cortex-m-rt/src/lib.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index eaefbbc..e55171a 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/src/lib.rs
@@ -525,7 +525,7 @@ pub unsafe extern "C" fn Reset() -> ! {
/// The signature of the specified function must be `fn() -> !` (never ending function)
#[macro_export]
macro_rules! entry {
- ($path:path) => {
+ ($path:expr) => {
#[export_name = "main"]
pub extern "C" fn __impl_main() -> ! {
// validate the signature of the program entry point
@@ -695,7 +695,7 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
/// $Name:ident,
///
/// // Path to the exception handler (a function)
-/// $handler:path,
+/// $handler:expr,
///
/// // Optional, state preserved across invocations of the handler
/// state: $State:ty = $initial_state:expr,
@@ -790,7 +790,7 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
/// ```
#[macro_export]
macro_rules! exception {
- (* , $handler:path) => {
+ (* , $handler:expr) => {
#[allow(unsafe_code)]
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
#[no_mangle]
@@ -808,7 +808,7 @@ macro_rules! exception {
}
};
- (HardFault, $handler:path) => {
+ (HardFault, $handler:expr) => {
#[allow(unsafe_code)]
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
#[no_mangle]
@@ -820,7 +820,7 @@ macro_rules! exception {
}
};
- ($Name:ident, $handler:path,state: $State:ty = $initial_state:expr) => {
+ ($Name:ident, $handler:expr,state: $State:ty = $initial_state:expr) => {
#[allow(unsafe_code)]
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
#[no_mangle]
@@ -837,7 +837,7 @@ macro_rules! exception {
}
};
- ($Name:ident, $handler:path) => {
+ ($Name:ident, $handler:expr) => {
#[allow(unsafe_code)]
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
#[no_mangle]