Skip to content

Commit

Permalink
Prefer target_vendor = "apple" on confstr
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Oct 10, 2024
1 parent bc63981 commit 5b16abe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions std/src/sys/pal/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ pub fn page_size() -> usize {
//
// [posix_confstr]:
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
#[cfg(target_vendor = "apple")]
fn confstr(key: c_int, size_hint: Option<usize>) -> io::Result<OsString> {
let mut buf: Vec<u8> = Vec::new();
let mut bytes_needed_including_nul = size_hint
Expand Down Expand Up @@ -765,7 +765,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(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] {
if #[cfg(target_vendor = "apple")] {
darwin_temp_dir()
} else if #[cfg(target_os = "android")] {
PathBuf::from("/data/local/tmp")
Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/unix/os/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn test_parse_glibc_version() {
// Smoke check `confstr`, do it for several hint values, to ensure our resizing
// logic is correct.
#[test]
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
fn test_confstr() {
for key in [libc::_CS_DARWIN_USER_TEMP_DIR, libc::_CS_PATH] {
let value_nohint = super::confstr(key, None).unwrap_or_else(|e| {
Expand Down

0 comments on commit 5b16abe

Please sign in to comment.