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