summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/maybe_polyfill
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/rustix/src/maybe_polyfill
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/maybe_polyfill')
-rw-r--r--vendor/rustix/src/maybe_polyfill/no_std/mod.rs11
-rw-r--r--vendor/rustix/src/maybe_polyfill/no_std/net/ip_addr.rs2
-rw-r--r--vendor/rustix/src/maybe_polyfill/no_std/os/fd/owned.rs36
-rw-r--r--vendor/rustix/src/maybe_polyfill/std/mod.rs10
4 files changed, 49 insertions, 10 deletions
diff --git a/vendor/rustix/src/maybe_polyfill/no_std/mod.rs b/vendor/rustix/src/maybe_polyfill/no_std/mod.rs
index ab088d862..84bf5b764 100644
--- a/vendor/rustix/src/maybe_polyfill/no_std/mod.rs
+++ b/vendor/rustix/src/maybe_polyfill/no_std/mod.rs
@@ -1,11 +1,12 @@
//! Polyfill of parts of the standard library for `no_std` builds.
//!
-//! All code in this subtree is derived from the standard library and licensed MIT or Apache 2.0
-//! at your option.
+//! All code in this subtree is derived from the standard library and licensed
+//! MIT or Apache 2.0 at your option.
//!
-//! This implementation is used when `std` is not available and polyfills the necessary items from
-//! `std`. When the `std` feature is specified (so the standard library is available), the file
-//! `src/polyfill/std` is used instead, which just imports the respective items from `std`.
+//! This implementation is used when `std` is not available and polyfills the
+//! necessary items from `std`. When the `std` feature is specified (so the
+//! standard library is available), the file `src/polyfill/std` is used
+//! instead, which just imports the respective items from `std`.
#[cfg(not(windows))]
pub mod io;
diff --git a/vendor/rustix/src/maybe_polyfill/no_std/net/ip_addr.rs b/vendor/rustix/src/maybe_polyfill/no_std/net/ip_addr.rs
index ffa5302e3..81415e960 100644
--- a/vendor/rustix/src/maybe_polyfill/no_std/net/ip_addr.rs
+++ b/vendor/rustix/src/maybe_polyfill/no_std/net/ip_addr.rs
@@ -1653,7 +1653,7 @@ impl Ipv6Addr {
&& !self.is_benchmarking()
}
- /// Returns the address's multicast scope if the address is multicast.
+ /// Returns the address' multicast scope if the address is multicast.
///
/// # Examples
///
diff --git a/vendor/rustix/src/maybe_polyfill/no_std/os/fd/owned.rs b/vendor/rustix/src/maybe_polyfill/no_std/os/fd/owned.rs
index 90b6f4712..fffe34bff 100644
--- a/vendor/rustix/src/maybe_polyfill/no_std/os/fd/owned.rs
+++ b/vendor/rustix/src/maybe_polyfill/no_std/os/fd/owned.rs
@@ -115,6 +115,42 @@ impl OwnedFd {
}
}
+impl BorrowedFd<'_> {
+ /// Creates a new `OwnedFd` instance that shares the same underlying file
+ /// description as the existing `BorrowedFd` instance.
+ #[cfg(not(any(target_arch = "wasm32", target_os = "hermit")))]
+ #[cfg_attr(staged_api, stable(feature = "io_safety", since = "1.63.0"))]
+ pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
+ // Avoid using file descriptors below 3 as they are used for stdio
+
+ // We want to atomically duplicate this file descriptor and set the
+ // CLOEXEC flag, and currently that's done via F_DUPFD_CLOEXEC. This
+ // is a POSIX flag that was added to Linux in 2.6.24.
+ #[cfg(not(target_os = "espidf"))]
+ let fd = crate::io::fcntl_dupfd_cloexec(self, 3)?;
+
+ // For ESP-IDF, F_DUPFD is used instead, because the CLOEXEC semantics
+ // will never be supported, as this is a bare metal framework with
+ // no capabilities for multi-process execution. While F_DUPFD is also
+ // not supported yet, it might be (currently it returns ENOSYS).
+ #[cfg(target_os = "espidf")]
+ let fd = crate::io::fcntl_dupfd(self, 3)?;
+
+ Ok(fd)
+ }
+
+ /// Creates a new `OwnedFd` instance that shares the same underlying file
+ /// description as the existing `BorrowedFd` instance.
+ #[cfg(any(target_arch = "wasm32", target_os = "hermit"))]
+ #[cfg_attr(staged_api, stable(feature = "io_safety", since = "1.63.0"))]
+ pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
+ Err(crate::io::const_io_error!(
+ crate::io::ErrorKind::Unsupported,
+ "operation not supported on WASI yet",
+ ))
+ }
+}
+
#[cfg_attr(staged_api, unstable(feature = "io_safety", issue = "87074"))]
impl AsRawFd for BorrowedFd<'_> {
#[inline]
diff --git a/vendor/rustix/src/maybe_polyfill/std/mod.rs b/vendor/rustix/src/maybe_polyfill/std/mod.rs
index 92b5cab5b..bcaceb9fb 100644
--- a/vendor/rustix/src/maybe_polyfill/std/mod.rs
+++ b/vendor/rustix/src/maybe_polyfill/std/mod.rs
@@ -1,8 +1,10 @@
-//! Imports from `std` that would be polyfilled for `no_std` builds (see `src/polyfill/no_std`).
+//! Imports from `std` that would be polyfilled for `no_std` builds (see
+//! `src/polyfill/no_std`).
//!
-//! This implementation is used when `std` is available and just imports the necessary items from
-//! `std`. For `no_std` builds, the file `src/polyfill/no_std` is used instead, which doesn't
-//! depend on the standard library.
+//! This implementation is used when `std` is available and just imports the
+//! necessary items from `std`. For `no_std` builds, the file
+//! `src/polyfill/no_std` is used instead, which doesn't depend on the standard
+//! library.
#[cfg(not(windows))]
pub mod io {