Преглед изворни кода

Add termination trait to lang-items.

David Craven пре 7 година
родитељ
комит
218d27bbd3
2 измењених фајлова са 17 додато и 6 уклоњено
  1. 1 3
      riscv-rt/Cargo.toml
  2. 16 3
      riscv-rt/src/lang_items.rs

+ 1 - 3
riscv-rt/Cargo.toml

@@ -10,6 +10,4 @@ license = "ISC"
 
 [dependencies]
 r0 = "^0.2.1"
-
-[dependencies.riscv]
-git = "https://github.com/dvc94ch/riscv"
+riscv = { path = "../riscv" }

+ 16 - 3
riscv-rt/src/lang_items.rs

@@ -3,7 +3,6 @@
 use riscv::asm;
 
 /// Default panic handler
-#[linkage = "weak"]
 #[lang = "panic_fmt"]
 unsafe extern "C" fn panic_fmt(
     _: ::core::fmt::Arguments, // fmt
@@ -34,12 +33,26 @@ unsafe extern "C" fn panic_fmt(
 // has to call `rustc_main`. That's covered by the `reset_handler` function in
 // root of this crate.
 #[lang = "start"]
-extern "C" fn start(
+extern "C" fn lang_start<T>(
     main: fn(),
     _argc: isize,
     _argv: *const *const u8,
-) -> isize {
+) -> isize
+    where
+    T: Termination,
+{
     main();
 
     0
 }
+
+#[lang = "termination"]
+pub trait Termination {
+    fn report(self) -> i32;
+}
+
+impl Termination for () {
+    fn report(self) -> i32 {
+        0
+    }
+}