use super::ctypes;
use axhal::mem::PAGE_SIZE_4K;
use core::ffi::{c_int, c_long};
#[no_mangle]
pub unsafe extern "C" fn ax_sysconf(name: c_int) -> c_long {
debug!("ax_sysconf <= {}", name);
ax_call_body!(ax_sysconf, {
match name as u32 {
ctypes::_SC_PAGE_SIZE => Ok(PAGE_SIZE_4K as c_long),
ctypes::_SC_PHYS_PAGES => Ok((axconfig::PHYS_MEMORY_SIZE / PAGE_SIZE_4K) as c_long),
ctypes::_SC_NPROCESSORS_ONLN => Ok(axconfig::SMP as c_long),
#[cfg(feature = "alloc")]
ctypes::_SC_AVPHYS_PAGES => Ok(axalloc::global_allocator().available_pages() as c_long),
#[cfg(feature = "alloc")]
ctypes::_SC_OPEN_MAX => Ok(super::fd_ops::AX_FILE_LIMIT as c_long),
_ => Ok(0),
}
})
}