summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2015-03-16 15:39:51 -0700
committerCarl Lerche <me@carllerche.com>2015-03-16 15:39:51 -0700
commit0e369e931f5927a31bec4e5ca6ee21ebb60e6e7f (patch)
tree437e82c3855109d4f18c9ebb7af221d0e89d0acf
parent9b640d53f5b72bedfd6cd589f77d9338d5b540f3 (diff)
downloadnix-0e369e931f5927a31bec4e5ca6ee21ebb60e6e7f.zip
Fix deprecation warnings
-rw-r--r--src/errno.rs45
-rw-r--r--src/lib.rs2
-rw-r--r--src/sched.rs4
-rw-r--r--test/test.rs2
4 files changed, 48 insertions, 5 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 {
diff --git a/src/lib.rs b/src/lib.rs
index 3826b4d7..ec3341e7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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 {
diff --git a/test/test.rs b/test/test.rs
index 7c5a6b20..ba66002a 100644
--- a/test/test.rs
+++ b/test/test.rs
@@ -1,4 +1,4 @@
-#![feature(core, libc, net, path, std_misc)]
+#![feature(core, libc, net, std_misc)]
extern crate nix;
extern crate libc;