Fix libnative

This commit is contained in:
Steven Fackler 2014-09-29 00:28:50 -07:00 committed by Steven Fackler
parent efbb15d59c
commit d3444779e6
6 changed files with 68 additions and 70 deletions

View File

@ -19,41 +19,42 @@ pub use self::signal::{SA_NODEFER, SA_NOCLDWAIT, SA_SIGINFO, SIGCHLD};
use libc;
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
pub static FIONBIO: libc::c_ulong = 0x8004667e;
#[cfg(target_os = "linux", target_arch = "x86")]
#[cfg(target_os = "linux", target_arch = "x86_64")]
#[cfg(target_os = "linux", target_arch = "arm")]
#[cfg(target_os = "android")]
#[cfg(any(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")),
target_os = "android"))]
pub static FIONBIO: libc::c_ulong = 0x5421;
#[cfg(target_os = "linux", target_arch = "mips")]
#[cfg(target_os = "linux", target_arch = "mipsel")]
#[cfg(all(target_os = "linux",
any(target_arch = "mips", target_arch = "mipsel")))]
pub static FIONBIO: libc::c_ulong = 0x667e;
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
pub static FIOCLEX: libc::c_ulong = 0x20006601;
#[cfg(target_os = "linux", target_arch = "x86")]
#[cfg(target_os = "linux", target_arch = "x86_64")]
#[cfg(target_os = "linux", target_arch = "arm")]
#[cfg(target_os = "android")]
#[cfg(any(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")),
target_os = "android"))]
pub static FIOCLEX: libc::c_ulong = 0x5451;
#[cfg(target_os = "linux", target_arch = "mips")]
#[cfg(target_os = "linux", target_arch = "mipsel")]
#[cfg(all(target_os = "linux",
any(target_arch = "mips", target_arch = "mipsel")))]
pub static FIOCLEX: libc::c_ulong = 0x6601;
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
pub static MSG_DONTWAIT: libc::c_int = 0x80;
#[cfg(target_os = "linux")]
#[cfg(target_os = "android")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub static MSG_DONTWAIT: libc::c_int = 0x40;
pub static WNOHANG: libc::c_int = 1;
@ -86,8 +87,7 @@ extern {
pub fn sigemptyset(set: *mut sigset_t) -> libc::c_int;
}
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod select {
pub static FD_SETSIZE: uint = 1024;
@ -101,10 +101,10 @@ mod select {
}
}
#[cfg(target_os = "android")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "linux"))]
mod select {
use std::uint;
use libc;
@ -123,10 +123,11 @@ mod select {
}
}
#[cfg(target_os = "linux", target_arch = "x86")]
#[cfg(target_os = "linux", target_arch = "x86_64")]
#[cfg(target_os = "linux", target_arch = "arm")]
#[cfg(target_os = "android")]
#[cfg(any(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")),
target_os = "android"))]
mod signal {
use libc;
@ -173,8 +174,8 @@ mod signal {
}
}
#[cfg(target_os = "linux", target_arch = "mips")]
#[cfg(target_os = "linux", target_arch = "mipsel")]
#[cfg(all(target_os = "linux",
any(target_arch = "mips", target_arch = "mipsel")))]
mod signal {
use libc;
@ -215,10 +216,10 @@ mod signal {
}
}
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
mod signal {
use libc;

View File

@ -130,8 +130,7 @@ impl rtio::RtioFileStream for FileDesc {
fn datasync(&mut self) -> IoResult<()> {
return super::mkerr_libc(os_datasync(self.fd()));
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
fn os_datasync(fd: c_int) -> c_int {
unsafe { libc::fcntl(fd, libc::F_FULLFSYNC) }
}
@ -139,7 +138,7 @@ impl rtio::RtioFileStream for FileDesc {
fn os_datasync(fd: c_int) -> c_int {
retry(|| unsafe { libc::fdatasync(fd) })
}
#[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "linux"))]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "linux")))]
fn os_datasync(fd: c_int) -> c_int {
retry(|| unsafe { libc::fsync(fd) })
}
@ -445,14 +444,14 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
// FileStat times are in milliseconds
fn mktime(secs: u64, nsecs: u64) -> u64 { secs * 1000 + nsecs / 1000000 }
#[cfg(not(target_os = "linux"), not(target_os = "android"))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn flags(stat: &libc::stat) -> u64 { stat.st_flags as u64 }
#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn flags(_stat: &libc::stat) -> u64 { 0 }
#[cfg(not(target_os = "linux"), not(target_os = "android"))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn gen(stat: &libc::stat) -> u64 { stat.st_gen as u64 }
#[cfg(target_os = "linux")] #[cfg(target_os = "android")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn gen(_stat: &libc::stat) -> u64 { 0 }
rtio::FileStat {

View File

@ -48,12 +48,12 @@ pub mod file;
#[path = "file_windows.rs"]
pub mod file;
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(target_os = "android")]
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "android",
target_os = "linux"))]
#[path = "timer_unix.rs"]
pub mod timer;

View File

@ -282,20 +282,20 @@ impl TcpStream {
}
}
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
seconds as libc::c_int)
}
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
seconds as libc::c_int)
}
#[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"),
not(target_os = "dragonfly"))]
#[cfg(not(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly")))]
fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> {
Ok(())
}

View File

@ -840,18 +840,17 @@ fn free_handle(_handle: *mut ()) {
#[cfg(unix)]
fn translate_status(status: c_int) -> rtio::ProcessExit {
#![allow(non_snake_case)]
#[cfg(target_os = "linux")]
#[cfg(target_os = "android")]
#[cfg(any(target_os = "linux", target_os = "android"))]
mod imp {
pub fn WIFEXITED(status: i32) -> bool { (status & 0xff) == 0 }
pub fn WEXITSTATUS(status: i32) -> i32 { (status >> 8) & 0xff }
pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f }
}
#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "dragonfly")]
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
mod imp {
pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
pub fn WEXITSTATUS(status: i32) -> i32 { status >> 8 }

View File

@ -77,10 +77,9 @@ pub use task::NativeTaskBuilder;
pub mod io;
pub mod task;
#[cfg(windows)]
#[cfg(android)]
#[cfg(any(windows, android))]
static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
#[cfg(unix, not(android))]
#[cfg(all(unix, not(android)))]
static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
#[lang = "start"]