#[cfg(not(feature = "rustc-dep-of-std"))]
extern crate alloc;
pub(crate) mod call;
pub use safa_abi::syscalls::SyscallTable as SyscallNum;
macro_rules! err_from_u16 {
($result:expr) => {
$result.into_result()
};
($result:expr, $ok:expr) => {
err_from_u16!($result).map(|()| $ok)
};
}
pub(crate) use err_from_u16;
pub use call::syscall;
macro_rules! define_syscall {
($num:path => { $(#[$attrss:meta])* $name:ident ($($arg:ident : $ty:ty),*) unreachable }) => {
$(#[$attrss])*
#[cfg_attr(
not(any(feature = "std", feature = "rustc-dep-of-std")),
unsafe(no_mangle)
)]
#[cfg_attr(any(feature = "std", feature = "rustc-dep-of-std"), inline(always))]
pub extern "C" fn $name($($arg: $ty),*) -> ! {
#[allow(unused_imports)]
use $crate::syscalls::types::IntoSyscallArg;
_ = $crate::syscalls::syscall!($num, $( $arg.into_syscall_arg() ),*);
unreachable!()
}
};
($num:path => { $(#[$attrss:meta])* $name:ident ($($arg:ident : $ty:ty),*) }) => {
$(#[$attrss])*
#[cfg_attr(
not(any(feature = "std", feature = "rustc-dep-of-std")),
unsafe(no_mangle)
)]
#[cfg_attr(any(feature = "std", feature = "rustc-dep-of-std"), inline(always))]
pub extern "C" fn $name($($arg: $ty),*) -> $crate::syscalls::types::SyscallResult {
#[allow(unused_imports)]
use $crate::syscalls::types::IntoSyscallArg;
let result = $crate::syscalls::syscall!($num, $( $arg ),*);
result
}
};
{$($num:path => { $(#[$attrss:meta])* $name:ident ($($arg:ident: $ty:ty),*) $($modifier:tt)* }),* $(,)?} => {
$(define_syscall!($num => { $(#[$attrss])* $name($($arg: $ty),*) $($modifier)* });)*
};
}
pub(crate) use define_syscall;
pub mod fs;
pub mod futex;
pub mod io;
pub mod mem;
pub mod misc;
pub mod process;
pub mod process_misc;
pub mod resources;
pub mod thread;
pub mod types;