stub some things

This commit is contained in:
nora 2023-10-01 16:42:44 +02:00
parent 609c5e6e3d
commit 3a98a2b822
7 changed files with 84 additions and 11 deletions

View file

@ -1,3 +1,7 @@
use core::ffi::c_uint;
use libuwuc::utils::SharedThinCstr;
#[no_mangle]
pub extern "C" fn __stack_chk_fail() -> ! {
unsafe {
@ -9,4 +13,19 @@ pub extern "C" fn __stack_chk_fail() -> ! {
#[no_mangle]
pub extern "C" fn __errno_location() -> *const i32 {
libuwuc::error::errno_location()
}
}
#[no_mangle]
pub unsafe extern "C" fn __assert_fail(
assertion: *const u8,
file: *const u8,
line: c_uint,
function: *const u8,
) -> ! {
libuwuc::misc::assert_failed(
SharedThinCstr::from_raw(assertion),
SharedThinCstr::from_raw(file),
line,
SharedThinCstr::from_nullable(function),
)
}

View file

@ -44,9 +44,13 @@ pub unsafe extern "C" fn printf(format: *const u8, mut args: ...) -> c_int {
}
}
#[no_mangle]
pub unsafe extern "C" fn __fprintf_chk(_flag: c_int, file: &FileStream, format: *const u8, mut args: ...) -> c_int {
pub unsafe extern "C" fn __fprintf_chk(
_flag: c_int,
file: &FileStream,
format: *const u8,
mut args: ...
) -> c_int {
let mut sink = WriteCounter(file, 0);
let result = libuwuc::fmt::printf::printf_generic(
@ -77,7 +81,6 @@ pub unsafe extern "C" fn fprintf(file: &FileStream, format: *const u8, mut args:
}
}
// STREAMS:
#[no_mangle]
@ -87,17 +90,37 @@ pub static stdout: &FileStream = &FileStream::from_raw_fd(STDOUT);
#[no_mangle]
pub static stderr: &FileStream = &FileStream::from_raw_fd(STDERR);
#[no_mangle]
pub unsafe extern "C" fn fgetc(_stream: *mut FileStream) -> c_int {
todo!()
}
#[no_mangle]
pub unsafe extern "C" fn ungetc(_c: c_int, _stream: *mut FileStream) -> c_int {
todo!()
}
#[no_mangle]
pub unsafe extern "C" fn fputc(c: c_int, stream: *mut FileStream) -> c_int {
libuwuc::io::stream::fputc(c as u8, &*stream)
}
#[no_mangle]
pub unsafe extern "C" fn fread(
_ptr: *const u8,
_size: usize,
_nmemb: usize,
_stream: *mut FileStream,
) -> usize {
todo!()
}
#[no_mangle]
pub unsafe extern "C" fn fwrite(
ptr: *const u8,
size: usize,
nitems: usize,
nmemb: usize,
stream: &FileStream,
) -> usize {
libuwuc::io::stream::fwrite(ptr, size, nitems, stream)
libuwuc::io::stream::fwrite(ptr, size, nmemb, stream)
}