Skip to content

Commit 441f195

Browse files
Mark consts to be ignored depending on freebsd version
1 parent e66a88c commit 441f195

File tree

2 files changed

+46
-44
lines changed

2 files changed

+46
-44
lines changed

libc-test/build.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,36 @@ fn test_freebsd(target: &str) {
20632063

20642064
"VM_TOTAL" if Some(11) == freebsd_ver => true,
20652065

2066+
// Added in FreeBSD 14.
2067+
"KERN_STACKTOP" if Some(14) > freebsd_ver => true,
2068+
// Added in FreeBSD 13.
2069+
"KERN_PROC_SIGFASTBLK"
2070+
| "USER_LOCALBASE"
2071+
| "TDP_SIGFASTBLOCK"
2072+
| "TDP_UIOHELD"
2073+
| "TDP_SIGFASTPENDING"
2074+
| "TDP2_COMPAT32RB"
2075+
| "P2_PROTMAX_ENABLE"
2076+
| "P2_PROTMAX_DISABLE"
2077+
| "CTLFLAG_NEEDGIANT"
2078+
| "CTL_SYSCTL_NEXTNOSKIP"
2079+
if Some(13) > freebsd_ver =>
2080+
{
2081+
true
2082+
}
2083+
// Added in FreeBSD 12.
2084+
"KERN_MAXPHYS"
2085+
| "KVME_FLAG_USER_WIRED"
2086+
| "TDP2_SBPAGES"
2087+
| "P2_ASLR_ENABLE"
2088+
| "P2_ASLR_DISABLE"
2089+
| "P2_ASLR_IGNSTART"
2090+
| "P_TREE_GRPEXITED"
2091+
if Some(12) > freebsd_ver =>
2092+
{
2093+
true
2094+
}
2095+
20662096
_ => false,
20672097
}
20682098
});

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,7 @@ pub const CTLFLAG_CAPWR: ::c_int = 0x00004000;
909909
pub const CTLFLAG_STATS: ::c_int = 0x00002000;
910910
pub const CTLFLAG_NOFETCH: ::c_int = 0x00001000;
911911
pub const CTLFLAG_CAPRW: ::c_int = CTLFLAG_CAPRD | CTLFLAG_CAPWR;
912-
cfg_if! {
913-
if #[cfg(any(freebsd13, freebsd14))] {
914-
pub const CTLFLAG_NEEDGIANT: ::c_int = 0x00000800;
915-
}
916-
}
912+
pub const CTLFLAG_NEEDGIANT: ::c_int = 0x00000800;
917913

918914
pub const CTLSHIFT_SECURE: ::c_int = 20;
919915
pub const CTLFLAG_SECURE1: ::c_int = CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE);
@@ -929,11 +925,7 @@ pub const CTL_SYSCTL_NAME2OID: ::c_int = 3;
929925
pub const CTL_SYSCTL_OIDFMT: ::c_int = 4;
930926
pub const CTL_SYSCTL_OIDDESCR: ::c_int = 5;
931927
pub const CTL_SYSCTL_OIDLABEL: ::c_int = 6;
932-
cfg_if! {
933-
if #[cfg(any(freebsd13, freebsd14))] {
934-
pub const CTL_SYSCTL_NEXTNOSKIP: ::c_int = 7;
935-
}
936-
}
928+
pub const CTL_SYSCTL_NEXTNOSKIP: ::c_int = 7;
937929

938930
pub const KERN_OSTYPE: ::c_int = 1;
939931
pub const KERN_OSRELEASE: ::c_int = 2;
@@ -1004,11 +996,7 @@ pub const KERN_PROC_OSREL: ::c_int = 40;
1004996
pub const KERN_PROC_SIGTRAMP: ::c_int = 41;
1005997
pub const KERN_PROC_CWD: ::c_int = 42;
1006998
pub const KERN_PROC_NFDS: ::c_int = 43;
1007-
cfg_if! {
1008-
if #[cfg(any(freebsd13, freebsd14))] {
1009-
pub const KERN_PROC_SIGFASTBLK: ::c_int = 44;
1010-
}
1011-
}
999+
pub const KERN_PROC_SIGFASTBLK: ::c_int = 44;
10121000

