omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / bridge / shlib / nvml.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note bridge/shlib/nvml.om: the 11 functions CUDApp's libnvidia-ml.so.1 exports (its libnvidia-ml.map) with |
| 3 | note the C signatures of its nvml.h, as real bodies: the shell of CUDApp's native/nvml/api.om and of the C |
| 4 | note glue its bridge generated (compat/nvml/libnvidia-ml.c), in Omega. Composed after |
| 5 | note gpu/nvidia/native/nvml/nvml.om, query.om, step.om and errstr.om (the request protocol, RM construction |
| 6 | note and error text, unchanged) into one object and built by bridge/shlib/shlib.om from nvml.tsv: every export |
| 7 | note is a frame export under the lock row's pthread mutex, and the transport is the three omega2_nvrm_* |
| 8 | note imports of libomega-nvrm.so.1 (native/nvrm/transport.om; in the gate the Omega RM fake, rmfake.om). |
| 9 | note States (nvml.tsv, frame words 8..13): NvS the 128-word step state, NvB the step buffer (request at 0, |
| 10 | note payload at PO, output at OO), NvR the transport's result word (0) and a copy word (1, 2), NvT the 32 |
| 11 | note cached error strings of 64 bytes, then "Unknown Error" at 2048 and the 32 cache flags at 2112, NvH the 8 |
| 12 | note device handles (a magic word and the index, 16 bytes each), NvLock the mutex. |
| 13 | note Every export answers as the C glue does: the body's code when it is an nvmlReturn_t value (0..30 or 999), |
| 14 | note else NVML_ERROR_UNKNOWN (999); outputs are written through C pointers (memcpy) only when the glue's checks |
| 15 | note pass (its o_ok), which holds for a body answering 999 with its outputs too. |
| 16 | note Differences from the C, all on a path the C reaches only by a bug: a trap anywhere in the unit (step, |
| 17 | note errstr or this shell) returns 999 at once (nvmlErrorString: NULL, not "Unknown Error"), without the |
| 18 | note C's put s 22 0 after a trap inside the step; a lock that cannot be taken returns the same. |
| 19 | |
| 20 | const HMAG ulong 5723342196145933892 |
| 21 | const UMAX ulong 4294967295 |
| 22 | const WMAX ulong 18446744073709551615 |
| 23 | |
| 24 | extern fn omega2_nvrm_ioctl r ulong fd ulong nr ulong b ulong hl ulong pl ulong to uint |
| 25 | extern fn omega2_nvrm_open_file r ulong b ulong pn ulong to uint |
| 26 | extern fn omega2_nvrm_close_file r ulong fd ulong to uint |
| 27 | extern fn memcpy d ulong s ulong n ulong to ulong |
| 28 | |
| 29 | note ap_put: the low n bytes of v to the C pointer d (through NvR word 1) |
| 30 | fn ap_put d ulong v ulong n ulong r edit ulong 8 fr view ulong 14 to void |
| 31 | put r 1 v |
| 32 | z = memcpy d add get fr 10 8 n |
| 33 | end |
| 34 | |
| 35 | note ap_act: the action the step requested (1 ioctl, 2 open, 3 close), its result in s 14 and the transport |
| 36 | note status in s 15; 0 is a malformed request. |
| 37 | fn ap_act s edit ulong SN r edit ulong 8 fr view ulong 14 to ulong |
| 38 | k = get s 8 |
| 39 | put r 0 0 |
| 40 | st = ulong 0 |
| 41 | if or eq k 0 gt k 3 |
| 42 | ret 0 |
| 43 | end |
| 44 | if eq k 1 |
| 45 | hl = get s 11 |
| 46 | pl = get s 12 |
| 47 | if or gt hl 4608 gt pl 55888 |
| 48 | ret 0 |
| 49 | end |
| 50 | st = ulong omega2_nvrm_ioctl get fr 10 get s 9 get s 10 get fr 9 hl pl |
| 51 | end |
| 52 | if eq k 2 |
| 53 | pn = get s 13 |
| 54 | if or eq pn 0 gt pn 55888 |
| 55 | ret 0 |
| 56 | end |
| 57 | st = ulong omega2_nvrm_open_file get fr 10 get fr 9 pn |
| 58 | end |
| 59 | if eq k 3 |
| 60 | st = ulong omega2_nvrm_close_file get fr 10 get s 9 |
| 61 | end |
| 62 | put s 14 get r 0 |
| 63 | put s 15 st |
| 64 | ret 1 |
| 65 | end |
| 66 | |
| 67 | note ap_run: step until the unit reports done (1) or the protocol fails (0), at most 4096 steps. |
| 68 | fn ap_run s edit ulong SN b edit uchar BN r edit ulong 8 fr view ulong 14 to ulong |
| 69 | ok = ulong 0 |
| 70 | put s 22 0 |
| 71 | for n ulong 4096 |
| 72 | c = nvml_step s b |
| 73 | if ne c 0 |
| 74 | break |
| 75 | end |
| 76 | if eq get s 8 0 |
| 77 | ok = 1 |
| 78 | break |
| 79 | end |
| 80 | if eq ap_act s r fr 0 |
| 81 | break |
| 82 | end |
| 83 | end |
| 84 | put s 22 0 |
| 85 | ret ok |
| 86 | end |
| 87 | |
| 88 | note ap_fin: the copy bounds: at most cap output bytes, output only with a destination, a scalar only with a |
| 89 | note destination and below 2^32. 1 accepts the step's result. |
| 90 | fn ap_fin s edit ulong SN cap ulong dst ulong scl ulong to ulong |
| 91 | n = get s 7 |
| 92 | if gt n cap |
| 93 | ret 0 |
| 94 | end |
| 95 | if and ne n 0 eq dst 0 |
| 96 | ret 0 |
| 97 | end |
| 98 | if ne get s 27 0 |
| 99 | if or eq scl 0 gt get s 5 UMAX |
| 100 | ret 0 |
| 101 | end |
| 102 | end |
| 103 | ret 1 |
| 104 | end |
| 105 | |
| 106 | note ap_code: the step's status when it is an nvmlReturn_t value, else NVML_ERROR_UNKNOWN. |
| 107 | fn ap_code s edit ulong SN to ulong |
| 108 | v = get s 6 |
| 109 | if or le v 30 eq v 999 |
| 110 | ret v |
| 111 | end |
| 112 | ret 999 |
| 113 | end |
| 114 | |
| 115 | note ap_set: the operation and its four arguments in s 0..4. |
| 116 | fn ap_set s edit ulong SN op ulong a1 ulong a2 ulong a3 ulong to void |
| 117 | put s 0 op |
| 118 | put s 1 a1 |
| 119 | put s 2 a2 |
| 120 | put s 3 a3 |
| 121 | put s 4 0 |
| 122 | end |
| 123 | |
| 124 | note ap_res: the export's answer: f 0 when it is an nvmlReturn_t value and f 1 holds no flag outside m |
| 125 | fn ap_res f edit ulong 8 m ulong to int |
| 126 | v = get f 0 |
| 127 | if gt v 30 |
| 128 | ret 999 |
| 129 | end |
| 130 | if ne and get f 1 not m 0 |
| 131 | ret 999 |
| 132 | end |
| 133 | ret int v |
| 134 | end |
| 135 | |
| 136 | note ap_ok: the glue's o_ok before its pointer checks: f 0 is an nvmlReturn_t value (0..30 or 999) and f 1 holds |
| 137 | note no flag outside m; a body answering NVML_ERROR_UNKNOWN (999) with outputs still has them written, as the C |
| 138 | fn ap_ok f edit ulong 8 m ulong to bool |
| 139 | v = get f 0 |
| 140 | if and gt v 30 ne v 999 |
| 141 | ret false |
| 142 | end |
| 143 | ret eq and get f 1 not m 0 |
| 144 | end |
| 145 | |
| 146 | note ap_hi: the pool index of the device handle d, or 2^64 - 1 when d is not one this library handed out |
| 147 | fn ap_hi d ulong h view ulong 16 fr view ulong 14 to ulong |
| 148 | a = get fr 12 |
| 149 | if lt d a |
| 150 | ret WMAX |
| 151 | end |
| 152 | o = sub d a |
| 153 | if or ge o 128 ne rem o 16 0 |
| 154 | ret WMAX |
| 155 | end |
| 156 | i = div o 16 |
| 157 | m = get h mul i 2 |
| 158 | x = get h add mul i 2 1 |
| 159 | if and eq m HMAG eq x i |
| 160 | ret i |
| 161 | end |
| 162 | ret WMAX |
| 163 | end |
| 164 | |
| 165 | note ap_nz: 1 when the C pointer v is not NULL |
| 166 | fn ap_nz v ulong to ulong |
| 167 | if eq v 0 |
| 168 | ret 0 |
| 169 | end |
| 170 | ret 1 |
| 171 | end |
| 172 | |
| 173 | note Init and Shutdown: no outputs. |
| 174 | fn ap_bare s edit ulong SN b edit uchar BN r edit ulong 8 fr view ulong 14 op ulong to int |
| 175 | f = new ulong 8 0 |
| 176 | put f 0 999 |
| 177 | ap_set s op 0 0 0 |
| 178 | if ne ap_run s b r fr 0 |
| 179 | if ne ap_fin s 0 0 0 0 |
| 180 | put f 0 ap_code s |
| 181 | end |
| 182 | end |
| 183 | ret ap_res f 0 |
| 184 | end |
| 185 | |
| 186 | export fn nvmlInit_v2 fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 to int |
| 187 | ret ap_bare s b r fr 1 |
| 188 | end |
| 189 | |
| 190 | export fn nvmlShutdown fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 to int |
| 191 | ret ap_bare s b r fr 2 |
| 192 | end |
| 193 | |
| 194 | note Count: f 2 deviceCount present, f 3 the count. |
| 195 | export fn nvmlDeviceGetCount_v2 fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 to int |
| 196 | f = new ulong 8 0 |
| 197 | put f 0 999 |
| 198 | p = get fr 0 |
| 199 | put f 2 ap_nz p |
| 200 | ap_set s 3 0 get f 2 0 |
| 201 | if eq ap_run s b r fr 0 |
| 202 | ret 999 |
| 203 | end |
| 204 | if eq ap_fin s 0 0 get f 2 0 |
| 205 | ret 999 |
| 206 | end |
| 207 | if ne get s 27 0 |
| 208 | put f 3 get s 5 |
| 209 | put f 1 1 |
| 210 | end |
| 211 | put f 0 ap_code s |
| 212 | c = ap_res f 1 |
| 213 | if ne get f 1 0 |
| 214 | if or eq p 0 gt get f 3 UMAX |
| 215 | ret 999 |
| 216 | end |
| 217 | if not ap_ok f 1 |
| 218 | ret c |
| 219 | end |
| 220 | ap_put p get f 3 4 r fr |
| 221 | end |
| 222 | ret c |
| 223 | end |
| 224 | |
| 225 | note HandleByIndex: f 2 index, f 3 device present, f 4 the handle index (below the pool of 8). |
| 226 | export fn nvmlDeviceGetHandleByIndex_v2 fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h edit ulong 16 to int |
| 227 | f = new ulong 8 0 |
| 228 | put f 0 999 |
| 229 | put f 2 and get fr 0 UMAX |
| 230 | p = get fr 1 |
| 231 | put f 3 ap_nz p |
| 232 | ap_set s 4 get f 2 get f 3 0 |
| 233 | if eq ap_run s b r fr 0 |
| 234 | ret 999 |
| 235 | end |
| 236 | if eq ap_fin s 0 0 1 0 |
| 237 | ret 999 |
| 238 | end |
| 239 | k = ap_code s |
| 240 | if eq k 0 |
| 241 | v = ulong 0 |
| 242 | if ne get s 27 0 |
| 243 | v = get s 5 |
| 244 | end |
| 245 | if ge v 8 |
| 246 | ret 999 |
| 247 | end |
| 248 | if ne get f 3 0 |
| 249 | put f 4 v |
| 250 | put f 1 1 |
| 251 | end |
| 252 | end |
| 253 | put f 0 k |
| 254 | c = ap_res f 1 |
| 255 | if or not ap_ok f 1 eq get f 1 0 |
| 256 | ret c |
| 257 | end |
| 258 | if or eq p 0 ge get f 4 8 |
| 259 | ret 999 |
| 260 | end |
| 261 | i = get f 4 |
| 262 | put h mul i 2 HMAG |
| 263 | put h add mul i 2 1 i |
| 264 | ap_put p add get fr 12 mul i 16 8 r fr |
| 265 | ret c |
| 266 | end |
| 267 | |
| 268 | note Name and UUID: f 2 device, f 3 buffer present, f 4 bytes written (with the NUL), f 5 length. |
| 269 | fn ap_str fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h view ulong 16 op ulong to int |
| 270 | f = new ulong 8 0 |
| 271 | put f 0 999 |
| 272 | put f 2 ap_hi get fr 0 h fr |
| 273 | p = get fr 1 |
| 274 | put f 3 ap_nz p |
| 275 | put f 5 and get fr 2 UMAX |
| 276 | ap_set s op get f 2 get f 3 get f 5 |
| 277 | if eq ap_run s b r fr 0 |
| 278 | ret 999 |
| 279 | end |
| 280 | if eq ap_fin s get f 5 get f 3 0 0 |
| 281 | ret 999 |
| 282 | end |
| 283 | n = get s 7 |
| 284 | if ne n 0 |
| 285 | put f 4 n |
| 286 | put f 1 1 |
| 287 | end |
| 288 | put f 0 ap_code s |
| 289 | c = ap_res f 1 |
| 290 | if or not ap_ok f 1 eq get f 1 0 |
| 291 | ret c |
| 292 | end |
| 293 | n = get f 4 |
| 294 | if or eq p 0 eq n 0 |
| 295 | ret 999 |
| 296 | end |
| 297 | if or gt n get f 5 gt n 22800 |
| 298 | ret 999 |
| 299 | end |
| 300 | if ne get b add OO sub n 1 0 |
| 301 | ret 999 |
| 302 | end |
| 303 | z = memcpy p add get fr 9 OO n |
| 304 | ret c |
| 305 | end |
| 306 | |
| 307 | export fn nvmlDeviceGetName fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h edit ulong 16 to int |
| 308 | ret ap_str fr s b r h 5 |
| 309 | end |
| 310 | |
| 311 | export fn nvmlDeviceGetUUID fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h edit ulong 16 to int |
| 312 | ret ap_str fr s b r h 6 |
| 313 | end |
| 314 | |
| 315 | note Temperature: f 2 device, f 3 sensor, f 4 temp present, f 5 the temperature. |
| 316 | export fn nvmlDeviceGetTemperature fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h edit ulong 16 to int |
| 317 | f = new ulong 8 0 |
| 318 | put f 0 999 |
| 319 | put f 2 ap_hi get fr 0 h fr |
| 320 | put f 3 and get fr 1 UMAX |
| 321 | p = get fr 2 |
| 322 | put f 4 ap_nz p |
| 323 | ap_set s 7 get f 2 get f 4 get f 3 |
| 324 | if eq ap_run s b r fr 0 |
| 325 | ret 999 |
| 326 | end |
| 327 | if eq ap_fin s 0 0 get f 4 0 |
| 328 | ret 999 |
| 329 | end |
| 330 | if ne get s 27 0 |
| 331 | put f 5 get s 5 |
| 332 | put f 1 1 |
| 333 | end |
| 334 | put f 0 ap_code s |
| 335 | c = ap_res f 1 |
| 336 | if or not ap_ok f 1 eq get f 1 0 |
| 337 | ret c |
| 338 | end |
| 339 | if or eq p 0 gt get f 5 UMAX |
| 340 | ret 999 |
| 341 | end |
| 342 | ap_put p get f 5 4 r fr |
| 343 | ret c |
| 344 | end |
| 345 | |
| 346 | note Memory (24 bytes) and utilization (8 bytes): f 2 device, f 3 record present. |
| 347 | fn ap_rec fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h view ulong 16 op ulong to int |
| 348 | f = new ulong 8 0 |
| 349 | put f 0 999 |
| 350 | put f 2 ap_hi get fr 0 h fr |
| 351 | p = get fr 1 |
| 352 | put f 3 ap_nz p |
| 353 | sz = ulong 24 |
| 354 | if eq op 9 |
| 355 | sz = 8 |
| 356 | end |
| 357 | ap_set s op get f 2 get f 3 0 |
| 358 | if eq ap_run s b r fr 0 |
| 359 | ret 999 |
| 360 | end |
| 361 | if eq ap_fin s sz get f 3 0 0 |
| 362 | ret 999 |
| 363 | end |
| 364 | n = get s 7 |
| 365 | if ne n 0 |
| 366 | if ne n sz |
| 367 | ret 999 |
| 368 | end |
| 369 | put f 1 1 |
| 370 | end |
| 371 | put f 0 ap_code s |
| 372 | c = ap_res f 1 |
| 373 | if or not ap_ok f 1 eq get f 1 0 |
| 374 | ret c |
| 375 | end |
| 376 | if eq p 0 |
| 377 | ret 999 |
| 378 | end |
| 379 | z = memcpy p add get fr 9 OO sz |
| 380 | ret c |
| 381 | end |
| 382 | |
| 383 | export fn nvmlDeviceGetMemoryInfo fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h edit ulong 16 to int |
| 384 | ret ap_rec fr s b r h 8 |
| 385 | end |
| 386 | |
| 387 | export fn nvmlDeviceGetUtilizationRates fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h edit ulong 16 to int |
| 388 | ret ap_rec fr s b r h 9 |
| 389 | end |
| 390 | |
| 391 | note Processes: f 2 device, f 3 infoCount present, f 4 *infoCount, f 5 infos present, f 6 records written; |
| 392 | note the capacity is 24 bytes per requested entry; f 7 the caller's *infoCount. |
| 393 | export fn nvmlDeviceGetComputeRunningProcesses_v3 fr view ulong 14 s edit ulong SN b edit uchar BN r edit ulong 8 h edit ulong 16 to int |
| 394 | f = new ulong 8 0 |
| 395 | put f 0 999 |
| 396 | put f 2 ap_hi get fr 0 h fr |
| 397 | p = get fr 1 |
| 398 | put f 3 ap_nz p |
| 399 | if ne p 0 |
| 400 | put r 2 0 |
| 401 | z = memcpy add get fr 10 16 p 4 |
| 402 | put f 4 get r 2 |
| 403 | end |
| 404 | put f 7 get f 4 |
| 405 | put f 5 ap_nz get fr 2 |
| 406 | c = ap_procs f s b r fr |
| 407 | if eq c 1000 |
| 408 | ret 999 |
| 409 | end |
| 410 | ap_pout f b r fr |
| 411 | ret c |
| 412 | end |
| 413 | |
| 414 | note the body of GetComputeRunningProcesses_v3 (nv_procs) and the glue's checks; its answer, or 1000 when the |
| 415 | note glue's o_ok is false (the export answers 999 then and writes nothing) |
| 416 | fn ap_procs f edit ulong 8 s edit ulong SN b edit uchar BN r edit ulong 8 fr view ulong 14 to int |
| 417 | w = get f 4 |
| 418 | put s 0 10 |
| 419 | put s 1 get f 2 |
| 420 | put s 2 get f 3 |
| 421 | put s 3 w |
| 422 | put s 4 get f 5 |
| 423 | if eq ap_run s b r fr 0 |
| 424 | ret 1000 |
| 425 | end |
| 426 | if eq ap_fin s mul w 24 get f 5 get f 3 0 |
| 427 | ret 1000 |
| 428 | end |
| 429 | m = ulong 0 |
| 430 | n = get s 7 |
| 431 | if ne n 0 |
| 432 | if ne rem n 24 0 |
| 433 | ret 1000 |
| 434 | end |
| 435 | put f 6 div n 24 |
| 436 | m = 4 |
| 437 | end |
| 438 | if ne get s 27 0 |
| 439 | put f 4 get s 5 |
| 440 | m = add m 2 |
| 441 | end |
| 442 | put f 1 m |
| 443 | put f 0 ap_code s |
| 444 | ret ap_pchk f fr |
| 445 | end |
| 446 | |
| 447 | note the glue's checks for GetComputeRunningProcesses_v3: *infoCount below 2^32, at most the requested and |
| 448 | note at most 950 records, each output with its pointer; 1000 when one fails |
| 449 | fn ap_pchk f edit ulong 8 fr view ulong 14 to int |
| 450 | if not ap_ok f 6 |
| 451 | ret 1000 |
| 452 | end |
| 453 | c = ap_res f 6 |
| 454 | m = get f 1 |
| 455 | if ne and m 2 0 |
| 456 | if or eq get fr 1 0 gt get f 4 UMAX |
| 457 | ret 1000 |
| 458 | end |
| 459 | end |
| 460 | if eq and m 4 0 |
| 461 | ret c |
| 462 | end |
| 463 | e = get f 6 |
| 464 | if eq get fr 2 0 |
| 465 | ret 1000 |
| 466 | end |
| 467 | if or gt e get f 7 gt e 950 |
| 468 | ret 1000 |
| 469 | end |
| 470 | ret c |
| 471 | end |
| 472 | |
| 473 | note the outputs of GetComputeRunningProcesses_v3: *infoCount, then each record field by field |
| 474 | fn ap_pout f edit ulong 8 b edit uchar BN r edit ulong 8 fr view ulong 14 to void |
| 475 | m = get f 1 |
| 476 | if ne and m 2 0 |
| 477 | ap_put get fr 1 get f 4 4 r fr |
| 478 | end |
| 479 | if eq and m 4 0 |
| 480 | ret |
| 481 | end |
| 482 | d = get fr 2 |
| 483 | o = add get fr 9 OO |
| 484 | for j ulong get f 6 bound 950 |
| 485 | e = mul j 24 |
| 486 | z = memcpy add d e add o e 4 |
| 487 | z = memcpy add add d e 8 add add o e 8 8 |
| 488 | z = memcpy add add d e 16 add add o e 16 4 |
| 489 | z = memcpy add add d e 20 add add o e 20 4 |
| 490 | end |
| 491 | end |
| 492 | |
| 493 | note ErrorString: the code sign-extended from the C int; each cache slot is filled once, so a returned |
| 494 | note pointer stays valid and unchanged for the life of the process; anything else answers "Unknown Error" |
| 495 | note (the fallback at NvT 2048, written from errstr's own text). |
| 496 | export fn nvmlErrorString fr view ulong 14 t edit uchar 2144 to ulong |
| 497 | fb = add get fr 11 2048 |
| 498 | k = ap_eslot t get fr 0 |
| 499 | if ge k 32 |
| 500 | ret fb |
| 501 | end |
| 502 | if ge ap_elen t mul k 64 64 |
| 503 | ret fb |
| 504 | end |
| 505 | ret add get fr 11 mul k 64 |
| 506 | end |
| 507 | |
| 508 | note ap_eslot: the cache slot of the C int x (sign-extended), filled on first use; 32 when the text does not fit. |
| 509 | note Writes the fallback text at 2048 first, once. |
| 510 | fn ap_eslot t edit uchar 2144 x ulong to ulong |
| 511 | o = new uchar 64 0 |
| 512 | if eq get t 2048 0 |
| 513 | v = nvml_errstr 1000 o |
| 514 | ap_ecopy t 2048 o |
| 515 | end |
| 516 | code = and x UMAX |
| 517 | if ge code 2147483648 |
| 518 | code = or code 18446744069414584320 |
| 519 | end |
| 520 | v = nvml_errstr code o |
| 521 | n = and v 255 |
| 522 | k = and shr v 8 255 |
| 523 | if or ge n 64 ge k 32 |
| 524 | ret 32 |
| 525 | end |
| 526 | if eq ulong get t add 2112 k 0 |
| 527 | ap_ecopy t mul k 64 o |
| 528 | put t add mul k 64 n uchar 0 |
| 529 | put t add 2112 k uchar 1 |
| 530 | end |
| 531 | ret k |
| 532 | end |
| 533 | |
| 534 | fn ap_ecopy t edit uchar 2144 z ulong o view uchar 64 to void |
| 535 | for j ulong 64 |
| 536 | put t add z j get o j |
| 537 | end |
| 538 | end |
| 539 | |
| 540 | note ap_elen: the offset of the first NUL in the 64 bytes at z (64: none) |
| 541 | fn ap_elen t view uchar 2144 z ulong to ulong |
| 542 | for i ulong 64 |
| 543 | if eq ulong get t add z i 0 |
| 544 | ret i |
| 545 | end |
| 546 | end |
| 547 | ret 64 |
| 548 | end |