Skip to content

Commit

Permalink
fix, mostly, solaris build.
Browse files Browse the repository at this point in the history
With few exceptions as newer interfaces like preadv/pwritev unsupported
only on solaris.
  • Loading branch information
devnexen committed Dec 8, 2023
1 parent b763d73 commit d310377
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 73 deletions.
2 changes: 2 additions & 0 deletions changelog/2248.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed solaris build globally.
Removed a subset of `InterfaceFlags` values specific to solaris/illumos as they are of i64 thus could not be cast to the expected i32 type.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ feature! {

#[cfg(any(linux_android,
bsd,
target_os = "illumos"))]
solarish))]
#[deny(missing_docs)]
pub mod ifaddrs;
#[cfg(not(target_os = "redox"))]
Expand Down
24 changes: 2 additions & 22 deletions src/net/if_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,6 @@ libc_bitflags!(
/// Interface is offline
#[cfg(solarish)]
IFF_OFFLINE;
#[cfg(target_os = "solaris")]
IFF_COS_ENABLED;
/// Prefer as source addr.
#[cfg(target_os = "solaris")]
IFF_PREFERRED;
/// RFC3041
#[cfg(target_os = "solaris")]
IFF_TEMPORARY;
/// MTU set with SIOCSLIFMTU
#[cfg(target_os = "solaris")]
IFF_FIXEDMTU;
/// Cannot send / receive packets
#[cfg(target_os = "solaris")]
IFF_VIRTUAL;
/// Local address in use
#[cfg(target_os = "solaris")]
IFF_DUPLICATE;
/// IPMP IP interface
#[cfg(target_os = "solaris")]
IFF_IPMP;
}
);

Expand All @@ -247,7 +227,7 @@ impl fmt::Display for InterfaceFlags {
bsd,
target_os = "fuchsia",
target_os = "linux",
target_os = "illumos",
solarish,
))]
mod if_nameindex {
use super::*;
Expand Down Expand Up @@ -374,6 +354,6 @@ mod if_nameindex {
bsd,
target_os = "fuchsia",
target_os = "linux",
target_os = "illumos",
solarish,
))]
pub use if_nameindex::*;
4 changes: 2 additions & 2 deletions src/sys/ioctl/bsd.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/// The datatype used for the ioctl number
#[doc(hidden)]
#[cfg(not(target_os = "illumos"))]
#[cfg(not(solarish))]
pub type ioctl_num_type = ::libc::c_ulong;

#[doc(hidden)]
#[cfg(target_os = "illumos")]
#[cfg(solarish)]
pub type ioctl_num_type = ::libc::c_int;

/// The datatype used for the 3rd argument
Expand Down
4 changes: 2 additions & 2 deletions src/sys/ioctl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ mod linux;
#[cfg(any(linux_android, target_os = "redox"))]
pub use self::linux::*;

#[cfg(any(bsd, target_os = "illumos", target_os = "haiku",))]
#[cfg(any(bsd, solarish, target_os = "haiku",))]
#[macro_use]
mod bsd;

#[cfg(any(bsd, target_os = "illumos", target_os = "haiku",))]
#[cfg(any(bsd, solarish, target_os = "haiku",))]
pub use self::bsd::*;

/// Convert raw ioctl return value to a Nix result
Expand Down
6 changes: 3 additions & 3 deletions src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ feature! {
pub mod fanotify;
}

