Skip to content

Commit

Permalink
Fix compilation under wasm32-wasi under various feature combinations. (
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Dec 6, 2023
1 parent 90513bc commit cb1ffab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
12 changes: 4 additions & 8 deletions src/maybe_polyfill/no_std/os/fd/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ impl OwnedFd {
Ok(fd.into())
}

/// Creates a new `OwnedFd` instance that shares the same underlying file handle
/// as the existing `OwnedFd` instance.
#[cfg(target_arch = "wasm32")]
pub fn try_clone(&self) -> crate::io::Result<Self> {
Err(crate::io::const_io_error!(
crate::io::ErrorKind::Unsupported,
"operation not supported on WASI yet",
))
Err(crate::io::Errno::NOSYS)
}
}

Expand Down Expand Up @@ -150,10 +149,7 @@ impl BorrowedFd<'_> {
#[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",
))
Err(crate::io::Errno::NOSYS)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/param/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//! between different processes on the same system.

mod auxv;
#[cfg(feature = "use-explicitly-provided-auxv")]
#[cfg(all(feature = "use-explicitly-provided-auxv", not(libc)))]
mod init;

pub use auxv::*;
#[cfg(feature = "use-explicitly-provided-auxv")]
#[cfg(all(feature = "use-explicitly-provided-auxv", not(libc)))]
pub use init::init;
4 changes: 3 additions & 1 deletion src/path/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,10 +1063,12 @@ where

#[cfg(not(feature = "alloc"))]
{
#[cfg(libc)]
#[cfg(all(libc, not(target_os = "wasi")))]
const LARGE_PATH_BUFFER_SIZE: usize = libc::PATH_MAX as usize;
#[cfg(linux_raw)]
const LARGE_PATH_BUFFER_SIZE: usize = linux_raw_sys::general::PATH_MAX as usize;
#[cfg(target_os = "wasi")]
const LARGE_PATH_BUFFER_SIZE: usize = 4096 as usize; // TODO: upstream this

// Taken from
// <https://github.com/rust-lang/rust/blob/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/common/small_c_string.rs>
Expand Down

0 comments on commit cb1ffab

Please sign in to comment.