mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Don't try to use confstr in Miri
This commit is contained in:
parent
b62ee10e54
commit
f98d9dd334
@ -704,7 +704,9 @@ pub fn page_size() -> usize {
|
|||||||
//
|
//
|
||||||
// [posix_confstr]:
|
// [posix_confstr]:
|
||||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html
|
// 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<usize>) -> io::Result<OsString> {
|
fn confstr(key: c_int, size_hint: Option<usize>) -> io::Result<OsString> {
|
||||||
let mut buf: Vec<u8> = Vec::with_capacity(0);
|
let mut buf: Vec<u8> = Vec::with_capacity(0);
|
||||||
let mut bytes_needed_including_nul = size_hint
|
let mut bytes_needed_including_nul = size_hint
|
||||||
@ -753,7 +755,7 @@ fn confstr(key: c_int, size_hint: Option<usize>) -> io::Result<OsString> {
|
|||||||
Ok(OsString::from_vec(buf))
|
Ok(OsString::from_vec(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_vendor = "apple")]
|
#[cfg(all(target_vendor = "apple", not(miri)))]
|
||||||
fn darwin_temp_dir() -> PathBuf {
|
fn darwin_temp_dir() -> PathBuf {
|
||||||
confstr(libc::_CS_DARWIN_USER_TEMP_DIR, Some(64)).map(PathBuf::from).unwrap_or_else(|_| {
|
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),
|
// It failed for whatever reason (there are several possible reasons),
|
||||||
@ -765,7 +767,7 @@ fn darwin_temp_dir() -> PathBuf {
|
|||||||
pub fn temp_dir() -> PathBuf {
|
pub fn temp_dir() -> PathBuf {
|
||||||
crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
|
crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(target_vendor = "apple")] {
|
if #[cfg(all(target_vendor = "apple", not(miri)))] {
|
||||||
darwin_temp_dir()
|
darwin_temp_dir()
|
||||||
} else if #[cfg(target_os = "android")] {
|
} else if #[cfg(target_os = "android")] {
|
||||||
PathBuf::from("/data/local/tmp")
|
PathBuf::from("/data/local/tmp")
|
||||||
|
@ -25,7 +25,7 @@ fn test_parse_glibc_version() {
|
|||||||
// Smoke check `confstr`, do it for several hint values, to ensure our resizing
|
// Smoke check `confstr`, do it for several hint values, to ensure our resizing
|
||||||
// logic is correct.
|
// logic is correct.
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_vendor = "apple")]
|
#[cfg(all(target_vendor = "apple", not(miri)))]
|
||||||
fn test_confstr() {
|
fn test_confstr() {
|
||||||
for key in [libc::_CS_DARWIN_USER_TEMP_DIR, libc::_CS_PATH] {
|
for key in [libc::_CS_DARWIN_USER_TEMP_DIR, libc::_CS_PATH] {
|
||||||
let value_nohint = super::confstr(key, None).unwrap_or_else(|e| {
|
let value_nohint = super::confstr(key, None).unwrap_or_else(|e| {
|
||||||
|
Loading…
Reference in New Issue
Block a user