summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dir.rs7
-rw-r--r--src/errno.rs241
-rw-r--r--src/fcntl.rs33
-rw-r--r--src/features.rs5
-rw-r--r--src/lib.rs3
-rw-r--r--src/macros.rs1
-rw-r--r--src/sys/mod.rs4
-rw-r--r--src/sys/signal.rs111
-rw-r--r--src/sys/stat.rs4
-rw-r--r--src/sys/statvfs.rs2
-rw-r--r--src/sys/wait.rs9
-rw-r--r--src/unistd.rs100
12 files changed, 462 insertions, 58 deletions
diff --git a/src/dir.rs b/src/dir.rs
index d8c05e96..42731a4e 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()) }
@@ -152,6 +155,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
@@ -166,6 +170,7 @@ impl Entry {
target_os = "l4re",
target_os = "linux",
target_os = "macos",
+ target_os = "redox",
target_os = "solaris")))]
pub fn ino(&self) -> u64 {
u64::from(self.0.d_fileno)
diff --git a/src/errno.rs b/src/errno.rs
index a8a2bf24..730160f2 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()
}
@@ -332,7 +332,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"))]
@@ -393,10 +394,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")]
@@ -412,12 +413,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",
@@ -427,12 +429,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",
@@ -455,22 +459,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",
@@ -510,7 +518,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"))]
@@ -534,19 +543,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"))]
@@ -1957,3 +1970,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 5bdc9dda..661b5ded 100644
--- a/src/fcntl.rs
+++ b/src/fcntl.rs
@@ -2,6 +2,7 @@ use {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::OsString;
@@ -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;
@@ -79,7 +81,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",
@@ -88,7 +91,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"))]
@@ -97,8 +101,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;
@@ -110,7 +116,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.
///
@@ -132,9 +138,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"))]
@@ -257,6 +265,7 @@ pub fn readlinkat<P: ?Sized + NixPath>(dirfd: RawFd, path: &P)
}
/// Computes the raw fd consumed by a function of the form `*at`.
+#[cfg(not(target_os = "redox"))]
pub(crate) fn at_rawfd(fd: Option<RawFd>) -> raw::c_int {
match fd {
None => libc::AT_FDCWD,
@@ -287,6 +296,7 @@ libc_bitflags!(
}
);
+#[cfg(not(target_os = "redox"))]
#[derive(Debug, Eq, Hash, PartialEq)]
pub enum FcntlArg<'a> {
F_DUPFD(RawFd),
@@ -317,6 +327,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
@@ -329,8 +350,11 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
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_OFD_SETLK(flock) => libc::fcntl(fd, libc::F_OFD_SETLK, flock),
@@ -364,6 +388,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 76cdfd3a..827eecac 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 7fd7ecb5..fda06c8f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -57,10 +57,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 5fb49e3b..1d298e6d 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -206,6 +206,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) => {
&(*(ptr::null() as *const $ty)).$field as *const _ as usize
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
index d3c2f92b..98339b0f 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 b746b3d4..ad5cc031 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -14,7 +14,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!{
@@ -58,9 +58,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,
}
}
@@ -103,9 +105,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()),
})
@@ -154,9 +158,11 @@ impl 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",
}
}
@@ -176,6 +182,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,
@@ -241,7 +278,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,
@@ -318,8 +356,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;
@@ -449,6 +492,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))
}
@@ -465,16 +509,31 @@ 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 {
- let mut s = mem::MaybeUninit::<libc::sigaction>::uninit();
- unsafe {
- let p = s.as_mut_ptr();
+ #[cfg(target_os = "redox")]
+ unsafe fn install_sig(p: *mut libc::sigaction, handler: SigHandler) {
+ (*p).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,
+ };
+ }
+
+ #[cfg(not(target_os = "redox"))]
+ unsafe fn install_sig(p: *mut libc::sigaction, handler: SigHandler) {
(*p).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,
};
+ }
+
+ let mut s = mem::MaybeUninit::<libc::sigaction>::uninit();
+ unsafe {
+ let p = s.as_mut_ptr();
+ install_sig(p, handler);
(*p).sa_flags = match handler {
+ #[cfg(not(target_os = "redox"))]
SigHandler::SigAction(_) => (flags | SaFlags::SA_SIGINFO).bits(),
_ => (flags - SaFlags::SA_SIGINFO).bits(),
};
@@ -496,6 +555,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,
@@ -505,6 +565,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.
@@ -590,6 +660,7 @@ pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result<SigHandler>
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| {
@@ -728,7 +799,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;
@@ -944,9 +1015,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 |
@@ -965,9 +1046,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 29582251..5d426844 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<FileStat> {
Ok(unsafe{dst.assume_init()})
}
+#[cfg(not(target_os = "redox"))]
pub fn fstatat<P: ?Sized + NixPath>(dirfd: RawFd, pathname: &P, f: AtFlags) -> Result<FileStat> {
let mut dst = mem::MaybeUninit::uninit();
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<P: ?Sized + NixPath>(
dirfd: Option<RawFd>,
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<P: ?Sized + NixPath>(
dirfd: Option<RawFd>,
path: &P,
diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs
index 26147803..8e8d367c 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)]
@@ -108,6 +109,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 d18c3757..252ef28d 100644
--- a/src/sys/wait.rs
+++ b/src/sys/wait.rs
@@ -15,6 +15,7 @@ libc_bitflags!(
target_os = "haiku",
target_os = "ios",
target_os = "linux",
+ target_os = "redox",
target_os = "macos",
target_os = "netbsd"))]
WEXITED;
@@ -24,6 +25,7 @@ libc_bitflags!(
target_os = "haiku",
target_os = "ios",
target_os = "linux",
+ target_os = "redox",
target_os = "macos",
target_os = "netbsd"))]
WSTOPPED;
@@ -33,16 +35,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 3589cb72..a663e7cd 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -2,14 +2,20 @@
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, PATH_MAX};
use std::{fmt, mem, ptr};
use std::convert::Infallible;
-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 sys::stat::Mode;
@@ -535,6 +541,7 @@ pub fn mkfifoat<P: ?Sized + NixPath>(dirfd: Option<RawFd>, path: &P, mode: Mode)
/// 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<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
path1: &P1,
dirfd: Option<RawFd>,
@@ -674,6 +681,7 @@ pub enum FchownatFlags {
/// # References
///
/// [fchownat(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchownat.html).
+#[cfg(not(target_os = "redox"))]
pub fn fchownat<P: ?Sized + NixPath>(
dirfd: Option<RawFd>,
path: &P,
@@ -866,6 +874,7 @@ pub fn execveat(dirfd: RawFd, pathname: &CStr, args: &[&CStr],
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)
@@ -878,6 +887,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<S: AsRef<OsStr>>(name: S) -> Result<()> {
// Handle some differences in type of the len arg across platforms.
cfg_if! {
@@ -1066,6 +1076,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)> {
@@ -1503,7 +1514,7 @@ pub fn getgroups() -> Result<Vec<Gid>> {
/// # 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",
@@ -1547,7 +1558,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<Vec<Gid>> {
let ngroups_max = match sysconf(SysconfVar::NGROUPS_MAX) {
Ok(Some(n)) => n as c_int,
@@ -1627,7 +1638,7 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
/// # 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"))] {
@@ -1738,6 +1749,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};
@@ -1819,7 +1831,7 @@ pub fn mkstemp<P: ?Sized + NixPath>(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,
@@ -1843,11 +1855,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,
@@ -1857,19 +1869,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
@@ -1883,17 +1896,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,
@@ -1994,9 +2008,11 @@ pub fn pathconf<P: ?Sized + NixPath>(path: &P, var: PathconfVar) -> Result<Optio
pub enum SysconfVar {
/// Maximum number of I/O operations in a single list I/O call supported by
/// the implementation.
+ #[cfg(not(target_os = "redox"))]
AIO_LISTIO_MAX = libc::_SC_AIO_LISTIO_MAX,
/// Maximum number of outstanding asynchronous I/O operations supported by
/// the implementation.
+ #[cfg(not(target_os = "redox"))]
AIO_MAX = libc::_SC_AIO_MAX,
#[cfg(any(target_os="android", target_os="dragonfly", target_os="freebsd",
target_os = "ios", target_os="linux", target_os = "macos",
@@ -2007,14 +2023,19 @@ pub enum SysconfVar {
/// Maximum length of argument to the exec functions including environment data.
ARG_MAX = libc::_SC_ARG_MAX,
/// Maximum number of functions that may be registered with `atexit`.
+ #[cfg(not(target_os = "redox"))]
ATEXIT_MAX = libc::_SC_ATEXIT_MAX,
/// Maximum obase values allowed by the bc utility.
+ #[cfg(not(target_os = "redox"))]
BC_BASE_MAX = libc::_SC_BC_BASE_MAX,
/// Maximum number of elements permitted in an array by the bc utility.
+ #[cfg(not(target_os = "redox"))]
BC_DIM_MAX = libc::_SC_BC_DIM_MAX,
/// Maximum scale value allowed by the bc utility.
+ #[cfg(not(target_os = "redox"))]
BC_SCALE_MAX = libc::_SC_BC_SCALE_MAX,
/// Maximum length of a string constant accepted by the bc utility.
+ #[cfg(not(target_os = "redox"))]
BC_STRING_MAX = libc::_SC_BC_STRING_MAX,
/// Maximum number of simultaneous processes per real user ID.
CHILD_MAX = libc::_SC_CHILD_MAX,
@@ -2022,11 +2043,14 @@ pub enum SysconfVar {
CLK_TCK = libc::_SC_CLK_TCK,
/// Maximum number of weights that can be assigned to an entry of the
/// LC_COLLATE order keyword in the locale definition file
+ #[cfg(not(target_os = "redox"))]
COLL_WEIGHTS_MAX = libc::_SC_COLL_WEIGHTS_MAX,
/// Maximum number of timer expiration overruns.
+ #[cfg(not(target_os = "redox"))]
DELAYTIMER_MAX = libc::_SC_DELAYTIMER_MAX,
/// Maximum number of expressions that can be nested within parentheses by
/// the expr utility.
+ #[cfg(not(target_os = "redox"))]
EXPR_NEST_MAX = libc::_SC_EXPR_NEST_MAX,
#[cfg(any(target_os="dragonfly", target_os="freebsd", target_os = "ios",
target_os="linux", target_os = "macos", target_os="netbsd",
@@ -2036,23 +2060,29 @@ pub enum SysconfVar {
HOST_NAME_MAX = libc::_SC_HOST_NAME_MAX,
/// Maximum number of iovec structures that one process has available for
/// use with `readv` or `writev`.
+ #[cfg(not(target_os = "redox"))]
IOV_MAX = libc::_SC_IOV_MAX,
/// Unless otherwise noted, the maximum length, in bytes, of a utility's
/// input line (either standard input or another file), when the utility is
/// described as processing text files. The length includes room for the
/// trailing <newline>.
+ #[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.
@@ -2067,6 +2097,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",
@@ -2079,24 +2110,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",
@@ -2104,6 +2143,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"))]
@@ -2125,10 +2165,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",
@@ -2153,10 +2196,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"))]
@@ -2164,10 +2210,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",
@@ -2182,18 +2231,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"))]
@@ -2258,17 +2310,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",
@@ -2302,26 +2360,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",
@@ -2336,6 +2402,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,
@@ -2366,6 +2433,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"))]