aboutsummaryrefslogtreecommitdiff
path: root/vendor/rustix/src/backend/libc/param
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/rustix/src/backend/libc/param
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/rustix/src/backend/libc/param')
-rw-r--r--vendor/rustix/src/backend/libc/param/auxv.rs54
-rw-r--r--vendor/rustix/src/backend/libc/param/mod.rs1
2 files changed, 55 insertions, 0 deletions
diff --git a/vendor/rustix/src/backend/libc/param/auxv.rs b/vendor/rustix/src/backend/libc/param/auxv.rs
new file mode 100644
index 0000000..880a1d4
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/param/auxv.rs
@@ -0,0 +1,54 @@
+use crate::backend::c;
+#[cfg(any(
+ all(target_os = "android", target_pointer_width = "64"),
+ target_os = "linux",
+))]
+use crate::ffi::CStr;
+
+// `getauxval` wasn't supported in glibc until 2.16.
+#[cfg(any(
+ all(target_os = "android", target_pointer_width = "64"),
+ target_os = "linux",
+))]
+weak!(fn getauxval(c::c_ulong) -> *mut c::c_void);
+
+#[inline]
+pub(crate) fn page_size() -> usize {
+ unsafe { c::sysconf(c::_SC_PAGESIZE) as usize }
+}
+
+#[cfg(not(any(target_os = "vita", target_os = "wasi")))]
+#[inline]
+pub(crate) fn clock_ticks_per_second() -> u64 {
+ unsafe { c::sysconf(c::_SC_CLK_TCK) as u64 }
+}
+
+#[cfg(any(
+ all(target_os = "android", target_pointer_width = "64"),
+ target_os = "linux",
+))]
+#[inline]
+pub(crate) fn linux_hwcap() -> (usize, usize) {
+ if let Some(libc_getauxval) = getauxval.get() {
+ unsafe {
+ let hwcap = libc_getauxval(c::AT_HWCAP) as usize;
+ let hwcap2 = libc_getauxval(c::AT_HWCAP2) as usize;
+ (hwcap, hwcap2)
+ }
+ } else {
+ (0, 0)
+ }
+}
+
+#[cfg(any(
+ all(target_os = "android", target_pointer_width = "64"),
+ target_os = "linux",
+))]
+#[inline]
+pub(crate) fn linux_execfn() -> &'static CStr {
+ if let Some(libc_getauxval) = getauxval.get() {
+ unsafe { CStr::from_ptr(libc_getauxval(c::AT_EXECFN).cast()) }
+ } else {
+ cstr!("")
+ }
+}
diff --git a/vendor/rustix/src/backend/libc/param/mod.rs b/vendor/rustix/src/backend/libc/param/mod.rs
new file mode 100644
index 0000000..2cb2fe7
--- /dev/null
+++ b/vendor/rustix/src/backend/libc/param/mod.rs
@@ -0,0 +1 @@
+pub(crate) mod auxv;