Skip to content

Commit 100f3f2

Browse files
Add mac structs
1 parent ec1e5ab commit 100f3f2

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

libc-test/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ fn main() {
155155
if target.starts_with("x86") {
156156
cfg.header("crt_externs.h");
157157
}
158-
cfg.header("net/route.h");
158+
cfg.header("net/route.h");
159+
cfg.header("net/route.h");
160+
cfg.header("sys/proc_info.h");
159161
}
160162

161163
if bsdlike {

src/unix/bsd/apple/b32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
pub type c_long = i32;
44
pub type c_ulong = u32;
5+
pub type boolean_t = ::c_int;
56

67
s! {
78
pub struct pthread_attr_t {

src/unix/bsd/apple/b64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
pub type c_long = i64;
44
pub type c_ulong = u64;
5+
pub type boolean_t = ::c_uint;
56

67
s! {
78
pub struct pthread_attr_t {

src/unix/bsd/apple/mod.rs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,79 @@ s! {
337337
__unused1: *mut ::c_void, //actually a function pointer
338338
pub sigev_notify_attributes: *mut ::pthread_attr_t
339339
}
340+
341+
pub struct proc_taskinfo {
342+
pub pti_virtual_size: u64,
343+
pub pti_resident_size: u64,
344+
pub pti_total_user: u64,
345+
pub pti_total_system: u64,
346+
pub pti_threads_user: u64,
347+
pub pti_threads_system: u64,
348+
pub pti_policy: i32,
349+
pub pti_faults: i32,
350+
pub pti_pageins: i32,
351+
pub pti_cow_faults: i32,
352+
pub pti_messages_sent: i32,
353+
pub pti_messages_received: i32,
354+
pub pti_syscalls_mach: i32,
355+
pub pti_syscalls_unix: i32,
356+
pub pti_csw: i32,
357+
pub pti_threadnum: i32,
358+
pub pti_numrunning: i32,
359+
pub pti_priority: i32,
360+
}
361+
362+
pub struct proc_bsdinfo {
363+
pub pbi_flags: u32,
364+
pub pbi_status: u32,
365+
pub pbi_xstatus: u32,
366+
pub pbi_pid: u32,
367+
pub pbi_ppid: u32,
368+
pub pbi_uid: ::uid_t,
369+
pub pbi_gid: ::gid_t,
370+
pub pbi_ruid: ::uid_t,
371+
pub pbi_rgid: ::gid_t,
372+
pub pbi_svuid: ::uid_t,
373+
pub pbi_svgid: ::gid_t,
374+
pub rfu_1: u32,
375+
pub pbi_comm: [::c_char; MAXCOMLEN],
376+
pub pbi_name: [::c_char; 32], // MAXCOMLEN * 2, but macro isn't happy...
377+
pub pbi_nfiles: u32,
378+
pub pbi_pgid: u32,
379+
pub pbi_pjobc: u32,
380+
pub e_tdev: u32,
381+
pub e_tpgid: u32,
382+
pub pbi_nice: i32,
383+
pub pbi_start_tvsec: u64,
384+
pub pbi_start_tvusec: u64,
385+
}
386+
387+
pub struct proc_taskallinfo {
388+
pub pbsd: proc_bsdinfo,
389+
pub ptinfo: proc_taskinfo,
390+
}
391+
392+
pub struct proc_threadinfo {
393+
pub pth_user_time: u64,
394+
pub pth_system_time: u64,
395+
pub pth_cpu_usage: i32,
396+
pub pth_policy: i32,
397+
pub pth_run_state: i32,
398+
pub pth_flags: i32,
399+
pub pth_sleep_time: i32,
400+
pub pth_curpri: i32,
401+
pub pth_priority: i32,
402+
pub pth_maxpriority: i32,
403+
pub pth_name: [::c_char; MAXTHREADNAMESIZE],
404+
}
405+
406+
pub struct xsw_usage {
407+
pub xsu_total: u64,
408+
pub xsu_avail: u64,
409+
pub xsu_used: u64,
410+
pub xsu_pagesize: u32,
411+
pub xsu_encrypted: ::boolean_t,
412+
}
340413
}
341414

342415
pub const _UTX_USERSIZE: usize = 256;
@@ -1541,6 +1614,14 @@ pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020;
15411614
pub const NET_RT_IFLIST2: ::c_int = 0x0006;
15421615
pub const RTM_IFINFO2: ::c_int = 0x0012;
15431616

1617+
pub const KERN_PROCARGS2: ::c_int = 49;
1618+
1619+
pub const PROC_PIDTASKALLINFO: ::c_int = 2;
1620+
pub const PROC_PIDTASKINFO: ::c_int = 4;
1621+
pub const PROC_PIDTHREADINFO: ::c_int = 5;
1622+
pub const MAXCOMLEN: usize = 16;
1623+
pub const MAXTHREADNAMESIZE: usize = 64;
1624+
15441625
f! {
15451626
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
15461627
status >> 8

0 commit comments

Comments
 (0)