Skip to content

Add more cfg aliases #2205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another place where we can use solarish

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be: solarish

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