Fix broken auto-mac-ios-opt build

This commit is contained in:
Nikita Baksalyar 2016-02-03 16:45:34 +03:00
parent bb6e646c7b
commit fae883c113
No known key found for this signature in database
GPG Key ID: 3EEA378A0EA758DA
2 changed files with 23 additions and 27 deletions

View File

@ -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::*;
@ -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);

View File

@ -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"))]
@ -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,