This commit is contained in:
nora 2023-10-08 11:52:35 +02:00
parent 8d1795ad1a
commit 4d4af78afe
10 changed files with 59 additions and 9 deletions

View file

@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["staticlib", "rlib", "cdylib"]
crate-type = ["staticlib", "rlib"]
[dependencies]

6
rawc/src/fcntl.rs Normal file
View file

@ -0,0 +1,6 @@
use libuwuc::{error::IntoOkOrErrno, utils::SharedThinCstr, io::fd::Fd};
#[no_mangle]
pub unsafe extern "C" fn open(path: SharedThinCstr<'_>, flags: i32) -> Fd {
libuwuc::io::fd::open(path, flags).into_ok_or_errno()
}

View file

@ -4,6 +4,7 @@
#![deny(clippy::no_mangle_with_rust_abi)]
#![warn(rust_2018_idioms)]
mod fcntl;
mod rt;
mod stdio;
mod stdlib;

View file

@ -2,7 +2,7 @@ use core::ffi::{c_char, c_int};
use libuwuc::{
error::IntoOkOrErrno,
io::{fd::Fd, stream::FileStream, traits::WriteCounter, STDERR, STDIN, STDOUT},
io::{stream::FileStream, traits::WriteCounter, STDERR, STDIN, STDOUT},
utils::SharedThinCstr,
};
@ -11,11 +11,9 @@ pub unsafe extern "C" fn puts(s: *const c_char) -> i32 {
libuwuc::io::puts(s)
}
// RAW FD:
#[no_mangle]
pub unsafe extern "C" fn open(path: SharedThinCstr<'_>, flags: i32) -> Fd {
libuwuc::io::fd::open(path, flags).into_ok_or_errno()
pub unsafe extern "C" fn putchar(char: i32) -> i32 {
libuwuc::io::stream::fputc(char, stdout)
}
// PRINTF:
@ -108,7 +106,7 @@ pub unsafe extern "C" fn ungetc(_c: c_int, _stream: *mut FileStream) -> c_int {
#[no_mangle]
pub unsafe extern "C" fn fputc(c: c_int, stream: *mut FileStream) -> c_int {
libuwuc::io::stream::fputc(c as u8, &*stream)
libuwuc::io::stream::fputc(c, &*stream)
}
#[no_mangle]

View file

@ -14,3 +14,8 @@ pub unsafe extern "C" fn write(fd: Fd, buf: *const u8, count: usize) -> isize {
.map(|n| n as isize)
.into_ok_or_errno()
}
#[no_mangle]
pub unsafe extern "C" fn lseek(fd: Fd, offset: i64, whence: i32) -> i64 {
libuwuc::io::sys_lseek(fd, offset, whence).into_ok_or_errno()
}