Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freebsd items #2451

Merged
merged 5 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Rust toolchain
# Should update the semverver revision in semver.sh if we touch nightly ver.
run: TOOLCHAIN=nightly-2021-07-23 sh ./ci/install-rust.sh
run: TOOLCHAIN=nightly-2021-09-30 sh ./ci/install-rust.sh
- name: Check breaking changes
run: sh ci/semver.sh linux

Expand All @@ -270,7 +270,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Rust toolchain
# Pin nightly version to make semverver compilable.
run: TOOLCHAIN=nightly-2021-07-23 sh ./ci/install-rust.sh
run: TOOLCHAIN=nightly-2021-09-30 sh ./ci/install-rust.sh
- name: Check breaking changes
run: sh ci/semver.sh macos

Expand Down
2 changes: 1 addition & 1 deletion ci/semver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi
rustup component add rustc-dev llvm-tools-preview

# Should update the nightly version in bors CI config if we touch this.
cargo install semverver --version=0.1.47
cargo install semverver --version=0.1.48

TARGETS=
case "${OS}" in
Expand Down
2 changes: 1 addition & 1 deletion libc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ default-features = false
[build-dependencies]
cc = "1.0.61"
# FIXME: Use fork ctest until the maintainer gets back.
ctest2 = "0.4"
ctest2 = "0.4.2"

[features]
default = [ "std" ]
Expand Down
26 changes: 26 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,7 @@ fn test_freebsd(target: &str) {
"sys/times.h",
"sys/timex.h",
"sys/types.h",
"kvm.h", // must be after "sys/types.h"
"sys/ucontext.h",
"sys/uio.h",
"sys/ktrace.h",
Expand Down Expand Up @@ -1991,6 +1992,16 @@ fn test_freebsd(target: &str) {
}
});

cfg.skip_type(move |ty| {
match ty {
// the struct "__kvm" is quite tricky to bind so since we only use a pointer to it
// for now, it doesn't matter too much...
"kvm_t" => true,

_ => false,
}
});

