Skip to content

Commit

Permalink
Merge #52
Browse files Browse the repository at this point in the history
52: Automated pull from `rust-lang/libc` r=pietroalbini a=github-actions[bot]

This PR pulls the following changes from the [`rust-lang/libc`](https://github.com/rust-lang/libc) repository:

* rust-lang/libc#3385
* rust-lang/libc#3386
* rust-lang/libc#3388
* rust-lang/libc#3381
* rust-lang/libc#3383
* rust-lang/libc#3384
* rust-lang/libc#3380
* rust-lang/libc#3352


Co-authored-by: Christian Duerr <chris.durr@phylum.io>
Co-authored-by: David Carlier <devnexen@gmail.com>
Co-authored-by: David CARLIER <devnexen@gmail.com>
Co-authored-by: Havard Eidnes <he@NetBSD.org>
Co-authored-by: bors <bors@rust-lang.org>
Co-authored-by: Артём Павлов [Artyom Pavlov] <newpavlov@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
7 people committed Oct 17, 2023
2 parents 099bf0b + a71506f commit d15c1ec
Show file tree
Hide file tree
Showing 41 changed files with 198 additions and 2 deletions.
15 changes: 15 additions & 0 deletions ferrocene/library/libc/libc-test/build.rs
Expand Up @@ -374,6 +374,7 @@ fn test_apple(target: &str) {
("vnode_info_path", "vip_path") => true,
("ifreq", "ifr_ifru") => true,
("ifkpi", "ifk_data") => true,
("ifconf", "ifc_ifcu") => true,
_ => false,
}
});
Expand Down Expand Up @@ -522,7 +523,19 @@ fn test_openbsd(target: &str) {
"sys/param.h",
}

cfg.skip_type(move |ty| {
if ty.starts_with("__c_anonymous_") {
return true;
}
match ty {
_ => false,
}
});

