This commit is contained in:
nora 2023-09-30 10:25:23 +02:00
parent de90913d46
commit 54e0e7604e
23 changed files with 77 additions and 33 deletions

13
c/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "c"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["rlib"]
[dependencies]
libuwuc = { path = "../libuwuc" }

11
c/src/lib.rs Normal file
View file

@ -0,0 +1,11 @@
#![no_std]
mod string;
// libcore seems to require this symbol, even though it's unused.
#[no_mangle]
fn rust_eh_personality() {
unsafe {
libuwuc::trap!();
}
}

13
c/src/string.rs Normal file
View file

@ -0,0 +1,13 @@
#[no_mangle]
pub(crate) unsafe extern "C" fn memset(ptr: *mut u8, constant: u8, len: usize) {
for i in 0..len {
unsafe {
*ptr.add(i) = constant;
}
}
}
#[no_mangle]
pub(crate) unsafe extern "C" fn strlen(s: *const u8) -> usize {
libuwuc::mem::strlen(s)
}