Add more from the std

This commit is contained in:
2026-03-20 09:47:32 +01:00
parent 3121c0b68b
commit 48a75485b6
297 changed files with 598 additions and 60308 deletions

View File

@@ -0,0 +1,73 @@
//! The PAL (platform abstraction layer) contains platform-specific abstractions
//! for implementing the features in the other submodules, such as e.g. bindings.
#![allow(missing_debug_implementations)]
cfg_select! {
unix => {
mod unix;
pub use self::unix::*;
}
windows => {
mod windows;
pub use self::windows::*;
}
target_os = "solid_asp3" => {
mod solid;
pub use self::solid::*;
}
target_os = "hermit" => {
mod hermit;
pub use self::hermit::*;
}
target_os = "motor" => {
mod motor;
pub use self::motor::*;
}
target_os = "trusty" => {
mod trusty;
pub use self::trusty::*;
}
target_os = "vexos" => {
mod vexos;
pub use self::vexos::*;
}
target_os = "wasi" => {
mod wasi;
pub use self::wasi::*;
}
target_family = "wasm" => {
mod wasm;
pub use self::wasm::*;
}
target_os = "xous" => {
mod xous;
pub use self::xous::*;
}
target_os = "uefi" => {
mod uefi;
pub use self::uefi::*;
}
all(target_vendor = "fortanix", target_env = "sgx") => {
mod sgx;
pub use self::sgx::*;
}
target_os = "teeos" => {
mod teeos;
pub use self::teeos::*;
}
target_os = "zkvm" => {
mod zkvm;
pub use self::zkvm::*;
}
target_os = "survos" => {
mod unsupported;
pub use self::unsupported::*;
mod survos;
pub use self::survos::*;
}
_ => {
mod unsupported;
pub use self::unsupported::*;
}
}

View File

@@ -0,0 +1,11 @@
/// # Safety
/// `argc` and `argv` are passed by the kernel
#[unsafe(no_mangle)]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe extern "C" fn _start(argc: isize, argv: *const *const u8) -> isize {
unsafe extern "C" {
fn main(argc: isize, argv: *const *const u8) -> isize;
}
unsafe { main(argc, argv) }
}

View File

@@ -0,0 +1,21 @@
use crate::io as std_io;
// SAFETY: must be called only once during runtime initialization.
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
// SAFETY: must be called only once during runtime cleanup.
// NOTE: this is not guaranteed to run, for example when the program aborts.
pub unsafe fn cleanup() {}
pub fn unsupported<T>() -> std_io::Result<T> {
Err(unsupported_err())
}
pub fn unsupported_err() -> std_io::Error {
std_io::Error::UNSUPPORTED_PLATFORM
}
pub fn abort_internal() -> ! {
core::intrinsics::abort();
}

View File

@@ -0,0 +1,6 @@
#![deny(unsafe_op_in_unsafe_fn)]
pub mod os;
mod common;
pub use common::*;

View File

@@ -0,0 +1,57 @@
use super::unsupported;
use crate::ffi::{OsStr, OsString};
use crate::marker::PhantomData;
use crate::path::{self, PathBuf};
use crate::{fmt, io};
pub fn getcwd() -> io::Result<PathBuf> {
unsupported()
}
pub fn chdir(_: &path::Path) -> io::Result<()> {
unsupported()
}
pub struct SplitPaths<'a>(!, PhantomData<&'a ()>);
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
panic!("unsupported")
}
impl<'a> Iterator for SplitPaths<'a> {
type Item = PathBuf;
fn next(&mut self) -> Option<PathBuf> {
self.0
}
}
#[derive(Debug)]
pub struct JoinPathsError;
pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError>
where
I: Iterator<Item = T>,
T: AsRef<OsStr>,
{
Err(JoinPathsError)
}
impl fmt::Display for JoinPathsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"not supported on this platform yet".fmt(f)
}
}
impl crate::error::Error for JoinPathsError {}
pub fn current_exe() -> io::Result<PathBuf> {
unsupported()
}
pub fn temp_dir() -> PathBuf {
panic!("no filesystem on this platform")
}
pub fn home_dir() -> Option<PathBuf> {
None
}