summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/errno.rs272
-rw-r--r--src/fcntl.rs62
-rw-r--r--src/features.rs2
-rw-r--r--src/sys/ioctl/mod.rs5
-rw-r--r--src/sys/ioctl/platform/netbsd.rs0
-rw-r--r--src/sys/mman.rs4
-rw-r--r--src/sys/signal.rs7
-rw-r--r--src/sys/socket/consts.rs28
-rw-r--r--src/sys/socket/sockopt.rs2
-rw-r--r--src/sys/termios.rs18
-rw-r--r--src/sys/wait.rs3
11 files changed, 351 insertions, 52 deletions
diff --git a/src/errno.rs b/src/errno.rs
index 4d8f0d3c..5ca8ef08 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -28,7 +28,7 @@ unsafe fn errno_location() -> *mut c_int {
__dfly_error()
}
-#[cfg(target_os = "openbsd")]
+#[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
unsafe fn errno_location() -> *mut c_int {
extern { fn __errno() -> *mut c_int; }
__errno()
@@ -280,7 +280,7 @@ 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"))]
+ #[cfg(any(target_os = "linux", target_os = "android", target_os = "netbsd"))]
EOPNOTSUPP => "Operation not supported on transport endpoint",
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -352,22 +352,22 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(target_os = "freebsd")]
ECAPMODE => "Not permitted in capability mode",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
ENEEDAUTH => "Need authenticator",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EOVERFLOW => "Value too large to be stored in data type",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))]
EILSEQ => "Illegal byte sequence",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
ENOATTR => "Attribute not found",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))]
EBADMSG => "Bad message",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "netbsd"))]
EPROTO => "Protocol error",
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
@@ -376,46 +376,46 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
EOWNERDEAD => "Previous owner died",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
ENOTSUP => "Operation not supported",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EPROCLIM => "Too many processes",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EUSERS => "Too many users",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EDQUOT => "Disc quota exceeded",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
ESTALE => "Stale NFS file handle",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EREMOTE => "Too many levels of remote in path",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EBADRPC => "RPC struct is bad",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
ERPCMISMATCH => "RPC version wrong",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EPROGUNAVAIL => "RPC prog. not avail",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EPROGMISMATCH => "Program version wrong",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EPROCUNAVAIL => "Bad procedure for program",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EFTYPE => "Inappropriate file type or format",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
EAUTH => "Authentication error",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
ECANCELED => "Operation canceled",
#[cfg(any(target_os = "macos", target_os = "ios"))]
@@ -436,22 +436,22 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(any(target_os = "macos", target_os = "ios"))]
EBADMACHO => "Malformed Macho file",
- #[cfg(any(target_os = "macos", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
EMULTIHOP => "Reserved",
- #[cfg(any(target_os = "macos", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
ENODATA => "No message available on STREAM",
- #[cfg(any(target_os = "macos", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
ENOLINK => "Reserved",
- #[cfg(any(target_os = "macos", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
ENOSR => "No STREAM resources",
- #[cfg(any(target_os = "macos", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
ENOSTR => "Not a STREAM",
- #[cfg(any(target_os = "macos", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "ios", target_os = "netbsd"))]
ETIME => "STREAM ioctl timeout",
#[cfg(any(target_os = "macos", target_os = "ios"))]
@@ -1655,6 +1655,222 @@ mod consts {
}
}
+#[cfg(target_os = "netbsd")]
+mod consts {
+ #[derive(Copy, Debug, Clone, PartialEq)]
+ pub enum Errno {
+ UnknownErrno = 0,
+ EPERM = 1,
+ ENOENT = 2,
+ ESRCH = 3,
+ EINTR = 4,
+ EIO = 5,
+ ENXIO = 6,
+ E2BIG = 7,
+ ENOEXEC = 8,
+ EBADF = 9,
+ ECHILD = 10,
+ EDEADLK = 11,
+ ENOMEM = 12,
+ EACCES = 13,
+ EFAULT = 14,
+ ENOTBLK = 15,
+ EBUSY = 16,
+ EEXIST = 17,
+ EXDEV = 18,
+ ENODEV = 19,
+ ENOTDIR = 20,
+ EISDIR = 21,
+ EINVAL = 22,
+ ENFILE = 23,
+ EMFILE = 24,
+ ENOTTY = 25,
+ ETXTBSY = 26,
+ EFBIG = 27,
+ ENOSPC = 28,
+ ESPIPE = 29,
+ EROFS = 30,
+ EMLINK = 31,
+ EPIPE = 32,
+ EDOM = 33,
+ ERANGE = 34,
+ EAGAIN = 35,
+ EINPROGRESS = 36,
+ EALREADY = 37,
+ ENOTSOCK = 38,
+ EDESTADDRREQ = 39,
+ EMSGSIZE = 40,
+ EPROTOTYPE = 41,
+ ENOPROTOOPT = 42,
+ EPROTONOSUPPORT = 43,
+ ESOCKTNOSUPPORT = 44,
+ EOPNOTSUPP = 45,
+ EPFNOSUPPORT = 46,
+ EAFNOSUPPORT = 47,
+ EADDRINUSE = 48,
+ EADDRNOTAVAIL = 49,
+ ENETDOWN = 50,
+ ENETUNREACH = 51,
+ ENETRESET = 52,
+ ECONNABORTED = 53,
+ ECONNRESET = 54,
+ ENOBUFS = 55,
+ EISCONN = 56,
+ ENOTCONN = 57,
+ ESHUTDOWN = 58,
+ ETOOMANYREFS = 59,
+ ETIMEDOUT = 60,
+ ECONNREFUSED = 61,
+ ELOOP = 62,
+ ENAMETOOLONG = 63,
+ EHOSTDOWN = 64,
+ EHOSTUNREACH = 65,
+ ENOTEMPTY = 66,
+ EPROCLIM = 67,
+ EUSERS = 68,
+ EDQUOT = 69,
+ ESTALE = 70,
+ EREMOTE = 71,
+ EBADRPC = 72,
+ ERPCMISMATCH = 73,
+ EPROGUNAVAIL = 74,
+ EPROGMISMATCH = 75,
+ EPROCUNAVAIL = 76,
+ ENOLCK = 77,
+ ENOSYS = 78,
+ EFTYPE = 79,
+ EAUTH = 80,
+ ENEEDAUTH = 81,
+ EIDRM = 82,
+ ENOMSG = 83,
+ EOVERFLOW = 84,
+ EILSEQ = 85,
+ ENOTSUP = 86,
+ ECANCELED = 87,
+ EBADMSG = 88,
+ ENODATA = 89,
+ ENOSR = 90,
+ ENOSTR = 91,
+ ETIME = 92,
+ ENOATTR = 93,
+ EMULTIHOP = 94,
+ ENOLINK = 95,
+ EPROTO = 96,
+ }
+
+ impl_errno!(Errno);
+
+ pub const ELAST: Errno = Errno::ENOTSUP;
+ pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
+
+ pub const EL2NSYNC: Errno = Errno::UnknownErrno;
+
+ pub fn from_i32(e: i32) -> Errno {
+ use self::Errno::*;
+
+ match e {
+ 0 => UnknownErrno,
+ 1 => EPERM,
+ 2 => ENOENT,
+ 3 => ESRCH,
+ 4 => EINTR,
+ 5 => EIO,
+ 6 => ENXIO,
+ 7 => E2BIG,
+ 8 => ENOEXEC,
+ 9 => EBADF,
+ 10 => ECHILD,
+ 11 => EDEADLK,
+ 12 => ENOMEM,
+ 13 => EACCES,
+ 14 => EFAULT,
+ 15 => ENOTBLK,
+ 16 => EBUSY,
+ 17 => EEXIST,
+ 18 => EXDEV,
+ 19 => ENODEV,
+ 20 => ENOTDIR,
+ 21 => EISDIR,
+ 22 => EINVAL,
+ 23 => ENFILE,
+ 24 => EMFILE,
+ 25 => ENOTTY,
+ 26 => ETXTBSY,
+ 27 => EFBIG,
+ 28 => ENOSPC,
+ 29 => ESPIPE,
+ 30 => EROFS,
+ 31 => EMLINK,
+ 32 => EPIPE,
+ 33 => EDOM,
+ 34 => ERANGE,
+ 35 => EAGAIN,
+ 36 => EINPROGRESS,
+ 37 => EALREADY,
+ 38 => ENOTSOCK,
+ 39 => EDESTADDRREQ,
+ 40 => EMSGSIZE,
+ 41 => EPROTOTYPE,
+ 42 => ENOPROTOOPT,
+ 43 => EPROTONOSUPPORT,
+ 44 => ESOCKTNOSUPPORT,
+ 45 => EOPNOTSUPP,
+ 46 => EPFNOSUPPORT,
+ 47 => EAFNOSUPPORT,
+ 48 => EADDRINUSE,
+ 49 => EADDRNOTAVAIL,
+ 50 => ENETDOWN,
+ 51 => ENETUNREACH,
+ 52 => ENETRESET,
+ 53 => ECONNABORTED,
+ 54 => ECONNRESET,
+ 55 => ENOBUFS,
+ 56 => EISCONN,
+ 57 => ENOTCONN,
+ 58 => ESHUTDOWN,
+ 59 => ETOOMANYREFS,
+ 60 => ETIMEDOUT,
+ 61 => ECONNREFUSED,
+ 62 => ELOOP,
+ 63 => ENAMETOOLONG,
+ 64 => EHOSTDOWN,
+ 65 => EHOSTUNREACH,
+ 66 => ENOTEMPTY,
+ 67 => EPROCLIM,
+ 68 => EUSERS,
+ 69 => EDQUOT,
+ 70 => ESTALE,
+ 71 => EREMOTE,
+ 72 => EBADRPC,
+ 73 => ERPCMISMATCH,
+ 74 => EPROGUNAVAIL,
+ 75 => EPROGMISMATCH,
+ 76 => EPROCUNAVAIL,
+ 77 => ENOLCK,
+ 78 => ENOSYS,
+ 79 => EFTYPE,
+ 80 => EAUTH,
+ 81 => ENEEDAUTH,
+ 82 => EIDRM,
+ 83 => ENOMSG,
+ 84 => EOVERFLOW,
+ 85 => EILSEQ,
+ 86 => ENOTSUP,
+ 87 => ECANCELED,
+ 88 => EBADMSG,
+ 89 => ENODATA,
+ 90 => ENOSR,
+ 91 => ENOSTR,
+ 92 => ETIME,
+ 93 => ENOATTR,
+ 94 => EMULTIHOP,
+ 95 => ENOLINK,
+ 96 => EPROTO,
+ _ => UnknownErrno,
+ }
+ }
+}
+
#[cfg(test)]
mod test {
diff --git a/src/fcntl.rs b/src/fcntl.rs
index b81ae27e..690872a5 100644
--- a/src/fcntl.rs
+++ b/src/fcntl.rs
@@ -50,7 +50,7 @@ mod ffi {
pub const F_SEAL_WRITE: c_int = 8;
}
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
mod os {
use libc::{c_int, c_short, off_t, pid_t};
@@ -68,17 +68,32 @@ mod ffi {
}
pub const F_DUPFD: c_int = 0;
- #[cfg(not(target_os = "dragonfly"))]
+ #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
pub const F_DUPFD_CLOEXEC: c_int = 67;
#[cfg(target_os = "dragonfly")]
pub const F_DUPFD_CLOEXEC: c_int = 17;
+ #[cfg(target_os = "netbsd")]
+ pub const F_DUPFD_CLOEXEC: c_int = 12;
pub const F_GETFD: c_int = 1;
pub const F_SETFD: c_int = 2;
pub const F_GETFL: c_int = 3;
pub const F_SETFL: c_int = 4;
+ #[cfg(target_os = "netbsd")]
+ pub const F_GETOWN: c_int = 5;
+ #[cfg(target_os = "netbsd")]
+ pub const F_SETOWN: c_int = 6;
+ pub const F_GETLK: c_int = 7;
pub const F_SETLK: c_int = 8;
pub const F_SETLKW: c_int = 9;
- pub const F_GETLK: c_int = 7;
+
+ #[cfg(target_os = "netbsd")]
+ pub const F_CLOSEM: c_int = 10;
+ #[cfg(target_os = "netbsd")]
+ pub const F_MAXFD: c_int = 11;
+ #[cfg(target_os = "netbsd")]
+ pub const F_GETNOSIGPIPE: c_int = 13;
+ #[cfg(target_os = "netbsd")]
+ pub const F_SETNOSIGPIPE: c_int = 14;
}
}
@@ -296,6 +311,47 @@ mod consts {
);
}
+#[cfg(target_os = "netbsd")]
+mod consts {
+ use libc::c_int;
+
+ bitflags!(
+ flags OFlag: c_int {
+ const O_ACCMODE = 0x0000003,
+ const O_RDONLY = 0x0000000,
+ const O_WRONLY = 0x0000001,
+ const O_RDWR = 0x0000002,
+ const O_NONBLOCK = 0x0000004,
+ const O_APPEND = 0x0000008,
+ const O_SHLOCK = 0x0000010,
+ const O_EXLOCK = 0x0000020,
+ const O_ASYNC = 0x0000040,
+ const O_SYNC = 0x0000080,
+ const O_NOFOLLOW = 0x0000100,
+ const O_CREAT = 0x0000200,
+ const O_TRUNC = 0x0000400,
+ const O_EXCL = 0x0000800,
+ const O_NOCTTY = 0x0008000,
+ const O_DSYNC = 0x0010000,
+ const O_RSYNC = 0x0020000,
+ const O_ALT_IO = 0x0040000,
+ const O_DIRECT = 0x0080000,
+ const O_NOSIGPIPE = 0x0100000,
+ const O_DIRECTORY = 0x0200000,
+ const O_CLOEXEC = 0x0400000,
+ const O_SEARCH = 0x0800000,
+ const O_FSYNC = O_SYNC.bits,
+ const O_NDELAY = O_NONBLOCK.bits,
+ }
+ );
+
+ bitflags!(
+ flags FdFlag: c_int {
+ const FD_CLOEXEC = 1
+ }
+ );
+}
+
#[cfg(target_os = "dragonfly")]
mod consts {
use libc::c_int;
diff --git a/src/features.rs b/src/features.rs
index f6a445f6..e6c5612d 100644
--- a/src/features.rs
+++ b/src/features.rs
@@ -92,7 +92,7 @@ mod os {
}
}
-#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
+#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
mod os {
pub fn socket_atomic_cloexec() -> bool {
false
diff --git a/src/sys/ioctl/mod.rs b/src/sys/ioctl/mod.rs
index 872da39f..4d4d1072 100644
--- a/src/sys/ioctl/mod.rs
+++ b/src/sys/ioctl/mod.rs
@@ -119,6 +119,11 @@ mod platform;
#[macro_use]
mod platform;
+#[cfg(target_os = "netbsd")]
+#[path = "platform/netbsd.rs"]
+#[macro_use]
+mod platform;
+
#[cfg(target_os = "openbsd")]
#[path = "platform/openbsd.rs"]
#[macro_use]
diff --git a/src/sys/ioctl/platform/netbsd.rs b/src/sys/ioctl/platform/netbsd.rs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/sys/ioctl/platform/netbsd.rs
diff --git a/src/sys/mman.rs b/src/sys/mman.rs
index ad29a015..0522ab52 100644
--- a/src/sys/mman.rs
+++ b/src/sys/mman.rs
@@ -113,7 +113,7 @@ mod consts {
pub const MAP_FAILED: isize = -1;
}
-#[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
+#[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd"))]
mod consts {
use libc::c_int;
@@ -127,6 +127,8 @@ mod consts {
pub const MAP_NORESERVE: MmapFlag = 0x00040;
pub const MAP_HASSEMAPHORE: MmapFlag = 0x00200;
pub const MAP_STACK: MmapFlag = 0x00400;
+ #[cfg(target_os = "netbsd")]
+ pub const MAP_WIRED: MmapFlag = 0x00800;
pub const MAP_NOSYNC: MmapFlag = 0x00800;
pub const MAP_FILE: MmapFlag = 0x00000;
pub const MAP_ANON: MmapFlag = 0x01000;
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index a01102f0..72cd17df 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -220,7 +220,8 @@ pub mod signal {
target_os = "ios",
target_os = "freebsd",
target_os = "openbsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "netbsd"))]
pub mod signal {
use libc;
@@ -273,7 +274,7 @@ pub mod signal {
pub struct sigset_t {
bits: [u32; 4],
}
- #[cfg(target_os = "dragonfly")]
+ #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct sigset_t {
@@ -323,7 +324,7 @@ pub mod signal {
pub sa_mask: sigset_t,
}
- #[cfg(target_os = "openbsd")]
+ #[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
#[repr(C)]
pub struct sigaction {
pub sa_handler: extern fn(libc::c_int),
diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs
index 35b07165..22bd02a2 100644
--- a/src/sys/socket/consts.rs
+++ b/src/sys/socket/consts.rs
@@ -1,9 +1,5 @@
-use libc::{self, c_int};
pub use self::os::*;
-pub const IPV6_ADD_MEMBERSHIP: c_int = libc::IPV6_ADD_MEMBERSHIP;
-pub const IPV6_DROP_MEMBERSHIP: c_int = libc::IPV6_DROP_MEMBERSHIP;
-
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use libc::{self, c_int, uint8_t};
@@ -77,6 +73,9 @@ mod os {
pub const IP_ADD_MEMBERSHIP: c_int = 35;
pub const IP_DROP_MEMBERSHIP: c_int = 36;
+ pub const IPV6_ADD_MEMBERSHIP: c_int = libc::IPV6_ADD_MEMBERSHIP;
+ pub const IPV6_DROP_MEMBERSHIP: c_int = libc::IPV6_DROP_MEMBERSHIP;
+
pub type InAddrT = u32;
// Declarations of special addresses
@@ -104,18 +103,20 @@ mod os {
}
// Not all of these constants exist on freebsd
-#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd", target_os = "netbsd"))]
mod os {
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd"))]
use libc::{self, c_int, uint8_t};
- #[cfg(any(target_os = "openbsd"))]
+ #[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
use libc::{c_int, uint8_t};
pub const AF_UNIX: c_int = 1;
pub const AF_LOCAL: c_int = AF_UNIX;
pub const AF_INET: c_int = 2;
+ #[cfg(target_os = "netbsd")]
+ pub const AF_INET6: c_int = 24;
#[cfg(target_os = "openbsd")]
pub const AF_INET6: c_int = 26;
#[cfg(target_os = "freebsd")]
@@ -138,7 +139,10 @@ mod os {
pub const SO_ACCEPTCONN: c_int = 0x0002;
pub const SO_BROADCAST: c_int = 0x0020;
pub const SO_DEBUG: c_int = 0x0001;
+ #[cfg(not(target_os = "netbsd"))]
pub const SO_DONTTRUNC: c_int = 0x2000;
+ #[cfg(target_os = "netbsd")]
+ pub const SO_USELOOPBACK: c_int = 0x0040;
pub const SO_ERROR: c_int = 0x1007;
pub const SO_DONTROUTE: c_int = 0x0010;
pub const SO_KEEPALIVE: c_int = 0x0008;
@@ -166,9 +170,14 @@ mod os {
pub const SO_REUSEPORT: c_int = 0x0200;
pub const SO_REUSESHAREUID: c_int = 0x1025;
pub const SO_SNDBUF: c_int = 0x1001;
+ #[cfg(not(target_os = "netbsd"))]
pub const SO_TIMESTAMP: c_int = 0x0400;
+ #[cfg(not(target_os = "netbsd"))]
pub const SO_TIMESTAMP_MONOTONIC: c_int = 0x0800;
+ #[cfg(target_os = "netbsd")]
+ pub const SO_TIMESTAMP: c_int = 0x2000;
pub const SO_TYPE: c_int = 0x1008;
+ #[cfg(not(target_os = "netbsd"))]
pub const SO_WANTMORE: c_int = 0x4000;
pub const SO_WANTOOBFLAG: c_int = 0x8000;
#[allow(overflowing_literals)]
@@ -182,6 +191,8 @@ mod os {
pub const TCP_KEEPALIVE: c_int = libc::TCP_KEEPALIVE;
#[cfg(target_os = "freebsd")]
pub const TCP_KEEPIDLE: c_int = libc::TCP_KEEPIDLE;
+ #[cfg(target_os = "netbsd")]
+ pub const TCP_KEEPIDLE: c_int = 3;
// Socket options for the IP layer of the socket
pub const IP_MULTICAST_IF: c_int = 9;
@@ -193,6 +204,11 @@ mod os {
pub const IP_ADD_MEMBERSHIP: c_int = 12;
pub const IP_DROP_MEMBERSHIP: c_int = 13;
+ #[cfg(not(target_os = "netbsd"))]
+ pub const IPV6_ADD_MEMBERSHIP: c_int = libc::IPV6_ADD_MEMBERSHIP;
+ #[cfg(not(target_os = "netbsd"))]
+ pub const IPV6_DROP_MEMBERSHIP: c_int = libc::IPV6_DROP_MEMBERSHIP;
+
pub type InAddrT = u32;
// Declarations of special addresses
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index 4c7354ab..ede9d408 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -121,7 +121,9 @@ sockopt_impl!(Both, TcpNoDelay, consts::IPPROTO_TCP, consts::TCP_NODELAY, bool);
sockopt_impl!(Both, Linger, consts::SOL_SOCKET, consts::SO_LINGER, super::linger);
sockopt_impl!(SetOnly, IpAddMembership, consts::IPPROTO_IP, consts::IP_ADD_MEMBERSHIP, super::ip_mreq);
sockopt_impl!(SetOnly, IpDropMembership, consts::IPPROTO_IP, consts::IP_DROP_MEMBERSHIP, super::ip_mreq);
+#[cfg(not(target_os = "netbsd"))]
sockopt_impl!(SetOnly, Ipv6AddMembership, consts::IPPROTO_IPV6, consts::IPV6_ADD_MEMBERSHIP, super::ipv6_mreq);
+#[cfg(not(target_os = "netbsd"))]
sockopt_impl!(SetOnly, Ipv6DropMembership, consts::IPPROTO_IPV6, consts::IPV6_DROP_MEMBERSHIP, super::ipv6_mreq);
sockopt_impl!(Both, IpMulticastTtl, consts::IPPROTO_IP, consts::IP_MULTICAST_TTL, u8);
sockopt_impl!(Both, IpMulticastLoop, consts::IPPROTO_IP, consts::IP_MULTICAST_LOOP, bool);
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 1ecac547..4e6b2e51 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -12,7 +12,7 @@ pub use self::ffi::consts::FlowArg::*;
mod ffi {
pub use self::consts::*;
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "linux"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd", target_os = "linux"))]
mod non_android {
use super::consts::*;
use libc::c_int;
@@ -36,7 +36,7 @@ mod ffi {
}
}
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "linux"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd", target_os = "linux"))]
pub use self::non_android::*;
// On Android before 5.0, Bionic directly inline these to ioctl() calls.
@@ -95,23 +95,23 @@ mod ffi {
pub use self::android::*;
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd"))]
pub mod consts {
- #[cfg(not(target_os = "dragonfly"))]
+ #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
use libc::{c_int, c_ulong, c_uchar};
- #[cfg(target_os = "dragonfly")]
+ #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
use libc::{c_int, c_uint, c_uchar};
- #[cfg(not(target_os = "dragonfly"))]
+ #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
pub type tcflag_t = c_ulong;
- #[cfg(target_os = "dragonfly")]
+ #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
pub type tcflag_t = c_uint;
pub type cc_t = c_uchar;
- #[cfg(not(target_os = "dragonfly"))]
+ #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
pub type speed_t = c_ulong;
- #[cfg(target_os = "dragonfly")]
+ #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
pub type speed_t = c_uint;
#[repr(C)]
diff --git a/src/sys/wait.rs b/src/sys/wait.rs
index 4a0f8b7e..59f7f5c4 100644
--- a/src/sys/wait.rs
+++ b/src/sys/wait.rs
@@ -112,7 +112,8 @@ mod status {
#[cfg(any(target_os = "freebsd",
target_os = "openbsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "netbsd"))]
mod status {
use sys::signal;