| 1 |
use crate::backend; |
| 2 |
#[cfg(any( |
| 3 |
linux_raw, |
| 4 |
any( |
| 5 |
all(target_os = "android", target_pointer_width = "64"), |
| 6 |
target_os = "linux", |
| 7 |
) |
| 8 |
))] |
| 9 |
use crate::ffi::CStr; |
| 10 |
|
| 11 |
/// `sysconf(_SC_PAGESIZE)`—Returns the process' page size. |
| 12 |
/// |
| 13 |
/// Also known as `getpagesize`. |
| 14 |
/// |
| 15 |
/// # References |
| 16 |
/// - [POSIX] |
| 17 |
/// - [Linux `sysconf`] |
| 18 |
/// - [Linux `getpagesize`] |
| 19 |
/// |
| 20 |
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html |
| 21 |
/// [Linux `sysconf`]: https://man7.org/linux/man-pages/man3/sysconf.3.html |
| 22 |
/// [Linux `getpagesize`]: https://man7.org/linux/man-pages/man2/getpagesize.2.html |
| 23 |
#[inline] |
| 24 |
#[doc(alias = "_SC_PAGESIZE")] |
| 25 |
#[doc(alias = "_SC_PAGE_SIZE")] |
| 26 |
#[doc(alias = "getpagesize")] |
| 27 |
pub fn page_size() -> usize { |
| 28 |
backend::param::auxv::page_size() |
| 29 |
} |
| 30 |
|
| 31 |
/// `sysconf(_SC_CLK_TCK)`—Returns the process' clock ticks per second. |
| 32 |
/// |
| 33 |
/// # References |
| 34 |
/// - [POSIX] |
| 35 |
/// - [Linux] |
| 36 |
/// |
| 37 |
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html |
| 38 |
/// [Linux]: https://man7.org/linux/man-pages/man3/sysconf.3.html |
| 39 |
#[cfg(not(any(target_os = "vita", target_os = "wasi")))] |
| 40 |
#[inline] |
| 41 |
#[doc(alias = "_SC_CLK_TCK")] |
| 42 |
pub fn clock_ticks_per_second() -> u64 { |
| 43 |
backend::param::auxv::clock_ticks_per_second() |
| 44 |
} |
| 45 |
|
| 46 |
/// `(getauxval(AT_HWCAP), getauxval(AT_HWCAP2)`—Returns the Linux "hwcap" |
| 47 |
/// data. |
| 48 |
/// |
| 49 |
/// Return the Linux `AT_HWCAP` and `AT_HWCAP2` values passed to the |
| 50 |
/// current process. Returns 0 for each value if it is not available. |
| 51 |
/// |
| 52 |
/// # References |
| 53 |
/// - [Linux] |
| 54 |
/// |
| 55 |
/// [Linux]: https://man7.org/linux/man-pages/man3/getauxval.3.html |
| 56 |
#[cfg(any( |
| 57 |
linux_raw, |
| 58 |
any( |
| 59 |
all(target_os = "android", target_pointer_width = "64"), |
| 60 |
target_os = "linux", |
| 61 |
) |
| 62 |
))] |
| 63 |
#[inline] |
| 64 |
pub fn linux_hwcap() -> (usize, usize) { |
| 65 |
backend::param::auxv::linux_hwcap() |
| 66 |
} |
| 67 |
|
| 68 |
/// `getauxval(AT_MINSIGSTKSZ)`—Returns the Linux "minsigstksz" data. |
| 69 |
/// |
| 70 |
/// Return the Linux `AT_MINSIGSTKSZ` value passed to the current process. |
| 71 |
/// Returns 0 if it is not available. |
| 72 |
/// |
| 73 |
/// # References |
| 74 |
/// - [Linux] |
| 75 |
/// |
| 76 |
/// [Linux]: https://man7.org/linux/man-pages/man3/getauxval.3.html |
| 77 |
#[cfg(any( |
| 78 |
linux_raw, |
| 79 |
any( |
| 80 |
all(target_os = "android", target_pointer_width = "64"), |
| 81 |
target_os = "linux", |
| 82 |
) |
| 83 |
))] |
| 84 |
#[inline] |
| 85 |
pub fn linux_minsigstksz() -> usize { |
| 86 |
backend::param::auxv::linux_minsigstksz() |
| 87 |
} |
| 88 |
|
| 89 |
/// `getauxval(AT_EXECFN)`—Returns the Linux "execfn" string. |
| 90 |
/// |
| 91 |
/// Return the string that Linux has recorded as the filesystem path to the |
| 92 |
/// executable. Returns an empty string if the string is not available. |
| 93 |
/// |
| 94 |
/// # References |
| 95 |
/// - [Linux] |
| 96 |
/// |
| 97 |
/// [Linux]: https://man7.org/linux/man-pages/man3/getauxval.3.html |
| 98 |
#[cfg(any( |
| 99 |
linux_raw, |
| 100 |
any( |
| 101 |
all(target_os = "android", target_pointer_width = "64"), |
| 102 |
target_os = "linux", |
| 103 |
) |
| 104 |
))] |
| 105 |
#[inline] |
| 106 |
pub fn linux_execfn() -> &'static CStr { |
| 107 |
backend::param::auxv::linux_execfn() |
| 108 |
} |