summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Neumann <mneumann@ntecs.de>2015-09-09 20:16:42 +0200
committerMichael Neumann <mneumann@ntecs.de>2015-09-09 20:16:42 +0200
commitf37e45628e44d86c16a6f02b38ea0a9d68e8b3d4 (patch)
tree3757e147ff4e9b4d30f493e63dec27e2eeebd6a7
parentfad667e4e2c72889b55bcc7a21d87fa72218e101 (diff)
downloadnix-f37e45628e44d86c16a6f02b38ea0a9d68e8b3d4.zip
Add/Fix support for DragonFly BSD
-rw-r--r--nix-test/src/const.c28
-rw-r--r--src/errno.rs307
-rw-r--r--src/fcntl.rs40
-rw-r--r--src/features.rs2
-rw-r--r--src/sys/event.rs69
-rw-r--r--src/sys/mman.rs12
-rw-r--r--src/sys/mod.rs4
-rw-r--r--src/sys/signal.rs21
-rw-r--r--src/sys/socket/consts.rs75
-rw-r--r--src/sys/termios.rs18
10 files changed, 542 insertions, 34 deletions
diff --git a/nix-test/src/const.c b/nix-test/src/const.c
index a09fc6d5..a0a6a116 100644
--- a/nix-test/src/const.c
+++ b/nix-test/src/const.c
@@ -186,6 +186,29 @@ get_int_const(const char* err) {
GET_CONST(ECANCELED);
#endif
+#if defined(__DragonFly__)
+ GET_CONST(ENEEDAUTH);
+ GET_CONST(EOVERFLOW);
+ GET_CONST(EILSEQ);
+ GET_CONST(ENOATTR);
+ GET_CONST(EBADMSG);
+ GET_CONST(EPROTO);
+ GET_CONST(ENOTSUP);
+ GET_CONST(EPROCLIM);
+ GET_CONST(EUSERS);
+ GET_CONST(EDQUOT);
+ GET_CONST(ESTALE);
+ GET_CONST(EREMOTE);
+ GET_CONST(EBADRPC);
+ GET_CONST(ERPCMISMATCH);
+ GET_CONST(EPROGUNAVAIL);
+ GET_CONST(EPROGMISMATCH);
+ GET_CONST(EPROCUNAVAIL);
+ GET_CONST(EFTYPE);
+ GET_CONST(EAUTH);
+ GET_CONST(ECANCELED);
+#endif
+
#ifdef DARWIN
GET_CONST(EPWROFF);
GET_CONST(EDEVERR);
@@ -204,10 +227,13 @@ get_int_const(const char* err) {
GET_CONST(EQFULL);
#endif
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__DragonFly__)
GET_CONST(EDOOFUS);
GET_CONST(EMULTIHOP);
GET_CONST(ENOLINK);
+#endif
+
+#ifdef __FreeBSD__
GET_CONST(ENOTCAPABLE);
GET_CONST(ECAPMODE);
#endif
diff --git a/src/errno.rs b/src/errno.rs
index 26281cdf..4d8f0d3c 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -304,7 +304,7 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(any(target_os = "linux", target_os = "android"))]
EDQUOT => "Quota exceeded",
- #[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
+ #[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "dragonfly"))]
ENOMEDIUM => "No medium found",
#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
@@ -337,13 +337,13 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(target_os = "linux")]
EHWPOISON => "Memory page has hardware error",
- #[cfg(target_os = "freebsd")]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
EDOOFUS => "Programming error",
- #[cfg(target_os = "freebsd")]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
EMULTIHOP => "Multihop attempted",
- #[cfg(target_os = "freebsd")]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
ENOLINK => "Link has been severed",
#[cfg(target_os = "freebsd")]
@@ -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 = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
ENEEDAUTH => "Need authenticator",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EOVERFLOW => "Value too large to be stored in data type",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios"))]
EILSEQ => "Illegal byte sequence",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
ENOATTR => "Attribute not found",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios"))]
EBADMSG => "Bad message",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios"))]
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 = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
ENOTSUP => "Operation not supported",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EPROCLIM => "Too many processes",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EUSERS => "Too many users",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EDQUOT => "Disc quota exceeded",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
ESTALE => "Stale NFS file handle",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EREMOTE => "Too many levels of remote in path",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EBADRPC => "RPC struct is bad",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
ERPCMISMATCH => "RPC version wrong",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EPROGUNAVAIL => "RPC prog. not avail",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EPROGMISMATCH => "Program version wrong",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EPROCUNAVAIL => "Bad procedure for program",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EFTYPE => "Inappropriate file type or format",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
EAUTH => "Authentication error",
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
ECANCELED => "Operation canceled",
#[cfg(any(target_os = "macos", target_os = "ios"))]
@@ -468,6 +468,12 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(target_os = "openbsd")]
EIPSEC => "IPsec processing failure",
+
+ #[cfg(target_os = "dragonfly")]
+ EUNUSED94 | EUNUSED95 | EUNUSED96 | EUNUSED97 | EUNUSED98 => "Unused",
+
+ #[cfg(target_os = "dragonfly")]
+ EASYNC => "Async",
}
}
@@ -1217,6 +1223,232 @@ mod consts {
}
+#[cfg(target_os = "dragonfly")]
+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,
+ ENOTSUP = 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,
+ ECANCELED = 85,
+ EILSEQ = 86,
+ ENOATTR = 87,
+ EDOOFUS = 88,
+ EBADMSG = 89,
+ EMULTIHOP = 90,
+ ENOLINK = 91,
+ EPROTO = 92,
+
+ ENOMEDIUM = 93,
+ EUNUSED94 = 94,
+ EUNUSED95 = 95,
+ EUNUSED96 = 96,
+ EUNUSED97 = 97,
+ EUNUSED98 = 98,
+ EASYNC = 99,
+ }
+
+ impl_errno!(Errno);
+
+ pub const ELAST: Errno = Errno::EASYNC;
+ pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
+ pub const EDEADLOCK: Errno = Errno::EDEADLK;
+ pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
+
+ 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 => ENOTSUP,
+ 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 => ECANCELED,
+ 86 => EILSEQ,
+ 87 => ENOATTR,
+ 88 => EDOOFUS,
+ 89 => EBADMSG,
+ 90 => EMULTIHOP,
+ 91 => ENOLINK,
+ 92 => EPROTO,
+ 93 => ENOMEDIUM,
+ 94 => EUNUSED94,
+ 95 => EUNUSED95,
+ 96 => EUNUSED96,
+ 97 => EUNUSED97,
+ 98 => EUNUSED98,
+ 99 => EASYNC,
+ _ => UnknownErrno,
+ }
+ }
+}
+
+
#[cfg(target_os = "openbsd")]
mod consts {
#[derive(Copy, Debug, Clone, PartialEq)]
@@ -1618,6 +1850,33 @@ mod test {
}
#[test]
+ #[cfg(target_os = "dragonfly")]
+ pub fn test_dragonfly_errnos() {
+ check_errno!(
+ EDOOFUS,
+ EMULTIHOP,
+ ENOLINK,
+ ENEEDAUTH,
+ EOVERFLOW,
+ EILSEQ,
+ ENOATTR,
+ EBADMSG,
+ EPROTO,
+ ENOTSUP,
+ EPROCLIM,
+ EUSERS,
+ EDQUOT,
+ ESTALE,
+ EREMOTE,
+ EBADRPC,
+ ERPCMISMATCH,
+ EPROGUNAVAIL,
+ EPROGMISMATCH,
+ EPROCUNAVAIL,
+ EAUTH);
+ }
+
+ #[test]
#[cfg(target_os = "openbsd")]
pub fn test_openbsd_errnos() {
check_errno!(
diff --git a/src/fcntl.rs b/src/fcntl.rs
index 6a0fdf96..b81ae27e 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 = "ios", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
mod os {
use libc::{c_int, c_short, off_t, pid_t};
@@ -68,7 +68,10 @@ mod ffi {
}
pub const F_DUPFD: c_int = 0;
+ #[cfg(not(target_os = "dragonfly"))]
pub const F_DUPFD_CLOEXEC: c_int = 67;
+ #[cfg(target_os = "dragonfly")]
+ pub const F_DUPFD_CLOEXEC: c_int = 17;
pub const F_GETFD: c_int = 1;
pub const F_SETFD: c_int = 2;
pub const F_GETFL: c_int = 3;
@@ -292,3 +295,38 @@ mod consts {
}
);
}
+
+#[cfg(target_os = "dragonfly")]
+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_CREAT = 0x0000200,
+ const O_EXCL = 0x0000800,
+ const O_NOCTTY = 0x0008000,
+ const O_TRUNC = 0x0000400,
+ const O_APPEND = 0x0000008,
+ const O_NONBLOCK = 0x0000004,
+ const O_DIRECTORY = 0x8000000, // different from FreeBSD!
+ const O_NOFOLLOW = 0x0000100,
+ const O_CLOEXEC = 0x0020000, // different from FreeBSD!
+ const O_SYNC = 0x0000080,
+ const O_NDELAY = O_NONBLOCK.bits,
+ const O_FSYNC = O_SYNC.bits,
+ const O_SHLOCK = 0x0000010, // different from FreeBSD!
+ const O_EXLOCK = 0x0000020,
+ const O_DIRECT = 0x0010000,
+ }
+ );
+
+ bitflags!(
+ flags FdFlag: c_int {
+ const FD_CLOEXEC = 1
+ }
+ );
+}
diff --git a/src/features.rs b/src/features.rs
index f4a1f4e3..f6a445f6 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 = "ios", target_os = "openbsd"))]
+#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "ios", target_os = "openbsd"))]
mod os {
pub fn socket_atomic_cloexec() -> bool {
false
diff --git a/src/sys/event.rs b/src/sys/event.rs
index e4297c04..23d8c679 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -38,6 +38,7 @@ mod ffi {
}
}
+#[cfg(not(target_os = "dragonfly"))]
#[repr(i16)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EventFilter {
@@ -56,6 +57,22 @@ pub enum EventFilter {
EVFILT_SYSCOUNT = 13
}
+#[cfg(target_os = "dragonfly")]
+#[repr(i16)] // u_short
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum EventFilter {
+ EVFILT_READ = -1,
+ EVFILT_WRITE = -2,
+ EVFILT_AIO = -3,
+ EVFILT_VNODE = -4,
+ EVFILT_PROC = -5,
+ EVFILT_SIGNAL = -6,
+ EVFILT_TIMER = -7,
+ EVFILT_EXCEPT = -8,
+ EVFILT_USER = -9,
+}
+
+#[cfg(not(target_os = "dragonfly"))]
bitflags!(
flags EventFlag: u16 {
const EV_ADD = 0x0001,
@@ -74,6 +91,25 @@ bitflags!(
}
);
+#[cfg(target_os = "dragonfly")]
+bitflags!(
+ flags EventFlag: u16 {
+ const EV_ADD = 0x0001,
+ const EV_DELETE = 0x0002,
+ const EV_ENABLE = 0x0004,
+ const EV_DISABLE = 0x0008,
+ const EV_RECEIPT = 0x0040,
+ const EV_ONESHOT = 0x0010,
+ const EV_CLEAR = 0x0020,
+ const EV_SYSFLAGS = 0xF000,
+ const EV_NODATA = 0x1000,
+ const EV_FLAG1 = 0x2000,
+ const EV_EOF = 0x8000,
+ const EV_ERROR = 0x4000
+ }
+);
+
+#[cfg(not(target_os = "dragonfly"))]
bitflags!(
flags FilterFlag: u32 {
const NOTE_TRIGGER = 0x01000000,
@@ -121,7 +157,40 @@ bitflags!(
}
);
+#[cfg(target_os = "dragonfly")]
+bitflags!(
+ flags FilterFlag: u32 {
+ const NOTE_TRIGGER = 0x01000000,
+ const NOTE_FFNOP = 0x00000000,
+ const NOTE_FFAND = 0x40000000,
+ const NOTE_FFOR = 0x80000000,
+ const NOTE_FFCOPY = 0xc0000000,
+ const NOTE_FFCTRLMASK = 0xc0000000,
+ const NOTE_FFLAGSMASK = 0x00ffffff,
+ const NOTE_LOWAT = 0x00000001,
+ const NOTE_DELETE = 0x00000001,
+ const NOTE_WRITE = 0x00000002,
+ const NOTE_EXTEND = 0x00000004,
+ const NOTE_ATTRIB = 0x00000008,
+ const NOTE_LINK = 0x00000010,
+ const NOTE_RENAME = 0x00000020,
+ const NOTE_REVOKE = 0x00000040,
+ const NOTE_EXIT = 0x80000000,
+ const NOTE_FORK = 0x40000000,
+ const NOTE_EXEC = 0x20000000,
+ const NOTE_SIGNAL = 0x08000000,
+ const NOTE_PDATAMASK = 0x000fffff,
+ const NOTE_PCTRLMASK = 0xf0000000, // NOTE: FreeBSD uses 0xfff00000,
+ const NOTE_TRACK = 0x00000001,
+ const NOTE_TRACKERR = 0x00000002,
+ const NOTE_CHILD = 0x00000004
+ }
+);
+
+#[cfg(not(target_os = "dragonfly"))]
pub const EV_POLL: EventFlag = EV_FLAG0;
+
+#[cfg(not(target_os = "dragonfly"))]
pub const EV_OOBAND: EventFlag = EV_FLAG1;
pub fn kqueue() -> Result<RawFd> {
diff --git a/src/sys/mman.rs b/src/sys/mman.rs
index 54f256b2..ad29a015 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 = "openbsd"))]
+#[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
mod consts {
use libc::c_int;
@@ -150,14 +150,24 @@ mod consts {
pub const MADV_AUTOSYNC : MmapAdvise = 7; /* refert to default flushing strategy */
pub const MADV_NOCORE : MmapAdvise = 8; /* do not include these pages in a core file */
pub const MADV_CORE : MmapAdvise = 9; /* revert to including pages in a core file */
+ #[cfg(not(target_os = "dragonfly"))]
pub const MADV_PROTECT : MmapAdvise = 10; /* protect process from pageout kill */
+ #[cfg(target_os = "dragonfly")]
+ pub const MADV_INVAL : MmapAdvise = 10; /* virt page tables have changed, inval pmap */
+ #[cfg(target_os = "dragonfly")]
+ pub const MADV_SETMAP : MmapAdvise = 11; /* set page table directory page for map */
pub type MmapSync = c_int;
pub const MS_ASYNC : MmapSync = 0x0001; /* [MF|SIO] return immediately */
pub const MS_INVALIDATE : MmapSync = 0x0002; /* [MF|SIO] invalidate all cached data */
+ #[cfg(not(target_os = "dragonfly"))]
pub const MS_SYNC : MmapSync = 0x0010; /* [MF|SIO] msync synchronously */
+ #[cfg(target_os = "dragonfly")]
+ pub const MS_SYNC : MmapSync = 0x0000; /* [MF|SIO] msync synchronously */
+ #[cfg(not(target_os = "dragonfly"))]
pub const MS_KILLPAGES : MmapSync = 0x0004; /* invalidate pages, leave mapped */
+ #[cfg(not(target_os = "dragonfly"))]
pub const MS_DEACTIVATE : MmapSync = 0x0008; /* deactivate pages, leave mapped */
pub const MAP_FAILED: isize = -1;
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
index 3df06c44..235449a0 100644
--- a/src/sys/mod.rs
+++ b/src/sys/mod.rs
@@ -2,7 +2,7 @@
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod epoll;
-#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "openbsd"))]
+#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
pub mod event;
// TODO: switch from feature flags to conditional builds
@@ -12,7 +12,7 @@ pub mod eventfd;
#[cfg(target_os = "linux")]
pub mod memfd;
-#[cfg(not(any(target_os = "ios", target_os = "freebsd")))]
+#[cfg(not(any(target_os = "ios", target_os = "freebsd", target_os = "dragonfly")))]
pub mod ioctl;
pub mod signal;
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 4a54c5d4..5f51bd11 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -241,15 +241,22 @@ pub mod signal {
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "openbsd"))]
pub type sigset_t = u32;
- #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+ #[cfg(target_os = "freebsd")]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct sigset_t {
bits: [u32; 4],
}
+ #[cfg(target_os = "dragonfly")]
+ #[repr(C)]
+ #[derive(Clone, Copy)]
+ pub struct sigset_t {
+ bits: [libc::c_uint; 4],
+ }
// This structure has more fields, but we're not all that interested in
// them.
+ #[cfg(not(target_os = "dragonfly"))]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct siginfo {
@@ -261,6 +268,18 @@ pub mod signal {
pub status: libc::c_int,
}
+ #[cfg(target_os = "dragonfly")]
+ #[repr(C)]
+ #[derive(Clone, Copy)]
+ pub struct siginfo {
+ pub si_signo: libc::c_int,
+ pub si_errno: libc::c_int,
+ pub si_code: libc::c_int,
+ pub pid: libc::c_int,
+ pub uid: libc::c_uint,
+ pub status: libc::c_int,
+ }
+
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[repr(C)]
#[allow(missing_copy_implementations)]
diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs
index ddd77c05..4deb9f59 100644
--- a/src/sys/socket/consts.rs
+++ b/src/sys/socket/consts.rs
@@ -205,6 +205,81 @@ mod os {
pub const SHUT_RDWR: c_int = 2;
}
+#[cfg(target_os = "dragonfly")]
+mod os {
+ 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;
+ pub const AF_INET6: c_int = 28;
+
+ pub const SOCK_STREAM: c_int = 1;
+ pub const SOCK_DGRAM: c_int = 2;
+ pub const SOCK_SEQPACKET: c_int = 5;
+ pub const SOCK_RAW: c_int = 3;
+ pub const SOCK_RDM: c_int = 4;
+
+ pub const SOL_SOCKET: c_int = 0xffff;
+ pub const IPPROTO_IP: c_int = 0;
+ pub const IPPROTO_IPV6: c_int = 41;
+ pub const IPPROTO_TCP: c_int = 6;
+ pub const IPPROTO_UDP: c_int = 17;
+
+ pub const SO_ACCEPTCONN: c_int = 0x0002;
+ pub const SO_BROADCAST: c_int = 0x0020;
+ pub const SO_DEBUG: c_int = 0x0001;
+ pub const SO_ERROR: c_int = 0x1007;
+ pub const SO_DONTROUTE: c_int = 0x0010;
+ pub const SO_KEEPALIVE: c_int = 0x0008;
+ pub const SO_LINGER: c_int = 0x0080;
+ pub const SO_NOSIGPIPE: c_int = 0x0800; // different value!
+ pub const SO_OOBINLINE: c_int = 0x0100;
+ pub const SO_RCVBUF: c_int = 0x1002;
+ pub const SO_RCVLOWAT: c_int = 0x1004;
+ pub const SO_SNDLOWAT: c_int = 0x1003;
+ pub const SO_RCVTIMEO: c_int = 0x1006;
+ pub const SO_SNDTIMEO: c_int = 0x1005;
+ pub const SO_REUSEADDR: c_int = 0x0004;
+ pub const SO_REUSEPORT: c_int = 0x0200;
+ pub const SO_SNDBUF: c_int = 0x1001;
+ pub const SO_TIMESTAMP: c_int = 0x0400;
+ pub const SO_TYPE: c_int = 0x1008;
+
+ // Socket options for TCP sockets
+ pub const TCP_NODELAY: c_int = 1;
+ pub const TCP_MAXSEG: c_int = 2;
+ pub const TCP_KEEPIDLE: c_int = 0x100;
+
+ // Socket options for the IP layer of the socket
+ pub const IP_MULTICAST_IF: c_int = 9;
+
+ pub type IpMulticastTtl = uint8_t;
+
+ pub const IP_MULTICAST_TTL: c_int = 10;
+ pub const IP_MULTICAST_LOOP: c_int = 11;
+ pub const IP_ADD_MEMBERSHIP: c_int = 12;
+ pub const IP_DROP_MEMBERSHIP: c_int = 13;
+
+ pub type InAddrT = u32;
+
+ // Declarations of special addresses
+ pub const INADDR_ANY: InAddrT = 0;
+ pub const INADDR_NONE: InAddrT = 0xffffffff;
+ pub const INADDR_BROADCAST: InAddrT = 0xffffffff;
+
+ pub type SockMessageFlags = i32;
+ // Flags for send/recv and their relatives
+ pub const MSG_OOB: SockMessageFlags = 0x1;
+ pub const MSG_PEEK: SockMessageFlags = 0x2;
+ pub const MSG_DONTWAIT: SockMessageFlags = 0x80;
+
+ // shutdown flags
+ pub const SHUT_RD: c_int = 0;
+ pub const SHUT_WR: c_int = 1;
+ pub const SHUT_RDWR: c_int = 2;
+}
+
#[cfg(test)]
mod test {
use super::*;
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index a9fd41ec..1ecac547 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 = "openbsd", target_os = "linux"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", 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 = "openbsd", target_os = "linux"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "linux"))]
pub use self::non_android::*;
// On Android before 5.0, Bionic directly inline these to ioctl() calls.
@@ -95,13 +95,24 @@ mod ffi {
pub use self::android::*;
- #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
pub mod consts {
+ #[cfg(not(target_os = "dragonfly"))]
use libc::{c_int, c_ulong, c_uchar};
+ #[cfg(target_os = "dragonfly")]
+ use libc::{c_int, c_uint, c_uchar};
+ #[cfg(not(target_os = "dragonfly"))]
pub type tcflag_t = c_ulong;
+ #[cfg(target_os = "dragonfly")]
+ pub type tcflag_t = c_uint;
+
pub type cc_t = c_uchar;
+
+ #[cfg(not(target_os = "dragonfly"))]
pub type speed_t = c_ulong;
+ #[cfg(target_os = "dragonfly")]
+ pub type speed_t = c_uint;
#[repr(C)]
#[derive(Clone, Copy)]
@@ -150,6 +161,7 @@ mod ffi {
const IXOFF = 0x00000400,
const IXANY = 0x00000800,
const IMAXBEL = 0x00002000,
+ #[cfg(not(target_os = "dragonfly"))]
const IUTF8 = 0x00004000,
}
}