mirror of
https://github.com/Noratrieb/libuwuc.git
synced 2026-01-14 11:45:05 +01:00
move
This commit is contained in:
parent
de90913d46
commit
54e0e7604e
23 changed files with 77 additions and 33 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -2,6 +2,13 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "c"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libuwuc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
|
|
|||
15
Cargo.toml
15
Cargo.toml
|
|
@ -1,18 +1,9 @@
|
|||
[package]
|
||||
name = "libuwuc"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[workspace]
|
||||
members = ["libuwuc", "c"]
|
||||
resolver = "2"
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "1.0.0"
|
||||
|
||||
[features]
|
||||
export_symbols = []
|
||||
|
|
|
|||
13
c/Cargo.toml
Normal file
13
c/Cargo.toml
Normal 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
11
c/src/lib.rs
Normal 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!();
|
||||
}
|
||||
}
|
||||
|
|
@ -8,11 +8,6 @@ pub(crate) unsafe extern "C" fn memset(ptr: *mut u8, constant: u8, len: usize) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub(crate) unsafe extern "C" fn strlen(mut s: *const u8) -> usize {
|
||||
let mut len = 0;
|
||||
while s.read() != 0 {
|
||||
len += 1;
|
||||
s = s.add(1);
|
||||
}
|
||||
len
|
||||
}
|
||||
pub(crate) unsafe extern "C" fn strlen(s: *const u8) -> usize {
|
||||
libuwuc::mem::strlen(s)
|
||||
}
|
||||
8
example-user/Cargo.lock
generated
8
example-user/Cargo.lock
generated
|
|
@ -2,6 +2,13 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "c"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libuwuc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
|
@ -12,6 +19,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
name = "example-user"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"c",
|
||||
"libuwuc",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -14,4 +14,5 @@ panic = "abort"
|
|||
panic = "abort"
|
||||
|
||||
[dependencies]
|
||||
libuwuc = { path = "..", features = ["export_symbols"] }
|
||||
c = { path = "../c" }
|
||||
libuwuc = { path = "../libuwuc" }
|
||||
|
|
@ -6,7 +6,7 @@ use core::ffi::c_char;
|
|||
|
||||
use libuwuc::{println, utils::SharedThinCstr};
|
||||
|
||||
extern crate libuwuc;
|
||||
extern crate c;
|
||||
|
||||
#[panic_handler]
|
||||
#[cfg(not(test))]
|
||||
|
|
@ -27,11 +27,3 @@ extern "C" fn main(_argc: i32, _argv: *const *const c_char) -> i32 {
|
|||
println!("PWD={pwd:?}");
|
||||
0
|
||||
}
|
||||
|
||||
// libcore seems to require this symbol, even though it's unused.
|
||||
#[no_mangle]
|
||||
fn rust_eh_personality() {
|
||||
unsafe {
|
||||
libuwuc::trap!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
libuwuc/Cargo.toml
Normal file
9
libuwuc/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "libuwuc"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "1.0.0"
|
||||
|
|
@ -63,7 +63,6 @@ pub fn getenv(name: SharedThinCstr) -> Option<SharedThinCstr> {
|
|||
fn getenv_inner(mut envp: EnvP, name: SharedThinCstr) -> Option<SharedThinCstr> {
|
||||
let mut eq_idx = 0;
|
||||
envp.find(|env| {
|
||||
println!("trying {env:?}");
|
||||
// Find ENV
|
||||
// EN=x
|
||||
// ENV=x <- this one
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#[cfg(test)]
|
||||
extern crate std;
|
||||
|
||||
mod basic_mem;
|
||||
pub mod mem;
|
||||
pub mod env;
|
||||
pub mod io;
|
||||
pub mod start;
|
||||
18
libuwuc/src/mem.rs
Normal file
18
libuwuc/src/mem.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#[inline]
|
||||
pub unsafe fn memset(ptr: *mut u8, constant: u8, len: usize) {
|
||||
for i in 0..len {
|
||||
unsafe {
|
||||
*ptr.add(i) = constant;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn strlen(mut s: *const u8) -> usize {
|
||||
let mut len = 0;
|
||||
while s.read() != 0 {
|
||||
len += 1;
|
||||
s = s.add(1);
|
||||
}
|
||||
len
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ pub(crate) unsafe extern "C" fn start(argc: u64, argv: *const *const c_char, rsp
|
|||
fn main(argc: c_int, argv: *const *const c_char) -> c_int;
|
||||
}
|
||||
|
||||
crate::env::debug_env();
|
||||
// crate::env::debug_env();
|
||||
|
||||
let result = main(argc as i32, argv);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue