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 / seed / authority / dispatch-gate.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note OM-CONTROL-659 action contract v1. See ../README.md for the trusted-caller boundary. |
| 3 | note No I/O, authority minting or persistence. Caller serializes and durably commits transitions. |
| 4 | note Record words 0..7: version,state,attempt,limit,generation,epoch,expiry,reserved. |
| 5 | note Words 8..31: operation,request,scope,provider,policy,grant identities, four words each. |
| 6 | note State 1 ready,2 in-flight,3 unknown,4 performed. No timeout implies not performed. |
| 7 | |
| 8 | fn actvalid r view ulong 32 to ulong |
| 9 | if ne get r 0 1 |
| 10 | ret 11 |
| 11 | end |
| 12 | if or lt get r 1 1 gt get r 1 4 |
| 13 | ret 12 |
| 14 | end |
| 15 | if or eq get r 3 0 gt get r 3 1024 |
| 16 | ret 12 |
| 17 | end |
| 18 | if gt get r 2 get r 3 |
| 19 | ret 12 |
| 20 | end |
| 21 | if and ne get r 1 1 eq get r 2 0 |
| 22 | ret 12 |
| 23 | end |
| 24 | if or eq get r 4 0 eq get r 5 0 |
| 25 | ret 12 |
| 26 | end |
| 27 | if or eq get r 6 0 ne get r 7 0 |
| 28 | ret 12 |
| 29 | end |
| 30 | for g ulong 6 |
| 31 | bits = ulong 0 |
| 32 | for j ulong 4 |
| 33 | bits = or bits get r add 8 add mul g 4 j |
| 34 | end |
| 35 | if eq bits 0 |
| 36 | ret 12 |
| 37 | end |
| 38 | end |
| 39 | ret 0 |
| 40 | end |
| 41 | |
| 42 | fn actbind r view ulong 32 c view ulong 32 to ulong |
| 43 | for g ulong 6 |
| 44 | diff = ulong 0 |
| 45 | for j ulong 4 |
| 46 | ix = add 8 add mul g 4 j |
| 47 | diff = or diff xor get r ix get c ix |
| 48 | end |
| 49 | if ne diff 0 |
| 50 | ret add 40 g |
| 51 | end |
| 52 | end |
| 53 | ret 0 |
| 54 | end |
| 55 | |
| 56 | fn actauth r view ulong 32 c view ulong 32 to ulong |
| 57 | if ne get c 0 1 |
| 58 | ret 11 |
| 59 | end |
| 60 | if or ne get c 3 0 or ne get c 6 0 ne get c 7 0 |
| 61 | ret 12 |
| 62 | end |
| 63 | if ne get c 1 1 |
| 64 | ret 30 |
| 65 | end |
| 66 | if ne get r 4 get c 4 |
| 67 | ret 31 |
| 68 | end |
| 69 | if ne get r 5 get c 5 |
| 70 | ret 32 |
| 71 | end |
| 72 | if ge get c 2 get r 6 |
| 73 | ret 33 |
| 74 | end |
| 75 | ret actbind r c |
| 76 | end |
| 77 | |
| 78 | fn actstart r edit ulong 32 c view ulong 32 to ulong |
| 79 | err = actvalid r |
| 80 | if ne err 0 |
| 81 | ret err |
| 82 | end |
| 83 | if eq get r 1 3 |
| 84 | ret 21 |
| 85 | end |
| 86 | if eq get r 1 4 |
| 87 | ret 22 |
| 88 | end |
| 89 | if ne get r 1 1 |
| 90 | ret 20 |
| 91 | end |
| 92 | if ge get r 2 get r 3 |
| 93 | ret 23 |
| 94 | end |
| 95 | err = actauth r c |
| 96 | if ne err 0 |
| 97 | ret err |
| 98 | end |
| 99 | put r 2 add get r 2 1 |
| 100 | put r 1 2 |
| 101 | ret 0 |
| 102 | end |
| 103 | |
| 104 | fn actlost r edit ulong 32 to ulong |
| 105 | err = actvalid r |
| 106 | if ne err 0 |
| 107 | ret err |
| 108 | end |
| 109 | if eq get r 1 3 |
| 110 | ret 0 |
| 111 | end |
| 112 | if ne get r 1 2 |
| 113 | ret 20 |
| 114 | end |
| 115 | put r 1 3 |
| 116 | ret 0 |
| 117 | end |
| 118 | |
| 119 | note A trusted receipt maps outcome 0 unknown,1 definitely not performed,2 performed. |
| 120 | note Not-found or timeout is outcome 0 unless the provider proves absence and quiescence. |
| 121 | note Receipt words 2/3: exact attempt and verification=1. Words 6/7 must be zero. |
| 122 | note Recording an observed outcome is permitted after expiry; another attempt is not. |
| 123 | fn actrecon r edit ulong 32 s view ulong 32 to ulong |
| 124 | err = actvalid r |
| 125 | if ne err 0 |
| 126 | ret err |
| 127 | end |
| 128 | if not or eq get r 1 2 eq get r 1 3 |
| 129 | ret 20 |
| 130 | end |
| 131 | if ne get s 0 1 |
| 132 | ret 11 |
| 133 | end |
| 134 | if or gt get s 1 2 or ne get s 6 0 ne get s 7 0 |
| 135 | ret 12 |
| 136 | end |
| 137 | if ne get s 3 1 |
| 138 | ret 36 |
| 139 | end |
| 140 | if ne get s 2 get r 2 |
| 141 | ret 35 |
| 142 | end |
| 143 | if ne get s 4 get r 4 |
| 144 | ret 31 |
| 145 | end |
| 146 | if ne get s 5 get r 5 |
| 147 | ret 32 |
| 148 | end |
| 149 | err = actbind r s |
| 150 | if ne err 0 |
| 151 | ret err |
| 152 | end |
| 153 | if eq get s 1 0 |
| 154 | put r 1 3 |
| 155 | ret 21 |
| 156 | end |
| 157 | if eq get s 1 1 |
| 158 | put r 1 1 |
| 159 | else |
| 160 | put r 1 4 |
| 161 | end |
| 162 | ret 0 |
| 163 | end |
| 164 | note SPDX-License-Identifier: AGPL-3.0-only |
| 165 | note Durable 32-word authority record store. Caller supplies the record and generation. |
| 166 | note Writes a temporary 256-byte file, fsyncs it, then atomically renames it into place. |
| 167 | note Reads require exactly 256 bytes; a short or torn file is refused. Store calls do not lock; the |
| 168 | note dispatcher holds lock.om around its read-check-persist window. |
| 169 | text recp "build/authority-store/rec" |
| 170 | text tmpp "build/authority-store/tmp" |
| 171 | text genp "build/authority-store/gen" |
| 172 | global sb uchar 256 |
| 173 | global stail uchar 1 |
| 174 | global spkt uchar 256 |
| 175 | global sn ulong 1 |
| 176 | global spath uchar 128 |
| 177 | global splen ulong 1 |
| 178 | global sgerr ulong 1 |
| 179 | fn put16 v ulong to void |
| 180 | put spkt get sn 0 uchar and v 255 |
| 181 | put spkt add get sn 0 1 uchar shr v 8 |
| 182 | put sn 0 add get sn 0 2 |
| 183 | end |
| 184 | fn setrec to void |
| 185 | put splen 0 len recp |
| 186 | for i ulong len recp |
| 187 | put spath i get recp i |
| 188 | end |
| 189 | end |
| 190 | fn settmp to void |
| 191 | put splen 0 len tmpp |
| 192 | for i ulong len tmpp |
| 193 | put spath i get tmpp i |
| 194 | end |
| 195 | end |
| 196 | fn setgen to void |
| 197 | put splen 0 len genp |
| 198 | for i ulong len genp |
| 199 | put spath i get genp i |
| 200 | end |
| 201 | end |
| 202 | fn pack2 to ulong |
| 203 | put sn 0 0 |
| 204 | put16 2 |
| 205 | put16 len tmpp |
| 206 | for i ulong len tmpp |
| 207 | put spkt add get sn 0 i get tmpp i |
| 208 | end |
| 209 | put sn 0 add get sn 0 len tmpp |
| 210 | put16 len recp |
| 211 | for i ulong len recp |
| 212 | put spkt add get sn 0 i get recp i |
| 213 | end |
| 214 | put sn 0 add get sn 0 len recp |
| 215 | ret get sn 0 |
| 216 | end |
| 217 | fn enc r view ulong 32 to void |
| 218 | for i ulong 32 |
| 219 | v = get r i |
| 220 | for j ulong 8 |
| 221 | put sb add mul i 8 j uchar and shr v mul j 8 255 |
| 222 | end |
| 223 | end |
| 224 | end |
| 225 | fn dec r edit ulong 32 to void |
| 226 | for i ulong 32 |
| 227 | v = ulong 0 |
| 228 | for j ulong 8 |
| 229 | v = or v shl ulong get sb add mul i 8 j mul j 8 |
| 230 | end |
| 231 | put r i v |
| 232 | end |
| 233 | end |
| 234 | note p10 effect |
| 235 | fn writerec r view ulong 32 to ulong |
| 236 | enc r |
| 237 | settmp |
| 238 | fd = fopen spath 0 get splen 0 577 384 |
| 239 | if lt fd 0 |
| 240 | ret 10 |
| 241 | end |
| 242 | n = write int fd sb 0 256 |
| 243 | if ne n 256 |
| 244 | note p10 allow E1 primary write error wins over cleanup close error |
| 245 | cleanup = fclose int fd |
| 246 | ret 11 |
| 247 | end |
| 248 | if ne fsync int fd 0 |
| 249 | note p10 allow E1 primary sync error wins over cleanup close error |
| 250 | cleanup = fclose int fd |
| 251 | ret 12 |
| 252 | end |
| 253 | if ne fclose int fd 0 |
| 254 | ret 13 |
| 255 | end |
| 256 | pn = pack2 |
| 257 | rr = renames spkt 0 pn 0 |
| 258 | if lt rr 0 |
| 259 | ret 14 |
| 260 | end |
| 261 | ret 0 |
| 262 | end |
| 263 | note p10 effect |
| 264 | fn readrec r edit ulong 32 to ulong |
| 265 | setrec |
| 266 | fd = fopen spath 0 get splen 0 0 0 |
| 267 | if lt fd 0 |
| 268 | ret 20 |
| 269 | end |
| 270 | n = read int fd sb 0 256 |
| 271 | extra = long -1 |
| 272 | if eq n 256 |
| 273 | extra = read int fd stail 0 1 |
| 274 | end |
| 275 | if ne fclose int fd 0 |
| 276 | ret 21 |
| 277 | end |
| 278 | if or ne n 256 ne extra 0 |
| 279 | ret 22 |
| 280 | end |
| 281 | dec r |
| 282 | ret 0 |
| 283 | end |
| 284 | note p10 effect |
| 285 | fn readgen to ulong |
| 286 | put sgerr 0 0 |
| 287 | setgen |
| 288 | fd = fopen spath 0 get splen 0 0 0 |
| 289 | if lt fd 0 |
| 290 | put sgerr 0 30 |
| 291 | ret 0 |
| 292 | end |
| 293 | n = read int fd sb 0 8 |
| 294 | extra = long -1 |
| 295 | if eq n 8 |
| 296 | extra = read int fd stail 0 1 |
| 297 | end |
| 298 | if ne fclose int fd 0 |
| 299 | put sgerr 0 31 |
| 300 | ret 0 |
| 301 | end |
| 302 | if or ne n 8 ne extra 0 |
| 303 | put sgerr 0 32 |
| 304 | ret 0 |
| 305 | end |
| 306 | v = ulong 0 |
| 307 | for j ulong 8 |
| 308 | v = or v shl ulong get sb j mul j 8 |
| 309 | end |
| 310 | ret v |
| 311 | end |
| 312 | note p10 effect |
| 313 | fn writegen v ulong to ulong |
| 314 | setgen |
| 315 | fd = fopen spath 0 get splen 0 577 384 |
| 316 | if lt fd 0 |
| 317 | ret 40 |
| 318 | end |
| 319 | for j ulong 8 |
| 320 | put sb j uchar and shr v mul j 8 255 |
| 321 | end |
| 322 | n = write int fd sb 0 8 |
| 323 | if ne n 8 |
| 324 | note p10 allow E1 primary write error wins over cleanup close error |
| 325 | cleanup = fclose int fd |
| 326 | ret 41 |
| 327 | end |
| 328 | if ne fsync int fd 0 |
| 329 | note p10 allow E1 primary sync error wins over cleanup close error |
| 330 | cleanup = fclose int fd |
| 331 | ret 42 |
| 332 | end |
| 333 | if ne fclose int fd 0 |
| 334 | ret 43 |
| 335 | end |
| 336 | ret 0 |
| 337 | end |
| 338 | note p10 pure |
| 339 | fn storevalid r view ulong 32 g ulong to ulong |
| 340 | if ne get r 0 1 |
| 341 | ret 51 |
| 342 | end |
| 343 | if ne get r 4 g |
| 344 | ret 52 |
| 345 | end |
| 346 | ret 0 |
| 347 | end |
| 348 | note SPDX-License-Identifier: AGPL-3.0-only |
| 349 | note Cross-process lock for the authority store. A lock is an O_EXCL file containing the owner pid. |
| 350 | note A contending process retries with a bounded sleep; a lock whose pid is gone is reclaimed. |
| 351 | note This serializes the read-check-persist window. It does not serialize the effect itself. |
| 352 | global lb uchar 8 |
| 353 | global lerr ulong 1 |
| 354 | text lpath "build/authority-store/lock" |
| 355 | |
| 356 | fn lpid p ulong to void |
| 357 | put lb 0 uchar and p 255 |
| 358 | put lb 1 uchar and shr p 8 255 |
| 359 | put lb 2 uchar and shr p 16 255 |
| 360 | put lb 3 uchar and shr p 24 255 |
| 361 | put lb 4 uchar and shr p 32 255 |
| 362 | put lb 5 uchar and shr p 40 255 |
| 363 | put lb 6 uchar and shr p 48 255 |
| 364 | put lb 7 uchar shr p 56 |
| 365 | end |
| 366 | |
| 367 | fn lget to ulong |
| 368 | v = ulong 0 |
| 369 | for i ulong 8 |
| 370 | v = or v shl ulong get lb i mul i 8 |
| 371 | end |
| 372 | ret v |
| 373 | end |
| 374 | |
| 375 | note p10 effect |
| 376 | fn ltake p ulong to ulong |
| 377 | fd = fopen lpath 0 len lpath 193 384 |
| 378 | if lt fd 0 |
| 379 | if eq fd -17 |
| 380 | ret 20 |
| 381 | end |
| 382 | ret 40 |
| 383 | end |
| 384 | lpid p |
| 385 | n = write int fd lb 0 8 |
| 386 | if ne n 8 |
| 387 | if ne fclose int fd 0 |
| 388 | ret 30 |
| 389 | end |
| 390 | ret 31 |
| 391 | end |
| 392 | if ne fclose int fd 0 |
| 393 | ret 31 |
| 394 | end |
| 395 | ret 0 |
| 396 | end |
| 397 | |
| 398 | note p10 effect |
| 399 | fn lread to ulong |
| 400 | put lerr 0 0 |
| 401 | fd = fopen lpath 0 len lpath 0 0 |
| 402 | if lt fd 0 |
| 403 | put lerr 0 32 |
| 404 | ret 0 |
| 405 | end |
| 406 | n = read int fd lb 0 8 |
| 407 | if ne fclose int fd 0 |
| 408 | put lerr 0 33 |
| 409 | ret 0 |
| 410 | end |
| 411 | if ne n 8 |
| 412 | put lerr 0 34 |
| 413 | ret 0 |
| 414 | end |
| 415 | ret lget |
| 416 | end |
| 417 | |
| 418 | note p10 effect |
| 419 | fn lrm to ulong |
| 420 | r = unlink lpath 0 len lpath |
| 421 | if lt r 0 |
| 422 | ret 41 |
| 423 | end |
| 424 | ret 0 |
| 425 | end |
| 426 | |
| 427 | note p10 effect |
| 428 | fn ltry p ulong to ulong |
| 429 | r = ltake p |
| 430 | if eq r 0 |
| 431 | ret 0 |
| 432 | end |
| 433 | if ne r 20 |
| 434 | ret r |
| 435 | end |
| 436 | q = lread |
| 437 | if ne get lerr 0 0 |
| 438 | ret 40 |
| 439 | end |
| 440 | k = killpid int q 0 |
| 441 | if ne k -3 |
| 442 | ret 20 |
| 443 | end |
| 444 | r = lrm |
| 445 | if ne r 0 |
| 446 | ret 41 |
| 447 | end |
| 448 | ret ltake p |
| 449 | end |
| 450 | |
| 451 | note p10 effect |
| 452 | fn lacq p ulong tries ulong to ulong |
| 453 | if gt tries 1000 |
| 454 | ret 43 |
| 455 | end |
| 456 | i = ulong 0 |
| 457 | while lt i tries bound 1000 |
| 458 | r = ltry p |
| 459 | if eq r 0 |
| 460 | ret 0 |
| 461 | end |
| 462 | if ne r 20 |
| 463 | ret r |
| 464 | end |
| 465 | if ne sleepns 1000000 0 |
| 466 | ret 42 |
| 467 | end |
| 468 | i = add i 1 |
| 469 | end |
| 470 | ret 22 |
| 471 | end |
| 472 | |
| 473 | fn lrel to ulong |
| 474 | ret lrm |
| 475 | end |
| 476 | note SPDX-License-Identifier: AGPL-3.0-only |
| 477 | note Single-effect dispatcher over the action contract and durable store. |
| 478 | note The state is persisted in-flight before the effect. A generation change during the effect |
| 479 | note marks the operation unknown; a duplicate or performed record is refused. The effect here is |
| 480 | note a synthetic fork child: mode '1' writes generation2, mode '2' exits1, mode '0' exits0. |
| 481 | global dstat uchar 4 |
| 482 | global dpkt uchar 256 |
| 483 | global dn ulong 1 |
| 484 | global dpath uchar 128 |
| 485 | global dplen ulong 1 |
| 486 | global dpid ulong 1 |
| 487 | text truep "/bin/true" |
| 488 | text strictp "seed/authority/effect-ok" |
| 489 | fn dput16 v ulong to void |
| 490 | put dpkt get dn 0 uchar and v 255 |
| 491 | put dpkt add get dn 0 1 uchar shr v 8 |
| 492 | put dn 0 add get dn 0 2 |
| 493 | end |
| 494 | fn dcopy to void |
| 495 | for i ulong get dplen 0 bound 128 |
| 496 | put dpkt add get dn 0 i get dpath i |
| 497 | end |
| 498 | put dn 0 add get dn 0 get dplen 0 |
| 499 | end |
| 500 | fn packtrue to ulong |
| 501 | put dn 0 0 |
| 502 | dput16 1 |
| 503 | dput16 len truep |
| 504 | for i ulong len truep |
| 505 | put dpkt add get dn 0 i get truep i |
| 506 | end |
| 507 | put dn 0 add get dn 0 len truep |
| 508 | ret get dn 0 |
| 509 | end |
| 510 | fn doreceipt r view ulong 32 s edit ulong 32 outcome ulong to void |
| 511 | for i ulong 32 |
| 512 | put s i 0 |
| 513 | end |
| 514 | put s 0 1 |
| 515 | put s 1 outcome |
| 516 | put s 2 get r 2 |
| 517 | put s 3 1 |
| 518 | put s 4 get r 4 |
| 519 | put s 5 get r 5 |
| 520 | for i ulong 24 |
| 521 | put s add 8 i get r add 8 i |
| 522 | end |
| 523 | end |
| 524 | note Preserve an already established failure; otherwise expose release failure. |
| 525 | fn dfinish code ulong to ulong |
| 526 | lk = lrel |
| 527 | if ne code 0 |
| 528 | ret code |
| 529 | end |
| 530 | if ne lk 0 |
| 531 | ret 78 |
| 532 | end |
| 533 | ret 0 |
| 534 | end |
| 535 | note p10 effect |
| 536 | fn dispatch r edit ulong 32 c view ulong 32 mode uchar to ulong |
| 537 | err = lacq get dpid 0 1000 |
| 538 | if ne err 0 |
| 539 | ret 80 |
| 540 | end |
| 541 | err = readrec r |
| 542 | if ne err 0 |
| 543 | ret dfinish 70 |
| 544 | end |
| 545 | g = readgen |
| 546 | if ne get sgerr 0 0 |
| 547 | ret dfinish 71 |
| 548 | end |
| 549 | err = storevalid r g |
| 550 | if ne err 0 |
| 551 | ret dfinish err |
| 552 | end |
| 553 | err = actstart r c |
| 554 | if ne err 0 |
| 555 | ret dfinish err |
| 556 | end |
| 557 | err = writerec r |
| 558 | if ne err 0 |
| 559 | ret dfinish 72 |
| 560 | end |
| 561 | lk = lrel |
| 562 | if ne lk 0 |
| 563 | ret 78 |
| 564 | end |
| 565 | pid = fork |
| 566 | if lt pid 0 |
| 567 | ret 73 |
| 568 | end |
| 569 | if eq pid 0 |
| 570 | if eq mode 49 |
| 571 | e = writegen 2 |
| 572 | if ne e 0 |
| 573 | exit int 97 |
| 574 | end |
| 575 | end |
| 576 | if eq mode 50 |
| 577 | exit int 1 |
| 578 | end |
| 579 | if eq mode 51 |
| 580 | n = packtrue |
| 581 | note p10 allow E1 exec returns only on failure and the next line exits 98 |
| 582 | rr = execprog dpkt 0 n |
| 583 | exit int 98 |
| 584 | end |
| 585 | if eq mode 52 |
| 586 | put dn 0 0 |
| 587 | dput16 1 |
| 588 | dput16 get dplen 0 |
| 589 | dcopy |
| 590 | note p10 allow E1 exec returns only on failure and the next line exits 98 |
| 591 | rx = execpure dpkt 0 get dn 0 |
| 592 | exit int 98 |
| 593 | end |
| 594 | exit int 0 |
| 595 | end |
| 596 | wr = waitpid int pid dstat 0 len dstat 0 |
| 597 | if ne wr long pid |
| 598 | ret 74 |
| 599 | end |
| 600 | sig = ulong get dstat 0 |
| 601 | code = ulong get dstat 1 |
| 602 | g2 = readgen |
| 603 | if ne get sgerr 0 0 |
| 604 | ret 75 |
| 605 | end |
| 606 | if ne g2 g |
| 607 | err = lacq get dpid 0 1000 |
| 608 | if ne err 0 |
| 609 | ret 80 |
| 610 | end |
| 611 | err = actlost r |
| 612 | if ne err 0 |
| 613 | ret dfinish 79 |
| 614 | end |
| 615 | err = writerec r |
| 616 | if ne err 0 |
| 617 | ret dfinish 77 |
| 618 | end |
| 619 | lk = dfinish 0 |
| 620 | if ne lk 0 |
| 621 | ret lk |
| 622 | end |
| 623 | ret 60 |
| 624 | end |
| 625 | err = lacq get dpid 0 1000 |
| 626 | if ne err 0 |
| 627 | ret 80 |
| 628 | end |
| 629 | s = new ulong 32 0 |
| 630 | outcome = ulong 0 |
| 631 | if and eq sig 0 eq code 0 |
| 632 | outcome = ulong 2 |
| 633 | end |
| 634 | doreceipt r s outcome |
| 635 | err = actrecon r s |
| 636 | if ne err 0 |
| 637 | err = writerec r |
| 638 | if ne err 0 |
| 639 | ret dfinish 77 |
| 640 | end |
| 641 | ret dfinish 76 |
| 642 | end |
| 643 | err = writerec r |
| 644 | if ne err 0 |
| 645 | ret dfinish 77 |
| 646 | end |
| 647 | lk = dfinish 0 |
| 648 | if ne lk 0 |
| 649 | ret lk |
| 650 | end |
| 651 | if eq outcome 0 |
| 652 | ret 61 |
| 653 | end |
| 654 | ret 0 |
| 655 | end |
| 656 | note SPDX-License-Identifier: AGPL-3.0-only |
| 657 | note Dispatcher checks: valid performed, duplicate, in-flight, unknown, limit, revocation and stale. |
| 658 | global checks ulong 1 |
| 659 | global fails ulong 1 |
| 660 | global report uchar 64 |
| 661 | text title "dispatch checks=" |
| 662 | text bd "build" |
| 663 | text dir "build/authority-store" |
| 664 | fn check got ulong want ulong to void |
| 665 | put checks 0 add get checks 0 1 |
| 666 | if ne got want |
| 667 | put fails 0 add get fails 0 1 |
| 668 | end |
| 669 | end |
| 670 | fn plan r edit ulong 32 to void |
| 671 | for i ulong 32 |
| 672 | put r i 0 |
| 673 | end |
| 674 | put r 0 1 |
| 675 | put r 1 1 |
| 676 | put r 3 3 |
| 677 | put r 4 1 |
| 678 | put r 5 9 |
| 679 | put r 6 100 |
| 680 | for i ulong 24 |
| 681 | put r add i 8 add i 100 |
| 682 | end |
| 683 | end |
| 684 | fn context c edit ulong 32 to void |
| 685 | for i ulong 32 |
| 686 | put c i 0 |
| 687 | end |
| 688 | put c 0 1 |
| 689 | put c 1 1 |
| 690 | put c 2 50 |
| 691 | put c 4 1 |
| 692 | put c 5 9 |
| 693 | for i ulong 24 |
| 694 | put c add i 8 add i 100 |
| 695 | end |
| 696 | end |
| 697 | fn summary to int |
| 698 | for i ulong len title |
| 699 | put report i get title i |
| 700 | end |
| 701 | n = get checks 0 |
| 702 | at = len title |
| 703 | put report at uchar add 48 div n 100 |
| 704 | put report add at 1 uchar add 48 rem div n 10 10 |
| 705 | put report add at 2 uchar add 48 rem n 10 |
| 706 | put report add at 3 32 |
| 707 | put report add at 4 uchar add 48 div get fails 0 100 |
| 708 | put report add at 5 uchar add 48 rem div get fails 0 10 10 |
| 709 | put report add at 6 uchar add 48 rem get fails 0 10 |
| 710 | put report add at 7 10 |
| 711 | w = write 1 report 0 add at 8 |
| 712 | if ne w long add at 8 |
| 713 | ret 2 |
| 714 | end |
| 715 | if ne get fails 0 0 |
| 716 | ret 1 |
| 717 | end |
| 718 | ret 0 |
| 719 | end |
| 720 | fn main to int |
| 721 | put dpid 0 ulong getpid |
| 722 | lk = lrel |
| 723 | mk = makedir bd 0 len bd 448 |
| 724 | if or eq mk 0 eq mk -17 |
| 725 | else |
| 726 | ret 90 |
| 727 | end |
| 728 | if ne makedir dir 0 len dir 448 0 |
| 729 | put sb 0 0 |
| 730 | end |
| 731 | r = new ulong 32 0 |
| 732 | c = new ulong 32 0 |
| 733 | plan r |
| 734 | context c |
| 735 | check writegen 1 0 |
| 736 | check writerec r 0 |
| 737 | check dispatch r c 48 0 |
| 738 | check readrec r 0 |
| 739 | check get r 1 4 |
| 740 | check get r 2 1 |
| 741 | check dispatch r c 48 22 |
| 742 | plan r |
| 743 | check writegen 1 0 |
| 744 | check writerec r 0 |
| 745 | check dispatch r c 51 0 |
| 746 | check readrec r 0 |
| 747 | check get r 1 4 |
| 748 | plan r |
| 749 | check writegen 1 0 |
| 750 | check writerec r 0 |
| 751 | for i ulong len strictp |
| 752 | put dpath i get strictp i |
| 753 | end |
| 754 | put dplen 0 len strictp |
| 755 | check dispatch r c 52 0 |
| 756 | check readrec r 0 |
| 757 | check get r 1 4 |
| 758 | plan r |
| 759 | put r 1 2 |
| 760 | put r 2 1 |
| 761 | check writerec r 0 |
| 762 | check dispatch r c 48 20 |
| 763 | plan r |
| 764 | put r 1 3 |
| 765 | put r 2 1 |
| 766 | check writerec r 0 |
| 767 | check dispatch r c 48 21 |
| 768 | plan r |
| 769 | put r 3 1 |
| 770 | put r 2 1 |
| 771 | check writerec r 0 |
| 772 | check dispatch r c 48 23 |
| 773 | plan r |
| 774 | check writegen 1 0 |
| 775 | check writerec r 0 |
| 776 | check dispatch r c 49 60 |
| 777 | check readrec r 0 |
| 778 | check get r 1 3 |
| 779 | check readgen 2 |
| 780 | check writegen 2 0 |
| 781 | plan r |
| 782 | check writerec r 0 |
| 783 | check dispatch r c 48 52 |
| 784 | plan r |
| 785 | put r 1 2 |
| 786 | put r 2 1 |
| 787 | check writerec r 0 |
| 788 | err = actlost r |
| 789 | check err 0 |
| 790 | check writerec r 0 |
| 791 | check readrec r 0 |
| 792 | check get r 1 3 |
| 793 | ret summary |
| 794 | end |