summaryrefslogtreecommitdiff
path: root/src/sys/socket/ffi.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/socket/ffi.rs')
-rw-r--r--src/sys/socket/ffi.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/sys/socket/ffi.rs b/src/sys/socket/ffi.rs
index 55a47eb6..265a97c9 100644
--- a/src/sys/socket/ffi.rs
+++ b/src/sys/socket/ffi.rs
@@ -3,9 +3,12 @@
pub use libc::{socket, listen, bind, accept, connect, setsockopt, sendto, recvfrom, getsockname, getpeername, recv, send};
-use libc::{c_int, c_void, socklen_t, size_t, ssize_t};
+use libc::{c_int, c_void, socklen_t, ssize_t};
-#[cfg(target_os = "macos")]
+#[cfg(not(target_os = "macos"))]
+use libc::size_t;
+
+#[cfg(not(target_os = "linux"))]
use libc::c_uint;
use sys::uio::IoVec;
@@ -23,19 +26,27 @@ pub type type_of_cmsg_data = c_uint;
#[cfg(not(target_os = "macos"))]
pub type type_of_cmsg_data = size_t;
+#[cfg(target_os = "linux")]
+pub type type_of_msg_iovlen = size_t;
+
+#[cfg(not(target_os = "linux"))]
+pub type type_of_msg_iovlen = c_uint;
+
// Private because we don't expose any external functions that operate
// directly on this type; we just use it internally at FFI boundaries.
// Note that in some cases we store pointers in *const fields that the
// kernel will proceed to mutate, so users should be careful about the
// actual mutability of data pointed to by this structure.
+//
+// FIXME: Replace these structs with the ones defined in libc
#[repr(C)]
pub struct msghdr<'a> {
pub msg_name: *const c_void,
pub msg_namelen: socklen_t,
pub msg_iov: *const IoVec<&'a [u8]>,
- pub msg_iovlen: size_t,
+ pub msg_iovlen: type_of_msg_iovlen,
pub msg_control: *const c_void,
- pub msg_controllen: size_t,
+ pub msg_controllen: type_of_cmsg_len,
pub msg_flags: c_int,
}