Sha256: 7d71f224f7d9c547b6b5e1425cad03466328b7b8ad2a62f49d9e29e075061e43

Contents?: true

Size: 1.31 KB

Versions: 17

Compression:

Stored size: 1.31 KB

Contents

use super::super::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(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!("")
    }
}

Version data entries

17 entries across 15 versions & 1 rubygems

Version Path
wasmtime-13.0.0 ./ext/cargo-vendor/rustix-0.37.23/src/backend/libc/param/auxv.rs
wasmtime-12.0.1 ./ext/cargo-vendor/rustix-0.37.23/src/backend/libc/param/auxv.rs
wasmtime-12.0.0 ./ext/cargo-vendor/rustix-0.37.23/src/backend/libc/param/auxv.rs
wasmtime-11.0.0 ./ext/cargo-vendor/rustix-0.37.23/src/backend/libc/param/auxv.rs
wasmtime-10.0.1 ./ext/cargo-vendor/rustix-0.37.23/src/backend/libc/param/auxv.rs
wasmtime-10.0.0 ./ext/cargo-vendor/rustix-0.37.23/src/backend/libc/param/auxv.rs
wasmtime-9.0.4 ./ext/cargo-vendor/rustix-0.37.23/src/backend/libc/param/auxv.rs
wasmtime-9.0.1 ./ext/cargo-vendor/rustix-0.37.19/src/backend/libc/param/auxv.rs
wasmtime-8.0.0 ./ext/cargo-vendor/rustix-0.36.12/src/backend/libc/param/auxv.rs
wasmtime-8.0.0 ./ext/cargo-vendor/rustix-0.37.13/src/backend/libc/param/auxv.rs
wasmtime-7.0.0 ./ext/cargo-vendor/rustix-0.36.11/src/backend/libc/param/auxv.rs
wasmtime-7.0.0 ./ext/cargo-vendor/rustix-0.37.5/src/backend/libc/param/auxv.rs
wasmtime-6.0.1 ./ext/cargo-vendor/rustix-0.36.8/src/backend/libc/param/auxv.rs
wasmtime-6.0.0 ./ext/cargo-vendor/rustix-0.36.8/src/backend/libc/param/auxv.rs
wasmtime-5.0.0 ./ext/cargo-vendor/rustix-0.36.7/src/backend/libc/param/auxv.rs
wasmtime-0.4.1 ./ext/cargo-vendor/rustix-0.36.5/src/backend/libc/param/auxv.rs
wasmtime-0.4.0 ./ext/cargo-vendor/rustix-0.36.5/src/backend/libc/param/auxv.rs