Skip to content

Commit

Permalink
Add DragonFlyBSD kinfo_proc and kinfo_lwp structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Freaky committed May 7, 2022
1 parent 78d6835 commit 2a11ec2
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libc-test/semver/dragonfly.txt
Expand Up @@ -1315,6 +1315,8 @@ kevent
killpg
kinfo_cputime
kinfo_file
kinfo_lwp
kinfo_proc
kqueue
labs
lastlog
Expand Down
103 changes: 103 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Expand Up @@ -32,6 +32,8 @@ pub type pthread_barrierattr_t = ::c_int;
pub type pthread_barrier_t = ::uintptr_t;
pub type pthread_spinlock_t = ::uintptr_t;

pub type segsz_t = usize;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum sem {}
impl ::Copy for sem {}
Expand All @@ -41,6 +43,24 @@ impl ::Clone for sem {
}
}

e!{
#[repr(u32)]
pub enum lwpstat {
LSRUN = 1,
LSSTOP = 2,
LSSLEEP = 3,
}

#[repr(u32)]
pub enum procstat {
SIDL = 1,
SACTIVE = 2,
SSTOP = 3,
SZOMB = 4,
SCORE = 5,
}
}

s! {
pub struct kevent {
pub ident: ::uintptr_t,
Expand Down Expand Up @@ -238,6 +258,84 @@ s! {
pub cp_msg: [::c_char; 32],
}

pub struct kinfo_lwp {
pub kl_pid: ::pid_t,
pub kl_tid: ::lwpid_t,
pub kl_flags: ::c_int,
pub kl_stat: ::lwpstat,
pub kl_lock: ::c_int,
pub kl_tdflags: ::c_int,
pub kl_mpcount: ::c_int,
pub kl_prio: ::c_int,
pub kl_tdprio: ::c_int,
pub kl_rtprio: ::rtprio,
pub kl_uticks: u64,
pub kl_sticks: u64,
pub kl_iticks: u64,
pub kl_cpticks: u64,
pub kl_pctcpu: ::c_uint,
pub kl_slptime: ::c_uint,
pub kl_origcpu: ::c_int,
pub kl_estcpu: ::c_int,
pub kl_cpuid: ::c_int,
pub kl_ru: ::rusage,
pub kl_siglist: ::sigset_t,
pub kl_sigmask: ::sigset_t,
pub kl_wchan: ::uintptr_t,
pub kl_wmesg: [::c_char; 9],
pub kl_comm: [::c_char; MAXCOMLEN+1],
}

pub struct kinfo_proc {
pub kp_paddr: ::uintptr_t,
pub kp_flags: ::c_int,
pub kp_stat: ::procstat,
pub kp_lock: ::c_int,
pub kp_acflag: ::c_int,
pub kp_traceflag: ::c_int,
pub kp_fd: ::uintptr_t,
pub kp_siglist: ::sigset_t,
pub kp_sigignore: ::sigset_t,
pub kp_sigcatch: ::sigset_t,
pub kp_sigflag: ::c_int,
pub kp_start: ::timeval,
pub kp_comm: [::c_char; MAXCOMLEN+1],
pub kp_uid: ::uid_t,
pub kp_ngroups: ::c_short,
pub kp_groups: [::gid_t; NGROUPS],
pub kp_ruid: ::uid_t,
pub kp_svuid: ::uid_t,
pub kp_rgid: ::gid_t,
pub kp_svgid: ::gid_t,
pub kp_pid: ::pid_t,
pub kp_ppid: ::pid_t,
pub kp_pgid: ::pid_t,
pub kp_jobc: ::c_int,
pub kp_sid: ::pid_t,
pub kp_login: [::c_char; 40], // MAXNAMELEN rounded up to the nearest sizeof(long)
pub kp_tdev: ::dev_t,
pub kp_tpgid: ::pid_t,
pub kp_tsid: ::pid_t,
pub kp_exitstat: ::c_ushort,
pub kp_nthreads: ::c_int,
pub kp_nice: ::c_int,
pub kp_swtime: ::c_uint,
pub kp_vm_map_size: ::size_t,
pub kp_vm_rssize: ::segsz_t,
pub kp_vm_swrss: ::segsz_t,
pub kp_vm_tsize: ::segsz_t,
pub kp_vm_dsize: ::segsz_t,
pub kp_vm_ssize: ::segsz_t,
pub kp_vm_prssize: ::c_uint,
pub kp_jailid: ::c_int,
pub kp_ru: ::rusage,
pub kp_cru: ::rusage,
pub kp_auxflags: ::c_int,
pub kp_lwp: ::kinfo_lwp,
pub kp_ktaddr: ::uintptr_t,
kp_spare: [::c_int; 2],
}

pub struct cpuctl_msr_args_t {
pub msr: ::c_int,
pub data: u64,
Expand Down Expand Up @@ -1348,6 +1446,11 @@ pub const UTIME_NOW: c_long = -1;

pub const MINCORE_SUPER: ::c_int = 0x20;

// kinfo_proc constants
pub const MAXCOMLEN: usize = 16;
pub const MAXLOGNAME: usize = 33;
pub const NGROUPS: usize = 16;

const_fn! {
{const} fn _CMSG_ALIGN(n: usize) -> usize {
(n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1)
Expand Down

0 comments on commit 2a11ec2

Please sign in to comment.