treewide: going no_std

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia1c001eb099ea8cae9bdf76642b873376a6a6964
This commit is contained in:
raf 2026-03-27 17:29:49 +03:00
commit 472dbfc7e7
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
14 changed files with 856 additions and 143 deletions

View file

@ -1,6 +1,7 @@
use std::{io, mem::MaybeUninit};
use alloc::string::String;
use core::mem::MaybeUninit;
use crate::syscall::sys_sysinfo;
use crate::{Error, syscall::sys_sysinfo};
/// Faster integer to string conversion without the formatting overhead.
#[inline]
@ -16,7 +17,8 @@ fn itoa(mut n: u64, buf: &mut [u8]) -> &str {
n /= 10;
}
unsafe { std::str::from_utf8_unchecked(&buf[i..]) }
// SAFETY: We only wrote ASCII digits
unsafe { core::str::from_utf8_unchecked(&buf[i..]) }
}
/// Gets the current system uptime.
@ -25,11 +27,11 @@ fn itoa(mut n: u64, buf: &mut [u8]) -> &str {
///
/// Returns an error if the system uptime cannot be retrieved.
#[cfg_attr(feature = "hotpath", hotpath::measure)]
pub fn get_current() -> Result<String, io::Error> {
pub fn get_current() -> Result<String, Error> {
let uptime_seconds = {
let mut info = MaybeUninit::uninit();
if unsafe { sys_sysinfo(info.as_mut_ptr()) } != 0 {
return Err(io::Error::last_os_error());
return Err(Error::last_os_error());
}
#[allow(clippy::cast_sign_loss)]
unsafe {