diff --git a/src/dir.rs b/src/dir.rs index 1820b5330f..7c42aec11b 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -2,7 +2,9 @@ use {Error, NixPath, Result}; use errno::Errno; use fcntl::{self, OFlag}; use libc; -use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; +use std::os::unix::io::{IntoRawFd, RawFd}; +#[cfg(not(target_os = "redox"))] +use std::os::unix::io::AsRawFd; use std::{ffi, ptr}; use sys; @@ -77,6 +79,7 @@ impl Dir { // `Dir` is safe to pass from one thread to another, as it's not reference-counted. unsafe impl Send for Dir {} +#[cfg(not(target_os = "redox"))] impl AsRawFd for Dir { fn as_raw_fd(&self) -> RawFd { unsafe { libc::dirfd(self.0.as_ptr()) } @@ -149,6 +152,7 @@ impl Entry { target_os = "l4re", target_os = "linux", target_os = "macos", + target_os = "redox", target_os = "solaris"))] pub fn ino(&self) -> u64 { self.0.d_ino as u64 @@ -163,6 +167,7 @@ impl Entry { target_os = "l4re", target_os = "linux", target_os = "macos", + target_os = "redox", target_os = "solaris")))] pub fn ino(&self) -> u64 { self.0.d_fileno as u64 diff --git a/src/errno.rs b/src/errno.rs index 6a2447bc52..e0b84ae67a 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -38,7 +38,7 @@ cfg_if! { unsafe fn errno_location() -> *mut c_int { libc::__errno() } - } else if #[cfg(target_os = "linux")] { + } else if #[cfg(any(target_os = "linux", target_os = "redox"))] { unsafe fn errno_location() -> *mut c_int { libc::__errno_location() } @@ -336,7 +336,8 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "linux", target_os = "android"))] EUSERS => "Too many users", - #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))] + #[cfg(any(target_os = "linux", target_os = "android", + target_os = "netbsd", target_os = "redox"))] EOPNOTSUPP => "Operation not supported on transport endpoint", #[cfg(any(target_os = "linux", target_os = "android"))] @@ -397,10 +398,10 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] EDOOFUS => "Programming error", - #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "redox"))] EMULTIHOP => "Multihop attempted", - #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] + #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "redox"))] ENOLINK => "Link has been severed", #[cfg(target_os = "freebsd")] @@ -416,12 +417,13 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] EOVERFLOW => "Value too large to be stored in data type", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "netbsd"))] + target_os = "netbsd", target_os = "redox"))] EILSEQ => "Illegal byte sequence", #[cfg(any(target_os = "macos", target_os = "freebsd", @@ -431,12 +433,14 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] EBADMSG => "Bad message", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] EPROTO => "Protocol error", #[cfg(any(target_os = "macos", target_os = "freebsd", @@ -459,22 +463,26 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] EUSERS => "Too many users", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] EDQUOT => "Disc quota exceeded", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] ESTALE => "Stale NFS file handle", #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] EREMOTE => "Too many levels of remote in path", #[cfg(any(target_os = "macos", target_os = "freebsd", @@ -514,7 +522,8 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", - target_os = "openbsd", target_os = "netbsd"))] + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] ECANCELED => "Operation canceled", #[cfg(any(target_os = "macos", target_os = "ios"))] @@ -538,19 +547,23 @@ fn desc(errno: Errno) -> &'static str { #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] EMULTIHOP => "Reserved", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "netbsd", target_os = "redox"))] ENODATA => "No message available on STREAM", #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] ENOLINK => "Reserved", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "netbsd", target_os = "redox"))] ENOSR => "No STREAM resources", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "netbsd", target_os = "redox"))] ENOSTR => "Not a STREAM", - #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))] + #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "netbsd", target_os = "redox"))] ETIME => "STREAM ioctl timeout", #[cfg(any(target_os = "macos", target_os = "ios"))] @@ -1961,3 +1974,197 @@ mod consts { } } } + +#[cfg(target_os = "redox")] +mod consts { + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] + pub enum Errno { + UnknownErrno = 0, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + EILSEQ = libc::EILSEQ, + ECANCELED = libc::ECANCELED, + EBADMSG = libc::EBADMSG, + ENODATA = libc::ENODATA, + ENOSR = libc::ENOSR, + ENOSTR = libc::ENOSTR, + ETIME = libc::ETIME, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + } + + pub const ELAST: Errno = Errno::UnknownErrno; + pub const EWOULDBLOCK: Errno = Errno::EAGAIN; + + pub const EL2NSYNC: Errno = Errno::UnknownErrno; + + pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::EILSEQ => EILSEQ, + libc::ECANCELED => ECANCELED, + libc::EBADMSG => EBADMSG, + libc::ENODATA => ENODATA, + libc::ENOSR => ENOSR, + libc::ENOSTR => ENOSTR, + libc::ETIME => ETIME, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + _ => UnknownErrno, + } + } +} diff --git a/src/fcntl.rs b/src/fcntl.rs index be6ee0f73a..6c12d8c1de 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -2,6 +2,7 @@ use {Error, Result, NixPath}; use errno::Errno; use libc::{self, c_int, c_uint, c_char, size_t, ssize_t}; use sys::stat::Mode; +#[cfg(not(target_os = "redox"))] use std::os::raw; use std::os::unix::io::RawFd; use std::ffi::OsStr; @@ -21,6 +22,7 @@ use sys::uio::IoVec; // For vmsplice target_env = "freebsd"))] pub use self::posix_fadvise::*; +#[cfg(not(target_os = "redox"))] libc_bitflags!{ pub struct AtFlags: c_int { AT_REMOVEDIR; @@ -78,7 +80,8 @@ libc_bitflags!( target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "redox"))] O_EXLOCK; /// Same as `O_SYNC`. #[cfg(any(target_os = "dragonfly", @@ -87,7 +90,8 @@ libc_bitflags!( all(target_os = "linux", not(target_env = "musl")), target_os = "macos", target_os = "netbsd", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "redox"))] O_FSYNC; /// Allow files whose sizes can't be represented in an `off_t` to be opened. #[cfg(any(target_os = "android", target_os = "linux"))] @@ -96,8 +100,10 @@ libc_bitflags!( #[cfg(any(target_os = "android", target_os = "linux"))] O_NOATIME; /// Don't attach the device as the process' controlling terminal. + #[cfg(not(target_os = "redox"))] O_NOCTTY; /// Same as `O_NONBLOCK`. + #[cfg(not(target_os = "redox"))] O_NDELAY; /// `open()` will fail if the given path is a symbolic link. O_NOFOLLOW; @@ -109,7 +115,7 @@ libc_bitflags!( /// Obtain a file descriptor for low-level access. /// /// The file itself is not opened and other file operations will fail. - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "redox"))] O_PATH; /// Only allow reading. /// @@ -131,9 +137,11 @@ libc_bitflags!( target_os = "ios", target_os = "macos", target_os = "netbsd", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "redox"))] O_SHLOCK; /// Implicitly follow each `write()` with an `fsync()`. + #[cfg(not(target_os = "redox"))] O_SYNC; /// Create an unnamed temporary file. #[cfg(any(target_os = "android", target_os = "linux"))] @@ -208,6 +216,7 @@ pub fn readlinkat<'a, P: ?Sized + NixPath>(dirfd: RawFd, path: &P, buffer: &'a m } /// Computes the raw fd consumed by a function of the form `*at`. +#[cfg(not(target_os = "redox"))] pub(crate) fn at_rawfd(fd: Option) -> raw::c_int { match fd { None => libc::AT_FDCWD, @@ -238,6 +247,7 @@ libc_bitflags!( } ); +#[cfg(not(target_os = "redox"))] #[derive(Debug, Eq, Hash, PartialEq)] pub enum FcntlArg<'a> { F_DUPFD(RawFd), @@ -268,6 +278,17 @@ pub enum FcntlArg<'a> { // TODO: Rest of flags } + +#[cfg(target_os = "redox")] +#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)] +pub enum FcntlArg { + F_DUPFD(RawFd), + F_DUPFD_CLOEXEC(RawFd), + F_GETFD, + F_SETFD(FdFlag), // FD_FLAGS + F_GETFL, + F_SETFL(OFlag), // O_NONBLOCK +} pub use self::FcntlArg::*; // TODO: Figure out how to handle value fcntl returns @@ -280,8 +301,11 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result { F_SETFD(flag) => libc::fcntl(fd, libc::F_SETFD, flag.bits()), F_GETFL => libc::fcntl(fd, libc::F_GETFL), F_SETFL(flag) => libc::fcntl(fd, libc::F_SETFL, flag.bits()), + #[cfg(not(target_os = "redox"))] F_SETLK(flock) => libc::fcntl(fd, libc::F_SETLK, flock), + #[cfg(not(target_os = "redox"))] F_SETLKW(flock) => libc::fcntl(fd, libc::F_SETLKW, flock), + #[cfg(not(target_os = "redox"))] F_GETLK(flock) => libc::fcntl(fd, libc::F_GETLK, flock), #[cfg(any(target_os = "android", target_os = "linux"))] F_ADD_SEALS(flag) => libc::fcntl(fd, libc::F_ADD_SEALS, flag.bits()), @@ -311,6 +335,7 @@ pub enum FlockArg { UnlockNonblock, } +#[cfg(not(target_os = "redox"))] pub fn flock(fd: RawFd, arg: FlockArg) -> Result<()> { use self::FlockArg::*; diff --git a/src/features.rs b/src/features.rs index 76cdfd3a1a..827eecacb5 100644 --- a/src/features.rs +++ b/src/features.rs @@ -94,7 +94,10 @@ mod os { } } -#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))] +#[cfg(any(target_os = "macos", target_os = "freebsd", + target_os = "dragonfly", target_os = "ios", + target_os = "openbsd", target_os = "netbsd", + target_os = "redox"))] mod os { /// Check if the OS supports atomic close-on-exec for sockets pub fn socket_atomic_cloexec() -> bool { diff --git a/src/lib.rs b/src/lib.rs index 71485d2af1..3f6fd9bc90 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,10 +59,13 @@ pub mod mount; target_os = "netbsd"))] pub mod mqueue; #[deny(missing_docs)] +#[cfg(not(target_os = "redox"))] pub mod net; #[deny(missing_docs)] +#[cfg(not(target_os = "redox"))] pub mod poll; #[deny(missing_docs)] +#[cfg(not(target_os = "redox"))] pub mod pty; pub mod sched; pub mod sys; diff --git a/src/macros.rs b/src/macros.rs index 3d1b0e4b76..fd0b62592b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -257,6 +257,7 @@ macro_rules! libc_enum { /// A Rust version of the familiar C `offset_of` macro. It returns the byte /// offset of `field` within struct `ty` +#[cfg(not(target_os = "redox"))] macro_rules! offset_of { ($ty:ty, $field:ident) => { &(*(0 as *const $ty)).$field as *const _ as usize diff --git a/src/sys/mod.rs b/src/sys/mod.rs index d3c2f92bba..98339b0ff3 100644 --- a/src/sys/mod.rs +++ b/src/sys/mod.rs @@ -34,6 +34,7 @@ pub mod ioctl; #[cfg(target_os = "linux")] pub mod memfd; +#[cfg(not(target_os = "redox"))] pub mod mman; pub mod pthread; @@ -53,6 +54,7 @@ pub mod quota; #[cfg(any(target_os = "linux"))] pub mod reboot; +#[cfg(not(target_os = "redox"))] pub mod select; #[cfg(any(target_os = "android", @@ -67,6 +69,7 @@ pub mod signal; #[cfg(any(target_os = "android", target_os = "linux"))] pub mod signalfd; +#[cfg(not(target_os = "redox"))] pub mod socket; pub mod stat; @@ -86,6 +89,7 @@ pub mod statvfs; #[cfg(any(target_os = "android", target_os = "linux"))] pub mod sysinfo; +#[cfg(not(target_os = "redox"))] pub mod termios; pub mod time; diff --git a/src/sys/signal.rs b/src/sys/signal.rs index 1013a77fd4..82ee897f21 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -13,7 +13,7 @@ use std::str::FromStr; use std::os::unix::io::RawFd; use std::ptr; -#[cfg(not(target_os = "openbsd"))] +#[cfg(not(any(target_os = "openbsd", target_os = "redox")))] pub use self::sigevent::*; libc_enum!{ @@ -57,9 +57,11 @@ libc_enum!{ #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))] SIGPWR, SIGSYS, - #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "linux", target_os = "redox")))] SIGEMT, - #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "linux", target_os = "redox")))] SIGINFO, } } @@ -102,9 +104,11 @@ impl FromStr for Signal { #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))] "SIGPWR" => Signal::SIGPWR, "SIGSYS" => Signal::SIGSYS, - #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "linux", target_os = "redox")))] "SIGEMT" => Signal::SIGEMT, - #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "linux", target_os = "redox")))] "SIGINFO" => Signal::SIGINFO, _ => return Err(Error::invalid_argument()), }) @@ -148,9 +152,11 @@ impl AsRef for Signal { #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))] Signal::SIGPWR => "SIGPWR", Signal::SIGSYS => "SIGSYS", - #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "linux", target_os = "redox")))] Signal::SIGEMT => "SIGEMT", - #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "linux")))] + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "linux", target_os = "redox")))] Signal::SIGINFO => "SIGINFO", } } @@ -164,6 +170,37 @@ impl fmt::Display for Signal { pub use self::Signal::*; +#[cfg(target_os = "redox")] +const SIGNALS: [Signal; 29] = [ + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGBUS, + SIGFPE, + SIGKILL, + SIGUSR1, + SIGSEGV, + SIGUSR2, + SIGPIPE, + SIGALRM, + SIGTERM, + SIGCHLD, + SIGCONT, + SIGSTOP, + SIGTSTP, + SIGTTIN, + SIGTTOU, + SIGURG, + SIGXCPU, + SIGXFSZ, + SIGVTALRM, + SIGPROF, + SIGWINCH, + SIGIO, + SIGSYS]; #[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), not(any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc64"))))] const SIGNALS: [Signal; 31] = [ SIGHUP, @@ -229,7 +266,8 @@ const SIGNALS: [Signal; 30] = [ SIGIO, SIGPWR, SIGSYS]; -#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten")))] +#[cfg(not(any(target_os = "linux", target_os = "android", + target_os = "emscripten", target_os = "redox")))] const SIGNALS: [Signal; 31] = [ SIGHUP, SIGINT, @@ -306,8 +344,13 @@ pub const SIGIOT : Signal = SIGABRT; pub const SIGPOLL : Signal = SIGIO; pub const SIGUNUSED : Signal = SIGSYS; +#[cfg(not(target_os = "redox"))] +type SaFlags_t = libc::c_int; +#[cfg(target_os = "redox")] +type SaFlags_t = libc::c_ulong; + libc_bitflags!{ - pub struct SaFlags: libc::c_int { + pub struct SaFlags: SaFlags_t { SA_NOCLDSTOP; SA_NOCLDWAIT; SA_NODEFER; @@ -435,6 +478,7 @@ pub enum SigHandler { Handler(extern fn(libc::c_int)), /// Use the given signal-catching function, which takes in the signal, information about how /// the signal was generated, and a pointer to the threads `ucontext_t`. + #[cfg(not(target_os = "redox"))] SigAction(extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void)) } @@ -451,14 +495,28 @@ impl SigAction { /// is the `SigAction` variant). `mask` specifies other signals to block during execution of /// the signal-catching function. pub fn new(handler: SigHandler, flags: SaFlags, mask: SigSet) -> SigAction { + #[cfg(not(target_os = "redox"))] + fn install_sig(s: &mut libc::sigaction, handler: SigHandler) { + s.sa_sigaction = match handler { + SigHandler::SigDfl => libc::SIG_DFL, + SigHandler::SigIgn => libc::SIG_IGN, + SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize, + SigHandler::SigAction(f) => f as *const extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize, + }; + } + #[cfg(target_os = "redox")] + fn install_sig(s: &mut libc::sigaction, handler: SigHandler) { + s.sa_handler = match handler { + SigHandler::SigDfl => libc::SIG_DFL, + SigHandler::SigIgn => libc::SIG_IGN, + SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize, + }; + } + let mut s = unsafe { mem::uninitialized::() }; - s.sa_sigaction = match handler { - SigHandler::SigDfl => libc::SIG_DFL, - SigHandler::SigIgn => libc::SIG_IGN, - SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize, - SigHandler::SigAction(f) => f as *const extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize, - }; + install_sig(&mut s, handler); s.sa_flags = match handler { + #[cfg(not(target_os = "redox"))] SigHandler::SigAction(_) => (flags | SaFlags::SA_SIGINFO).bits(), _ => (flags - SaFlags::SA_SIGINFO).bits(), }; @@ -479,6 +537,7 @@ impl SigAction { } /// Returns the action's handler. + #[cfg(not(target_os = "redox"))] pub fn handler(&self) -> SigHandler { match self.sigaction.sa_sigaction { libc::SIG_DFL => SigHandler::SigDfl, @@ -488,6 +547,16 @@ impl SigAction { f => SigHandler::Handler( unsafe { mem::transmute(f) } ), } } + + /// Returns the action's handler. + #[cfg(target_os = "redox")] + pub fn handler(&self) -> SigHandler { + match self.sigaction.sa_handler { + libc::SIG_DFL => SigHandler::SigDfl, + libc::SIG_IGN => SigHandler::SigIgn, + f => SigHandler::Handler( unsafe { mem::transmute(f) } ), + } + } } /// Changes the action taken by a process on receipt of a specific signal. @@ -571,6 +640,7 @@ pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result SigHandler::SigDfl => libc::signal(signal, libc::SIG_DFL), SigHandler::SigIgn => libc::signal(signal, libc::SIG_IGN), SigHandler::Handler(handler) => libc::signal(signal, handler as libc::sighandler_t), + #[cfg(not(target_os = "redox"))] SigHandler::SigAction(_) => return Err(Error::UnsupportedOperation), }; Errno::result(res).map(|oldhandler| { @@ -702,7 +772,7 @@ pub enum SigevNotify { si_value: libc::intptr_t }, } -#[cfg(not(target_os = "openbsd"))] +#[cfg(not(any(target_os = "openbsd", target_os = "redox")))] mod sigevent { use libc; use std::mem; @@ -918,9 +988,19 @@ mod tests { use libc; thread::spawn(|| { extern fn test_sigaction_handler(_: libc::c_int) {} + #[cfg(not(target_os = "redox"))] extern fn test_sigaction_action(_: libc::c_int, _: *mut libc::siginfo_t, _: *mut libc::c_void) {} + #[cfg(not(target_os = "redox"))] + fn test_sigaction_sigaction(flags: SaFlags, mask: SigSet) { + let handler_act = SigHandler::SigAction(test_sigaction_action); + let action_act = SigAction::new(handler_act, flags, mask); + assert_eq!(action_act.handler(), handler_act); + } + #[cfg(target_os = "redox")] + fn test_sigaction_sigaction() {} + let handler_sig = SigHandler::Handler(test_sigaction_handler); let flags = SaFlags::SA_ONSTACK | SaFlags::SA_RESTART | @@ -939,9 +1019,7 @@ mod tests { assert!(mask.contains(SIGUSR1)); assert!(!mask.contains(SIGUSR2)); - let handler_act = SigHandler::SigAction(test_sigaction_action); - let action_act = SigAction::new(handler_act, flags, mask); - assert_eq!(action_act.handler(), handler_act); + test_sigaction_sigaction(flags, mask); let action_dfl = SigAction::new(SigHandler::SigDfl, flags, mask); assert_eq!(action_dfl.handler(), SigHandler::SigDfl); diff --git a/src/sys/stat.rs b/src/sys/stat.rs index 66c8c9dd1b..9e95f92b65 100644 --- a/src/sys/stat.rs +++ b/src/sys/stat.rs @@ -3,6 +3,7 @@ pub use libc::stat as FileStat; use {Result, NixPath}; use errno::Errno; +#[cfg(not(target_os = "redox"))] use fcntl::{AtFlags, at_rawfd}; use libc; use std::mem; @@ -112,6 +113,7 @@ pub fn fstat(fd: RawFd) -> Result { Ok(dst) } +#[cfg(not(target_os = "redox"))] pub fn fstatat(dirfd: RawFd, pathname: &P, f: AtFlags) -> Result { let mut dst = unsafe { mem::uninitialized() }; let res = pathname.with_nix_path(|cstr| { @@ -157,6 +159,7 @@ pub enum FchmodatFlags { /// # References /// /// [fchmodat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmodat.html). +#[cfg(not(target_os = "redox"))] pub fn fchmodat( dirfd: Option, path: &P, @@ -260,6 +263,7 @@ pub enum UtimensatFlags { /// # References /// /// [utimensat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/utimens.html). +#[cfg(not(target_os = "redox"))] pub fn utimensat( dirfd: Option, path: &P, diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs index e5980369d5..bb1deb5ebb 100644 --- a/src/sys/statvfs.rs +++ b/src/sys/statvfs.rs @@ -10,6 +10,7 @@ use libc::{self, c_ulong}; use {Result, NixPath}; use errno::Errno; +#[cfg(not(target_os = "redox"))] libc_bitflags!( /// File system mount Flags #[repr(C)] @@ -109,6 +110,7 @@ impl Statvfs { } /// Get the mount flags + #[cfg(not(target_os = "redox"))] pub fn flags(&self) -> FsFlags { FsFlags::from_bits_truncate(self.0.f_flag) } diff --git a/src/sys/wait.rs b/src/sys/wait.rs index c54f7ec579..a98bbe7051 100644 --- a/src/sys/wait.rs +++ b/src/sys/wait.rs @@ -14,6 +14,7 @@ libc_bitflags!( target_os = "haiku", target_os = "ios", target_os = "linux", + target_os = "redox", target_os = "macos", target_os = "netbsd"))] WEXITED; @@ -23,6 +24,7 @@ libc_bitflags!( target_os = "haiku", target_os = "ios", target_os = "linux", + target_os = "redox", target_os = "macos", target_os = "netbsd"))] WSTOPPED; @@ -32,16 +34,17 @@ libc_bitflags!( target_os = "haiku", target_os = "ios", target_os = "linux", + target_os = "redox", target_os = "macos", target_os = "netbsd"))] WNOWAIT; /// Don't wait on children of other threads in this group - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "redox"))] __WNOTHREAD; /// Wait on all children, regardless of type - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "redox"))] __WALL; - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "redox"))] __WCLONE; } ); diff --git a/src/unistd.rs b/src/unistd.rs index f422f09198..6b93d55133 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -2,13 +2,19 @@ use errno::{self, Errno}; use {Error, Result, NixPath}; -use fcntl::{AtFlags, at_rawfd, fcntl, FdFlag, OFlag}; +#[cfg(not(target_os = "redox"))] +use fcntl::{AtFlags, at_rawfd}; +use fcntl::{FdFlag, OFlag, fcntl}; use fcntl::FcntlArg::F_SETFD; use libc::{self, c_char, c_void, c_int, c_long, c_uint, size_t, pid_t, off_t, uid_t, gid_t, mode_t}; use std::{fmt, mem, ptr}; -use std::ffi::{CString, CStr, OsString, OsStr}; -use std::os::unix::ffi::{OsStringExt, OsStrExt}; +use std::ffi::{CString, CStr, OsString}; +#[cfg(not(target_os = "redox"))] +use std::ffi::{OsStr}; +use std::os::unix::ffi::OsStringExt; +#[cfg(not(target_os = "redox"))] +use std::os::unix::ffi::OsStrExt; use std::os::unix::io::RawFd; use std::path::PathBuf; use void::Void; @@ -515,6 +521,7 @@ pub fn mkfifo(path: &P, mode: Mode) -> Result<()> { /// directory. This is identical to `libc::symlink(path1, path2)`. /// /// See also [symlinkat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/symlinkat.html). +#[cfg(not(target_os = "redox"))] pub fn symlinkat( path1: &P1, dirfd: Option, @@ -640,6 +647,7 @@ pub enum FchownatFlags { /// # References /// /// [fchownat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchownat.html). +#[cfg(not(target_os = "redox"))] pub fn fchownat( dirfd: Option, path: &P, @@ -833,6 +841,7 @@ pub fn execveat(dirfd: RawFd, pathname: &CString, args: &[CString], note="Deprecated in MacOSX 10.5" ))] #[cfg_attr(any(target_os = "macos", target_os = "ios"), allow(deprecated))] +#[cfg(not(target_os = "redox"))] pub fn daemon(nochdir: bool, noclose: bool) -> Result<()> { let res = unsafe { libc::daemon(nochdir as c_int, noclose as c_int) }; Errno::result(res).map(drop) @@ -845,6 +854,7 @@ pub fn daemon(nochdir: bool, noclose: bool) -> Result<()> { /// On some systems, the host name is limited to as few as 64 bytes. An error /// will be return if the name is not valid or the current process does not have /// permissions to update the host name. +#[cfg(not(target_os = "redox"))] pub fn sethostname>(name: S) -> Result<()> { // Handle some differences in type of the len arg across platforms. cfg_if! { @@ -1031,6 +1041,7 @@ pub fn pipe() -> Result<(RawFd, RawFd)> { target_os = "emscripten", target_os = "freebsd", target_os = "linux", + target_os = "redox", target_os = "netbsd", target_os = "openbsd"))] pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> { @@ -1384,7 +1395,7 @@ pub fn getgroups() -> Result> { /// # try_main().unwrap(); /// # } /// ``` -#[cfg(not(any(target_os = "ios", target_os = "macos")))] +#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))] pub fn setgroups(groups: &[Gid]) -> Result<()> { cfg_if! { if #[cfg(any(target_os = "dragonfly", @@ -1428,7 +1439,7 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> { /// and `setgroups()`. Additionally, while some implementations will return a /// partial list of groups when `NGROUPS_MAX` is exceeded, this implementation /// will only ever return the complete list or else an error. -#[cfg(not(any(target_os = "ios", target_os = "macos")))] +#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))] pub fn getgrouplist(user: &CStr, group: Gid) -> Result> { let ngroups_max = match sysconf(SysconfVar::NGROUPS_MAX) { Ok(Some(n)) => n as c_int, @@ -1519,7 +1530,7 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result> { /// # try_main().unwrap(); /// # } /// ``` -#[cfg(not(any(target_os = "ios", target_os = "macos")))] +#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))] pub fn initgroups(user: &CStr, group: Gid) -> Result<()> { cfg_if! { if #[cfg(any(target_os = "ios", target_os = "macos"))] { @@ -1630,6 +1641,7 @@ pub fn sleep(seconds: c_uint) -> c_uint { unsafe { libc::sleep(seconds) } } +#[cfg(not(target_os = "redox"))] pub mod acct { use libc; use {Result, NixPath}; @@ -1711,7 +1723,7 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> { #[repr(i32)] pub enum PathconfVar { #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "linux", - target_os = "netbsd", target_os = "openbsd"))] + target_os = "netbsd", target_os = "openbsd", target_os = "redox"))] /// Minimum number of bits needed to represent, as a signed integer value, /// the maximum size of a regular file allowed in the specified directory. FILESIZEBITS = libc::_PC_FILESIZEBITS, @@ -1735,11 +1747,11 @@ pub enum PathconfVar { /// a pipe. PIPE_BUF = libc::_PC_PIPE_BUF, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "linux", - target_os = "netbsd", target_os = "openbsd"))] + target_os = "netbsd", target_os = "openbsd", target_os = "redox"))] /// Symbolic links can be created. POSIX2_SYMLINKS = libc::_PC_2_SYMLINKS, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "redox"))] /// Minimum number of bytes of storage actually allocated for any portion of /// a file. POSIX_ALLOC_SIZE_MIN = libc::_PC_ALLOC_SIZE_MIN, @@ -1749,19 +1761,20 @@ pub enum PathconfVar { /// `POSIX_REC_MIN_XFER_SIZE` and `POSIX_REC_MAX_XFER_SIZE` values. POSIX_REC_INCR_XFER_SIZE = libc::_PC_REC_INCR_XFER_SIZE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "redox"))] /// Maximum recommended file transfer size. POSIX_REC_MAX_XFER_SIZE = libc::_PC_REC_MAX_XFER_SIZE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "redox"))] /// Minimum recommended file transfer size. POSIX_REC_MIN_XFER_SIZE = libc::_PC_REC_MIN_XFER_SIZE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "redox"))] /// Recommended file transfer buffer alignment. POSIX_REC_XFER_ALIGN = libc::_PC_REC_XFER_ALIGN, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "redox"))] /// Maximum number of bytes in a symbolic link. SYMLINK_MAX = libc::_PC_SYMLINK_MAX, /// The use of `chown` and `fchown` is restricted to a process with @@ -1775,17 +1788,18 @@ pub enum PathconfVar { /// disable terminal special character handling. _POSIX_VDISABLE = libc::_PC_VDISABLE, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "redox"))] /// Asynchronous input or output operations may be performed for the /// associated file. _POSIX_ASYNC_IO = libc::_PC_ASYNC_IO, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "openbsd"))] + target_os = "linux", target_os = "openbsd", target_os = "redox"))] /// Prioritized input or output operations may be performed for the /// associated file. _POSIX_PRIO_IO = libc::_PC_PRIO_IO, #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", - target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] + target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "redox"))] /// Synchronized input or output operations may be performed for the /// associated file. _POSIX_SYNC_IO = libc::_PC_SYNC_IO, @@ -1886,9 +1900,11 @@ pub fn pathconf(path: &P, var: PathconfVar) -> Result. + #[cfg(not(target_os = "redox"))] LINE_MAX = libc::_SC_LINE_MAX, /// Maximum length of a login name. LOGIN_NAME_MAX = libc::_SC_LOGIN_NAME_MAX, /// Maximum number of simultaneous supplementary group IDs per process. NGROUPS_MAX = libc::_SC_NGROUPS_MAX, /// Initial size of `getgrgid_r` and `getgrnam_r` data buffers + #[cfg(not(target_os = "redox"))] GETGR_R_SIZE_MAX = libc::_SC_GETGR_R_SIZE_MAX, /// Initial size of `getpwuid_r` and `getpwnam_r` data buffers + #[cfg(not(target_os = "redox"))] GETPW_R_SIZE_MAX = libc::_SC_GETPW_R_SIZE_MAX, /// The maximum number of open message queue descriptors a process may hold. + #[cfg(not(target_os = "redox"))] MQ_OPEN_MAX = libc::_SC_MQ_OPEN_MAX, /// The maximum number of message priorities supported by the implementation. + #[cfg(not(target_os = "redox"))] MQ_PRIO_MAX = libc::_SC_MQ_PRIO_MAX, /// A value one greater than the maximum value that the system may assign to /// a newly-created file descriptor. @@ -1958,6 +1988,7 @@ pub enum SysconfVar { /// The implementation supports barriers. _POSIX_BARRIERS = libc::_SC_BARRIERS, /// The implementation supports asynchronous input and output. + #[cfg(not(target_os = "redox"))] _POSIX_ASYNCHRONOUS_IO = libc::_SC_ASYNCHRONOUS_IO, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", @@ -1970,24 +2001,32 @@ pub enum SysconfVar { /// The implementation supports the Process CPU-Time Clocks option. _POSIX_CPUTIME = libc::_SC_CPUTIME, /// The implementation supports the File Synchronization option. + #[cfg(not(target_os = "redox"))] _POSIX_FSYNC = libc::_SC_FSYNC, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))] /// The implementation supports the IPv6 option. _POSIX_IPV6 = libc::_SC_IPV6, /// The implementation supports job control. + #[cfg(not(target_os = "redox"))] _POSIX_JOB_CONTROL = libc::_SC_JOB_CONTROL, /// The implementation supports memory mapped Files. + #[cfg(not(target_os = "redox"))] _POSIX_MAPPED_FILES = libc::_SC_MAPPED_FILES, /// The implementation supports the Process Memory Locking option. + #[cfg(not(target_os = "redox"))] _POSIX_MEMLOCK = libc::_SC_MEMLOCK, /// The implementation supports the Range Memory Locking option. + #[cfg(not(target_os = "redox"))] _POSIX_MEMLOCK_RANGE = libc::_SC_MEMLOCK_RANGE, /// The implementation supports memory protection. + #[cfg(not(target_os = "redox"))] _POSIX_MEMORY_PROTECTION = libc::_SC_MEMORY_PROTECTION, /// The implementation supports the Message Passing option. + #[cfg(not(target_os = "redox"))] _POSIX_MESSAGE_PASSING = libc::_SC_MESSAGE_PASSING, /// The implementation supports the Monotonic Clock option. + #[cfg(not(target_os = "redox"))] _POSIX_MONOTONIC_CLOCK = libc::_SC_MONOTONIC_CLOCK, #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", @@ -1995,6 +2034,7 @@ pub enum SysconfVar { /// The implementation supports the Prioritized Input and Output option. _POSIX_PRIORITIZED_IO = libc::_SC_PRIORITIZED_IO, /// The implementation supports the Process Scheduling option. + #[cfg(not(target_os = "redox"))] _POSIX_PRIORITY_SCHEDULING = libc::_SC_PRIORITY_SCHEDULING, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))] @@ -2016,10 +2056,13 @@ pub enum SysconfVar { /// The implementation supports the Regular Expression Handling option. _POSIX_REGEXP = libc::_SC_REGEXP, /// Each process has a saved set-user-ID and a saved set-group-ID. + #[cfg(not(target_os = "redox"))] _POSIX_SAVED_IDS = libc::_SC_SAVED_IDS, /// The implementation supports semaphores. + #[cfg(not(target_os = "redox"))] _POSIX_SEMAPHORES = libc::_SC_SEMAPHORES, /// The implementation supports the Shared Memory Objects option. + #[cfg(not(target_os = "redox"))] _POSIX_SHARED_MEMORY_OBJECTS = libc::_SC_SHARED_MEMORY_OBJECTS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", @@ -2044,10 +2087,13 @@ pub enum SysconfVar { target_os="openbsd"))] _POSIX_SS_REPL_MAX = libc::_SC_SS_REPL_MAX, /// The implementation supports the Synchronized Input and Output option. + #[cfg(not(target_os = "redox"))] _POSIX_SYNCHRONIZED_IO = libc::_SC_SYNCHRONIZED_IO, /// The implementation supports the Thread Stack Address Attribute option. + #[cfg(not(target_os = "redox"))] _POSIX_THREAD_ATTR_STACKADDR = libc::_SC_THREAD_ATTR_STACKADDR, /// The implementation supports the Thread Stack Size Attribute option. + #[cfg(not(target_os = "redox"))] _POSIX_THREAD_ATTR_STACKSIZE = libc::_SC_THREAD_ATTR_STACKSIZE, #[cfg(any(target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", target_os="openbsd"))] @@ -2055,10 +2101,13 @@ pub enum SysconfVar { _POSIX_THREAD_CPUTIME = libc::_SC_THREAD_CPUTIME, /// The implementation supports the Non-Robust Mutex Priority Inheritance /// option. + #[cfg(not(target_os = "redox"))] _POSIX_THREAD_PRIO_INHERIT = libc::_SC_THREAD_PRIO_INHERIT, /// The implementation supports the Non-Robust Mutex Priority Protection option. + #[cfg(not(target_os = "redox"))] _POSIX_THREAD_PRIO_PROTECT = libc::_SC_THREAD_PRIO_PROTECT, /// The implementation supports the Thread Execution Scheduling option. + #[cfg(not(target_os = "redox"))] _POSIX_THREAD_PRIORITY_SCHEDULING = libc::_SC_THREAD_PRIORITY_SCHEDULING, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", @@ -2073,18 +2122,21 @@ pub enum SysconfVar { /// The implementation supports the Robust Mutex Priority Protection option. _POSIX_THREAD_ROBUST_PRIO_PROTECT = libc::_SC_THREAD_ROBUST_PRIO_PROTECT, /// The implementation supports thread-safe functions. + #[cfg(not(target_os = "redox"))] _POSIX_THREAD_SAFE_FUNCTIONS = libc::_SC_THREAD_SAFE_FUNCTIONS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))] /// The implementation supports the Thread Sporadic Server option. _POSIX_THREAD_SPORADIC_SERVER = libc::_SC_THREAD_SPORADIC_SERVER, /// The implementation supports threads. + #[cfg(not(target_os = "redox"))] _POSIX_THREADS = libc::_SC_THREADS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))] /// The implementation supports timeouts. _POSIX_TIMEOUTS = libc::_SC_TIMEOUTS, /// The implementation supports timers. + #[cfg(not(target_os = "redox"))] _POSIX_TIMERS = libc::_SC_TIMERS, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))] @@ -2149,17 +2201,23 @@ pub enum SysconfVar { /// using at least 64 bits. _POSIX_V6_LPBIG_OFFBIG = libc::_SC_V6_LPBIG_OFFBIG, /// The implementation supports the C-Language Binding option. + #[cfg(not(target_os = "redox"))] _POSIX2_C_BIND = libc::_SC_2_C_BIND, /// The implementation supports the C-Language Development Utilities option. + #[cfg(not(target_os = "redox"))] _POSIX2_C_DEV = libc::_SC_2_C_DEV, /// The implementation supports the Terminal Characteristics option. + #[cfg(not(target_os = "redox"))] _POSIX2_CHAR_TERM = libc::_SC_2_CHAR_TERM, /// The implementation supports the FORTRAN Development Utilities option. + #[cfg(not(target_os = "redox"))] _POSIX2_FORT_DEV = libc::_SC_2_FORT_DEV, /// The implementation supports the FORTRAN Runtime Utilities option. + #[cfg(not(target_os = "redox"))] _POSIX2_FORT_RUN = libc::_SC_2_FORT_RUN, /// The implementation supports the creation of locales by the localedef /// utility. + #[cfg(not(target_os = "redox"))] _POSIX2_LOCALEDEF = libc::_SC_2_LOCALEDEF, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="netbsd", @@ -2193,26 +2251,34 @@ pub enum SysconfVar { /// The implementation supports the Track Batch Job Request option. _POSIX2_PBS_TRACK = libc::_SC_2_PBS_TRACK, /// The implementation supports the Software Development Utilities option. + #[cfg(not(target_os = "redox"))] _POSIX2_SW_DEV = libc::_SC_2_SW_DEV, /// The implementation supports the User Portability Utilities option. + #[cfg(not(target_os = "redox"))] _POSIX2_UPE = libc::_SC_2_UPE, /// Integer value indicating version of the Shell and Utilities volume of /// POSIX.1 to which the implementation conforms. + #[cfg(not(target_os = "redox"))] _POSIX2_VERSION = libc::_SC_2_VERSION, /// The size of a system page in bytes. /// /// POSIX also defines an alias named `PAGESIZE`, but Rust does not allow two /// enum constants to have the same value, so nix omits `PAGESIZE`. PAGE_SIZE = libc::_SC_PAGE_SIZE, + #[cfg(not(target_os = "redox"))] PTHREAD_DESTRUCTOR_ITERATIONS = libc::_SC_THREAD_DESTRUCTOR_ITERATIONS, + #[cfg(not(target_os = "redox"))] PTHREAD_KEYS_MAX = libc::_SC_THREAD_KEYS_MAX, + #[cfg(not(target_os = "redox"))] PTHREAD_STACK_MIN = libc::_SC_THREAD_STACK_MIN, + #[cfg(not(target_os = "redox"))] PTHREAD_THREADS_MAX = libc::_SC_THREAD_THREADS_MAX, RE_DUP_MAX = libc::_SC_RE_DUP_MAX, #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))] RTSIG_MAX = libc::_SC_RTSIG_MAX, + #[cfg(not(target_os = "redox"))] SEM_NSEMS_MAX = libc::_SC_SEM_NSEMS_MAX, #[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", @@ -2227,6 +2293,7 @@ pub enum SysconfVar { target_os="linux", target_os = "macos", target_os="netbsd", target_os="openbsd"))] SYMLOOP_MAX = libc::_SC_SYMLOOP_MAX, + #[cfg(not(target_os = "redox"))] TIMER_MAX = libc::_SC_TIMER_MAX, TTY_NAME_MAX = libc::_SC_TTY_NAME_MAX, TZNAME_MAX = libc::_SC_TZNAME_MAX, @@ -2257,6 +2324,7 @@ pub enum SysconfVar { _XOPEN_REALTIME_THREADS = libc::_SC_XOPEN_REALTIME_THREADS, /// The implementation supports the Issue 4, Version 2 Shared Memory Option /// Group. + #[cfg(not(target_os = "redox"))] _XOPEN_SHM = libc::_SC_XOPEN_SHM, #[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios", target_os="linux", target_os = "macos", target_os="openbsd"))]