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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//! Port of `unsupported/Platform.c` — htop's portable fallback platform, used
//! when no OS-specific backend matches. Every hook returns a fixed/degenerate
//! value, so the whole file is self-contained (no platform FFI) and compiles
//! on every target.
//!
//! Ported here:
//! - `Platform_init` (`Platform.c:92`)
//! - `Platform_done` (`Platform.c:97`)
//! - `Platform_setBindings` (`Platform.c:101`)
//! - `Platform_getUptime` (`Platform.c:106`)
//! - `Platform_getLoadAverage` (`Platform.c:110`)
//! - `Platform_getMaxPid` (`Platform.c:116`)
//! - `Platform_getProcessEnv` (`Platform.c:144`)
//! - `Platform_getFileDescriptors` (`Platform.c:154`)
//! - `Platform_getDiskIO` (`Platform.c:159`)
//! - `Platform_getNetworkIO` (`Platform.c:164`)
//! - `Platform_getBattery` (`Platform.c:169`)
//! - `Platform_setCPUValues` (`Platform.c:120`)
//! - `Platform_setMemoryValues` (`Platform.c:132`)
//! - `Platform_setSwapValues` (`Platform.c:140`)
//! - `Platform_getHostname` (`Platform.c:174`)
//! - `Platform_getRelease` (`Platform.c:178`)
//!
//! Still `todo!()` and blocked on unported substrate:
//! - `Platform_getProcessLocks` — `FileLocks_ProcessData` is unmodeled
//! (returns `NULL` unconditionally here), the same blocker the native
//! darwin/linux ports carry.
use crateACPresence;
use crateDiskIOData;
use crateMeter;
use crateNetworkIOData;
use crateString_safeStrncpy;
/// `CPUMeter.h` `CPU_METER_FREQUENCY = 8` — index into `Meter::values`.
const CPU_METER_FREQUENCY: usize = 8;
/// `CPUMeter.h` `CPU_METER_TEMPERATURE = 9` — index into `Meter::values`.
const CPU_METER_TEMPERATURE: usize = 9;
/// File-local `enum { MEMORY_CLASS_USED = 0, ... }` (`Platform.c:45`).
const MEMORY_CLASS_USED: usize = 0;
/// File-local `enum { ..., MEMORY_CLASS_CACHED }` (`Platform.c:47`).
const MEMORY_CLASS_CACHED: usize = 1;
/// The C file-`static const char Platform_unsupported[] = "unsupported"`
/// (`unsupported/Platform.c:90`).
const Platform_unsupported: &str = "unsupported";
/// Port of `bool Platform_init(void)` (`Platform.c:92`).
/// Port of `void Platform_done(void)` (`Platform.c:97`).
/// Port of `void Platform_setBindings(Htop_Action* keys)` (`Platform.c:101`).
/// Port of `int Platform_getUptime(void)` (`Platform.c:106`).
/// Port of `void Platform_getLoadAverage(double* one, double* five, double*
/// fifteen)` (`Platform.c:110`).
/// Port of `pid_t Platform_getMaxPid(void)` (`Platform.c:116`).
/// Port of `double Platform_setCPUValues(Meter* this, unsigned int cpu)`
/// (`Platform.c:120`). The fallback platform reports no CPU load: it only
/// marks frequency/temperature unavailable (`NAN`), sets one item, and
/// returns a 0% total.
/// Port of `void Platform_setMemoryValues(Meter* this)` (`Platform.c:132`).
/// The fallback platform has no memory figures, so both classes are `NAN`.
/// Port of `void Platform_setSwapValues(Meter* this)` (`Platform.c:140`).
/// The C body is `(void) this;` — a no-op on the fallback platform.
/// Port of `char* Platform_getProcessEnv(pid_t pid)` (`Platform.c:144`).
/// The fallback platform exposes no environment, so this is always `None`.
/// TODO: port of `FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid)`
/// from `Platform.c:149`. Blocked: `FileLocks_ProcessData` is unmodeled
/// (returns `NULL` unconditionally here).
/// Port of `void Platform_getFileDescriptors(double* used, double* max)`
/// (`Platform.c:154`). Fixed placeholder values on the fallback platform.
/// Port of `bool Platform_getDiskIO(DiskIOData* data)` (`Platform.c:159`).
/// Port of `bool Platform_getNetworkIO(NetworkIOData* data)`
/// (`Platform.c:164`).
/// Port of `void Platform_getBattery(double* percent, ACPresence* isOnAC)`
/// (`Platform.c:169`).
/// Port of `void Platform_getHostname(char* buffer, size_t size)`
/// (`Platform.c:174`). Writes the literal "unsupported".
/// Port of `const char* Platform_getRelease(void)` (`Platform.c:178`).
/// Port of `unsupported/Platform.h:95`. Non-PCP build: no dynamic meters, so the
/// `static inline` returns `NULL`.
/// Port of `unsupported/Platform.h:99`. `ATTR_UNUSED` no-op teardown for the
/// non-PCP build's (nonexistent) dynamic-meter table.
/// Port of `unsupported/Platform.h:101`. `ATTR_UNUSED` no-op meter init.
/// Port of `unsupported/Platform.h:103`. `ATTR_UNUSED` no-op value update.
/// Port of `unsupported/Platform.h:105`. `ATTR_UNUSED` no-op display.
/// Port of `unsupported/Platform.h:121`. Non-PCP build: no dynamic screens, so the
/// `static inline` returns `NULL`.
/// Port of `unsupported/Platform.h:131`. `ATTR_UNUSED` no-op teardown for the
/// non-PCP build's (nonexistent) dynamic-screen table.
/// Port of `unsupported/Platform.h:129`. `ATTR_UNUSED` no-op — non-PCP builds add
/// no dynamic-screen columns.