Skip to content

Commit 0e369e9

Browse files
committed
Fix deprecation warnings
1 parent 9b640d5 commit 0e369e9

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

src/errno.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,52 @@
1-
use std::os::errno;
1+
use libc::c_int;
22
use std::num::from_i32;
33

44
pub use self::consts::*;
55
pub use self::consts::Errno::*;
66

7+
/// Returns the platform-specific value of errno
8+
pub fn errno() -> i32 {
9+
#[cfg(any(target_os = "macos",
10+
target_os = "ios",
11+
target_os = "freebsd"))]
12+
unsafe fn errno_location() -> *const c_int {
13+
extern { fn __error() -> *const c_int; }
14+
__error()
15+
}
16+
17+
#[cfg(target_os = "bitrig")]
18+
fn errno_location() -> *const c_int {
19+
extern {
20+
fn __errno() -> *const c_int;
21+
}
22+
unsafe {
23+
__errno()
24+
}
25+
}
26+
27+
#[cfg(target_os = "dragonfly")]
28+
unsafe fn errno_location() -> *const c_int {
29+
extern { fn __dfly_error() -> *const c_int; }
30+
__dfly_error()
31+
}
32+
33+
#[cfg(target_os = "openbsd")]
34+
unsafe fn errno_location() -> *const c_int {
35+
extern { fn __errno() -> *const c_int; }
36+
__errno()
37+
}
38+
39+
#[cfg(any(target_os = "linux", target_os = "android"))]
40+
unsafe fn errno_location() -> *const c_int {
41+
extern { fn __errno_location() -> *const c_int; }
42+
__errno_location()
43+
}
44+
45+
unsafe {
46+
(*errno_location()) as i32
47+
}
48+
}
49+
750
macro_rules! impl_errno {
851
($errno:ty) => {
952
impl $errno {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! defined in.
55
#![crate_name = "nix"]
66

7-
#![feature(collections, core, net, linkage, libc, os, path, std_misc)]
7+
#![feature(collections, core, net, linkage, libc, std_misc)]
88
#![allow(non_camel_case_types)]
99

1010
#[macro_use]

src/sched.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ mod cpuset_attribs {
4949
#[cfg(all(target_arch = "x86", target_os = "linux"))]
5050
mod cpuset_attribs {
5151
use super::CpuMask;
52-
pub const CPU_SETSIZE: usize = 1024us;
53-
pub const CPU_MASK_BITS: usize = 32us;
52+
pub const CPU_SETSIZE: usize = 1024;
53+
pub const CPU_MASK_BITS: usize = 32;
5454

5555
#[inline]
5656
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {

test/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(core, libc, net, path, std_misc)]
1+
#![feature(core, libc, net, std_misc)]
22

33
extern crate nix;
44
extern crate libc;

0 commit comments

Comments
 (0)