summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-12-12 18:02:59 +0000
committerbors <bors@rust-lang.org>2021-12-12 18:02:59 +0000
commit18bfd17b15f0fc05728c711c1a9a4a862810a76d (patch)
treec2dd02547fd6108ce9a503e0ef99ccf40bd99787
parentf42fe9a349300d4a07ba2ee8df4475005e1a5ef7 (diff)
parentda089ce64faa83ac58f29795dd2db0bc3c0c14ba (diff)
downloadrust-libc-18bfd17b15f0fc05728c711c1a9a4a862810a76d.tar.gz
Auto merge of #2589 - devnexen:sockcred2_fbsd_fix_proposal, r=Amanieu
freebsd proposal to move sockcred2 usage in the root mod while ignori… …ng it for FreeBSD 12.
-rw-r--r--libc-test/build.rs6
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs22
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs22
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs20
4 files changed, 26 insertions, 44 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index fcd6ad6137..c9f3211063 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2196,6 +2196,9 @@ fn test_freebsd(target: &str) {
// `ptrace_coredump` introduced in FreeBSD 14.
"ptrace_coredump" if Some(14) > freebsd_ver => true,
+ // `sockcred2` is not available in FreeBSD 12.
+ "sockcred2" if Some(13) > freebsd_ver => true,
+
_ => false,
}
});
@@ -2233,6 +2236,9 @@ fn test_freebsd(target: &str) {
true
}
+ // This is not available in FreeBSD 12.
+ "SOCKCRED2SIZE" if Some(13) > freebsd_ver => true,
+
_ => false,
}
});
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
index ee8be8401a..cc92b17501 100644
--- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
@@ -30,17 +30,6 @@ s! {
pub ext: [u64; 4],
}
- pub struct sockcred2 {
- pub sc_version: ::c_int,
- pub sc_pid: ::pid_t,
- pub sc_uid: ::uid_t,
- pub sc_euid: ::uid_t,
- pub sc_gid: ::gid_t,
- pub sc_egid: ::gid_t,
- pub sc_ngroups: ::c_int,
- pub sc_groups: [::gid_t; 1],
- }
-
pub struct kvm_page {
pub kp_version: ::u_int,
pub kp_paddr: ::kpaddr_t,
@@ -479,17 +468,6 @@ pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4;
pub const MINCORE_SUPER: ::c_int = 0x20;
-f! {
- pub fn SOCKCRED2SIZE(ngrps: usize) -> usize {
- let ngrps = if ngrps > 0 {
- ngrps - 1
- } else {
- 0
- };
- ::mem::size_of::<sockcred2>() + ::mem::size_of::<::gid_t>() * ngrps
- }
-}
-
extern "C" {
pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int;
pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int;
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
index 56269f7e8e..56b6412b46 100644
--- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
@@ -30,17 +30,6 @@ s! {
pub ext: [u64; 4],
}
- pub struct sockcred2 {
- pub sc_version: ::c_int,
- pub sc_pid: ::pid_t,
- pub sc_uid: ::uid_t,
- pub sc_euid: ::uid_t,
- pub sc_gid: ::gid_t,
- pub sc_egid: ::gid_t,
- pub sc_ngroups: ::c_int,
- pub sc_groups: [::gid_t; 1],
- }
-
pub struct kvm_page {
pub kp_version: ::u_int,
pub kp_paddr: ::kpaddr_t,
@@ -479,17 +468,6 @@ pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4;
pub const MINCORE_SUPER: ::c_int = 0x60;
-f! {
- pub fn SOCKCRED2SIZE(ngrps: usize) -> usize {
- let ngrps = if ngrps > 0 {
- ngrps - 1
- } else {
- 0
- };
- ::mem::size_of::<sockcred2>() + ::mem::size_of::<::gid_t>() * ngrps
- }
-}
-
extern "C" {
pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int;
pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int;
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index f87a5cf0d9..5ac41cf25c 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -945,6 +945,17 @@ s! {
pub generation: ::c_long,
pub numdevs: ::c_int,
}
+
+ pub struct sockcred2 {
+ pub sc_version: ::c_int,
+ pub sc_pid: ::pid_t,
+ pub sc_uid: ::uid_t,
+ pub sc_euid: ::uid_t,
+ pub sc_gid: ::gid_t,
+ pub sc_egid: ::gid_t,
+ pub sc_ngroups: ::c_int,
+ pub sc_groups: [::gid_t; 1],
+ }
}
s_no_extra_traits! {
@@ -3701,6 +3712,15 @@ f! {
let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits);
0 != cpuset.__bits[idx] & (1 << offset)
}
+
+ pub fn SOCKCRED2SIZE(ngrps: usize) -> usize {
+ let ngrps = if ngrps > 0 {
+ ngrps - 1
+ } else {
+ 0
+ };
+ ::mem::size_of::<sockcred2>() + ::mem::size_of::<::gid_t>() * ngrps
+ }
}
safe_f! {