aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples
diff options
context:
space:
mode:
Diffstat (limited to 'cortex-m-rt/examples')
-rw-r--r--cortex-m-rt/examples/unsafety.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/unsafety.rs b/cortex-m-rt/examples/unsafety.rs
new file mode 100644
index 0000000..a9f0234
--- /dev/null
+++ b/cortex-m-rt/examples/unsafety.rs
@@ -0,0 +1,36 @@
+//! Checks that the declared unsafety is respected by the attributes
+
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_semihosting;
+
+use cortex_m_rt::{entry, exception, ExceptionFrame};
+
+#[entry]
+unsafe fn main() -> ! {
+ foo();
+
+ loop {}
+}
+
+#[exception]
+unsafe fn DefaultHandler(_irqn: i16) {
+ foo();
+}
+
+#[exception]
+unsafe fn HardFault(_ef: &ExceptionFrame) -> ! {
+ foo();
+
+ loop {}
+}
+
+#[exception]
+unsafe fn SysTick() {
+ foo();
+}
+
+unsafe fn foo() {}