10131001
pub const KIPC_MAXSOCKBUF: ::c_int = 1;
10141002
pub const KIPC_SOCKBUF_WASTE: ::c_int = 2;
@@ -1051,11 +1039,7 @@ pub const USER_POSIX2_SW_DEV: ::c_int = 17;
10511039
pub const USER_POSIX2_UPE: ::c_int = 18;
10521040
pub const USER_STREAM_MAX: ::c_int = 19;
10531041
pub const USER_TZNAME_MAX: ::c_int = 20;
1054-
cfg_if! {
1055-
if #[cfg(any(freebsd13, freebsd14))] {
1056-
pub const USER_LOCALBASE: ::c_int = 21;
1057-
}
1058-
}
1042+
pub const USER_LOCALBASE: ::c_int = 21;
10591043

10601044
pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1;
10611045
pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2;
@@ -1862,11 +1846,7 @@ pub const KVME_FLAG_NOCOREDUMP: ::c_int = 0x00000004;
18621846
pub const KVME_FLAG_SUPER: ::c_int = 0x00000008;
18631847
pub const KVME_FLAG_GROWS_UP: ::c_int = 0x00000010;
18641848
pub const KVME_FLAG_GROWS_DOWN: ::c_int = 0x00000020;
1865-
cfg_if! {
1866-
if #[cfg(any(freebsd12, freebsd13, freebsd14))] {
1867-
pub const KVME_FLAG_USER_WIRED: ::c_int = 0x00000040;
1868-
}
1869-
}
1849+
pub const KVME_FLAG_USER_WIRED: ::c_int = 0x00000040;
18701850

18711851
pub const KKST_MAXLEN: ::c_int = 1024;
18721852
/// Stack is valid.
@@ -2127,25 +2107,17 @@ pub const SLOCK: ::c_char = 7;
21272107

21282108
pub const P_MAGIC: ::c_int = 0xbeefface;
21292109

2130-
cfg_if! {
2131-
if #[cfg(any(freebsd13, freebsd14))] {
2132-
pub const TDP_SIGFASTBLOCK: ::c_int = 0x00000100;
2133-
pub const TDP_UIOHELD: ::c_int = 0x10000000;
2134-
pub const TDP_SIGFASTPENDING: ::c_int = 0x80000000;
2135-
pub const TDP2_COMPAT32RB: ::c_int = 0x00000002;
2136-
pub const P2_PROTMAX_ENABLE: ::c_int = 0x00000200;
2137-
pub const P2_PROTMAX_DISABLE: ::c_int = 0x00000400;
2138-
}
2139-
}
2140-
cfg_if! {
2141-
if #[cfg(any(freebsd12, freebsd13, freebsd14))] {
2142-
pub const TDP2_SBPAGES: ::c_int = 0x00000001;
2143-
pub const P2_ASLR_ENABLE: ::c_int = 0x00000040;
2144-
pub const P2_ASLR_DISABLE: ::c_int = 0x00000080;
2145-
pub const P2_ASLR_IGNSTART: ::c_int = 0x00000100;
2146-
pub const P_TREE_GRPEXITED: ::c_int = 0x00000008;
2147-
}
2148-
}
2110+
pub const TDP_SIGFASTBLOCK: ::c_int = 0x00000100;
2111+
pub const TDP_UIOHELD: ::c_int = 0x10000000;
2112+
pub const TDP_SIGFASTPENDING: ::c_int = 0x80000000;
2113+
pub const TDP2_COMPAT32RB: ::c_int = 0x00000002;
2114+
pub const P2_PROTMAX_ENABLE: ::c_int = 0x00000200;
2115+
pub const P2_PROTMAX_DISABLE: ::c_int = 0x00000400;
2116+
pub const TDP2_SBPAGES: ::c_int = 0x00000001;
2117+
pub const P2_ASLR_ENABLE: ::c_int = 0x00000040;
2118+
pub const P2_ASLR_DISABLE: ::c_int = 0x00000080;
2119+
pub const P2_ASLR_IGNSTART: ::c_int = 0x00000100;
2120+
pub const P_TREE_GRPEXITED: ::c_int = 0x00000008;
21492121

21502122
const_fn! {
21512123
{const} fn _ALIGN(p: usize) -> usize {

0 commit comments

Comments
 (0)