Skip to content

Commit

Permalink
Add more cfg aliases
Browse files Browse the repository at this point in the history
Add cfg aliases for linux_android, bsd, and freebsdlike.  Use them in
many places, though not everywhere they could theoretically be used.

Fixes nix-rust#2188
  • Loading branch information
asomers committed Nov 24, 2023
1 parent c1147c6 commit 74477b4
Show file tree
Hide file tree
Showing 46 changed files with 502 additions and 1,101 deletions.
9 changes: 9 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ use cfg_aliases::cfg_aliases;

fn main() {
cfg_aliases! {
android: { target_os = "android" },
dragonfly: { target_os = "dragonfly" },
ios: { target_os = "ios" },
freebsd: { target_os = "freebsd" },
linux: { target_os = "linux" },
macos: { target_os = "macos" },
netbsd: { target_os = "netbsd" },
openbsd: { target_os = "openbsd" },
watchos: { target_os = "watchos" },
tvos: { target_os = "tvos" },
apple_targets: { any(ios, macos, watchos, tvos) },
bsd: { any(freebsd, dragonfly, ios, macos, netbsd, openbsd, tvos, watchos) },
linux_android: { any(android, linux) },
freebsdlike: { any(dragonfly, freebsd)}
}
}
156 changes: 19 additions & 137 deletions src/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,21 +794,11 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(target_os = "freebsd")]
ECAPMODE => "Not permitted in capability mode",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
ENEEDAUTH => "Need authenticator",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd",
bsd,
target_os = "redox",
target_os = "illumos",
target_os = "solaris"
Expand All @@ -825,36 +815,13 @@ fn desc(errno: Errno) -> &'static str {
))]
EILSEQ => "Illegal byte sequence",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd",
target_os = "haiku"
))]
#[cfg(any(bsd, target_os = "haiku"))]
ENOATTR => "Attribute not found",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd",
target_os = "redox",
target_os = "haiku"
))]
#[cfg(any(bsd, target_os = "redox", target_os = "haiku"))]
EBADMSG => "Bad message",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd",
target_os = "redox",
target_os = "haiku"
))]
#[cfg(any(bsd, target_os = "redox", target_os = "haiku"))]
EPROTO => "Protocol error",

#[cfg(any(
Expand All @@ -874,45 +841,22 @@ fn desc(errno: Errno) -> &'static str {
EOWNERDEAD => "Previous owner died",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd",
bsd,
target_os = "aix",
target_os = "illumos",
target_os = "solaris",
target_os = "haiku"
))]
ENOTSUP => "Operation not supported",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "aix",
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(any(bsd, target_os = "aix"))]
EPROCLIM => "Too many processes",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "aix",
target_os = "openbsd",
target_os = "netbsd",
target_os = "redox"
))]
#[cfg(any(bsd, target_os = "aix", target_os = "redox"))]
EUSERS => "Too many users",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd",
bsd,
target_os = "redox",
target_os = "aix",
target_os = "illumos",
Expand All @@ -922,11 +866,7 @@ fn desc(errno: Errno) -> &'static str {
EDQUOT => "Disc quota exceeded",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd",
bsd,
target_os = "redox",
target_os = "aix",
target_os = "illumos",
Expand All @@ -935,89 +875,31 @@ fn desc(errno: Errno) -> &'static str {
))]
ESTALE => "Stale NFS file handle",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "aix",
target_os = "openbsd",
target_os = "netbsd",
target_os = "redox"
))]
#[cfg(any(bsd, target_os = "aix", target_os = "redox"))]
EREMOTE => "Too many levels of remote in path",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
EBADRPC => "RPC struct is bad",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
ERPCMISMATCH => "RPC version wrong",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
EPROGUNAVAIL => "RPC prog. not avail",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
EPROGMISMATCH => "Program version wrong",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
EPROCUNAVAIL => "Bad procedure for program",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
EFTYPE => "Inappropriate file type or format",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "openbsd",
target_os = "netbsd"
))]
#[cfg(bsd)]
EAUTH => "Authentication error",

#[cfg(any(
target_os = "freebsd",
target_os = "dragonfly",
apple_targets,
target_os = "aix",
target_os = "openbsd",
target_os = "netbsd",
target_os = "redox"
))]
#[cfg(any(bsd, target_os = "aix", target_os = "redox"))]
ECANCELED => "Operation canceled",

#[cfg(apple_targets)]
Expand Down
Loading

0 comments on commit 74477b4

Please sign in to comment.