diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-12-19 15:23:50 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2017-12-19 15:23:50 +0000 |
commit | b68db41543d16d862e07ddbd143f43b92533d60b (patch) | |
tree | ab1f601bc9e67bc31ef833dcebc973b9ee899b67 /src/sys | |
parent | 291d618322a360e2b3ac99ca7c1fde19ba6b4b2c (diff) | |
parent | 709cbdf12cacb6ecf42cca9000d1d46380b6ba62 (diff) | |
download | nix-b68db41543d16d862e07ddbd143f43b92533d60b.zip |
Merge #799
799: Fix nix on Dragonfly r=Susurrus a=mneumann
This commit replaces pull request https://github.com/nix-rust/nix/pull/684. It fixes building `nix` on DragonFly. All tests pass. This requires most recent libc to build: https://github.com/rust-lang/libc/pull/851.
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/socket/ffi.rs | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/sys/socket/ffi.rs b/src/sys/socket/ffi.rs index 265a97c9..d91b130e 100644 --- a/src/sys/socket/ffi.rs +++ b/src/sys/socket/ffi.rs @@ -5,32 +5,32 @@ pub use libc::{socket, listen, bind, accept, connect, setsockopt, sendto, recvfr use libc::{c_int, c_void, socklen_t, ssize_t}; -#[cfg(not(target_os = "macos"))] -use libc::size_t; - -#[cfg(not(target_os = "linux"))] -use libc::c_uint; - use sys::uio::IoVec; -#[cfg(target_os = "linux")] -pub type type_of_cmsg_len = size_t; - -#[cfg(not(target_os = "linux"))] -pub type type_of_cmsg_len = socklen_t; - -// OSX always aligns struct cmsghdr as if it were a 32-bit OS -#[cfg(target_os = "macos")] -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; +cfg_if! { + if #[cfg(target_os = "dragonfly")] { + use libc::c_uint; + pub type type_of_cmsg_len = socklen_t; + pub type type_of_cmsg_data = c_int; + pub type type_of_msg_iovlen = c_uint; + } else if #[cfg(target_os = "linux")] { + use libc::size_t; + pub type type_of_cmsg_len = size_t; + pub type type_of_cmsg_data = size_t; + pub type type_of_msg_iovlen = size_t; + } else if #[cfg(target_os = "macos")] { + use libc::c_uint; + pub type type_of_cmsg_len = socklen_t; + // OSX always aligns struct cmsghdr as if it were a 32-bit OS + pub type type_of_cmsg_data = c_uint; + pub type type_of_msg_iovlen = c_uint; + } else { + use libc::{c_uint, size_t}; + pub type type_of_cmsg_len = socklen_t; + pub type type_of_cmsg_data = size_t; + 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. |