Skip to content

Commit 74477b4

Browse files
committed
Add more cfg aliases
Add cfg aliases for linux_android, bsd, and freebsdlike. Use them in many places, though not everywhere they could theoretically be used. Fixes #2188
1 parent c1147c6 commit 74477b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+502
-1101
lines changed

build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ use cfg_aliases::cfg_aliases;
22

33
fn main() {
44
cfg_aliases! {
5+
android: { target_os = "android" },
6+
dragonfly: { target_os = "dragonfly" },
57
ios: { target_os = "ios" },
8+
freebsd: { target_os = "freebsd" },
9+
linux: { target_os = "linux" },
610
macos: { target_os = "macos" },
11+
netbsd: { target_os = "netbsd" },
12+
openbsd: { target_os = "openbsd" },
713
watchos: { target_os = "watchos" },
814
tvos: { target_os = "tvos" },
915
apple_targets: { any(ios, macos, watchos, tvos) },
16+
bsd: { any(freebsd, dragonfly, ios, macos, netbsd, openbsd, tvos, watchos) },
17+
linux_android: { any(android, linux) },
18+
freebsdlike: { any(dragonfly, freebsd)}
1019
}
1120
}

src/errno.rs

Lines changed: 19 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -794,21 +794,11 @@ fn desc(errno: Errno) -> &'static str {
794794
#[cfg(target_os = "freebsd")]
795795
ECAPMODE => "Not permitted in capability mode",
796796

797-
#[cfg(any(
798-
target_os = "freebsd",
799-
target_os = "dragonfly",
800-
apple_targets,
801-
target_os = "openbsd",
802-
target_os = "netbsd"
803-
))]
797+
#[cfg(bsd)]
804798
ENEEDAUTH => "Need authenticator",
805799

806800
#[cfg(any(
807-
target_os = "freebsd",
808-
target_os = "dragonfly",
809-
apple_targets,
810-
target_os = "openbsd",
811-
target_os = "netbsd",
801+
bsd,
812802
target_os = "redox",
813803
target_os = "illumos",
814804
target_os = "solaris"
@@ -825,36 +815,13 @@ fn desc(errno: Errno) -> &'static str {
825815
))]
826816
EILSEQ => "Illegal byte sequence",
827817

828-
#[cfg(any(
829-
target_os = "freebsd",
830-
target_os = "dragonfly",
831-
apple_targets,
832-
target_os = "openbsd",
833-
target_os = "netbsd",
834-
target_os = "haiku"
835-
))]
818+
#[cfg(any(bsd, target_os = "haiku"))]
836819
ENOATTR => "Attribute not found",
837820

838-
#[cfg(any(
839-
target_os = "freebsd",
840-
target_os = "dragonfly",
841-
apple_targets,
842-
target_os = "openbsd",
843-
target_os = "netbsd",
844-
target_os = "redox",
845-
target_os = "haiku"
846-
))]
821+
#[cfg(any(bsd, target_os = "redox", target_os = "haiku"))]
847822
EBADMSG => "Bad message",
848823

849-
#[cfg(any(
850-
target_os = "freebsd",
851-
target_os = "dragonfly",
852-
apple_targets,
853-
target_os = "openbsd",
854-
target_os = "netbsd",
855-
target_os = "redox",
856-
target_os = "haiku"
857-
))]
824+
#[cfg(any(bsd, target_os = "redox", target_os = "haiku"))]
858825
EPROTO => "Protocol error",
859826

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

876843
#[cfg(any(
877-
target_os = "freebsd",
878-
target_os = "dragonfly",
879-
apple_targets,
880-
target_os = "openbsd",
881-
target_os = "netbsd",
844+
bsd,
882845
target_os = "aix",
883846
target_os = "illumos",
884847
target_os = "solaris",
885848
target_os = "haiku"
886849
))]
887850
ENOTSUP => "Operation not supported",
888851

889-
#[cfg(any(
890-
target_os = "freebsd",
891-
target_os = "dragonfly",
892-
apple_targets,
893-
target_os = "aix",
894-
target_os = "openbsd",
895-
target_os = "netbsd"
896-
))]
852+
#[cfg(any(bsd, target_os = "aix"))]
897853
EPROCLIM => "Too many processes",
898854

