diff options
author | Michael Neumann <mneumann@ntecs.de> | 2017-11-17 12:23:41 +0100 |
---|---|---|
committer | Michael Neumann <mneumann@ntecs.de> | 2017-12-19 10:45:23 +0100 |
commit | 709cbdf12cacb6ecf42cca9000d1d46380b6ba62 (patch) | |
tree | ca4959e8ee070e910e3cb398dc6848c1135feb94 /src/sys | |
parent | f778523d4d557ad2af720b33998b7b81c375c8e5 (diff) | |
download | nix-709cbdf12cacb6ecf42cca9000d1d46380b6ba62.zip |
Fix support for DragonFly
* DragonFly does not have a O_DSYNC flag
* Fix type_of_cmsg_data on DragonFly
* No fexecve() on DragonFly
* Do not run aio test cases on DragonFly
* Keep target lists in alphabetical order
* Unscrable #[cfg] directives and use cfg_if! macro instead
* Fix errno on DragonFly
Below follows an explanation why we have to use a C extension
to get errno working on DragonFly:
DragonFly uses a thread-local errno variable, but #[thread_local] is
feature-gated and not available in stable Rust as of this writing (Rust
1.21.0). We have to use a C extension (src/errno_dragonfly.c) to access
it.
Tracking issue for `thread_local` stabilization:
https://github.com/rust-lang/rust/issues/29594
Once this becomes stable, we can remove build.rs, src/errno_dragonfly.c,
remove the build-dependency from Cargo.toml, and use:
extern {
#[thread_local]
static errno: c_int;
}
Now all targets will use the build.rs script, but only on DragonFly this
will do something. Also, there are no additional dependencies for
targets other than DragonFly (no gcc dep).
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. |