Skip to content

Commit

Permalink
Fix broken auto-mac-ios-opt build
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaksalyar committed Feb 3, 2016
1 parent bb6e646 commit fae883c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
6 changes: 1 addition & 5 deletions src/libstd/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use prelude::v1::*;
use io::prelude::*;
use os::unix::prelude::*;

Expand All @@ -23,11 +24,6 @@ use sys::fd::FileDesc;
use sys::platform::raw;
use sys::{cvt, cvt_r};
use sys_common::{AsInner, FromInner};
use vec::Vec;
#[cfg(target_os = "solaris")]
use core_collections::borrow::ToOwned;
#[cfg(target_os = "solaris")]
use boxed::Box;

pub struct File(FileDesc);

Expand Down
44 changes: 22 additions & 22 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,28 +507,6 @@ pub fn home_dir() -> Option<PathBuf> {
fallback()
}).map(PathBuf::from);

#[cfg(not(target_os = "solaris"))]
unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd,
buf: &mut Vec<c_char>) -> Option<()> {
let mut result = ptr::null_mut();
match libc::getpwuid_r(me, passwd, buf.as_mut_ptr(),
buf.capacity() as libc::size_t,
&mut result) {
0 if !result.is_null() => Some(()),
_ => None
}
}

#[cfg(target_os = "solaris")]
unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd,
buf: &mut Vec<c_char>) -> Option<()> {
// getpwuid_r semantics is different on Illumos/Solaris:
// http://illumos.org/man/3c/getpwuid_r
let result = libc::getpwuid_r(me, passwd, buf.as_mut_ptr(),
buf.capacity() as libc::size_t);
if result.is_null() { None } else { Some(()) }
}

#[cfg(any(target_os = "android",
target_os = "ios",
target_os = "nacl"))]
Expand All @@ -537,6 +515,28 @@ pub fn home_dir() -> Option<PathBuf> {
target_os = "ios",
target_os = "nacl")))]
unsafe fn fallback() -> Option<OsString> {
#[cfg(not(target_os = "solaris"))]
unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd,
buf: &mut Vec<c_char>) -> Option<()> {
let mut result = ptr::null_mut();
match libc::getpwuid_r(me, passwd, buf.as_mut_ptr(),
buf.capacity() as libc::size_t,
&mut result) {
0 if !result.is_null() => Some(()),
_ => None
}
}

#[cfg(target_os = "solaris")]
unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd,
buf: &mut Vec<c_char>) -> Option<()> {
// getpwuid_r semantics is different on Illumos/Solaris:
// http://illumos.org/man/3c/getpwuid_r
let result = libc::getpwuid_r(me, passwd, buf.as_mut_ptr(),
buf.capacity() as libc::size_t);
if result.is_null() { None } else { Some(()) }
}

let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) {
n if n < 0 => 512 as usize,
n => n as usize,
Expand Down

0 comments on commit fae883c

Please sign in to comment.