example of test and calling C from rust

This commit is contained in:
Travis Burtrum 2021-10-25 03:04:51 -04:00
parent 2675aa13c9
commit 3359073498
2 changed files with 23 additions and 6 deletions

View File

@ -1,15 +1,28 @@
#![no_std]
use core::panic::PanicInfo;
/// This function is called on panic.
#[cfg(not(test))]
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
#[no_mangle]
pub extern "C" fn get_rust_u8() -> u8 {
9
}
//9
unsafe { get_c_u8() }
}
extern "C" {
fn get_c_u8() -> u8;
}
#[cfg(test)]
mod tests {
use crate::*;
#[test]
fn it_works() {
assert_eq!(get_rust_u8(), 9);
}
}

View File

@ -58,6 +58,10 @@
#define MAX_LIST 20
uint8_t get_c_u8(void) {
return 20;
}
struct glyph
{
int xoff;