Skip to content

Commit 6ce7e79

Browse files
committed
Don't try to use confstr in Miri
1 parent 14aef3d commit 6ce7e79

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

std/src/sys/pal/unix/os.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,9 @@ pub fn page_size() -> usize {
704704
//
705705
// [posix_confstr]:
706706
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html
707-
#[cfg(target_vendor = "apple")]
707+
//
708+
// FIXME: Support `confstr` in Miri.
709+
#[cfg(all(target_vendor = "apple", not(miri)))]
708710
fn confstr(key: c_int, size_hint: Option<usize>) -> io::Result<OsString> {
709711
let mut buf: Vec<u8> = Vec::with_capacity(0);
710712
let mut bytes_needed_including_nul = size_hint
@@ -753,7 +755,7 @@ fn confstr(key: c_int, size_hint: Option<usize>) -> io::Result<OsString> {
753755
Ok(OsString::from_vec(buf))
754756
}
755757

756-
#[cfg(target_vendor = "apple")]
758+
#[cfg(all(target_vendor = "apple", not(miri)))]
757759
fn darwin_temp_dir() -> PathBuf {
758760
confstr(libc::_CS_DARWIN_USER_TEMP_DIR, Some(64)).map(PathBuf::from).unwrap_or_else(|_| {
759761
// It failed for whatever reason (there are several possible reasons),
@@ -765,7 +767,7 @@ fn darwin_temp_dir() -> PathBuf {
765767
pub fn temp_dir() -> PathBuf {
766768
crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
767769
cfg_if::cfg_if! {
768-
if #[cfg(target_vendor = "apple")] {
770+
if #[cfg(all(target_vendor = "apple", not(miri)))] {
769771
darwin_temp_dir()
770772
} else if #[cfg(target_os = "android")] {
771773
PathBuf::from("/data/local/tmp")

std/src/sys/pal/unix/os/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn test_parse_glibc_version() {
2525
// Smoke check `confstr`, do it for several hint values, to ensure our resizing
2626
// logic is correct.
2727
#[test]
28-
#[cfg(target_vendor = "apple")]
28+
#[cfg(all(target_vendor = "apple", not(miri)))]
2929
fn test_confstr() {
3030
for key in [libc::_CS_DARWIN_USER_TEMP_DIR, libc::_CS_PATH] {
3131
let value_nohint = super::confstr(key, None).unwrap_or_else(|e| {

0 commit comments

Comments
 (0)