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
//! Partial port of `UnsupportedMachine.c` — the fallback per-host `Machine`.
//!
//! Ported here:
//! - [`Machine_delete`] (`UnsupportedMachine.c:30`)
//! - `Machine_isCPUonline` (`UnsupportedMachine.c:36`)
//! - [`Machine_scan`] (`UnsupportedMachine.c:44`)
//! - `Machine_getCPUPhysicalCoreID` (`UnsupportedMachine.c:56`)
//! - `Machine_getCPUThreadIndex` (`UnsupportedMachine.c:62`)
//!
//! Still `todo!()` and blocked on unported substrate:
//! - `Machine_new` calls `Machine_init`, which `machine.rs` defines only under
//! `#[cfg(target_os = "macos")]`. This module is compiled on *all* targets
//! (the fallback platform is not cfg-gated), so calling the macos-only
//! `Machine_init` here would break every non-macos build. The native darwin
//! `Machine_new` port works because the darwin module is itself macos-gated.
use crate;
/// Port of `typedef struct UnsupportedMachine_` (`UnsupportedMachine.h`). The
/// fallback host embeds the base [`Machine`] and adds the two scalar memory
/// fields the fallback `Machine_scan` zeroes (`memory_t` == `u64`).
/// `#[repr(C)]` keeps `super_` at offset 0 so the C `(UnsupportedMachine*)super`
/// downcast is sound.
/// TODO: port of `Machine* Machine_new(UsersTable* usersTable, uid_t userId)`
/// from `UnsupportedMachine.c:18`. Blocked: the C body calls `Machine_init`,
/// which `machine.rs` defines only under `#[cfg(target_os = "macos")]`; this
/// fallback module is compiled on all targets, so the call cannot be issued
/// portably without breaking non-macos builds.
/// Port of `void Machine_delete(Machine* super)` (`UnsupportedMachine.c:30`).
/// C casts back to `UnsupportedMachine*`, runs [`Machine_done`] on the base,
/// then `free(this)`. The owning `Box<UnsupportedMachine>` is consumed:
/// `Machine_done` tears the base down and the `Box` drop reclaims the
/// allocation (the C `free`).
/// Port of `bool Machine_isCPUonline(const Machine* host, unsigned int id)`
/// (`UnsupportedMachine.c:36`). The fallback platform always reports online.
/// Port of `void Machine_scan(Machine* super)` (`UnsupportedMachine.c:44`). The
/// fallback platform reports one CPU and no memory/swap — every figure is
/// hard-zeroed each scan.
/// Port of `int Machine_getCPUPhysicalCoreID(const Machine* host, unsigned int
/// id)` (`UnsupportedMachine.c:56`).
/// Port of `int Machine_getCPUThreadIndex(const Machine* host, unsigned int
/// id)` (`UnsupportedMachine.c:62`).