From f98d9dd334b4ff254912533d8b9b3cc4349f6f6a Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 10 Oct 2024 20:45:39 +0200 Subject: Don't try to use confstr in Miri --- library/std/src/sys/pal/unix/os.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'library/std/src/sys/pal/unix/os.rs') diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs index d26a1bdef74..f207131ddf3 100644 --- a/library/std/src/sys/pal/unix/os.rs +++ b/library/std/src/sys/pal/unix/os.rs @@ -704,7 +704,9 @@ pub fn page_size() -> usize { // // [posix_confstr]: // https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html -#[cfg(target_vendor = "apple")] +// +// FIXME: Support `confstr` in Miri. +#[cfg(all(target_vendor = "apple", not(miri)))] fn confstr(key: c_int, size_hint: Option) -> io::Result { let mut buf: Vec = Vec::with_capacity(0); let mut bytes_needed_including_nul = size_hint @@ -753,7 +755,7 @@ fn confstr(key: c_int, size_hint: Option) -> io::Result { Ok(OsString::from_vec(buf)) } -#[cfg(target_vendor = "apple")] +#[cfg(all(target_vendor = "apple", not(miri)))] fn darwin_temp_dir() -> PathBuf { confstr(libc::_CS_DARWIN_USER_TEMP_DIR, Some(64)).map(PathBuf::from).unwrap_or_else(|_| { // It failed for whatever reason (there are several possible reasons), @@ -765,7 +767,7 @@ fn darwin_temp_dir() -> PathBuf { pub fn temp_dir() -> PathBuf { crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| { cfg_if::cfg_if! { - if #[cfg(target_vendor = "apple")] { + if #[cfg(all(target_vendor = "apple", not(miri)))] { darwin_temp_dir() } else if #[cfg(target_os = "android")] { PathBuf::from("/data/local/tmp") -- cgit 1.4.1-3-g733a5