diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/rustix-0.36.5/src/param | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix-0.36.5/src/param')
-rw-r--r-- | vendor/rustix-0.36.5/src/param/auxv.rs | 96 | ||||
-rw-r--r-- | vendor/rustix-0.36.5/src/param/init.rs | 23 | ||||
-rw-r--r-- | vendor/rustix-0.36.5/src/param/mod.rs | 31 |
3 files changed, 150 insertions, 0 deletions
diff --git a/vendor/rustix-0.36.5/src/param/auxv.rs b/vendor/rustix-0.36.5/src/param/auxv.rs new file mode 100644 index 000000000..03be2a29d --- /dev/null +++ b/vendor/rustix-0.36.5/src/param/auxv.rs @@ -0,0 +1,96 @@ +use crate::backend; +#[cfg(any( + linux_raw, + all( + libc, + any( + all(target_os = "android", target_pointer_width = "64"), + target_os = "linux", + ) + ) +))] +use crate::ffi::CStr; + +/// `sysconf(_SC_PAGESIZE)`—Returns the process' page size. +/// +/// Also known as `getpagesize`. +/// +/// # References +/// - [POSIX] +/// - [Linux `sysconf`] +/// - [Linux `getpagesize`] +/// +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html +/// [Linux `sysconf`]: https://man7.org/linux/man-pages/man3/sysconf.3.html +/// [Linux `getpagesize`]: https://man7.org/linux/man-pages/man2/getpagesize.2.html +#[inline] +#[doc(alias = "_SC_PAGESIZE")] +#[doc(alias = "_SC_PAGE_SIZE")] +#[doc(alias = "getpagesize")] +pub fn page_size() -> usize { + backend::param::auxv::page_size() +} + +/// `sysconf(_SC_CLK_TCK)`—Returns the process' clock ticks per second. +/// +/// # References +/// - [POSIX] +/// - [Linux] +/// +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html +/// [Linux]: https://man7.org/linux/man-pages/man3/sysconf.3.html +#[cfg(not(target_os = "wasi"))] +#[inline] +#[doc(alias = "_SC_CLK_TCK")] +pub fn clock_ticks_per_second() -> u64 { + backend::param::auxv::clock_ticks_per_second() +} + +/// `(getauxval(AT_HWCAP), getauxval(AT_HWCAP2)`—Returns the Linux "hwcap" +/// data. +/// +/// Return the Linux `AT_HWCAP` and `AT_HWCAP2` values passed to the +/// current process. Returns 0 for each value if it is not available. +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man3/getauxval.3.html +#[cfg(any( + linux_raw, + all( + libc, + any( + all(target_os = "android", target_pointer_width = "64"), + target_os = "linux", + ) + ) +))] +#[inline] +pub fn linux_hwcap() -> (usize, usize) { + backend::param::auxv::linux_hwcap() +} + +/// `getauxval(AT_EXECFN)`—Returns the Linux "execfn" string. +/// +/// Return the string that Linux has recorded as the filesystem path to the +/// executable. Returns an empty string if the string is not available. +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man3/getauxval.3.html +#[cfg(any( + linux_raw, + all( + libc, + any( + all(target_os = "android", target_pointer_width = "64"), + target_os = "linux", + ) + ) +))] +#[inline] +pub fn linux_execfn() -> &'static CStr { + backend::param::auxv::linux_execfn() +} diff --git a/vendor/rustix-0.36.5/src/param/init.rs b/vendor/rustix-0.36.5/src/param/init.rs new file mode 100644 index 000000000..d261fabd2 --- /dev/null +++ b/vendor/rustix-0.36.5/src/param/init.rs @@ -0,0 +1,23 @@ +//! rustix's `init` function. +//! +//! # Safety +//! +//! On mustang, or on any non-glibc non-musl platform, the `init` function must +//! be called before any other function in this module. It is unsafe because it +//! operates on raw pointers. +#![allow(unsafe_code)] + +use crate::backend; + +/// Initialize process-wide state. +/// +/// # Safety +/// +/// This must be passed a pointer to the original environment variable block +/// set up by the OS at process startup, and it must be called before any +/// other rustix functions are called. +#[inline] +#[doc(hidden)] +pub unsafe fn init(envp: *mut *mut u8) { + backend::param::auxv::init(envp) +} diff --git a/vendor/rustix-0.36.5/src/param/mod.rs b/vendor/rustix-0.36.5/src/param/mod.rs new file mode 100644 index 000000000..c47aca985 --- /dev/null +++ b/vendor/rustix-0.36.5/src/param/mod.rs @@ -0,0 +1,31 @@ +//! Process parameters. +//! +//! These values correspond to `sysconf` in POSIX, and the auxv array in Linux. +//! Despite the POSIX name “sysconf”, these aren't *system* configuration +//! parameters; they're *process* configuration parameters, as they may differ +//! between different processes on the same system. + +#[cfg(feature = "param")] +mod auxv; +#[cfg(target_vendor = "mustang")] +mod init; + +#[cfg(feature = "param")] +#[cfg(not(target_os = "wasi"))] +pub use auxv::clock_ticks_per_second; +#[cfg(feature = "param")] +pub use auxv::page_size; +#[cfg(feature = "param")] +#[cfg(any( + linux_raw, + all( + libc, + any( + all(target_os = "android", target_pointer_width = "64"), + target_os = "linux", + ) + ) +))] +pub use auxv::{linux_execfn, linux_hwcap}; +#[cfg(target_vendor = "mustang")] +pub use init::init; |