hello_rust: changes for target support
This commit is contained in:
parent
0baf524def
commit
aa2c9e7c33
@ -31,4 +31,6 @@ MODULE = $(CONFIG_EXAMPLES_HELLO_RUST)
|
|||||||
|
|
||||||
MAINSRC = hello_rust_main.rs
|
MAINSRC = hello_rust_main.rs
|
||||||
|
|
||||||
|
RUSTFLAGS += -C panic=abort
|
||||||
|
|
||||||
include $(APPDIR)/Application.mk
|
include $(APPDIR)/Application.mk
|
||||||
|
@ -23,16 +23,35 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Uses
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Externs
|
* Externs
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
pub fn printf(format: *const u8, ...) -> i32;
|
pub fn printf(format: *const u8, ...) -> i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Panic handler (needed for [no_std] compilation)
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#[panic_handler]
|
||||||
|
fn panic(_panic: &PanicInfo<'_>) -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public functions
|
* Public functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -42,14 +61,12 @@ extern "C"
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn hello_rust_main(_argc: i32, _argv: *const *const u8) -> i32
|
pub extern "C" fn hello_rust_main(_argc: i32, _argv: *const *const u8) -> i32 {
|
||||||
{
|
|
||||||
/* "Hello, Rust!!" using printf() from libc */
|
/* "Hello, Rust!!" using printf() from libc */
|
||||||
|
|
||||||
unsafe
|
unsafe {
|
||||||
{
|
|
||||||
printf(b"Hello, Rust!!\n\0" as *const u8);
|
printf(b"Hello, Rust!!\n\0" as *const u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exit with status 0 */
|
/* exit with status 0 */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user