#[cfg(any(bsd, linux_android, target_os = "redox", target_os = "illumos"))]
#[cfg(any(bsd, linux_android, target_os = "redox", solarish))]
#[cfg(feature = "ioctl")]
#[cfg_attr(docsrs, doc(cfg(feature = "ioctl")))]
#[macro_use]
Expand Down Expand Up @@ -88,7 +88,7 @@ feature! {
#[cfg(not(any(
target_os = "redox",
target_os = "fuchsia",
target_os = "illumos",
solarish,
target_os = "haiku"
)))]
feature! {
Expand Down Expand Up @@ -182,7 +182,7 @@ feature! {
#[cfg(all(
any(
target_os = "freebsd",
target_os = "illumos",
solarish,
target_os = "linux",
target_os = "netbsd"
),
Expand Down
38 changes: 19 additions & 19 deletions src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(any(
bsd,
linux_android,
target_os = "illumos",
solarish,
target_os = "haiku",
target_os = "fuchsia",
target_os = "aix",
Expand Down Expand Up @@ -230,7 +230,7 @@ pub enum AddressFamily {
#[cfg(bsd)]
Hylink = libc::AF_HYLINK,
/// Link layer interface
#[cfg(any(bsd, target_os = "illumos"))]
#[cfg(any(bsd, solarish))]
Link = libc::AF_LINK,
/// connection-oriented IP, aka ST II
#[cfg(bsd)]
Expand Down Expand Up @@ -265,7 +265,7 @@ impl AddressFamily {
libc::PF_ROUTE => Some(AddressFamily::Route),
#[cfg(linux_android)]
libc::AF_PACKET => Some(AddressFamily::Packet),
#[cfg(any(bsd, target_os = "illumos"))]
#[cfg(any(bsd, solarish))]
libc::AF_LINK => Some(AddressFamily::Link),
#[cfg(any(linux_android, apple_targets))]
libc::AF_VSOCK => Some(AddressFamily::Vsock),
Expand Down Expand Up @@ -506,7 +506,7 @@ impl UnixAddr {
cfg_if! {
if #[cfg(any(linux_android,
target_os = "fuchsia",
target_os = "illumos",
solarish,
target_os = "redox",
))]
{
Expand Down Expand Up @@ -547,7 +547,7 @@ impl SockaddrLike for UnixAddr {
cfg_if! {
if #[cfg(any(linux_android,
target_os = "fuchsia",
target_os = "illumos",
solarish,
target_os = "redox",
))] {
let su_len = len.unwrap_or(
Expand Down Expand Up @@ -577,7 +577,7 @@ impl SockaddrLike for UnixAddr {
cfg_if! {
if #[cfg(any(linux_android,
target_os = "fuchsia",
target_os = "illumos",
solarish,
target_os = "redox",
))] {
self.sun_len = new_length as u8;
Expand Down Expand Up @@ -1101,7 +1101,7 @@ impl SockaddrLike for SockaddrStorage {
#[cfg(any(
linux_android,
target_os = "fuchsia",
target_os = "illumos",
solarish,
))]
if i32::from(ss.ss_family) == libc::AF_UNIX {
// Safe because we UnixAddr is strictly smaller than
Expand Down Expand Up @@ -1131,7 +1131,7 @@ impl SockaddrLike for SockaddrStorage {
libc::AF_INET6 => unsafe {
SockaddrIn6::from_raw(addr, l).map(|sin6| Self { sin6 })
},
#[cfg(any(bsd, target_os = "illumos", target_os = "haiku"))]
#[cfg(any(bsd, solarish, target_os = "haiku"))]
#[cfg(feature = "net")]
libc::AF_LINK => unsafe {
LinkAddr::from_raw(addr, l).map(|dl| Self { dl })
Expand All @@ -1158,7 +1158,7 @@ impl SockaddrLike for SockaddrStorage {
}
}

#[cfg(any(linux_android, target_os = "fuchsia", target_os = "illumos"))]
#[cfg(any(linux_android, target_os = "fuchsia", solarish))]
fn len(&self) -> libc::socklen_t {
match self.as_unix_addr() {
// The UnixAddr type knows its own length
Expand Down Expand Up @@ -1219,7 +1219,7 @@ impl SockaddrStorage {
cfg_if! {
if #[cfg(any(linux_android,
target_os = "fuchsia",
target_os = "illumos",
solarish,
))]
{
let p = unsafe{ &self.ss as *const libc::sockaddr_storage };
Expand Down Expand Up @@ -1248,7 +1248,7 @@ impl SockaddrStorage {
cfg_if! {
if #[cfg(any(linux_android,
target_os = "fuchsia",
target_os = "illumos",
solarish,
))]
{
let p = unsafe{ &self.ss as *const libc::sockaddr_storage };
Expand Down Expand Up @@ -1282,7 +1282,7 @@ impl SockaddrStorage {
as_link_addr, as_link_addr_mut, LinkAddr,
AddressFamily::Packet, libc::sockaddr_ll, dl}

#[cfg(any(bsd, target_os = "illumos"))]
#[cfg(any(bsd, solarish))]
#[cfg(feature = "net")]
accessors! {
as_link_addr, as_link_addr_mut, LinkAddr,
Expand Down Expand Up @@ -1332,7 +1332,7 @@ impl fmt::Display for SockaddrStorage {
libc::AF_INET => self.sin.fmt(f),
#[cfg(feature = "net")]
libc::AF_INET6 => self.sin6.fmt(f),
#[cfg(any(bsd, target_os = "illumos"))]
#[cfg(any(bsd, solarish))]
#[cfg(feature = "net")]
libc::AF_LINK => self.dl.fmt(f),
#[cfg(linux_android)]
Expand Down Expand Up @@ -1394,7 +1394,7 @@ impl Hash for SockaddrStorage {
libc::AF_INET => self.sin.hash(s),
#[cfg(feature = "net")]
libc::AF_INET6 => self.sin6.hash(s),
#[cfg(any(bsd, target_os = "illumos"))]
#[cfg(any(bsd, solarish))]
#[cfg(feature = "net")]
libc::AF_LINK => self.dl.hash(s),
#[cfg(linux_android)]
Expand Down Expand Up @@ -1424,7 +1424,7 @@ impl PartialEq for SockaddrStorage {
(libc::AF_INET, libc::AF_INET) => self.sin == other.sin,
#[cfg(feature = "net")]
(libc::AF_INET6, libc::AF_INET6) => self.sin6 == other.sin6,
#[cfg(any(bsd, target_os = "illumos"))]
#[cfg(any(bsd, solarish))]
#[cfg(feature = "net")]
(libc::AF_LINK, libc::AF_LINK) => self.dl == other.dl,
#[cfg(linux_android)]
Expand Down Expand Up @@ -1854,7 +1854,7 @@ mod datalink {
}
}

#[cfg(any(bsd, target_os = "illumos", target_os = "haiku", target_os = "aix"))]
#[cfg(any(bsd, solarish, target_os = "haiku", target_os = "aix"))]
mod datalink {
feature! {
#![feature = "net"]
Expand Down Expand Up @@ -2128,7 +2128,7 @@ mod tests {
mod link {
#![allow(clippy::cast_ptr_alignment)]

#[cfg(any(apple_targets, target_os = "illumos"))]
#[cfg(any(apple_targets, solarish))]
use super::super::super::socklen_t;
use super::*;

Expand Down Expand Up @@ -2215,9 +2215,9 @@ mod tests {
}
}

#[cfg(target_os = "illumos")]
#[cfg(solarish)]
#[test]
fn illumos_tap() {
fn solarish_tap() {
let bytes = [25u8, 0, 0, 0, 6, 0, 6, 0, 24, 101, 144, 221, 76, 176];
let ptr = bytes.as_ptr();
let sa = ptr as *const libc::sockaddr;
Expand Down
9 changes: 4 additions & 5 deletions src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ libc_bitflags! {
#[cfg(any(linux_android,
freebsdlike,
netbsdlike,
target_os = "illumos"))]
solarish))]
SOCK_NONBLOCK;
/// Set close-on-exec on the new descriptor
#[cfg(any(linux_android,
freebsdlike,
netbsdlike,
target_os = "illumos"))]
solarish))]
SOCK_CLOEXEC;
/// Return `EPIPE` instead of raising `SIGPIPE`
#[cfg(target_os = "netbsd")]
Expand Down Expand Up @@ -343,8 +343,7 @@ libc_bitflags! {
#[cfg(any(linux_android,
netbsdlike,
target_os = "fuchsia",
target_os = "freebsd",
target_os = "solaris"))]
target_os = "freebsd"))]
MSG_WAITFORONE;
}
}
Expand Down Expand Up @@ -2156,7 +2155,7 @@ pub fn accept(sockfd: RawFd) -> Result<RawFd> {
netbsdlike,
target_os = "emscripten",
target_os = "fuchsia",
target_os = "illumos",
solarish,
target_os = "linux",
))]
pub fn accept4(sockfd: RawFd, flags: SockFlag) -> Result<RawFd> {
Expand Down
4 changes: 2 additions & 2 deletions src/sys/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const fn zero_init_timespec() -> timespec {
all(
any(
target_os = "freebsd",
target_os = "illumos",
solarish,
target_os = "linux",
target_os = "netbsd"
),
Expand Down Expand Up @@ -97,7 +97,7 @@ pub(crate) mod timer {
const TFD_TIMER_CANCEL_ON_SET = libc::TFD_TIMER_CANCEL_ON_SET;
}
}
#[cfg(any(freebsdlike, target_os = "netbsd", target_os = "illumos"))]
#[cfg(any(freebsdlike, target_os = "netbsd", solarish))]
bitflags! {
/// Flags that are used for arming the timer.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
Expand Down
4 changes: 2 additions & 2 deletions src/sys/uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn readv<Fd: AsFd>(fd: Fd, iov: &mut [IoSliceMut<'_>]) -> Result<usize> {
/// or an error occurs. The file offset is not changed.
///
/// See also: [`writev`](fn.writev.html) and [`pwrite`](fn.pwrite.html)
#[cfg(not(any(target_os = "redox", target_os = "haiku")))]
#[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "solaris")))]
pub fn pwritev<Fd: AsFd>(
fd: Fd,
iov: &[IoSlice<'_>],
Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn pwritev<Fd: AsFd>(
/// changed.
///
/// See also: [`readv`](fn.readv.html) and [`pread`](fn.pread.html)
#[cfg(not(any(target_os = "redox", target_os = "haiku")))]
#[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "solaris")))]
// Clippy doesn't know that we need to pass iov mutably only because the
// mutation happens after converting iov to a pointer
#[allow(clippy::needless_pass_by_ref_mut)]
Expand Down
6 changes: 3 additions & 3 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
/// will only ever return the complete list or else an error.
#[cfg(not(any(
target_os = "aix",
target_os = "illumos",
solarish,
apple_targets,
target_os = "redox"
)))]
Expand Down Expand Up @@ -3200,9 +3200,9 @@ impl From<User> for libc::passwd {
target_os = "haiku",
)))]
pw_expire: u.expire,
#[cfg(target_os = "illumos")]
#[cfg(solarish)]
pw_age: CString::new("").unwrap().into_raw(),
#[cfg(target_os = "illumos")]
#[cfg(solarish)]
pw_comment: CString::new("").unwrap().into_raw(),
#[cfg(freebsdlike)]
pw_fields: 0,
Expand Down
12 changes: 10 additions & 2 deletions test/sys/test_uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ fn test_pread() {
}

#[test]
#[cfg(not(any(target_os = "redox", target_os = "haiku")))]
#[cfg(not(any(
target_os = "redox",
target_os = "haiku",
target_os = "solaris"
)))]
fn test_pwritev() {
use std::io::Read;

Expand Down Expand Up @@ -175,7 +179,11 @@ fn test_pwritev() {
}

#[test]
#[cfg(not(any(target_os = "redox", target_os = "haiku")))]
#[cfg(not(any(
target_os = "redox",
target_os = "haiku",
target_os = "solaris"
)))]
fn test_preadv() {
use std::io::Write;

Expand Down
Loading

0 comments on commit d310377

Please sign in to comment.