Fix clean build and remove object

This commit is contained in:
Kitsu 2021-12-09 14:32:45 +03:00
parent 17ca59abe0
commit 345624c745
3 changed files with 34 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#![no_std]
mod nanolibc;
mod sys;
pub use sys::*;

33
src/nanolibc.rs Normal file
View File

@ -0,0 +1,33 @@
#[no_mangle]
pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8 {
for i in 0..n {
*dest.add(i) = *src.add(i);
}
dest
}
#[no_mangle]
pub unsafe extern "C" fn memset(s: *mut u8, x: i32, n: usize) -> *mut u8 {
for i in 0..n {
*s.add(i) = x as u8;
}
s
}
#[no_mangle]
pub unsafe extern "C" fn memcmp(s1: *mut u8, s2: *const u8, n: usize) -> i32 {
for i in 0..n {
let x = *s1.add(i);
let y = *s2.add(i);
if x == y {
continue;
}
let (x, y) = (i32::from(x), i32::from(y));
return x - y;
}
0
}

Binary file not shown.