diff options
author | Carl Lerche <me@carllerche.com> | 2015-03-16 15:39:51 -0700 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2015-03-16 15:39:51 -0700 |
commit | 0e369e931f5927a31bec4e5ca6ee21ebb60e6e7f (patch) | |
tree | 437e82c3855109d4f18c9ebb7af221d0e89d0acf /src | |
parent | 9b640d53f5b72bedfd6cd589f77d9338d5b540f3 (diff) | |
download | nix-0e369e931f5927a31bec4e5ca6ee21ebb60e6e7f.zip |
Fix deprecation warnings
Diffstat (limited to 'src')
-rw-r--r-- | src/errno.rs | 45 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/sched.rs | 4 |
3 files changed, 47 insertions, 4 deletions
diff --git a/src/errno.rs b/src/errno.rs index cb62f442..68915193 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -1,9 +1,52 @@ -use std::os::errno; +use libc::c_int; use std::num::from_i32; pub use self::consts::*; pub use self::consts::Errno::*; +/// 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 = "bitrig")] + fn errno_location() -> *const c_int { + extern { + fn __errno() -> *const c_int; + } + unsafe { + __errno() + } + } + + #[cfg(target_os = "dragonfly")] + unsafe fn errno_location() -> *const c_int { + extern { fn __dfly_error() -> *const c_int; } + __dfly_error() + } + + #[cfg(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() + } + + unsafe { + (*errno_location()) as i32 + } +} + macro_rules! impl_errno { ($errno:ty) => { impl $errno { @@ -4,7 +4,7 @@ //! defined in. #![crate_name = "nix"] -#![feature(collections, core, net, linkage, libc, os, path, std_misc)] +#![feature(collections, core, net, linkage, libc, std_misc)] #![allow(non_camel_case_types)] #[macro_use] diff --git a/src/sched.rs b/src/sched.rs index 0dff3cad..aa09b316 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -49,8 +49,8 @@ mod cpuset_attribs { #[cfg(all(target_arch = "x86", target_os = "linux"))] mod cpuset_attribs { use super::CpuMask; - pub const CPU_SETSIZE: usize = 1024us; - pub const CPU_MASK_BITS: usize = 32us; + pub const CPU_SETSIZE: usize = 1024; + pub const CPU_MASK_BITS: usize = 32; #[inline] pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask { |