Verified Commit 439a559b authored by Jeremy Soller's avatar Jeremy Soller

Fix compilation if Redox becomes part of the unix target family

parent 493d2b65
......@@ -8,7 +8,7 @@ mod notify;
#[cfg(target_os = "redox")]
pub mod redox;
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
pub mod unix;
pub use self::event_loop::{
......@@ -27,7 +27,7 @@ pub use self::handler::{
pub use self::notify::{
NotifyError,
};
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
pub use self::unix::{
pipe,
PipeReader,
......
......@@ -204,7 +204,7 @@ pub use poll::Iter as EventsIter;
#[doc(hidden)]
pub use io::deprecated::would_block;
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
pub mod unix {
//! Unix only extensions
pub use sys::EventedFd;
......
......@@ -571,24 +571,24 @@ impl fmt::Debug for UdpSocket {
*
*/
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
use std::os::unix::io::{IntoRawFd, AsRawFd, FromRawFd, RawFd};
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
impl IntoRawFd for UdpSocket {
fn into_raw_fd(self) -> RawFd {
self.sys.into_raw_fd()
}
}
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
impl AsRawFd for UdpSocket {
fn as_raw_fd(&self) -> RawFd {
self.sys.as_raw_fd()
}
}
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
impl FromRawFd for UdpSocket {
unsafe fn from_raw_fd(fd: RawFd) -> UdpSocket {
UdpSocket {
......@@ -597,4 +597,3 @@ impl FromRawFd for UdpSocket {
}
}
}
......@@ -3,9 +3,9 @@ use event_imp::{self as event, Ready, Event, Evented, PollOpt};
use std::{fmt, io, ptr, usize};
use std::cell::UnsafeCell;
use std::{mem, ops, isize};
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
use std::os::unix::io::AsRawFd;
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
use std::os::unix::io::RawFd;
use std::process;
use std::sync::{Arc, Mutex, Condvar};
......@@ -1221,7 +1221,7 @@ impl fmt::Debug for Poll {
}
}
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
impl AsRawFd for Poll {
fn as_raw_fd(&self) -> RawFd {
self.selector.as_raw_fd()
......@@ -2776,7 +2776,7 @@ impl Clone for SelectorId {
}
#[test]
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
pub fn as_raw_fd() {
let poll = Poll::new().unwrap();
assert!(poll.as_raw_fd() > 0);
......
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
pub use self::unix::{
Awakener,
EventedFd,
......@@ -12,14 +12,14 @@ pub use self::unix::{
set_nonblock,
};
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
pub use self::unix::READY_ALL;
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
#[cfg(feature = "with-deprecated")]
pub use self::unix::UnixSocket;
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
pub mod unix;
#[cfg(windows)]
......@@ -69,5 +69,5 @@ pub use self::redox::{
#[cfg(target_os = "redox")]
mod redox;
#[cfg(not(all(unix, not(target_os = "fuchsia"))))]
#[cfg(not(all(unix, not(target_os = "fuchsia"), not(target_os = "redox"))))]
pub const READY_ALL: usize = 0;
......@@ -6,8 +6,8 @@ use syscall::{fcntl, F_SETFL, F_GETFL, O_NONBLOCK};
use {io, poll, Evented, Ready, Poll, PollOpt, Token};
pub fn set_nonblock(fd: RawFd) -> io::Result<()> {
let flags = fcntl(fd, F_GETFL, 0).map_err(super::from_syscall_error)?;
fcntl(fd, F_SETFL, flags | O_NONBLOCK).map_err(super::from_syscall_error)
let flags = fcntl(fd as usize, F_GETFL, 0).map_err(super::from_syscall_error)?;
fcntl(fd as usize, F_SETFL, flags | O_NONBLOCK).map_err(super::from_syscall_error)
.map(|_| ())
}
......
......@@ -13,7 +13,7 @@ pub use self::tcp::{TcpStream, TcpListener};
pub use self::udp::UdpSocket;
use std::io::{Error, Result};
use std::os::unix::io::FromRawFd;
use std::os::unix::io::{FromRawFd, RawFd};
use syscall::{self, pipe2, O_NONBLOCK, O_CLOEXEC};
pub fn pipe() -> Result<(Io, Io)> {
......@@ -21,7 +21,7 @@ pub fn pipe() -> Result<(Io, Io)> {
pipe2(&mut fds, O_NONBLOCK | O_CLOEXEC).map_err(from_syscall_error)?;
unsafe {
Ok((Io::from_raw_fd(fds[0]), Io::from_raw_fd(fds[1])))
Ok((Io::from_raw_fd(fds[0] as RawFd), Io::from_raw_fd(fds[1] as RawFd)))
}
}
......
......@@ -119,7 +119,7 @@ impl UdpSocket {
self.sys.recv(buf).map_non_block()
}
/// Connects the UDP socket setting the default destination for `send()`
/// Connects the UDP socket setting the default destination for `send()`
/// and limiting packets that are read via `recv` from the address specified
/// in `addr`.
pub fn connect(&self, addr: SocketAddr)
......@@ -298,24 +298,24 @@ impl Evented for UdpSocket {
*
*/
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
use std::os::unix::io::{IntoRawFd, AsRawFd, FromRawFd, RawFd};
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
impl IntoRawFd for UdpSocket {
fn into_raw_fd(self) -> RawFd {
self.sys.into_raw_fd()
}
}
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
impl AsRawFd for UdpSocket {
fn as_raw_fd(&self) -> RawFd {
self.sys.as_raw_fd()
}
}
#[cfg(all(unix, not(target_os = "fuchsia")))]
#[cfg(all(unix, not(target_os = "fuchsia"), not(target_os = "redox")))]
impl FromRawFd for UdpSocket {
unsafe fn from_raw_fd(fd: RawFd) -> UdpSocket {
UdpSocket {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment