Skip to content

Commit

Permalink
Merge #798
Browse files Browse the repository at this point in the history
798: More libc ffi r=Susurrus a=Susurrus

Blocking on rust-lang/libc#850 for Android support.
  • Loading branch information
bors[bot] committed Nov 18, 2017
2 parents b335685 + d625194 commit 2d270c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 43 deletions.
67 changes: 26 additions & 41 deletions src/errno.rs
Original file line number Diff line number Diff line change
@@ -1,52 +1,37 @@
use libc::c_int;
use libc::{self, c_int};
use std::{fmt, io, error};
use {Error, Result};

pub use self::consts::*;
pub use self::consts::Errno::*;

#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd"))]
unsafe fn errno_location() -> *mut c_int {
extern { fn __error() -> *mut c_int; }
__error()
}

#[cfg(target_os = "bitrig")]
fn errno_location() -> *mut c_int {
extern {
fn __errno() -> *mut c_int;
}
unsafe {
__errno()
cfg_if! {
if #[cfg(any(target_os = "freebsd",
target_os = "ios",
target_os = "macos"))] {
unsafe fn errno_location() -> *mut c_int {
libc::__error()
}
} else if #[cfg(target_os = "dragonfly")] {
unsafe fn errno_location() -> *mut c_int {
// FIXME: Replace with errno-dragonfly crate as this is no longer the correct
// implementation.
extern { fn __dfly_error() -> *mut c_int; }
__dfly_error()
}
} else if #[cfg(any(target_os = "android",
target_os = "netbsd",
target_os = "openbsd"))] {
unsafe fn errno_location() -> *mut c_int {
libc::__errno()
}
} else if #[cfg(target_os = "linux")] {
unsafe fn errno_location() -> *mut c_int {
libc::__errno_location()
}
}
}

#[cfg(target_os = "dragonfly")]
unsafe fn errno_location() -> *mut c_int {
extern { fn __dfly_error() -> *mut c_int; }
__dfly_error()
}

#[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
unsafe fn errno_location() -> *mut c_int {
extern { fn __errno() -> *mut c_int; }
__errno()
}

#[cfg(target_os = "linux")]
unsafe fn errno_location() -> *mut c_int {
extern { fn __errno_location() -> *mut c_int; }
__errno_location()
}

#[cfg(target_os = "android")]
unsafe fn errno_location() -> *mut c_int {
extern { fn __errno() -> *mut c_int; }
__errno()
}

/// Sets the platform-specific errno to no-error
unsafe fn clear() -> () {
*errno_location() = 0;
Expand Down Expand Up @@ -520,7 +505,7 @@ fn desc(errno: Errno) -> &'static str {

#[cfg(target_os = "dragonfly")]
EUNUSED94 | EUNUSED95 | EUNUSED96 | EUNUSED97 | EUNUSED98 => "Unused",

#[cfg(target_os = "dragonfly")]
EASYNC => "Async",
}
Expand Down
3 changes: 1 addition & 2 deletions src/sys/aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ libc_enum! {
/// do it like `fsync`
O_SYNC,
/// on supported operating systems only, do it like `fdatasync`
#[cfg(any(target_os = "bitrig",
target_os = "ios",
#[cfg(any(target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand Down

0 comments on commit 2d270c9

Please sign in to comment.