cfg.skip_struct(move |ty| {
if ty.starts_with("__c_anonymous_") {
return true;
}
match ty {
// FIXME: actually a union
"sigval" => true,
Expand Down Expand Up @@ -596,6 +609,8 @@ fn test_openbsd(target: &str) {
// conflicting with `p_type` macro from <resolve.h>.
("Elf32_Phdr", "p_type") => true,
("Elf64_Phdr", "p_type") => true,
// ifr_ifru is defined is an union
("ifreq", "ifr_ifru") => true,
_ => false,
}
});
Expand Down
2 changes: 2 additions & 0 deletions ferrocene/library/libc/libc-test/semver/apple.txt
Expand Up @@ -1883,6 +1883,7 @@ endpwent
endservent
endutxent
exchangedata
execvP
faccessat
fchdir
fchflags
Expand Down Expand Up @@ -1957,6 +1958,7 @@ if_freenameindex
if_msghdr
if_nameindex
ifaddrs
ifconf
ifkpi
ifreq
image_offset
Expand Down
2 changes: 2 additions & 0 deletions ferrocene/library/libc/libc-test/semver/dragonfly.txt
Expand Up @@ -1287,6 +1287,8 @@ eui64_aton
eui64_hostton
eui64_ntoa
eui64_ntohost
exect
execvP
exit_status
explicit_bzero
faccessat
Expand Down
2 changes: 2 additions & 0 deletions ferrocene/library/libc/libc-test/semver/freebsd.txt
Expand Up @@ -1770,6 +1770,8 @@ eui64_aton
eui64_hostton
eui64_ntoa
eui64_ntohost
exect
execvP
explicit_bzero
extattr_delete_fd
extattr_delete_file
Expand Down
1 change: 1 addition & 0 deletions ferrocene/library/libc/libc-test/semver/linux-gnu.txt
Expand Up @@ -31,6 +31,7 @@ BPF_FS_MAGIC
BTRFS_SUPER_MAGIC
CGROUP2_SUPER_MAGIC
CGROUP_SUPER_MAGIC
CLONE_NEWTIME
CODA_SUPER_MAGIC
CRAMFS_MAGIC
DEAD_PROCESS
Expand Down
1 change: 1 addition & 0 deletions ferrocene/library/libc/libc-test/semver/linux.txt
Expand Up @@ -1375,6 +1375,7 @@ MCAST_MSFILTER
MCAST_UNBLOCK_SOURCE
MCL_CURRENT
MCL_FUTURE
MCL_ONFAULT
MEMBARRIER_CMD_GLOBAL
MEMBARRIER_CMD_GLOBAL_EXPEDITED
MEMBARRIER_CMD_QUERY
Expand Down
1 change: 1 addition & 0 deletions ferrocene/library/libc/libc-test/semver/openbsd.txt
Expand Up @@ -1083,6 +1083,7 @@ if_freenameindex
if_msghdr
if_nameindex
ifaddrs
ifreq
in6_pktinfo
initgroups
ip_mreqn
Expand Down
56 changes: 55 additions & 1 deletion ferrocene/library/libc/src/unix/bsd/apple/mod.rs
Expand Up @@ -1129,6 +1129,15 @@ s! {
pub validattr: attribute_set_t,
pub nativeattr: attribute_set_t,
}

#[cfg_attr(libc_packedN, repr(packed(4)))]
pub struct ifconf {
pub ifc_len: ::c_int,
#[cfg(libc_union)]
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
#[cfg(not(libc_union))]
pub ifc_ifcu: *mut ifreq,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1464,6 +1473,14 @@ s_no_extra_traits! {
pub ifr_name: [::c_char; ::IFNAMSIZ],
#[cfg(libc_union)]
pub ifr_ifru: __c_anonymous_ifr_ifru,
#[cfg(not(libc_union))]
pub ifr_ifru: ::sockaddr,
}

#[cfg(libc_union)]
pub union __c_anonymous_ifc_ifcu {
pub ifcu_buf: *mut ::c_char,
pub ifcu_req: *mut ifreq,
}
}

Expand Down Expand Up @@ -2977,6 +2994,7 @@ cfg_if! {
impl PartialEq for ifreq {
fn eq(&self, other: &ifreq) -> bool {
self.ifr_name == other.ifr_name
&& self.ifr_ifru == other.ifr_ifru
}
}

Expand All @@ -2986,17 +3004,48 @@ cfg_if! {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ifreq")
.field("ifr_name", &self.ifr_name)
.field("ifr_ifru", &self.ifr_ifru)
.finish()
}
}

impl ::hash::Hash for ifreq {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.ifr_name.hash(state);
#[cfg(libc_union)]
self.ifr_ifru.hash(state);
}
}

#[cfg(libc_union)]
impl Eq for __c_anonymous_ifc_ifcu {}

#[cfg(libc_union)]
impl PartialEq for __c_anonymous_ifc_ifcu {
fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool {
unsafe {
self.ifcu_buf == other.ifcu_buf &&
self.ifcu_req == other.ifcu_req
}
}
}

#[cfg(libc_union)]
impl ::fmt::Debug for __c_anonymous_ifc_ifcu {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("ifc_ifcu")
.field("ifcu_buf", unsafe { &self.ifcu_buf })
.field("ifcu_req", unsafe { &self.ifcu_req })
.finish()
}
}

#[cfg(libc_union)]
impl ::hash::Hash for __c_anonymous_ifc_ifcu {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe { self.ifcu_buf.hash(state) };
unsafe { self.ifcu_req.hash(state) };
}
}
}
}

Expand Down Expand Up @@ -6347,6 +6396,11 @@ extern "C" {
dev: dev_t,
) -> ::c_int;
pub fn freadlink(fd: ::c_int, buf: *mut ::c_char, size: ::size_t) -> ::c_int;
pub fn execvP(
file: *const ::c_char,
search_path: *const ::c_char,
argv: *const *mut ::c_char,
) -> ::c_int;
}

