Skip to content

Commit

Permalink
Add struct ctl_info for Apple
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfried committed Jan 21, 2023
1 parent ad3ce34 commit 950827b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.rs
Expand Up @@ -83,6 +83,11 @@ fn main() {
println!("cargo:rustc-cfg=libc_non_exhaustive");
}

// Rust >= 1.47 supports long array:
if rustc_minor_ver >= 47 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_long_array");
}

if rustc_minor_ver >= 51 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_ptr_addr_of");
}
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/apple.txt
Expand Up @@ -266,6 +266,7 @@ CTLFLAG_RD
CTLFLAG_RW
CTLFLAG_SECURE
CTLFLAG_WR
CTLIOCGINFO
CTLTYPE
CTLTYPE_INT
CTLTYPE_NODE
Expand Down Expand Up @@ -1844,6 +1845,7 @@ copyfile
copyfile_flags_t
cpu_subtype_t
cpu_type_t
ctl_info
difftime
dirfd
disconnectx
Expand Down
8 changes: 8 additions & 0 deletions src/unix/bsd/apple/long_array.rs
@@ -0,0 +1,8 @@
s! {
pub struct ctl_info {
pub ctl_id: u32,
pub ctl_name: [::c_char; MAX_KCTL_NAME],
}
}

pub const MAX_KCTL_NAME: usize = 96;
9 changes: 9 additions & 0 deletions src/unix/bsd/apple/mod.rs
Expand Up @@ -3313,6 +3313,8 @@ pub const MINCORE_MODIFIED: ::c_int = 0x4;
pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8;
pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10;

pub const CTLIOCGINFO: c_ulong = 0xc0644e03;

//
// sys/netinet/in.h
// Protocols (RFC 1700)
Expand Down Expand Up @@ -5931,3 +5933,10 @@ cfg_if! {
// Unknown target_arch
}
}

cfg_if! {
if #[cfg(libc_long_array)] {
mod long_array;
pub use self::long_array::*;
}
}

0 comments on commit 950827b

Please sign in to comment.