Skip to content

Commit dbe3c5a

Browse files
committed
Add DragonFlyBSD kinfo_proc and kinfo_lwp structs
1 parent 78d6835 commit dbe3c5a

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

libc-test/semver/dragonfly.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,8 @@ kevent
13151315
killpg
13161316
kinfo_cputime
13171317
kinfo_file
1318+
kinfo_lwp
1319+
kinfo_proc
13181320
kqueue
13191321
labs
13201322
lastlog

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub type pthread_barrierattr_t = ::c_int;
3232
pub type pthread_barrier_t = ::uintptr_t;
3333
pub type pthread_spinlock_t = ::uintptr_t;
3434

35+
pub type segsz_t = usize;
36+
3537
#[cfg_attr(feature = "extra_traits", derive(Debug))]
3638
pub enum sem {}
3739
impl ::Copy for sem {}
@@ -41,6 +43,24 @@ impl ::Clone for sem {
4143
}
4244
}
4345

46+
e! {
47+
#[repr(u32)]
48+
pub enum lwpstat {
49+
LSRUN = 1,
50+
LSSTOP = 2,
51+
LSSLEEP = 3,
52+
}
53+
54+
#[repr(u32)]
55+
pub enum procstat {
56+
SIDL = 1,
57+
SACTIVE = 2,
58+
SSTOP = 3,
59+
SZOMB = 4,
60+
SCORE = 5,
61+
}
62+
}
63+
4464
s! {
4565
pub struct kevent {
4666
pub ident: ::uintptr_t,
@@ -238,6 +258,84 @@ s! {
238258
pub cp_msg: [::c_char; 32],
239259
}
240260

261+
pub struct kinfo_lwp {
262+
pub kl_pid: ::pid_t,
263+
pub kl_tid: ::lwpid_t,
264+
pub kl_flags: ::c_int,
265+
pub kl_stat: ::lwpstat,
266+
pub kl_lock: ::c_int,
267+
pub kl_tdflags: ::c_int,
268+
pub kl_mpcount: ::c_int,
269+
pub kl_prio: ::c_int,
270+
pub kl_tdprio: ::c_int,
271+
pub kl_rtprio: ::rtprio,
272+
pub kl_uticks: u64,
273+
pub kl_sticks: u64,
274+
pub kl_iticks: u64,
275+
pub kl_cpticks: u64,
276+
pub kl_pctcpu: ::c_uint,
277+
pub kl_slptime: ::c_uint,
278+
pub kl_origcpu: ::c_int,
279+
pub kl_estcpu: ::c_int,
280+
pub kl_cpuid: ::c_int,
281+
pub kl_ru: ::rusage,
282+
pub kl_siglist: ::sigset_t,
283+
pub kl_sigmask: ::sigset_t,
284+
pub kl_wchan: ::uintptr_t,
285+
pub kl_wmesg: [::c_char; 9],
286+
pub kl_comm: [::c_char; MAXCOMLEN+1],
287+
}
288+
289+
pub struct kinfo_proc {
290+
pub kp_paddr: ::uintptr_t,
291+
pub kp_flags: ::c_int,
292+
pub kp_stat: ::procstat,
293+
pub kp_lock: ::c_int,
294+
pub kp_acflag: ::c_int,
295+
pub kp_traceflag: ::c_int,
296+
pub kp_fd: ::uintptr_t,
297+
pub kp_siglist: ::sigset_t,
298+
pub kp_sigignore: ::sigset_t,
299+
pub kp_sigcatch: ::sigset_t,
300+
pub kp_sigflag: ::c_int,
301+
pub kp_start: ::timeval,
302+
pub kp_comm: [::c_char; MAXCOMLEN+1],
303+
pub kp_uid: ::uid_t,
304+
pub kp_ngroups: ::c_short,
305+
pub kp_groups: [::gid_t; NGROUPS],
306+
pub kp_ruid: ::uid_t,
307+
pub kp_svuid: ::uid_t,
308+
pub kp_rgid: ::gid_t,
309+
pub kp_svgid: ::gid_t,
310+
pub kp_pid: ::pid_t,
311+
pub kp_ppid: ::pid_t,
312+
pub kp_pgid: ::pid_t,
313+
pub kp_jobc: ::c_int,
314+
pub kp_sid: ::pid_t,
315+
pub kp_login: [::c_char; 40], // MAXNAMELEN rounded up to the nearest sizeof(long)
316+
pub kp_tdev: ::dev_t,
317+
pub kp_tpgid: ::pid_t,
318+
pub kp_tsid: ::pid_t,
319+
pub kp_exitstat: ::c_ushort,
320+
pub kp_nthreads: ::c_int,
321+
pub kp_nice: ::c_int,
322+
pub kp_swtime: ::c_uint,
323+
pub kp_vm_map_size: ::size_t,
324+
pub kp_vm_rssize: ::segsz_t,
325+
pub kp_vm_swrss: ::segsz_t,
326+
pub kp_vm_tsize: ::segsz_t,
327+
pub kp_vm_dsize: ::segsz_t,
328+
pub kp_vm_ssize: ::segsz_t,
329+
pub kp_vm_prssize: ::c_uint,
330+
pub kp_jailid: ::c_int,
331+
pub kp_ru: ::rusage,
332+
pub kp_cru: ::rusage,
333+
pub kp_auxflags: ::c_int,
334+
pub kp_lwp: ::kinfo_lwp,
335+
pub kp_ktaddr: ::uintptr_t,
336+
kp_spare: [::c_int; 2],
337+
}
338+
241339
pub struct cpuctl_msr_args_t {
242340
pub msr: ::c_int,
243341
pub data: u64,
@@ -1348,6 +1446,11 @@ pub const UTIME_NOW: c_long = -1;
13481446

13491447
pub const MINCORE_SUPER: ::c_int = 0x20;
13501448

1449+
// kinfo_proc constants
1450+
pub const MAXCOMLEN: usize = 16;
1451+
pub const MAXLOGNAME: usize = 33;
1452+
pub const NGROUPS: usize = 16;
1453+
13511454
const_fn! {
13521455
{const} fn _CMSG_ALIGN(n: usize) -> usize {
13531456
(n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1)

0 commit comments

Comments
 (0)