Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/gpu/nvidia/checks/inventory.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / gpu / nvidia / checks / inventory.om` 1098 lines ยท 20857 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: Apache-2.0 3 note gpu/nvidia/checks/inventory.om: writes gpu/nvidia/checks/INVENTORY.tsv, the inventory of the files of CUDApp 4 note tests/ and tools/ that are not Omega, in seeded Omega (Linux AArch64). Nobody types that table: this program 5 note derives it from the files themselves, the list of Omega files under gpu/ and the decisions in ports.tsv. 6 note Build from the omega-mv root: seed/out/omc < gpu/nvidia/checks/inventory.om > inventory 7 note Run from the CUDApp checkout root: inventory LIST GPULIST PORTS LABEL > INVENTORY.tsv 8 note LIST the paths of CUDApp tests/ and tools/, one per line (git ls-files tests tools); a path ending in .om 9 note is skipped (those are Omega already) 10 note GPULIST the paths of the files under gpu/ of the omega-mv head the inventory is read against, one per line 11 note PORTS gpu/nvidia/checks/ports.tsv: PATH, a tab, ported|retired|blocked, a tab, the detail; # starts a comment. 12 note Each row must name a path of LIST exactly once, or the run fails (exit 1): a stale decision is loud. 13 note LABEL one line naming the inputs (heads), copied into the header 14 note Columns: path kind bytes lines tier marker om_ref same_stem status detail summary 15 note kind the extension, or none 16 note tier data (not code), device (a device marker in the text), tiered (a device marker and a --host-only or 17 note --sim tier), host (code with no device marker). A heuristic over the text, not a run. 18 note marker the first device marker found, in the order of the m_ texts below, or - 19 note om_ref the first NAME.om named in the text that is a file of GPULIST: gpu/nvidia/NAME.om (om/ and native/ 20 note read as gpu/nvidia/), or, when NAME holds a '/', a GPULIST file ending in /NAME.om; or - 21 note same_stem the file gpu/nvidia/PATH.om of GPULIST, where PATH is the path without its extension (tests/X/y.c 22 note gives gpu/nvidia/tests/X/y.om): an Omega program of the same name, or - 23 note status ported, retired or blocked from PORTS, else open 24 note summary the first comment line of the file that is not a licence line (md: the first heading), or - 25 note Files and lists are read whole into memory that grows to fit them (run-time pools); nothing is cut. A 26 note path of LIST that Linux could not open (PATH_MAX) is refused, naming it. Exit 0 written, 1 a PORTS row names 27 note no path of LIST, 2 bad usage, unreadable input, or memory the host refused. 28 text t_usage "usage: inventory LIST GPULIST PORTS LABEL (run from the CUDApp checkout root)\n" 29 text t_unread "inventory: cannot read, or the host refused the memory for: " 30 text t_plong "inventory: a LIST path is longer than Linux PATH_MAX allows: " 31 text t_badport "inventory: ports.tsv row is not PATHported|retired|blockedDETAIL: " 32 text t_stale "inventory: ports.tsv rows that name no path of LIST, or name one twice: " 33 text t_h1 "# gpu/nvidia/checks/INVENTORY.tsv, generated by gpu/nvidia/checks/inventory.om; do not edit by hand.\n# inputs: " 34 text t_h2 "path\tkind\tbytes\tlines\ttier\tmarker\tom_ref\tsame_stem\tstatus\tdetail\tsummary\n" 35 text t_tot "# files=" 36 text t_code " code=" 37 text t_data " data=" 38 text t_dev " device=" 39 text t_tier " tiered=" 40 text t_host " host=" 41 text t_por " ported=" 42 text t_ret " retired=" 43 text t_blk " blocked=" 44 text t_open " open=" 45 text t_okh "# open by tier/kind:" 46 text t_dash "-" 47 text t_none "none" 48 text t_ktdata "data" 49 text t_nl "\n" 50 text t_ktdev "device" 51 text t_kttier "tiered" 52 text t_kthost "host" 53 text t_kopen "open\t-" 54 text t_ported "ported" 55 text t_retired "retired" 56 text t_blocked "blocked" 57 text t_gn "gpu/nvidia/" 58 text t_copyr "Copyright" 59 text t_dotom ".om" 60 text t_spdx "SPDX" 61 text t_hostonly "--host-only" 62 text t_sim "--sim" 63 text t_m1 "/dev/nvidia" 64 text t_m2 "/dev/kfd" 65 text t_m3 "/dev/dri" 66 text t_m4 "omega_gpu_session_open" 67 text t_m5 "nvrm_open" 68 text t_m6 "cuInit" 69 text t_m7 "hipMalloc" 70 text t_m8 "ioctl(" 71 text t_m9 "nvidia-smi" 72 text t_m10 "spark-window" 73 text t_kc "c" 74 text t_kh "h" 75 text t_kpy "py" 76 text t_ksh "sh" 77 text t_kmk "mk" 78 text t_kinc "inc" 79 text t_kmd "md" 80 global g_f uchar * 81 global g_lst uchar * 82 global g_gpu uchar * 83 global g_prt uchar * 84 note a path for fopen: Linux PATH_MAX, the longest path open(2) takes (getconf PATH_MAX / gives 4096) 85 global g_pa uchar 4096 86 note the LABEL argument: Linux MAX_ARG_STRLEN, the longest single argument execve passes (32 pages of 4096) 87 global g_lab uchar 131072 88 global g_o uchar 65536 89 global g_ok uchar * 90 global g_n ulong 48 91 note g_n: 0 path length, 1 file length, 2 list length, 3 gpu list length, 4 ports length, 5 output length, 92 note 6 label length, 7 entry start, 8 entry end, 9 ports rows matched, 10 files, 11 code, 12 data, 13 device, 93 note 14 tiered, 15 host, 16 ported, 17 retired, 18 blocked, 19 open, 20 summary start, 21 summary end, 94 note 22 om_ref start, 23 om_ref end (in g_gpu), 24 stem start, 25 stem end (in g_lst), 26 extension start, 95 note 27 same_stem start, 28 same_stem end, 29 port line start, 30 port line end, 31 ports rows, 32 bytes of g_ok, 96 note 33 the tier of this row (1 device, 2 tiered, 3 host, 4 data) 97 note g_ok: one key per open row, its tier byte, its kind, a newline (the open-by-kind footer line) 98 note ---- output 99 fn oflush to void 100 o = ulong 0 101 n = get g_n 5 102 while lt o n bound 65537 103 x = write 1 g_o o sub n o 104 if le x 0 105 exit 2 106 end 107 o = add o ulong x 108 end 109 put g_n 5 0 110 end 111 fn oc c ulong to void 112 n = get g_n 5 113 if ge n len g_o 114 oflush 115 n = 0 116 end 117 put g_o n uchar c 118 put g_n 5 add n 1 119 end 120 fn ot t view uchar * to void 121 for i ulong len t bound 4096 122 oc ulong get t i 123 end 124 end 125 fn onum v ulong to void 126 if ge v 10 127 onum div v 10 128 end 129 oc add 48 rem v 10 130 end 131 fn otab to void 132 oc 9 133 end 134 fn ofr s ulong e ulong to void 135 for i ulong sub e s bound `9223372036854775807` 136 c = ulong get g_f add s i 137 if or eq c 9 eq c 13 138 c = 32 139 end 140 oc c 141 end 142 end 143 fn olr s ulong e ulong to void 144 for i ulong sub e s bound `9223372036854775807` 145 oc ulong get g_lst add s i 146 end 147 end 148 fn ogr s ulong e ulong to void 149 for i ulong sub e s bound `9223372036854775807` 150 oc ulong get g_gpu add s i 151 end 152 end 153 fn opr s ulong e ulong to void 154 for i ulong sub e s bound `9223372036854775807` 155 oc ulong get g_prt add s i 156 end 157 end 158 fn eput t view uchar * to void 159 r = write 2 t 0 len t 160 end 161 fn epath to void 162 r = write 2 g_pa 0 get g_n 0 163 r = write 2 t_nl 0 1 164 end 165 note ---- files 166 fn pclr to void 167 put g_n 0 0 168 end 169 fn pc c ulong to void 170 n = get g_n 0 171 put g_pa n uchar c 172 put g_n 0 add n 1 173 end 174 note read the file named by g_pa into g_f, growing g_f to fit: its length, or -1 unreadable, -2 the host refused 175 note the memory 176 fn fload to long 177 r = fopen g_pa 0 get g_n 0 int 524288 int 0 178 if lt r 0 179 ret long -1 180 end 181 fd = int r 182 n = ulong 0 183 res = long 0 184 while true bound `9223372036854775807` 185 if ge add n 1 len g_f 186 q = enlarge g_f add add n n 65536 187 if lt q 0 188 res = long -2 189 break 190 end 191 end 192 x = read fd g_f n sub len g_f n 193 if lt x 0 194 res = long -1 195 break 196 end 197 if eq x 0 198 break 199 end 200 n = add n ulong x 201 end 202 r = fclose fd 203 if lt res 0 204 ret res 205 end 206 put g_n 1 n 207 ret long n 208 end 209 note argument I into g_pa, then the file into g_f; exits 2 when either fails 210 fn aload i ulong to ulong 211 r = argread i g_pa 0 4095 212 if lt r 1 213 eput t_usage 214 exit 2 215 end 216 put g_n 0 ulong r 217 x = fload 218 if lt x 0 219 eput t_unread 220 epath 221 exit 2 222 end 223 ret ulong x 224 end 225 note ---- character classes 226 fn alnum c ulong to bool 227 if and ge c 48 le c 57 228 ret true 229 end 230 if and ge c 65 le c 90 231 ret true 232 end 233 if and ge c 97 le c 122 234 ret true 235 end 236 ret false 237 end 238 fn tokch c ulong to bool 239 if alnum c 240 ret true 241 end 242 if or or or eq c 95 eq c 46 eq c 47 eq c 45 243 ret true 244 end 245 ret false 246 end 247 note ---- search in g_f 248 fn fat i ulong t view uchar * to bool 249 n = get g_n 1 250 m = len t 251 if gt add i m n 252 ret false 253 end 254 for j ulong m bound `9223372036854775807` 255 if ne get g_f add i j get t j 256 ret false 257 end 258 end 259 ret true 260 end 261 fn fhas t view uchar * to bool 262 n = get g_n 1 263 m = len t 264 if gt m n 265 ret false 266 end 267 for i ulong add sub n m 1 bound `9223372036854775807` 268 if fat i t 269 ret true 270 end 271 end 272 ret false 273 end 274 note the first device marker in g_f, 1..10, or 0 275 fn marker to ulong 276 if fhas t_m1 277 ret 1 278 end 279 if fhas t_m2 280 ret 2 281 end 282 if fhas t_m3 283 ret 3 284 end 285 if fhas t_m4 286 ret 4 287 end 288 if fhas t_m5 289 ret 5 290 end 291 if fhas t_m6 292 ret 6 293 end 294 if fhas t_m7 295 ret 7 296 end 297 if fhas t_m8 298 ret 8 299 end 300 if fhas t_m9 301 ret 9 302 end 303 if fhas t_m10 304 ret 10 305 end 306 ret 0 307 end 308 fn omark m ulong to void 309 if eq m 1 310 ot t_m1 311 end 312 if eq m 2 313 ot t_m2 314 end 315 if eq m 3 316 ot t_m3 317 end 318 if eq m 4 319 ot t_m4 320 end 321 if eq m 5 322 ot t_m5 323 end 324 if eq m 6 325 ot t_m6 326 end 327 if eq m 7 328 ot t_m7 329 end 330 if eq m 8 331 ot t_m8 332 end 333 if eq m 9 334 ot t_m9 335 end 336 if eq m 10 337 ot t_m10 338 end 339 if eq m 0 340 ot t_dash 341 end 342 end 343 note ---- the list entry g_lst[g_n 7, g_n 8): extension and stem 344 note sets 24 stem start, 25 stem end, 26 extension start (= entry end when there is none) 345 fn names to void 346 s = get g_n 7 347 e = get g_n 8 348 b = s 349 d = e 350 for i ulong sub e s bound `9223372036854775807` 351 c = get g_lst add s i 352 if eq c 47 353 b = add add s i 1 354 d = e 355 end 356 if eq c 46 357 d = add s i 358 end 359 end 360 put g_n 24 b 361 put g_n 25 d 362 if lt d e 363 put g_n 26 add d 1 364 else 365 put g_n 26 e 366 end 367 end 368 fn lext t view uchar * to bool 369 s = get g_n 26 370 e = get g_n 8 371 if ne sub e s len t 372 ret false 373 end 374 for i ulong len t bound `9223372036854775807` 375 if ne get g_lst add s i get t i 376 ret false 377 end 378 end 379 ret true 380 end 381 fn iscode to bool 382 if or or lext t_kc lext t_kh lext t_kpy 383 ret true 384 end 385 if or or lext t_ksh lext t_kmk lext t_kinc 386 ret true 387 end 388 if ge get g_n 1 2 389 if and eq get g_f 0 35 eq get g_f 1 33 390 ret true 391 end 392 end 393 ret false 394 end 395 fn isdotom to bool 396 s = get g_n 7 397 e = get g_n 8 398 if lt sub e s 3 399 ret false 400 end 401 c3 = get g_lst sub e 3 402 c2 = get g_lst sub e 2 403 c1 = get g_lst sub e 1 404 ret and and eq c3 46 eq c2 111 eq c1 109 405 end 406 note ---- the gpu list 407 note gpu line [lo, hi) equals PREFIX then g_f[ts, te) 408 fn gpeq lo ulong hi ulong pre view uchar * ts ulong te ulong to bool 409 m = len pre 410 tl = sub te ts 411 if ne sub hi lo add m tl 412 ret false 413 end 414 for i ulong m bound `9223372036854775807` 415 if ne get g_gpu add lo i get pre i 416 ret false 417 end 418 end 419 for j ulong tl bound `9223372036854775807` 420 c = get g_f add ts j 421 if ne get g_gpu add add lo m j c 422 ret false 423 end 424 end 425 ret true 426 end 427 note gpu line [lo, hi) ends with '/' then g_f[ts, te) 428 fn gpsuf lo ulong hi ulong ts ulong te ulong to bool 429 tl = sub te ts 430 if le sub hi lo tl 431 ret false 432 end 433 if ne get g_gpu sub sub hi tl 1 47 434 ret false 435 end 436 b = sub hi tl 437 for j ulong tl bound `9223372036854775807` 438 c = get g_f add ts j 439 if ne get g_gpu add b j c 440 ret false 441 end 442 end 443 ret true 444 end 445 note find a gpu line for the token g_f[ts, te): mode 0 exact under gpu/nvidia/, mode 1 by suffix; sets 22, 23 446 fn gfind ts ulong te ulong mode ulong to bool 447 n = get g_n 3 448 s = ulong 0 449 note every pass consumes at least one byte of the gpu list 450 while lt s n bound `9223372036854775807` 451 e = s 452 while and lt e n ne get g_gpu e 10 bound `9223372036854775807` 453 e = add e 1 454 end 455 hit = false 456 if eq mode 0 457 hit = gpeq s e t_gn ts te 458 else 459 hit = gpsuf s e ts te 460 end 461 if hit 462 put g_n 22 s 463 put g_n 23 e 464 ret true 465 end 466 s = add e 1 467 end 468 ret false 469 end 470 note the token that ends with ".om" at g_f[i, i+3): its start, or i when there is none 471 fn tokstart i ulong to ulong 472 b = i 473 while gt b 0 bound `9223372036854775807` 474 if not tokch ulong get g_f sub b 1 475 break 476 end 477 b = sub b 1 478 end 479 ret b 480 end 481 fn slashin s ulong e ulong to bool 482 for i ulong sub e s bound `9223372036854775807` 483 if eq get g_f add s i 47 484 ret true 485 end 486 end 487 ret false 488 end 489 fn omref to bool 490 n = get g_n 1 491 if lt n 3 492 ret false 493 end 494 for i ulong sub n 2 bound `9223372036854775807` 495 if fat i t_dotom 496 ok = true 497 if lt add i 3 n 498 if or alnum ulong get g_f add i 3 eq get g_f add i 3 95 499 ok = false 500 end 501 end 502 if ok 503 b = tokstart i 504 if lt b i 505 if gfind b add i 3 0 506 ret true 507 end 508 if and slashin b i gfind b add i 3 1 509 ret true 510 end 511 end 512 end 513 end 514 end 515 ret false 516 end 517 fn gdotom hi ulong to bool 518 if ne get g_gpu sub hi 3 46 519 ret false 520 end 521 if ne get g_gpu sub hi 2 111 522 ret false 523 end 524 ret eq get g_gpu sub hi 1 109 525 end 526 note gpu line [lo, hi) is gpu/nvidia/ then the list entry up to its extension, then ".om" 527 fn stemeq lo ulong hi ulong to bool 528 m = len t_gn 529 ss = get g_n 7 530 sl = sub get g_n 25 ss 531 if ne sub hi lo add add m sl 3 532 ret false 533 end 534 for i ulong m bound `9223372036854775807` 535 if ne get g_gpu add lo i get t_gn i 536 ret false 537 end 538 end 539 for j ulong sl bound `9223372036854775807` 540 c = get g_lst add ss j 541 if ne get g_gpu add add lo m j c 542 ret false 543 end 544 end 545 ret gdotom hi 546 end 547 fn samestem to bool 548 n = get g_n 3 549 s = ulong 0 550 while lt s n bound `9223372036854775807` 551 e = s 552 while and lt e n ne get g_gpu e 10 bound `9223372036854775807` 553 e = add e 1 554 end 555 if stemeq s e 556 put g_n 27 s 557 put g_n 28 e 558 ret true 559 end 560 s = add e 1 561 end 562 ret false 563 end 564 note ---- summary: the first comment line of g_f that is not a licence line; sets 20, 21 565 note style 0 C (/* * //), 1 hash (#, not #!), 2 Markdown (first # heading) 566 fn hasalnum s ulong e ulong to bool 567 for i ulong sub e s bound `9223372036854775807` 568 if alnum ulong get g_f add s i 569 ret true 570 end 571 end 572 ret false 573 end 574 note g_f[p] is c 575 fn fis p ulong c ulong to bool 576 ret eq ulong get g_f p c 577 end 578 fn skipsp s ulong e ulong to ulong 579 p = s 580 while and lt p e or fis p 32 fis p 9 bound `9223372036854775807` 581 p = add p 1 582 end 583 ret p 584 end 585 note trailing spaces, "*/" and quotes off the end 586 fn trimend s ulong e ulong to ulong 587 q = e 588 while gt q s bound `9223372036854775807` 589 c = get g_f sub q 1 590 if or or or eq c 32 eq c 9 eq c 13 eq c 34 591 q = sub q 1 592 continue 593 end 594 note two ifs, not one and: Omega's and reads both sides, and q - 2 is below 0 when q is 1 595 if and eq c 47 gt sub q s 1 596 if eq get g_f sub q 2 42 597 q = sub q 2 598 continue 599 end 600 end 601 break 602 end 603 ret q 604 end 605 note the text of a line [s, e) after its comment marker, as a start; e when it is not a comment line 606 fn cstart s ulong e ulong style ulong to ulong 607 p = skipsp s e 608 if ge p e 609 ret e 610 end 611 c = get g_f p 612 if eq style 0 613 d = ulong 0 614 if lt add p 1 e 615 d = ulong get g_f add p 1 616 end 617 if and eq c 47 or eq d 42 eq d 47 618 p = add p 2 619 while and lt p e or fis p 42 fis p 47 bound `9223372036854775807` 620 p = add p 1 621 end 622 ret skipsp p e 623 end 624 if eq c 42 625 p = add p 1 626 if and lt p e eq get g_f p 47 627 ret e 628 end 629 ret skipsp p e 630 end 631 ret e 632 end 633 if eq c 34 634 if and lt add p 2 e and fis add p 1 34 fis add p 2 34 635 ret skipsp add p 3 e 636 end 637 ret e 638 end 639 if ne c 35 640 ret e 641 end 642 if and lt add p 1 e eq get g_f add p 1 33 643 ret e 644 end 645 while and lt p e eq get g_f p 35 bound `9223372036854775807` 646 p = add p 1 647 end 648 ret skipsp p e 649 end 650 fn hastext s ulong e ulong t view uchar * to bool 651 m = len t 652 if lt sub e s m 653 ret false 654 end 655 for i ulong add sub sub e s m 1 bound `9223372036854775807` 656 if fat add s i t 657 ret true 658 end 659 end 660 ret false 661 end 662 fn spdx s ulong e ulong to bool 663 ret or hastext s e t_spdx hastext s e t_copyr 664 end 665 fn summary style ulong to bool 666 n = get g_n 1 667 s = ulong 0 668 lines = ulong 0 669 while and lt s n lt lines 80 bound `9223372036854775807` 670 e = s 671 while and lt e n ne get g_f e 10 bound `9223372036854775807` 672 e = add e 1 673 end 674 p = cstart s e style 675 q = trimend p e 676 if and lt p q and hasalnum p q not spdx p q 677 put g_n 20 p 678 put g_n 21 q 679 ret true 680 end 681 s = add e 1 682 lines = add lines 1 683 end 684 ret false 685 end 686 fn summ to bool 687 if or lext t_kc lext t_kh 688 ret summary 0 689 end 690 if or iscode lext t_kmd 691 ret summary 1 692 end 693 ret false 694 end 695 note ---- ports.tsv 696 note the decision field of port line [s, e): 1 ported, 2 retired, 3 blocked, 0 malformed; the path ends at the tab 697 fn pdec s ulong e ulong to ulong 698 t = s 699 while and lt t e ne get g_prt t 9 bound `9223372036854775807` 700 t = add t 1 701 end 702 if or eq t s ge t e 703 ret 0 704 end 705 d = add t 1 706 u = d 707 while and lt u e ne get g_prt u 9 bound `9223372036854775807` 708 u = add u 1 709 end 710 if ge u e 711 ret 0 712 end 713 r = ulong 0 714 if pword d u t_ported 715 r = 1 716 end 717 if pword d u t_retired 718 r = 2 719 end 720 if pword d u t_blocked 721 r = 3 722 end 723 ret r 724 end 725 fn pword s ulong e ulong t view uchar * to bool 726 if ne sub e s len t 727 ret false 728 end 729 for i ulong len t bound `9223372036854775807` 730 if ne get g_prt add s i get t i 731 ret false 732 end 733 end 734 ret true 735 end 736 note every ports row is well formed; counts rows into 31; exits 2 on a malformed one 737 fn pcheck to void 738 n = get g_n 4 739 s = ulong 0 740 k = ulong 0 741 while lt s n bound `9223372036854775807` 742 e = s 743 while and lt e n ne get g_prt e 10 bound `9223372036854775807` 744 e = add e 1 745 end 746 if and lt s e ne get g_prt s 35 747 if eq pdec s e 0 748 eput t_badport 749 r = write 2 g_prt s sub e s 750 r = write 2 t_nl 0 1 751 exit 2 752 end 753 k = add k 1 754 end 755 s = add e 1 756 end 757 put g_n 31 k 758 end 759 note the port row of the list entry: sets 29, 30 to its line and returns the decision, 0 when there is none 760 fn pfind to ulong 761 n = get g_n 4 762 ls = get g_n 7 763 ll = sub get g_n 8 ls 764 s = ulong 0 765 while lt s n bound `9223372036854775807` 766 e = s 767 while and lt e n ne get g_prt e 10 bound `9223372036854775807` 768 e = add e 1 769 end 770 note two ifs, not one and: Omega's and reads both sides, and s + ll may lie past the end of g_prt 771 if gt sub e s ll 772 if eq get g_prt add s ll 9 773 if peq s ls ll 774 put g_n 29 s 775 put g_n 30 e 776 ret pdec s e 777 end 778 end 779 end 780 s = add e 1 781 end 782 ret 0 783 end 784 fn peq s ulong ls ulong ll ulong to bool 785 for i ulong ll bound `9223372036854775807` 786 c = get g_lst add ls i 787 if ne get g_prt add s i c 788 ret false 789 end 790 end 791 ret true 792 end 793 fn bump k ulong to void 794 put g_n k add get g_n k 1 795 end 796 note ---- one row 797 fn row to void 798 s = get g_n 7 799 e = get g_n 8 800 names 801 pclr 802 if ge sub e s len g_pa 803 eput t_plong 804 r = write 2 g_lst s sub e s 805 r = write 2 t_nl 0 1 806 exit 2 807 end 808 for i ulong sub e s bound 4096 809 pc ulong get g_lst add s i 810 end 811 x = fload 812 if lt x 0 813 eput t_unread 814 epath 815 exit 2 816 end 817 bump 10 818 olr s e 819 otab 820 if lt get g_n 26 e 821 olr get g_n 26 e 822 else 823 ot t_none 824 end 825 otab 826 onum get g_n 1 827 otab 828 nl = ulong 0 829 for i ulong get g_n 1 bound `9223372036854775807` 830 if eq get g_f i 10 831 nl = add nl 1 832 end 833 end 834 onum nl 835 otab 836 m = ulong 0 837 if iscode 838 bump 11 839 m = marker 840 if eq m 0 841 bump 15 842 ot t_kthost 843 put g_n 33 3 844 else 845 if or fhas t_hostonly fhas t_sim 846 bump 14 847 ot t_kttier 848 put g_n 33 2 849 else 850 bump 13 851 ot t_ktdev 852 put g_n 33 1 853 end 854 end 855 else 856 bump 12 857 ot t_ktdata 858 put g_n 33 4 859 end 860 otab 861 omark m 862 otab 863 row2 864 end 865 fn row2 to void 866 if omref 867 ogr get g_n 22 get g_n 23 868 else 869 ot t_dash 870 end 871 otab 872 if samestem 873 ogr get g_n 27 get g_n 28 874 else 875 ot t_dash 876 end 877 otab 878 d = pfind 879 if eq d 0 880 bump 19 881 ot t_kopen 882 okadd 883 else 884 bump 9 885 bump add 15 d 886 t = get g_n 29 887 while ne get g_prt t 9 bound `9223372036854775807` 888 t = add t 1 889 end 890 opr add t 1 get g_n 30 891 end 892 otab 893 if summ 894 ofr get g_n 20 get g_n 21 895 else 896 ot t_dash 897 end 898 oc 10 899 end 900 note copy g_f into the list pool k (2 LIST, 3 GPULIST, 4 PORTS), growing it to fit with one zero byte past the 901 note copy, so that reading the byte at the end of the text (in the eager and of the line loops) stays in range, 902 note an empty file too; exits 2 when the host refuses the memory 903 fn copyf k ulong to void 904 n = get g_n 1 905 q = long 0 906 if eq k 2 907 q = enlarge g_lst add n 1 908 end 909 if eq k 3 910 q = enlarge g_gpu add n 1 911 end 912 if eq k 4 913 q = enlarge g_prt add n 1 914 end 915 if lt q 0 916 eput t_unread 917 epath 918 exit 2 919 end 920 for i ulong n bound `9223372036854775807` 921 if eq k 2 922 put g_lst i get g_f i 923 end 924 if eq k 3 925 put g_gpu i get g_f i 926 end 927 if eq k 4 928 put g_prt i get g_f i 929 end 930 end 931 put g_n k n 932 end 933 note ---- the open-by-kind line: keys of open rows in g_ok, counted in the order each key first appears 934 fn okc c ulong to void 935 n = get g_n 32 936 if ge n len g_ok 937 q = enlarge g_ok add mul n 2 64 938 if lt q 0 939 eput t_unread 940 r = write 2 t_nl 0 1 941 exit 2 942 end 943 end 944 put g_ok n uchar c 945 put g_n 32 add n 1 946 end 947 fn okadd to void 948 okc get g_n 33 949 s = get g_n 26 950 e = get g_n 8 951 if lt s e 952 for i ulong sub e s bound `9223372036854775807` 953 okc ulong get g_lst add s i 954 end 955 else 956 for i ulong len t_none bound 16 957 okc ulong get t_none i 958 end 959 end 960 okc 10 961 end 962 fn oknext a ulong to ulong 963 p = a 964 while ne get g_ok p 10 bound `9223372036854775807` 965 p = add p 1 966 end 967 ret add p 1 968 end 969 fn okeq a ulong b ulong to bool 970 i = ulong 0 971 while eq get g_ok add a i get g_ok add b i bound `9223372036854775807` 972 if eq get g_ok add a i 10 973 ret true 974 end 975 i = add i 1 976 end 977 ret false 978 end 979 fn okname a ulong to void 980 t = ulong get g_ok a 981 if eq t 1 982 ot t_ktdev 983 end 984 if eq t 2 985 ot t_kttier 986 end 987 if eq t 3 988 ot t_kthost 989 end 990 if eq t 4 991 ot t_ktdata 992 end 993 oc 47 994 p = add a 1 995 while ne get g_ok p 10 bound `9223372036854775807` 996 oc ulong get g_ok p 997 p = add p 1 998 end 999 end 1000 fn okline to void 1001 n = get g_n 32 1002 ot t_okh 1003 a = ulong 0 1004 while lt a n bound `9223372036854775807` 1005 seen = ulong 0 1006 b = ulong 0 1007 while lt b a bound `9223372036854775807` 1008 if okeq a b 1009 seen = 1 1010 end 1011 b = oknext b 1012 end 1013 if eq seen 0 1014 c = ulong 0 1015 b = a 1016 while lt b n bound `9223372036854775807` 1017 if okeq a b 1018 c = add c 1 1019 end 1020 b = oknext b 1021 end 1022 oc 32 1023 okname a 1024 oc 61 1025 onum c 1026 end 1027 a = oknext a 1028 end 1029 oc 10 1030 end 1031 fn tot k ulong t view uchar * to void 1032 ot t 1033 onum get g_n k 1034 end 1035 fn main to int 1036 if ne argcnt 5 1037 eput t_usage 1038 ret 2 1039 end 1040 x = aload 1 1041 copyf 2 1042 x = aload 2 1043 copyf 3 1044 x = aload 3 1045 copyf 4 1046 r = argread 4 g_lab 0 len g_lab 1047 if lt r 0 1048 eput t_usage 1049 ret 2 1050 end 1051 put g_n 6 ulong r 1052 pcheck 1053 ot t_h1 1054 for i ulong get g_n 6 bound 131072 1055 c = ulong get g_lab i 1056 if or eq c 10 eq c 9 1057 c = 32 1058 end 1059 oc c 1060 end 1061 oc 10 1062 ot t_h2 1063 n = get g_n 2 1064 s = ulong 0 1065 while lt s n bound `9223372036854775807` 1066 e = s 1067 while and lt e n ne get g_lst e 10 bound `9223372036854775807` 1068 e = add e 1 1069 end 1070 if lt s e 1071 put g_n 7 s 1072 put g_n 8 e 1073 if not isdotom 1074 row 1075 end 1076 end 1077 s = add e 1 1078 end 1079 okline 1080 tot 10 t_tot 1081 tot 11 t_code 1082 tot 12 t_data 1083 tot 13 t_dev 1084 tot 14 t_tier 1085 tot 15 t_host 1086 tot 16 t_por 1087 tot 17 t_ret 1088 tot 18 t_blk 1089 tot 19 t_open 1090 oc 10 1091 oflush 1092 if ne get g_n 9 get g_n 31 1093 eput t_stale 1094 r = write 2 t_nl 0 1 1095 ret 1 1096 end 1097 ret 0 1098 end