Add cr_pid to FreeBSD xucred - an unreleased addition in FreeBSD 13
definition: https://svnweb.freebsd.org/base/head/sys/sys/ucred.h?view=markup#l85 manpage: https://www.freebsd.org/cgi/man.cgi?query=unix&sektion=0&manpath=FreeBSD+13-current&format=html Continue comparing and hashing __cr_unused1 for backwards compatibility.
This commit is contained in:
parent
fe4be350a8
commit
3f62e51d24
|
@ -1821,6 +1821,9 @@ fn test_freebsd(target: &str) {
|
||||||
});
|
});
|
||||||
|
|
||||||
cfg.skip_struct(move |ty| {
|
cfg.skip_struct(move |ty| {
|
||||||
|
if ty.starts_with("__c_anonymous_") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
match ty {
|
match ty {
|
||||||
// `mmsghdr` is not available in FreeBSD 10
|
// `mmsghdr` is not available in FreeBSD 10
|
||||||
"mmsghdr" if Some(10) == freebsd_ver => true,
|
"mmsghdr" if Some(10) == freebsd_ver => true,
|
||||||
|
@ -1898,6 +1901,9 @@ fn test_freebsd(target: &str) {
|
||||||
("Elf32_Phdr", "p_type") => true,
|
("Elf32_Phdr", "p_type") => true,
|
||||||
("Elf64_Phdr", "p_type") => true,
|
("Elf64_Phdr", "p_type") => true,
|
||||||
|
|
||||||
|
// not available until FreeBSD 12, and is an anonymous union there.
|
||||||
|
("xucred", "cr_pid__c_anonymous_union") => true,
|
||||||
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -171,6 +171,14 @@ s! {
|
||||||
pub sdl_route: [::c_ushort; 16],
|
pub sdl_route: [::c_ushort; 16],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct xucred {
|
||||||
|
pub cr_version: ::c_uint,
|
||||||
|
pub cr_uid: ::uid_t,
|
||||||
|
pub cr_ngroups: ::c_short,
|
||||||
|
pub cr_groups: [::gid_t; 16],
|
||||||
|
__cr_unused1: *mut ::c_void,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct stack_t {
|
pub struct stack_t {
|
||||||
pub ss_sp: *mut ::c_char,
|
pub ss_sp: *mut ::c_char,
|
||||||
pub ss_size: ::size_t,
|
pub ss_size: ::size_t,
|
||||||
|
@ -238,7 +246,6 @@ s_no_extra_traits! {
|
||||||
pub sigev_value: ::sigval,
|
pub sigev_value: ::sigval,
|
||||||
__unused3: *mut ::c_void //actually a function pointer
|
__unused3: *mut ::c_void //actually a function pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
|
|
|
@ -135,6 +135,23 @@ s_no_extra_traits! {
|
||||||
pub __ut_spare: [::c_char; 64],
|
pub __ut_spare: [::c_char; 64],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
pub union __c_anonymous_cr_pid {
|
||||||
|
__cr_unused: *mut ::c_void,
|
||||||
|
pub cr_pid: ::pid_t,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct xucred {
|
||||||
|
pub cr_version: ::c_uint,
|
||||||
|
pub cr_uid: ::uid_t,
|
||||||
|
pub cr_ngroups: ::c_short,
|
||||||
|
pub cr_groups: [::gid_t; 16],
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
pub cr_pid__c_anonymous_union: __c_anonymous_cr_pid,
|
||||||
|
#[cfg(not(libc_union))]
|
||||||
|
__cr_unused1: *mut ::c_void,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct sockaddr_dl {
|
pub struct sockaddr_dl {
|
||||||
pub sdl_len: ::c_uchar,
|
pub sdl_len: ::c_uchar,
|
||||||
pub sdl_family: ::c_uchar,
|
pub sdl_family: ::c_uchar,
|
||||||
|
@ -217,6 +234,73 @@ cfg_if! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
impl PartialEq for __c_anonymous_cr_pid {
|
||||||
|
fn eq(&self, other: &__c_anonymous_cr_pid) -> bool {
|
||||||
|
unsafe { self.cr_pid == other.cr_pid}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
impl Eq for __c_anonymous_cr_pid {}
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
impl ::fmt::Debug for __c_anonymous_cr_pid {
|
||||||
|
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||||
|
f.debug_struct("cr_pid")
|
||||||
|
.field("cr_pid", unsafe { &self.cr_pid })
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
impl ::hash::Hash for __c_anonymous_cr_pid {
|
||||||
|
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
unsafe { self.cr_pid.hash(state) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for xucred {
|
||||||
|
fn eq(&self, other: &xucred) -> bool {
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
let equal_cr_pid = self.cr_pid__c_anonymous_union
|
||||||
|
== other.cr_pid__c_anonymous_union;
|
||||||
|
#[cfg(not(libc_union))]
|
||||||
|
let equal_cr_pid = self.__cr_unused1 == other.__cr_unused1;
|
||||||
|
|
||||||
|
self.cr_version == other.cr_version
|
||||||
|
&& self.cr_uid == other.cr_uid
|
||||||
|
&& self.cr_ngroups == other.cr_ngroups
|
||||||
|
&& self.cr_groups == other.cr_groups
|
||||||
|
&& equal_cr_pid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl Eq for xucred {}
|
||||||
|
impl ::fmt::Debug for xucred {
|
||||||
|
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
|
||||||
|
let mut struct_formatter = f.debug_struct("xucred");
|
||||||
|
struct_formatter.field("cr_version", &self.cr_version);
|
||||||
|
struct_formatter.field("cr_uid", &self.cr_uid);
|
||||||
|
struct_formatter.field("cr_ngroups", &self.cr_ngroups);
|
||||||
|
struct_formatter.field("cr_groups", &self.cr_groups);
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
struct_formatter.field(
|
||||||
|
"cr_pid__c_anonymous_union",
|
||||||
|
&self.cr_pid__c_anonymous_union
|
||||||
|
);
|
||||||
|
struct_formatter.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ::hash::Hash for xucred {
|
||||||
|
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
self.cr_version.hash(state);
|
||||||
|
self.cr_uid.hash(state);
|
||||||
|
self.cr_ngroups.hash(state);
|
||||||
|
self.cr_groups.hash(state);
|
||||||
|
#[cfg(libc_union)]
|
||||||
|
self.cr_pid__c_anonymous_union.hash(state);
|
||||||
|
#[cfg(not(libc_union))]
|
||||||
|
self.__cr_unused1.hash(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for sockaddr_dl {
|
impl PartialEq for sockaddr_dl {
|
||||||
fn eq(&self, other: &sockaddr_dl) -> bool {
|
fn eq(&self, other: &sockaddr_dl) -> bool {
|
||||||
self.sdl_len == other.sdl_len
|
self.sdl_len == other.sdl_len
|
||||||
|
|
|
@ -219,14 +219,6 @@ s! {
|
||||||
pub cmcred_groups: [::gid_t; CMGROUP_MAX],
|
pub cmcred_groups: [::gid_t; CMGROUP_MAX],
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct xucred {
|
|
||||||
pub cr_version: ::c_uint,
|
|
||||||
pub cr_uid: ::uid_t,
|
|
||||||
pub cr_ngroups: ::c_short,
|
|
||||||
pub cr_groups: [::gid_t; 16],
|
|
||||||
__cr_unused1: *mut ::c_void,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct rtprio {
|
pub struct rtprio {
|
||||||
pub type_: ::c_ushort,
|
pub type_: ::c_ushort,
|
||||||
pub prio: ::c_ushort,
|
pub prio: ::c_ushort,
|
||||||
|
|
Loading…
Reference in New Issue