diff options
| author | Richard Diamond <wichard@vitalitystudios.com> | 2015-10-24 20:51:34 -0500 |
|---|---|---|
| committer | Richard Diamond <wichard@vitalitystudios.com> | 2015-10-28 17:23:28 -0500 |
| commit | a7d93c939a9cedbc239b3ce647fb8a22125a4d22 (patch) | |
| tree | c21ab99f1eb5dc33d46121bb5912dc691e73530d /src/libstd/sys/unix/os.rs | |
| parent | 8d86d1a4e17239361ecebced0d5dd246efa95512 (diff) | |
| download | rust-a7d93c939a9cedbc239b3ce647fb8a22125a4d22.tar.gz rust-a7d93c939a9cedbc239b3ce647fb8a22125a4d22.zip | |
Port the standard crates to PNaCl/NaCl.
Diffstat (limited to 'src/libstd/sys/unix/os.rs')
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 59b385b9481..c328c84f62a 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -34,30 +34,15 @@ const TMPBUF_SZ: usize = 128; /// Returns the platform-specific value of errno pub fn errno() -> i32 { - #[cfg(any(target_os = "macos", - target_os = "ios", - target_os = "freebsd"))] - unsafe fn errno_location() -> *const c_int { - extern { fn __error() -> *const c_int; } - __error() - } - - #[cfg(target_os = "dragonfly")] - unsafe fn errno_location() -> *const c_int { - extern { fn __dfly_error() -> *const c_int; } - __dfly_error() - } - - #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] - unsafe fn errno_location() -> *const c_int { - extern { fn __errno() -> *const c_int; } - __errno() - } - - #[cfg(any(target_os = "linux", target_os = "android"))] - unsafe fn errno_location() -> *const c_int { - extern { fn __errno_location() -> *const c_int; } - __errno_location() + extern { + #[cfg_attr(any(target_os = "linux", target_os = "android"), link_name = "__errno_location")] + #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd", + target_env = "newlib"), + link_name = "__errno")] + #[cfg_attr(target_os = "dragonfly", link_name = "__dfly_error")] + #[cfg_attr(any(target_os = "macos", target_os = "ios", target_os = "freebsd"), + link_name = "__error")] + fn errno_location() -> *const c_int; } unsafe { @@ -67,14 +52,9 @@ pub fn errno() -> i32 { /// Gets a detailed string description for the given error number. pub fn error_string(errno: i32) -> String { - #[cfg(target_os = "linux")] - extern { - #[link_name = "__xpg_strerror_r"] - fn strerror_r(errnum: c_int, buf: *mut c_char, - buflen: libc::size_t) -> c_int; - } - #[cfg(not(target_os = "linux"))] extern { + #[cfg_attr(any(target_os = "linux", target_env = "newlib"), + link_name = "__xpg_strerror_r")] fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: libc::size_t) -> c_int; } @@ -361,7 +341,8 @@ pub fn args() -> Args { target_os = "dragonfly", target_os = "bitrig", target_os = "netbsd", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "nacl"))] pub fn args() -> Args { use sys_common; let bytes = sys_common::args::clone().unwrap_or(Vec::new()); @@ -473,10 +454,12 @@ pub fn home_dir() -> Option<PathBuf> { }).map(PathBuf::from); #[cfg(any(target_os = "android", - target_os = "ios"))] + target_os = "ios", + target_os = "nacl"))] unsafe fn fallback() -> Option<OsString> { None } #[cfg(not(any(target_os = "android", - target_os = "ios")))] + target_os = "ios", + target_os = "nacl")))] unsafe fn fallback() -> Option<OsString> { let amt = match libc::sysconf(c::_SC_GETPW_R_SIZE_MAX) { n if n < 0 => 512 as usize, |
