mirror of
https://github.com/Noratrieb/libuwuc.git
synced 2026-01-14 19:55:07 +01:00
more things
This commit is contained in:
parent
1baf8df4a8
commit
5673cf51db
18 changed files with 292 additions and 9 deletions
4
rawc/build.rs
Normal file
4
rawc/build.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
println!("cargo:rustc-link-arg=-nostartfiles");
|
||||
println!("cargo:rustc-link-arg=-nostdlib");
|
||||
}
|
||||
|
|
@ -1,11 +1,15 @@
|
|||
#![no_std]
|
||||
#![feature(panic_info_message)]
|
||||
#![deny(clippy::no_mangle_with_rust_abi)]
|
||||
|
||||
mod rt;
|
||||
mod stdio;
|
||||
mod stdlib;
|
||||
mod string;
|
||||
|
||||
// libcore seems to require this symbol, even though it's unused.
|
||||
#[no_mangle]
|
||||
#[allow(clippy::no_mangle_with_rust_abi)]
|
||||
fn rust_eh_personality() {
|
||||
unsafe {
|
||||
libuwuc::trap!();
|
||||
|
|
|
|||
7
rawc/src/rt.rs
Normal file
7
rawc/src/rt.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#[no_mangle]
|
||||
pub extern "C" fn __stack_chk_fail() -> ! {
|
||||
unsafe {
|
||||
let _ = libuwuc::io::write_all(libuwuc::io::STDERR, b"error: stack overflow");
|
||||
libuwuc::start::abort();
|
||||
}
|
||||
}
|
||||
14
rawc/src/stdlib.rs
Normal file
14
rawc/src/stdlib.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn malloc(size: usize) -> *mut u8 {
|
||||
libuwuc::alloc::malloc_zeroed(size, 16)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn free(ptr: *mut u8) {
|
||||
libuwuc::alloc::free(ptr)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn exit(code: i32) -> ! {
|
||||
libuwuc::start::exit(code as i64 as _)
|
||||
}
|
||||
|
|
@ -9,13 +9,13 @@ pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8, size: usize) -> *
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe fn memcmp(s1: *const u8, s2: *const u8, size: usize) -> i32 {
|
||||
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, size: usize) -> i32 {
|
||||
libuwuc::mem::memcmp(s1, s2, size)
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe fn bcmp(s1: *const u8, s2: *const u8, size: usize) -> i32 {
|
||||
pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, size: usize) -> i32 {
|
||||
libuwuc::mem::memcmp(s1, s2, size)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue