#![doc = include_str!("../README.md")]
#![doc(html_root_url = "https://docs.rs/syscall-numbers/4.0.1")]
#![warn(
unsafe_op_in_unsafe_fn,
//missing_docs,
keyword_idents,
macro_use_extern_crate,
missing_debug_implementations,
non_ascii_idents,
trivial_casts,
trivial_numeric_casts,
unstable_features,
unused_extern_crates,
unused_import_braces,
unused_labels,
variant_size_differences,
unused_qualifications
)]
#![no_std]
pub mod aarch64;
pub mod arm;
pub mod loongarch64;
pub mod m68k;
pub mod microblaze;
pub mod mips;
pub mod mips64;
pub mod mipsn32;
pub mod or1k;
pub mod powerpc;
pub mod powerpc64;
pub mod riscv32;
pub mod riscv64;
pub mod s390x;
pub mod sh;
pub mod x32;
pub mod x86;
pub mod x86_64;
#[cfg(target_arch = "aarch64")]
pub use aarch64 as native;
#[cfg(target_arch = "arm")]
pub use arm as native;
#[cfg(target_arch = "loongarch64")]
pub use loongarch64 as native;
#[cfg(target_arch = "m68k")]
pub use m68k as native;
#[cfg(target_arch = "mips")]
pub use mips as native;
#[cfg(target_arch = "mips64")]
pub use mips64 as native;
#[cfg(target_arch = "mips32r6")]
pub use mipsn32 as native;
#[cfg(target_arch = "powerpc")]
pub use powerpc as native;
#[cfg(target_arch = "powerpc64")]
pub use powerpc64 as native;
#[cfg(target_arch = "riscv32")]
pub use riscv32 as native;
#[cfg(target_arch = "riscv64")]
pub use riscv64 as native;
#[cfg(target_arch = "s390x")]
pub use s390x as native;
#[cfg(all(target_arch = "x86_64", target_abi = "x32"))]
pub use x32 as native;
#[cfg(target_arch = "x86")]
pub use x86 as native;
#[cfg(all(target_arch = "x86_64", not(target_abi = "x32")))]
pub use x86_64 as native;
use core::ffi::c_long;
pub(crate) fn sys_call_name(
names: &'static [&'static str],
base_index: c_long,
number: c_long,
) -> Option<&'static str> {
if number >= base_index {
if let Ok(index) = usize::try_from(number - base_index) {
return names.get(index).filter(|&&name| !name.is_empty()).cloned();
}
}
None
}
pub(crate) fn is_valid_sys_call_number(
names: &'static [&'static str],
base_index: c_long,
number: c_long,
) -> bool {
if let Ok(names_len) = c_long::try_from(names.len()) {
let last_number = base_index + names_len - 1;
return number >= base_index && number <= last_number;
}
false
}