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")]
page_size() -> usize27 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")]
clock_ticks_per_second() -> u6442 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]
linux_hwcap() -> (usize, usize)64 pub fn linux_hwcap() -> (usize, usize) {
65 backend::param::auxv::linux_hwcap()
66 }
67
68 /// `getauxval(AT_EXECFN)`—Returns the Linux "execfn" string.
69 ///
70 /// Return the string that Linux has recorded as the filesystem path to the
71 /// executable. Returns an empty string if the string 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]
linux_execfn() -> &'static CStr85 pub fn linux_execfn() -> &'static CStr {
86 backend::param::auxv::linux_execfn()
87 }
88