899-
#[cfg(any(
900-
target_os = "freebsd",
901-
target_os = "dragonfly",
902-
apple_targets,
903-
target_os = "aix",
904-
target_os = "openbsd",
905-
target_os = "netbsd",
906-
target_os = "redox"
907-
))]
855+
#[cfg(any(bsd, target_os = "aix", target_os = "redox"))]
908856
EUSERS => "Too many users",
909857

910858
#[cfg(any(
911-
target_os = "freebsd",
912-
target_os = "dragonfly",
913-
apple_targets,
914-
target_os = "openbsd",
915-
target_os = "netbsd",
859+
bsd,
916860
target_os = "redox",
917861
target_os = "aix",
918862
target_os = "illumos",
@@ -922,11 +866,7 @@ fn desc(errno: Errno) -> &'static str {
922866
EDQUOT => "Disc quota exceeded",
923867

924868
#[cfg(any(
925-
target_os = "freebsd",
926-
target_os = "dragonfly",
927-
apple_targets,
928-
target_os = "openbsd",
929-
target_os = "netbsd",
869+
bsd,
930870
target_os = "redox",
931871
target_os = "aix",
932872
target_os = "illumos",
@@ -935,89 +875,31 @@ fn desc(errno: Errno) -> &'static str {
935875
))]
936876
ESTALE => "Stale NFS file handle",
937877

938-
#[cfg(any(
939-
target_os = "freebsd",
940-
target_os = "dragonfly",
941-
apple_targets,
942-
target_os = "aix",
943-
target_os = "openbsd",
944-
target_os = "netbsd",
945-
target_os = "redox"
946-
))]
878+
#[cfg(any(bsd, target_os = "aix", target_os = "redox"))]
947879
EREMOTE => "Too many levels of remote in path",
948880

949-
#[cfg(any(
950-
target_os = "freebsd",
951-
target_os = "dragonfly",
952-
apple_targets,
953-
target_os = "openbsd",
954-
target_os = "netbsd"
955-
))]
881+
#[cfg(bsd)]
956882
EBADRPC => "RPC struct is bad",
957883

958-
#[cfg(any(
959-
target_os = "freebsd",
960-
target_os = "dragonfly",
961-
apple_targets,
962-
target_os = "openbsd",
963-
target_os = "netbsd"
964-
))]
884+
#[cfg(bsd)]
965885
ERPCMISMATCH => "RPC version wrong",
966886

967-
#[cfg(any(
968-
target_os = "freebsd",
969-
target_os = "dragonfly",
970-
apple_targets,
971-
target_os = "openbsd",
972-
target_os = "netbsd"
973-
))]
887+
#[cfg(bsd)]
974888
EPROGUNAVAIL => "RPC prog. not avail",
975889

976-
#[cfg(any(
977-
target_os = "freebsd",
978-
target_os = "dragonfly",
979-
apple_targets,
980-
target_os = "openbsd",
981-
target_os = "netbsd"
982-
))]
890+
#[cfg(bsd)]
983891
EPROGMISMATCH => "Program version wrong",
984892

985-
#[cfg(any(
986-
target_os = "freebsd",
987-
target_os = "dragonfly",
988-
apple_targets,
989-
target_os = "openbsd",
990-
target_os = "netbsd"
991-
))]
893+
#[cfg(bsd)]
992894
EPROCUNAVAIL => "Bad procedure for program",
993895

994-
#[cfg(any(
995-
target_os = "freebsd",
996-
target_os = "dragonfly",
997-
apple_targets,
998-
target_os = "openbsd",
999-
target_os = "netbsd"
1000-
))]
896+
#[cfg(bsd)]
1001897
EFTYPE => "Inappropriate file type or format",
1002898

1003-
#[cfg(any(
1004-
target_os = "freebsd",
1005-
target_os = "dragonfly",
1006-
apple_targets,
1007-
target_os = "openbsd",
1008-
target_os = "netbsd"
1009-
))]
899+
#[cfg(bsd)]
1010900
EAUTH => "Authentication error",
1011901

1012-
#[cfg(any(
1013-
target_os = "freebsd",
1014-
target_os = "dragonfly",
1015-
apple_targets,
1016-
target_os = "aix",
1017-
target_os = "openbsd",
1018-
target_os = "netbsd",
1019-
target_os = "redox"
1020-
))]
902+
#[cfg(any(bsd, target_os = "aix", target_os = "redox"))]
1021903
ECANCELED => "Operation canceled",
1022904

1023905
#[cfg(apple_targets)]

0 commit comments

Comments
 (0)