1
0
Fork 0
forked from koniifer/ableos

Don't fail to compile on unsupported architectures

This commit is contained in:
Erin 2024-02-14 01:25:44 +01:00
parent c978b408e2
commit 34d1bf415e
4 changed files with 49 additions and 6 deletions

View file

@ -1,13 +1,27 @@
macro_rules! arch_specific {
{
$({$($cfg:tt)*} : $mod:ident;)*
} => {$(
#[cfg($($cfg)*)]
mod $mod;
} => {
$(
#[cfg($($cfg)*)]
mod $mod;
#[cfg($($cfg)*)]
pub use $mod::*;
)*};
#[cfg($($cfg)*)]
pub use $mod::*;
#[cfg($($cfg)*)]
pub const FL_ARCH_SPECIFIC_SUPPORTED: bool = true;
)*
#[cfg(not(any($($($cfg)*),*)))]
mod unsupported;
#[cfg(not(any($($($cfg)*),*)))]
pub use unsupported::*;
#[cfg(not(any($($($cfg)*),*)))]
pub const FL_ARCH_SPECIFIC_SUPPORTED: bool = false;
};
}
arch_specific! {

View file

@ -0,0 +1,16 @@
use hbbytecode::RoundingMode;
#[inline(always)]
pub fn conv64to32(_: f64, _: RoundingMode) -> f32 {
f32::NAN
}
#[inline(always)]
pub fn f32toint(_: f32, _: RoundingMode) -> i64 {
i64::MAX
}
#[inline(always)]
pub fn f64toint(_: f64, _: RoundingMode) -> i64 {
i64::MAX
}

View file

@ -25,6 +25,8 @@ mod float;
mod utils;
mod vmrun;
pub use float::FL_ARCH_SPECIFIC_SUPPORTED;
use {
bmc::BlockCopier,
mem::{Address, Memory},

View file

@ -14,6 +14,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("== HB×RT (Holey Bytes Experimental Runtime) v0.1 ==");
eprintln!("[W] Currently supporting only flat images");
if !hbvm::FL_ARCH_SPECIFIC_SUPPORTED {
eprintln!(
"\
[W] Architecture not fully supported!\n \
FTI32, FTI64 will yield {:#x}\n \
FC64T32 will yield NaN\
",
i64::MAX,
)
}
let mut args = args().skip(1);
let Some(image_path) = args.next() else {
eprintln!("[E] Missing image path");