Skip to content

Commit

Permalink
Add more freebsd items
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Oct 19, 2021
1 parent 5b308d9 commit 9ab890d
Show file tree
Hide file tree
Showing 5 changed files with 532 additions and 14 deletions.
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

0 comments on commit 9ab890d

Please sign in to comment.