summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorAndrew J. Stone <andrew.j.stone.1@gmail.com>2015-05-07 23:27:37 -0400
committerCarl Lerche <me@carllerche.com>2015-05-11 22:06:19 -0700
commit1a2d6d51f4f585e975eb3fb420904427d1f706f4 (patch)
treebdff15cefec1fe003b7b78e0233f208611757a0e /src/sys
parentecbbf1a8176130ca845b23c3e9dfe37d45da3c13 (diff)
downloadnix-1a2d6d51f4f585e975eb3fb420904427d1f706f4.zip
Get the library to build on freebsd
`cargo build` works.
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/mman.rs49
-rw-r--r--src/sys/mod.rs4
-rw-r--r--src/sys/signal.rs1
-rw-r--r--src/sys/socket/consts.rs3
-rw-r--r--src/sys/termios.rs4
5 files changed, 56 insertions, 5 deletions
diff --git a/src/sys/mman.rs b/src/sys/mman.rs
index a905744d..d3f3b7ae 100644
--- a/src/sys/mman.rs
+++ b/src/sys/mman.rs
@@ -112,6 +112,55 @@ mod consts {
pub const MAP_FAILED: isize = -1;
}
+#[cfg(target_os = "freebsd")]
+mod consts {
+ use libc::c_int;
+
+ pub type MmapFlag = c_int;
+
+ pub const MAP_SHARED: MmapFlag = 0x00001;
+ pub const MAP_PRIVATE: MmapFlag = 0x00002;
+ pub const MAP_FIXED: MmapFlag = 0x00010;
+
+ pub const MAP_RENAME: MmapFlag = 0x00020;
+ pub const MAP_NORESERVE: MmapFlag = 0x00040;
+ pub const MAP_HASSEMAPHORE: MmapFlag = 0x00200;
+ pub const MAP_STACK: MmapFlag = 0x00400;
+ pub const MAP_NOSYNC: MmapFlag = 0x00800;
+ pub const MAP_FILE: MmapFlag = 0x00000;
+ pub const MAP_ANON: MmapFlag = 0x01000;
+
+ pub type MmapProt = c_int;
+
+ pub const PROT_READ: MmapProt = 0x1;
+ pub const PROT_WRITE: MmapProt = 0x2;
+ pub const PROT_EXEC: MmapProt = 0x4;
+ pub const PROT_NONE: MmapProt = 0x0;
+
+ pub type MmapAdvise = c_int;
+
+ pub const MADV_NORMAL : MmapAdvise = 0; /* No further special treatment. */
+ pub const MADV_RANDOM : MmapAdvise = 1; /* Expect random page references. */
+ pub const MADV_SEQUENTIAL : MmapAdvise = 2; /* Expect sequential page references. */
+ pub const MADV_WILLNEED : MmapAdvise = 3; /* Will need these pages. */
+ pub const MADV_DONTNEED : MmapAdvise = 4; /* Don't need these pages. */
+ pub const MADV_FREE : MmapAdvise = 5; /* pages unneeded, discard contents */
+ pub const MADV_NOSYNC : MmapAdvise = 6; /* try to avoid flushes to physical media*/
+ 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 */
+ pub const MADV_PROTECT : MmapAdvise = 10; /* protect process from pageout kill */
+
+ 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 */
+ pub const MS_SYNC : MmapSync = 0x0010; /* [MF|SIO] msync synchronously */
+ pub const MS_KILLPAGES : MmapSync = 0x0004; /* invalidate pages, leave mapped */
+ pub const MS_DEACTIVATE : MmapSync = 0x0008; /* deactivate pages, leave mapped */
+
+ pub const MAP_FAILED: isize = -1;
+}
mod ffi {
use libc::{c_void, size_t, c_int, c_char, mode_t};
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
index f25aecb4..f0fda20a 100644
--- a/src/sys/mod.rs
+++ b/src/sys/mod.rs
@@ -2,14 +2,14 @@
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod epoll;
-#[cfg(any(target_os = "macos", target_os = "ios"))]
+#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))]
pub mod event;
// TODO: switch from feature flags to conditional builds
#[cfg(feature = "eventfd")]
pub mod eventfd;
-#[cfg(not(target_os = "ios"))]
+#[cfg(not(any(target_os = "ios", target_os = "freebsd")))]
pub mod ioctl;
pub mod signal;
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 112a7bcd..8f3ecdcf 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -242,6 +242,7 @@ pub mod signal {
pub type sigset_t = u32;
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
#[repr(C)]
+ #[derive(Clone, Copy)]
pub struct sigset_t {
bits: [u32; 4],
}
diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs
index 539c50e9..a2bb535b 100644
--- a/src/sys/socket/consts.rs
+++ b/src/sys/socket/consts.rs
@@ -90,7 +90,8 @@ mod os {
pub const MSG_DONTWAIT: SockMessageFlags = 0x40;
}
-#[cfg(any(target_os = "macos", target_os = "ios"))]
+// Not all of these constants exist on freebsd
+#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "ios"))]
mod os {
use libc::{c_int, uint8_t};
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 57612f0b..0c636e77 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -17,7 +17,7 @@ mod ffi {
// `Termios` contains bitflags which are not considered
// `foreign-function-safe` by the compiler.
#[allow(improper_ctypes)]
- #[cfg(any(target_os = "macos", target_os = "linux"))]
+ #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "linux"))]
extern {
pub fn cfgetispeed(termios: *const Termios) -> speed_t;
pub fn cfgetospeed(termios: *const Termios) -> speed_t;
@@ -89,7 +89,7 @@ mod ffi {
pub use self::android::*;
- #[cfg(target_os = "macos")]
+ #[cfg(any(target_os = "macos", target_os = "freebsd"))]
pub mod consts {
use libc::{c_int, c_ulong, c_uchar};