pub unsafe fn mach_task_self() -> ::mach_port_t {
Expand Down
Expand Up @@ -967,6 +967,8 @@ s! {
pub ifc_len: ::c_int,
#[cfg(libc_union)]
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
#[cfg(not(libc_union))]
pub ifc_ifcu: *mut ifreq,
}

pub struct au_mask_t {
Expand Down
11 changes: 11 additions & 0 deletions ferrocene/library/libc/src/unix/bsd/freebsdlike/mod.rs
Expand Up @@ -1772,6 +1772,17 @@ extern "C" {
len: ::c_int,
) -> ::c_int;
pub fn reboot(howto: ::c_int) -> ::c_int;

pub fn exect(
path: *const ::c_char,
argv: *const *mut ::c_char,
envp: *const *mut ::c_char,
) -> ::c_int;
pub fn execvP(
file: *const ::c_char,
search_path: *const ::c_char,
argv: *const *mut ::c_char,
) -> ::c_int;
}

#[link(name = "rt")]
Expand Down
Expand Up @@ -10,7 +10,7 @@ type __pthread_spin_t = __cpu_simple_lock_nv_t;
pub type vm_size_t = ::uintptr_t; // FIXME: deprecated since long time
pub type lwpid_t = ::c_uint;
pub type shmatt_t = ::c_uint;
pub type cpuid_t = u64;
pub type cpuid_t = ::c_ulong;
pub type cpuset_t = _cpuset;
pub type pthread_spin_t = ::c_uchar;
pub type timer_t = ::c_int;
Expand Down
74 changes: 74 additions & 0 deletions ferrocene/library/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs
Expand Up @@ -533,6 +533,14 @@ s! {
pub key: *mut ::c_char,
pub data: *mut ::c_void,
}

pub struct ifreq {
pub ifr_name: [::c_char; ::IFNAMSIZ],
#[cfg(libc_union)]
pub ifr_ifru: __c_anonymous_ifr_ifru,
#[cfg(not(libc_union))]
pub ifr_ifru: ::sockaddr,
}
}

impl siginfo_t {
Expand Down Expand Up @@ -608,6 +616,18 @@ s_no_extra_traits! {
align: [::c_char; 160],
}

#[cfg(libc_union)]
pub union __c_anonymous_ifr_ifru {
pub ifru_addr: ::sockaddr,
pub ifru_dstaddr: ::sockaddr,
pub ifru_broadaddr: ::sockaddr,
pub ifru_flags: ::c_short,
pub ifru_metric: ::c_int,
pub ifru_vnetid: i64,
pub ifru_media: u64,
pub ifru_data: *mut ::c_char,
pub ifru_index: ::c_uint,
}
}

cfg_if! {
Expand Down Expand Up @@ -814,6 +834,60 @@ cfg_if! {
unsafe { self.align.hash(state) };
}
}

#[cfg(libc_union)]
impl PartialEq for __c_anonymous_ifr_ifru {
fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool {
unsafe {
self.ifru_addr == other.ifru_addr
&& self.ifru_dstaddr == other.ifru_dstaddr
&& self.ifru_broadaddr == other.ifru_broadaddr
&& self.ifru_flags == other.ifru_flags
&& self.ifru_metric == other.ifru_metric
&& self.ifru_vnetid == other.ifru_vnetid
&& self.ifru_media == other.ifru_media
&& self.ifru_data == other.ifru_data
&& self.ifru_index == other.ifru_index
}
}
}

#[cfg(libc_union)]
impl Eq for __c_anonymous_ifr_ifru {}

#[cfg(libc_union)]
impl ::fmt::Debug for __c_anonymous_ifr_ifru {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("__c_anonymous_ifr_ifru")
.field("ifru_addr", unsafe { &self.ifru_addr })
.field("ifru_dstaddr", unsafe { &self.ifru_dstaddr })
.field("ifru_broadaddr", unsafe { &self.ifru_broadaddr })
.field("ifru_flags", unsafe { &self.ifru_flags })
.field("ifru_metric", unsafe { &self.ifru_metric })
.field("ifru_vnetid", unsafe { &self.ifru_vnetid })
.field("ifru_media", unsafe { &self.ifru_media })
.field("ifru_data", unsafe { &self.ifru_data })
.field("ifru_index", unsafe { &self.ifru_index })
.finish()
}
}

