mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-21 18:44:01 +00:00
32 lines
473 B
Rust
32 lines
473 B
Rust
#![no_std]
|
|
|
|
use core::panic::PanicInfo;
|
|
|
|
#[panic_handler]
|
|
fn panic(_info: &PanicInfo) -> ! {
|
|
loop {
|
|
core::hint::spin_loop();
|
|
}
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn cleonos_rust_guarded_len(ptr: *const u8, max_len: usize) -> u64 {
|
|
let mut i: usize = 0;
|
|
|
|
if ptr.is_null() {
|
|
return 0;
|
|
}
|
|
|
|
while i < max_len {
|
|
let ch = unsafe { *ptr.add(i) };
|
|
|
|
if ch == 0 {
|
|
break;
|
|
}
|
|
|
|
i += 1;
|
|
}
|
|
|
|
i as u64
|
|
}
|