Commit 71afa0d
committed
openkal-emscripten 0.1.0: an implementation written above a C library
Every other implementation in this ecosystem is written on a kernel's own
interface. Emscripten has no kernel to issue a call to: it has a C library over
a JavaScript host, and clause 2 permits exactly this arrangement in as many
words -- "an implementation may be built upon a C library, beneath one, or
without one". This is the first here to take the first of the three.
That direction makes the code thin and not easy. What an above-libc
implementation has to get right is the places where the C library's vocabulary
and openkal's do NOT correspond, and each is commented where it occurs:
fs openkal has no ambient working directory, which `openat` matches
exactly; one preopen at `/`, because a platform with no command
line has no one to say which; `remove` is one operation over
`unlink` and `rmdir`, retried only on the condition that names the
other kind; `.` and `..` are not entries, because openkal has no
parent relation
memory the granularity is the alignment honoured and not wasm's 64 KiB
page, which is the unit linear memory GROWS in; a recorded defect
in this ecosystem is a C library reading a truthful granularity of
1 as a page size
time the monotonic granularity is MEASURED rather than asked for:
`clock_getres` answers a nanosecond and that is about the struct,
while a browser deliberately coarsens `performance.now()`
random `getentropy` is the host's cryptographic generator; MEMFS's
`/dev/urandom` is a different source reached through the file system
terminal asked of the machine per call, so one module answers correctly
under node and in a browser without a build-time switch
net the calls are real and the transport is a WebSocket proxy, so the
interface is provided and `kal_net_props` claims nothing --
HALFCLOSE in particular, because `shutdown` succeeds and no peer is
told
timeout `poll` then the operation, and the granularity is `poll`'s
millisecond rather than the clock's
THREE INTERFACES ARE NOT PROVIDED AND THE ABSENCE IS THE REPORT.
`openkal.process`, `openkal.exec` and `openkal.space`: there is no fork, no
exec, no writable-then-executable memory and no second address space. Measured:
wasm-ld: error: obj/main.o: undefined symbol: kal_process_spawn
which is clause 6.2's second time. Providing them so that they returned an
error would be the shape the specification forbids -- present and always
failing, which the caller cannot tell from a condition -- and would move a fact
known at link time to run time.
THE ARGUMENTS TOOK THREE ATTEMPTS AND THE PLATFORM REFUSED TWO. `.init_array`
with a `(argc, argv, envp)` signature does not link -- "constructor functions
cannot take arguments", because wasm's start section takes none. A weak
interposer on the entry point has no seam: the name belongs to the program. The
host has them, and `EM_ASM` reaches it; index zero also has a JS-free source in
musl's `__progname_full`, so a browser still reports the name it was started
by. The first version of that copy used `stringToUTF8` into a `_malloc` scratch
buffer and aborted with "malloc() called but not included in the build" -- a
library cannot require an export list from every program that uses it -- so it
uses `TextEncoder` and `HEAPU8.set`, which need nothing exported.
`openkal.task` IS CARRIED BY A FEATURE, AND THE MEASUREMENT DECIDED THAT.
Threads need `-pthread`, which selects a different C library build, memory
model and loader contract. With the interface compiled and `kal_task_start`
reporting kal_err_not_supported, the suite said:
DID NOT HOLD an execution context starts
DID NOT HOLD four execution contexts start
DID NOT HOLD contexts that ran at the same time have identities distinct
and the suite is right: a capability word is for how an interface behaves, not
for whether its central operation works at all. So without the feature the
translation unit is empty, the eight symbols do not exist, and
`kal_interfaces()` -- keyed on the compiler's own `__EMSCRIPTEN_PTHREADS__`
rather than on a name this package invented -- does not claim it. The feature
is not yet usable end to end because `-pthread` must reach every package in the
graph including the specification's, and mcpp has no whole-graph flag channel;
that limitation is recorded in the README rather than worked around.
`handle.h` IS COPIED FROM openkal-linux AND ITS CONSTANT WAS NOT. That file
splits the handle word at bit 32, which is the whole width of a pointer here:
handle.h:22: warning: shift count >= width of type
The index width is now derived from `kMaxDescriptor` and the generation takes
what is left -- 15 bits here, 47 on a 64-bit host, from one expression. The
generation wraps sooner as a result, and that is stated rather than left to be
inferred from the other implementation's numbers.
CONFORMANCE, measured with emsdk 6.0.9 under node: 86 held, 0 did not hold,
13 not observed. The exported surface is 86 names, twelve complete groups,
three absent groups, and nothing beginning with `kal_` the specification does
not name.0 parents commit 71afa0d
348 files changed
Lines changed: 5632 additions & 0 deletions
File tree
- .github/workflows
- src
- threads
- target
- wasm32-emscripten
- 106b730e3a8868d0
- obj
- mcpplibs_openkal/src
- pcm.cache
- 302e40faebcba915
- obj
- mcpplibs_openkal/src
- pcm.cache
- 8d95f18fa88eae4b
- obj
- mcpplibs_openkal/src
- pcm.cache
- 9bf57b35ea012a06
- obj
- mcpplibs_openkal/src
- pcm.cache
- b17c00a99a1210c5
- obj
- mcpplibs_openkal/src
- pcm.cache
- e16aba71f122785b
- obj
- mcpplibs_openkal/src
- pcm.cache
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
0 commit comments