1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Partial port of `OpenBSDMachine.c` — the OpenBSD per-host `Machine`.
//!
//! Ported here (operate on the base [`Machine`], so no unported substrate
//! is needed):
//! - `Machine_getCPUPhysicalCoreID` (`OpenBSDMachine.c:296`)
//! - `Machine_getCPUThreadIndex` (`OpenBSDMachine.c:302`)
//!
//! Still `todo!()` and blocked on unported substrate:
//! - `Machine_isCPUonline` reads `OpenBSDMachine.cpuData[id + 1].online`, so
//! it needs the `OpenBSDMachine` struct modeled.
//! - the `OpenBSDMachine` struct plus `OpenBSDMachine_updateCPUcount` /
//! `_scanMemoryInfo` / `_scanCPUTime` / `getKernelCPUTimes` /
//! `kernelCPUTimesToHtop` need the `hw.ncpu`/`kern.cp_time2` sysctl scan.
//! - `Machine_scan` / `Machine_new` / `Machine_delete` additionally need
//! `Machine_init` / `Machine_done` (still stubs in `machine.rs`) and
//! `kvm_openfiles`/`kvm_close` FFI.
use crateMachine;
/// TODO: port of `static void OpenBSDMachine_updateCPUcount(OpenBSDMachine*
/// this)` from `OpenBSDMachine.c:34`. Blocked: needs the `OpenBSDMachine`
/// struct and the `hw.ncpu`/`hw.ncpuonline` sysctls.
/// TODO: port of `Machine* Machine_new(UsersTable* usersTable, uid_t userId)`
/// from `OpenBSDMachine.c:91`. Blocked: needs `Machine_init` (stub in
/// `machine.rs`), the `OpenBSDMachine` struct and `kvm_openfiles` FFI.
/// TODO: port of `void Machine_delete(Machine* super)` from
/// `OpenBSDMachine.c:124`. Blocked: needs `Machine_done` (stub in
/// `machine.rs`), the `OpenBSDMachine` struct and `kvm_close` FFI.
/// TODO: port of `static void OpenBSDMachine_scanMemoryInfo(Machine* super)`
/// from `OpenBSDMachine.c:135`. Blocked: needs the `OpenBSDMachine` struct and
/// the `vm.uvmexp`/`bcstats` sysctl scan.
/// TODO: port of `static void getKernelCPUTimes(int cpuId, u_int64_t* times)`
/// from `OpenBSDMachine.c:193`. Blocked: needs the per-CPU `kern.cp_time2`
/// sysctl scan.
/// TODO: port of `static void kernelCPUTimesToHtop(const u_int64_t* times,
/// CPUData* cpu)` from `OpenBSDMachine.c:201`. Blocked: needs the
/// `OpenBSDMachine` `CPUData` struct.
/// TODO: port of `static void OpenBSDMachine_scanCPUTime(Machine* super)` from
/// `OpenBSDMachine.c:238`. Blocked: needs the `OpenBSDMachine` scan helpers
/// above.
/// TODO: port of `void Machine_scan(Machine* super)` from
/// `OpenBSDMachine.c:281`. Blocked: needs the `OpenBSDMachine` scan helpers
/// above.
/// TODO: port of `bool Machine_isCPUonline(const Machine* super, unsigned int
/// id)` from `OpenBSDMachine.c:289`. Blocked: reads
/// `OpenBSDMachine.cpuData[id + 1].online`, so it needs the `OpenBSDMachine`
/// struct modeled.
/// Port of `int Machine_getCPUPhysicalCoreID(const Machine* host, unsigned int
/// id)` (`OpenBSDMachine.c:296`).
/// Port of `int Machine_getCPUThreadIndex(const Machine* host, unsigned int
/// id)` (`OpenBSDMachine.c:302`).