#[cfg(libc_union)]
impl ::hash::Hash for __c_anonymous_ifr_ifru {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
self.ifru_addr.hash(state);
self.ifru_dstaddr.hash(state);
self.ifru_broadaddr.hash(state);
self.ifru_flags.hash(state);
self.ifru_metric.hash(state);
self.ifru_vnetid.hash(state);
self.ifru_media.hash(state);
self.ifru_data.hash(state);
self.ifru_index.hash(state);
}
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions ferrocene/library/libc/src/unix/linux_like/android/mod.rs
Expand Up @@ -1707,6 +1707,7 @@ pub const REG_BACKR: ::c_int = 1024;

pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const MCL_ONFAULT: ::c_int = 0x0004;

pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::tcflag_t = 0x00000800;
Expand Down
Expand Up @@ -341,6 +341,7 @@ pub const SOCK_DGRAM: ::c_int = 2;

pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const MCL_ONFAULT: ::c_int = 0x0004;

pub const POLLWRNORM: ::c_short = 0x100;
pub const POLLWRBAND: ::c_short = 0x200;
Expand Down
Expand Up @@ -290,6 +290,7 @@ pub const SOCK_DGRAM: ::c_int = 2;

pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const MCL_ONFAULT: ::c_int = 0x0004;

pub const POLLWRNORM: ::c_short = 0x100;
pub const POLLWRBAND: ::c_short = 0x200;
Expand Down
Expand Up @@ -293,6 +293,7 @@ pub const PTRACE_SYSEMU_SINGLESTEP: ::c_uint = 32;

pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const MCL_ONFAULT: ::c_int = 0x0004;

pub const POLLWRNORM: ::c_short = 0x100;
pub const POLLWRBAND: ::c_short = 0x200;
Expand Down
Expand Up @@ -719,6 +719,7 @@ pub const RTLD_NOLOAD: ::c_int = 0x8;

pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const MCL_ONFAULT: ::c_int = 0x0004;

pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
Expand Down
Expand Up @@ -293,6 +293,7 @@ pub const SOCK_DGRAM: ::c_int = 2;

pub const MCL_CURRENT: ::c_int = 0x2000;
pub const MCL_FUTURE: ::c_int = 0x4000;
pub const MCL_ONFAULT: ::c_int = 0x8000;

pub const POLLWRNORM: ::c_short = 0x100;
pub const POLLWRBAND: ::c_short = 0x200;
Expand Down
Expand Up @@ -393,6 +393,7 @@ pub const EISNAM: ::c_int = 120;
pub const EREMOTEIO: ::c_int = 121;
pub const MCL_CURRENT: ::c_int = 1;
pub const MCL_FUTURE: ::c_int = 2;
pub const MCL_ONFAULT: ::c_int = 4;
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const CBAUD: ::tcflag_t = 4111;
Expand Down
Expand Up @@ -363,6 +363,7 @@ pub const EREMOTEIO: ::c_int = 121;

pub const MCL_CURRENT: ::c_int = 0x2000;
pub const MCL_FUTURE: ::c_int = 0x4000;
pub const MCL_ONFAULT: ::c_int = 0x8000;

pub const SIGSTKSZ: ::size_t = 16384;
pub const MINSIGSTKSZ: ::size_t = 4096;
Expand Down
Expand Up @@ -507,6 +507,7 @@ pub const PTRACE_SYSEMU_SINGLESTEP: ::c_uint = 32;

pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const MCL_ONFAULT: ::c_int = 0x0004;

pub const POLLWRNORM: ::c_short = 0x100;
pub const POLLWRBAND: ::c_short = 0x200;
Expand Down

0 comments on commit d15c1ec

Please sign in to comment.