cfg.skip_struct(move |ty| {
if ty.starts_with("__c_anonymous_") {
return true;
Expand Down Expand Up @@ -2084,6 +2095,21 @@ fn test_freebsd(target: &str) {
// a_un field is a union
("Elf32_Auxinfo", "a_un") => true,
("Elf64_Auxinfo", "a_un") => true,

// FIXME: structs too complicated to bind for now...
("kinfo_proc", "ki_paddr") => true,
("kinfo_proc", "ki_addr") => true,
("kinfo_proc", "ki_tracep") => true,
("kinfo_proc", "ki_textvp") => true,
("kinfo_proc", "ki_fd") => true,
("kinfo_proc", "ki_vmspace") => true,
("kinfo_proc", "ki_pcb") => true,
("kinfo_proc", "ki_tdaddr") => true,
("kinfo_proc", "ki_pd") => true,

// We ignore this field because we needed to use a hack in order to make rust 1.19
// happy...
("kinfo_proc", "ki_sparestrings") => true,
_ => false,
}
});
Expand Down
19 changes: 11 additions & 8 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub type host_flavor_t = integer_t;
pub type host_info64_t = *mut integer_t;
pub type processor_flavor_t = ::c_int;
pub type thread_flavor_t = natural_t;
pub type thread_inspect_t = mach_port_t;
pub type thread_inspect_t = ::mach_port_t;
pub type policy_t = ::c_int;
pub type mach_vm_address_t = u64;
pub type mach_vm_offset_t = u64;
Expand Down Expand Up @@ -90,7 +90,7 @@ pub type thread_identifier_info_data_t = thread_identifier_info;
pub type thread_extended_info_t = *mut thread_extended_info;
pub type thread_extended_info_data_t = thread_extended_info;

pub type thread_t = mach_port_t;
pub type thread_t = ::mach_port_t;
pub type thread_policy_flavor_t = natural_t;
pub type thread_policy_t = *mut integer_t;
pub type thread_latency_qos_t = integer_t;
Expand All @@ -117,7 +117,7 @@ pub type vm_statistics_data_t = vm_statistics;
pub type vm_statistics64_t = *mut vm_statistics64;
pub type vm_statistics64_data_t = vm_statistics64;

pub type task_t = mach_port_t;
pub type task_t = ::mach_port_t;

pub type sysdir_search_path_enumeration_state = ::c_uint;

Expand Down Expand Up @@ -5270,11 +5270,14 @@ extern "C" {
out_processor_infoCnt: *mut mach_msg_type_number_t,
) -> ::kern_return_t;

pub static mut mach_task_self_: mach_port_t;
pub fn task_for_pid(host: mach_port_t, pid: ::pid_t, task: *mut mach_port_t)
-> ::kern_return_t;
pub static mut mach_task_self_: ::mach_port_t;
pub fn task_for_pid(
host: ::mach_port_t,
pid: ::pid_t,
task: *mut ::mach_port_t,
) -> ::kern_return_t;
pub fn task_info(
host: mach_port_t,
host: ::mach_port_t,
flavor: task_flavor_t,
task_info_out: task_info_t,
task_info_count: *mut mach_msg_type_number_t,
Expand All @@ -5299,7 +5302,7 @@ extern "C" {
pub static vm_page_size: vm_size_t;
}

pub unsafe fn mach_task_self() -> mach_port_t {
pub unsafe fn mach_task_self() -> ::mach_port_t {
mach_task_self_
}

Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ cfg_if! {

pub const ELAST: ::c_int = 96;
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
pub const KI_NSPARE_PTR: usize = 6;

extern "C" {
// Return type ::c_int was removed in FreeBSD 12
Expand Down
14 changes: 14 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ s! {
pub udata: *mut ::c_void,
pub ext: [u64; 4],
}

pub struct kvm_page {
pub version: ::c_uint,
pub paddr: ::c_ulong,
pub kmap_vaddr: ::c_ulong,
pub dmap_vaddr: ::c_ulong,
pub prot: ::vm_prot_t,
pub offset: ::u_long,
pub len: ::size_t,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -212,6 +222,10 @@ pub const SO_DOMAIN: ::c_int = 0x1019;
pub const EINTEGRITY: ::c_int = 97;
pub const ELAST: ::c_int = 97;

/// max length of devicename
pub const SPECNAMELEN: ::c_int = 63;
pub const KI_NSPARE_PTR: usize = 6;

extern "C" {
pub fn setgrent();
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
Expand Down
23 changes: 23 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub type nlink_t = u64;
pub type dev_t = u64;
pub type ino_t = ::c_ulong;
pub type shmatt_t = ::c_uint;
pub type kpaddr_t = u64;
pub type kssize_t = i64;

s! {
pub struct shmid_ds {
Expand Down Expand Up @@ -37,6 +39,16 @@ s! {
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,
pub kp_kmap_vaddr: ::kvaddr_t,
pub kp_dmap_vaddr: ::kvaddr_t,
pub kp_prot: ::vm_prot_t,
pub kp_offset: ::off_t,
pub kp_len: ::size_t,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -228,6 +240,12 @@ pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3;
pub const SCM_CREDS2: ::c_int = 0x08;

pub const KF_TYPE_EVENTFD: ::c_int = 13;

/// max length of devicename
pub const SPECNAMELEN: ::c_int = 255;
pub const KI_NSPARE_PTR: usize = 5;

f! {
pub fn SOCKCRED2SIZE(ngrps: usize) -> usize {
let ngrps = if ngrps > 0 {
Expand Down Expand Up @@ -269,6 +287,11 @@ extern "C" {
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
}

#[link(name = "kvm")]
extern "C" {
pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t;
}

cfg_if! {
if #[cfg(any(target_arch = "x86_64",
target_arch = "aarch64"))] {
Expand Down
Loading