Skip to content

Commit f6084a7

Browse files
committed
Auto merge of #2465 - asomers:fbsd-consts, r=JohnTitor
Properly expose more constants on FreeBSD The freebsd12 and freebsd13 modules should only be used for symbols that _change_ in those versions, not for newly added symbols. Mostly they should be used for versioned ELF symbols. It does no harm to publish ordinary constants in the base FreeBSD module even if they weren't defined in the lowest supported version of FreeBSD, but it does make it much easier for consumers to use them.
2 parents 7638a12 + 3418986 commit f6084a7

File tree

4 files changed

+52
-49
lines changed

4 files changed

+52
-49
lines changed

libc-test/build.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,10 +1899,10 @@ fn test_freebsd(target: &str) {
18991899

19001900
cfg.skip_const(move |name| {
19011901
match name {
1902-
// These constants are to be introduced in yet-unreleased FreeBSD 12.2.
1902+
// These constants were introduced in FreeBSD 13:
19031903
"F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
19041904
| "F_SEAL_WRITE"
1905-
if Some(12) <= freebsd_ver =>
1905+
if Some(13) > freebsd_ver =>
19061906
{
19071907
true
19081908
}
@@ -1916,6 +1916,7 @@ fn test_freebsd(target: &str) {
19161916
| "IPV6_ORIGDSTADDR"
19171917
| "IPV6_RECVORIGDSTADDR"
19181918
| "NI_NUMERICSCOPE"
1919+
| "SO_DOMAIN"
19191920
if Some(11) == freebsd_ver =>
19201921
{
19211922
true
@@ -1986,11 +1987,32 @@ fn test_freebsd(target: &str) {
19861987
// commit/06b00ceaa914a3907e4e27bad924f44612bae1d7
19871988
"MINCORE_SUPER" if Some(13) == freebsd_ver => true,
19881989

1990+
// Added in FreeBSD 12.0
1991+
"EINTEGRITY" if Some(11) == freebsd_ver => true,
1992+
19891993
// This was increased to 97 in FreeBSD 12.2 and 13.
19901994
// https://github.com/freebsd/freebsd/
19911995
// commit/72a21ba0f62da5e86a1c0b462aeb3f5ff849a1b7
19921996
"ELAST" if Some(12) == freebsd_ver => true,
19931997

1998+
// Added in FreeBSD 12.0 (r331279)
1999+
"GRND_NONBLOCK" | "GRND_RANDOM" if Some(11) == freebsd_ver => true,
2000+
// Added in FreeBSD 13.0 (r356667)
2001+
"GRND_INSECURE" if Some(13) > freebsd_ver => true,
2002+
2003+
// Added in FreeBSD 12.1 (r343964 and r345228)
2004+
"PROC_ASLR_CTL" | "PROC_ASLR_STATUS" | "PROC_PROCCTL_MD_MIN"
2005+
if Some(11) == freebsd_ver =>
2006+
{
2007+
true
2008+
}
2009+
2010+
// Added in FreeBSD 13.0 (r349609)
2011+
"PROC_PROTMAX_CTL" | "PROC_PROTMAX_STATUS" if Some(13) > freebsd_ver => true,
2012+
2013+
// Added in in FreeBSD 13.0 (r367776 and r367287)
2014+
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,
2015+
19942016
_ => false,
19952017
}
19962018
});

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,26 +200,7 @@ cfg_if! {
200200
}
201201
}
202202

203-
pub const F_ADD_SEALS: ::c_int = 19;
204-
pub const F_GET_SEALS: ::c_int = 20;
205-
pub const F_SEAL_SEAL: ::c_int = 0x0001;
206-
pub const F_SEAL_SHRINK: ::c_int = 0x0002;
207-
pub const F_SEAL_GROW: ::c_int = 0x0004;
208-
pub const F_SEAL_WRITE: ::c_int = 0x0008;
209-
210-
pub const GRND_NONBLOCK: ::c_uint = 0x1;
211-
pub const GRND_RANDOM: ::c_uint = 0x2;
212-
213203
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
214-
215-
pub const PROC_ASLR_CTL: ::c_int = 13;
216-
pub const PROC_ASLR_STATUS: ::c_int = 14;
217-
218-
pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
219-
220-
pub const SO_DOMAIN: ::c_int = 0x1019;
221-
222-
pub const EINTEGRITY: ::c_int = 97;
223204
pub const ELAST: ::c_int = 97;
224205

225206
/// max length of devicename

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -213,32 +213,8 @@ cfg_if! {
213213
}
214214
}
215215

216-
pub const F_ADD_SEALS: ::c_int = 19;
217-
pub const F_GET_SEALS: ::c_int = 20;
218-
pub const F_SEAL_SEAL: ::c_int = 0x0001;
219-
pub const F_SEAL_SHRINK: ::c_int = 0x0002;
220-
pub const F_SEAL_GROW: ::c_int = 0x0004;
221-
pub const F_SEAL_WRITE: ::c_int = 0x0008;
222-
223-
pub const GRND_NONBLOCK: ::c_uint = 0x1;
224-
pub const GRND_RANDOM: ::c_uint = 0x2;
225-
226216
pub const RAND_MAX: ::c_int = 0x7fff_ffff;
227-
228-
pub const SO_DOMAIN: ::c_int = 0x1019;
229-
230-
pub const EINTEGRITY: ::c_int = 97;
231217
pub const ELAST: ::c_int = 97;
232-
pub const GRND_INSECURE: ::c_uint = 0x4;
233-
234-
pub const PROC_ASLR_CTL: ::c_int = 13;
235-
pub const PROC_ASLR_STATUS: ::c_int = 14;
236-
pub const PROC_PROTMAX_CTL: ::c_int = 15;
237-
pub const PROC_PROTMAX_STATUS: ::c_int = 16;
238-
pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
239-
240-
pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3;
241-
pub const SCM_CREDS2: ::c_int = 0x08;
242218

243219
pub const KF_TYPE_EVENTFD: ::c_int = 13;
244220

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ pub const ENOTCAPABLE: ::c_int = 93;
796796
pub const ECAPMODE: ::c_int = 94;
797797
pub const ENOTRECOVERABLE: ::c_int = 95;
798798
pub const EOWNERDEAD: ::c_int = 96;
799+
pub const EINTEGRITY: ::c_int = 97;
799800
pub const RLIMIT_NPTS: ::c_int = 11;
800801
pub const RLIMIT_SWAP: ::c_int = 12;
801802
pub const RLIMIT_KQUEUES: ::c_int = 13;
@@ -1072,6 +1073,8 @@ pub const MNT_UNION: ::c_int = 0x00000020;
10721073
pub const MNT_EXPUBLIC: ::c_int = 0x20000000;
10731074
pub const MNT_NONBUSY: ::c_int = 0x04000000;
10741075

1076+
pub const SCM_CREDS2: ::c_int = 0x08;
1077+
10751078
pub const SO_BINTIME: ::c_int = 0x2000;
10761079
pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
10771080
pub const SO_NO_DDP: ::c_int = 0x8000;
@@ -1085,9 +1088,11 @@ pub const SO_SETFIB: ::c_int = 0x1014;
10851088
pub const SO_USER_COOKIE: ::c_int = 0x1015;
10861089
pub const SO_PROTOCOL: ::c_int = 0x1016;
10871090
pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
1091+
pub const SO_DOMAIN: ::c_int = 0x1019;
10881092
pub const SO_VENDOR: ::c_int = 0x80000000;
10891093

10901094
pub const LOCAL_CREDS: ::c_int = 2;
1095+
pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3;
10911096
pub const LOCAL_CONNWAIT: ::c_int = 4;
10921097
pub const LOCAL_VENDOR: ::c_int = SO_VENDOR;
10931098

@@ -1136,8 +1141,13 @@ pub const PROC_TRAPCAP_CTL: ::c_int = 9;
11361141
pub const PROC_TRAPCAP_STATUS: ::c_int = 10;
11371142
pub const PROC_PDEATHSIG_CTL: ::c_int = 11;
11381143
pub const PROC_PDEATHSIG_STATUS: ::c_int = 12;
1144+
pub const PROC_ASLR_CTL: ::c_int = 13;
1145+
pub const PROC_ASLR_STATUS: ::c_int = 14;
1146+
pub const PROC_PROTMAX_CTL: ::c_int = 15;
1147+
pub const PROC_PROTMAX_STATUS: ::c_int = 16;
11391148
pub const PROC_STACKGAP_CTL: ::c_int = 17;
11401149
pub const PROC_STACKGAP_STATUS: ::c_int = 18;
1150+
pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
11411151

11421152
pub const AF_SLOW: ::c_int = 33;
11431153
pub const AF_SCLUSTER: ::c_int = 34;
@@ -1604,14 +1614,28 @@ pub const UF_READONLY: ::c_ulong = 0x00001000;
16041614
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
16051615
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
16061616

1617+
// fcntl commands
1618+
pub const F_ADD_SEALS: ::c_int = 19;
1619+
pub const F_DUP2FD: ::c_int = 10;
1620+
pub const F_DUP2FD_CLOEXEC: ::c_int = 18;
1621+
pub const F_GET_SEALS: ::c_int = 20;
16071622
pub const F_OGETLK: ::c_int = 7;
16081623
pub const F_OSETLK: ::c_int = 8;
16091624
pub const F_OSETLKW: ::c_int = 9;
1610-
pub const F_DUP2FD: ::c_int = 10;
1611-
pub const F_SETLK_REMOTE: ::c_int = 14;
1612-
pub const F_READAHEAD: ::c_int = 15;
16131625
pub const F_RDAHEAD: ::c_int = 16;
1614-
pub const F_DUP2FD_CLOEXEC: ::c_int = 18;
1626+
pub const F_READAHEAD: ::c_int = 15;
1627+
pub const F_SETLK_REMOTE: ::c_int = 14;
1628+
1629+
// for use with F_ADD_SEALS
1630+
pub const F_SEAL_GROW: ::c_int = 4;
1631+
pub const F_SEAL_SEAL: ::c_int = 1;
1632+
pub const F_SEAL_SHRINK: ::c_int = 2;
1633+
pub const F_SEAL_WRITE: ::c_int = 8;
1634+
1635+
// For getrandom()
1636+
pub const GRND_NONBLOCK: ::c_uint = 0x1;
1637+
pub const GRND_RANDOM: ::c_uint = 0x2;
1638+
pub const GRND_INSECURE: ::c_uint = 0x4;
16151639

16161640
// For realhostname* api
16171641
pub const HOSTNAME_FOUND: ::c_int = 0;

0 commit comments

Comments
 (0)