1
0
mirror of https://github.com/golang/go synced 2024-11-26 07:47:57 -07:00

select/chan

R=r
DELTA=517  (137 added, 98 deleted, 282 changed)
OCL=13495
CL=13495
This commit is contained in:
Ken Thompson 2008-07-26 14:21:21 -07:00
parent 949ab5c7ff
commit 120827284e
4 changed files with 421 additions and 382 deletions

View File

@ -47,7 +47,7 @@ func mapassign2(hmap *map[any]any, key any, val any, pres bool);
func newchan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any);
func chanrecv1(hchan *chan any) (elem any);
func chanrecv2(hchan *chan any) (elem any, pres bool);
func chanrecv3(hchan *chan any) (elem any, pres bool);
func chanrecv3(hchan *chan any, elem *any) (pres bool);
func chansend1(hchan *chan any, elem any);
func chansend2(hchan *chan any, elem any) (pres bool);

View File

@ -3,10 +3,10 @@ char* sysimport =
"type sys._esys_002 {}\n"
"type sys.any 24\n"
"type sys._esys_003 *sys.any\n"
"type sys._osys_361 {_esys_359 sys._esys_003}\n"
"type sys._osys_372 {_esys_370 sys._esys_003}\n"
"type sys.uint32 6\n"
"type sys._isys_363 {_esys_360 sys.uint32}\n"
"type sys._esys_001 (sys._esys_002 sys._osys_361 sys._isys_363)\n"
"type sys._isys_374 {_esys_371 sys.uint32}\n"
"type sys._esys_001 (sys._esys_002 sys._osys_372 sys._isys_374)\n"
"var !sys.mal sys._esys_001\n"
"type sys._esys_005 {}\n"
"type sys._esys_006 {}\n"
@ -16,282 +16,283 @@ char* sysimport =
"type sys._esys_009 {}\n"
"type sys._esys_010 {}\n"
"type sys.int32 5\n"
"type sys._isys_369 {_esys_368 sys.int32}\n"
"type sys._esys_008 (sys._esys_009 sys._esys_010 sys._isys_369)\n"
"type sys._isys_380 {_esys_379 sys.int32}\n"
"type sys._esys_008 (sys._esys_009 sys._esys_010 sys._isys_380)\n"
"var !sys.panicl sys._esys_008\n"
"type sys._esys_012 {}\n"
"type sys._esys_013 {}\n"
"type sys.bool 12\n"
"type sys._isys_374 {_esys_373 sys.bool}\n"
"type sys._esys_011 (sys._esys_012 sys._esys_013 sys._isys_374)\n"
"type sys._isys_385 {_esys_384 sys.bool}\n"
"type sys._esys_011 (sys._esys_012 sys._esys_013 sys._isys_385)\n"
"var !sys.printbool sys._esys_011\n"
"type sys._esys_015 {}\n"
"type sys._esys_016 {}\n"
"type sys.float64 10\n"
"type sys._isys_379 {_esys_378 sys.float64}\n"
"type sys._esys_014 (sys._esys_015 sys._esys_016 sys._isys_379)\n"
"type sys._isys_390 {_esys_389 sys.float64}\n"
"type sys._esys_014 (sys._esys_015 sys._esys_016 sys._isys_390)\n"
"var !sys.printfloat sys._esys_014\n"
"type sys._esys_018 {}\n"
"type sys._esys_019 {}\n"
"type sys.int64 7\n"
"type sys._isys_384 {_esys_383 sys.int64}\n"
"type sys._esys_017 (sys._esys_018 sys._esys_019 sys._isys_384)\n"
"type sys._isys_395 {_esys_394 sys.int64}\n"
"type sys._esys_017 (sys._esys_018 sys._esys_019 sys._isys_395)\n"
"var !sys.printint sys._esys_017\n"
"type sys._esys_021 {}\n"
"type sys._esys_022 {}\n"
"type sys._esys_023 25\n"
"type sys.string *sys._esys_023\n"
"type sys._isys_389 {_esys_388 sys.string}\n"
"type sys._esys_020 (sys._esys_021 sys._esys_022 sys._isys_389)\n"
"type sys._isys_400 {_esys_399 sys.string}\n"
"type sys._esys_020 (sys._esys_021 sys._esys_022 sys._isys_400)\n"
"var !sys.printstring sys._esys_020\n"
"type sys._esys_025 {}\n"
"type sys._esys_026 {}\n"
"type sys._esys_027 *sys.any\n"
"type sys._isys_394 {_esys_393 sys._esys_027}\n"
"type sys._esys_024 (sys._esys_025 sys._esys_026 sys._isys_394)\n"
"type sys._isys_405 {_esys_404 sys._esys_027}\n"
"type sys._esys_024 (sys._esys_025 sys._esys_026 sys._isys_405)\n"
"var !sys.printpointer sys._esys_024\n"
"type sys._esys_029 {}\n"
"type sys._osys_401 {_esys_398 sys.string}\n"
"type sys._isys_403 {_esys_399 sys.string _esys_400 sys.string}\n"
"type sys._esys_028 (sys._esys_029 sys._osys_401 sys._isys_403)\n"
"type sys._osys_412 {_esys_409 sys.string}\n"
"type sys._isys_414 {_esys_410 sys.string _esys_411 sys.string}\n"
"type sys._esys_028 (sys._esys_029 sys._osys_412 sys._isys_414)\n"
"var !sys.catstring sys._esys_028\n"
"type sys._esys_031 {}\n"
"type sys._osys_411 {_esys_408 sys.int32}\n"
"type sys._isys_413 {_esys_409 sys.string _esys_410 sys.string}\n"
"type sys._esys_030 (sys._esys_031 sys._osys_411 sys._isys_413)\n"
"type sys._osys_422 {_esys_419 sys.int32}\n"
"type sys._isys_424 {_esys_420 sys.string _esys_421 sys.string}\n"
"type sys._esys_030 (sys._esys_031 sys._osys_422 sys._isys_424)\n"
"var !sys.cmpstring sys._esys_030\n"
"type sys._esys_033 {}\n"
"type sys._osys_422 {_esys_418 sys.string}\n"
"type sys._isys_424 {_esys_419 sys.string _esys_420 sys.int32 _esys_421 sys.int32}\n"
"type sys._esys_032 (sys._esys_033 sys._osys_422 sys._isys_424)\n"
"type sys._osys_433 {_esys_429 sys.string}\n"
"type sys._isys_435 {_esys_430 sys.string _esys_431 sys.int32 _esys_432 sys.int32}\n"
"type sys._esys_032 (sys._esys_033 sys._osys_433 sys._isys_435)\n"
"var !sys.slicestring sys._esys_032\n"
"type sys._esys_035 {}\n"
"type sys.uint8 2\n"
"type sys._osys_433 {_esys_430 sys.uint8}\n"
"type sys._isys_435 {_esys_431 sys.string _esys_432 sys.int32}\n"
"type sys._esys_034 (sys._esys_035 sys._osys_433 sys._isys_435)\n"
"type sys._osys_444 {_esys_441 sys.uint8}\n"
"type sys._isys_446 {_esys_442 sys.string _esys_443 sys.int32}\n"
"type sys._esys_034 (sys._esys_035 sys._osys_444 sys._isys_446)\n"
"var !sys.indexstring sys._esys_034\n"
"type sys._esys_037 {}\n"
"type sys._osys_442 {_esys_440 sys.string}\n"
"type sys._isys_444 {_esys_441 sys.int64}\n"
"type sys._esys_036 (sys._esys_037 sys._osys_442 sys._isys_444)\n"
"type sys._osys_453 {_esys_451 sys.string}\n"
"type sys._isys_455 {_esys_452 sys.int64}\n"
"type sys._esys_036 (sys._esys_037 sys._osys_453 sys._isys_455)\n"
"var !sys.intstring sys._esys_036\n"
"type sys._esys_039 {}\n"
"type sys._osys_451 {_esys_448 sys.string}\n"
"type sys._osys_462 {_esys_459 sys.string}\n"
"type sys._esys_040 *sys.uint8\n"
"type sys._isys_453 {_esys_449 sys._esys_040 _esys_450 sys.int32}\n"
"type sys._esys_038 (sys._esys_039 sys._osys_451 sys._isys_453)\n"
"type sys._isys_464 {_esys_460 sys._esys_040 _esys_461 sys.int32}\n"
"type sys._esys_038 (sys._esys_039 sys._osys_462 sys._isys_464)\n"
"var !sys.byteastring sys._esys_038\n"
"type sys._esys_042 {}\n"
"type sys._esys_043 <>\n"
"type sys._osys_462 {_esys_458 sys._esys_043}\n"
"type sys._osys_473 {_esys_469 sys._esys_043}\n"
"type sys._esys_044 *sys.uint8\n"
"type sys._esys_045 *sys.uint8\n"
"type sys._ssys_469 {}\n"
"type sys._esys_046 *sys._ssys_469\n"
"type sys._isys_464 {_esys_459 sys._esys_044 _esys_460 sys._esys_045 _esys_461 sys._esys_046}\n"
"type sys._esys_041 (sys._esys_042 sys._osys_462 sys._isys_464)\n"
"type sys._ssys_480 {}\n"
"type sys._esys_046 *sys._ssys_480\n"
"type sys._isys_475 {_esys_470 sys._esys_044 _esys_471 sys._esys_045 _esys_472 sys._esys_046}\n"
"type sys._esys_041 (sys._esys_042 sys._osys_473 sys._isys_475)\n"
"var !sys.mkiface sys._esys_041\n"
"type sys._esys_048 {}\n"
"type sys._osys_473 {_esys_472 sys.int32}\n"
"type sys._osys_484 {_esys_483 sys.int32}\n"
"type sys._esys_049 {}\n"
"type sys._esys_047 (sys._esys_048 sys._osys_473 sys._esys_049)\n"
"type sys._esys_047 (sys._esys_048 sys._osys_484 sys._esys_049)\n"
"var !sys.argc sys._esys_047\n"
"type sys._esys_051 {}\n"
"type sys._osys_477 {_esys_476 sys.int32}\n"
"type sys._osys_488 {_esys_487 sys.int32}\n"
"type sys._esys_052 {}\n"
"type sys._esys_050 (sys._esys_051 sys._osys_477 sys._esys_052)\n"
"type sys._esys_050 (sys._esys_051 sys._osys_488 sys._esys_052)\n"
"var !sys.envc sys._esys_050\n"
"type sys._esys_054 {}\n"
"type sys._osys_482 {_esys_480 sys.string}\n"
"type sys._isys_484 {_esys_481 sys.int32}\n"
"type sys._esys_053 (sys._esys_054 sys._osys_482 sys._isys_484)\n"
"type sys._osys_493 {_esys_491 sys.string}\n"
"type sys._isys_495 {_esys_492 sys.int32}\n"
"type sys._esys_053 (sys._esys_054 sys._osys_493 sys._isys_495)\n"
"var !sys.argv sys._esys_053\n"
"type sys._esys_056 {}\n"
"type sys._osys_490 {_esys_488 sys.string}\n"
"type sys._isys_492 {_esys_489 sys.int32}\n"
"type sys._esys_055 (sys._esys_056 sys._osys_490 sys._isys_492)\n"
"type sys._osys_501 {_esys_499 sys.string}\n"
"type sys._isys_503 {_esys_500 sys.int32}\n"
"type sys._esys_055 (sys._esys_056 sys._osys_501 sys._isys_503)\n"
"var !sys.envv sys._esys_055\n"
"type sys._esys_058 {}\n"
"type sys._osys_499 {_esys_496 sys.float64 _esys_497 sys.int32}\n"
"type sys._isys_501 {_esys_498 sys.float64}\n"
"type sys._esys_057 (sys._esys_058 sys._osys_499 sys._isys_501)\n"
"type sys._osys_510 {_esys_507 sys.float64 _esys_508 sys.int32}\n"
"type sys._isys_512 {_esys_509 sys.float64}\n"
"type sys._esys_057 (sys._esys_058 sys._osys_510 sys._isys_512)\n"
"var !sys.frexp sys._esys_057\n"
"type sys._esys_060 {}\n"
"type sys._osys_508 {_esys_505 sys.float64}\n"
"type sys._isys_510 {_esys_506 sys.float64 _esys_507 sys.int32}\n"
"type sys._esys_059 (sys._esys_060 sys._osys_508 sys._isys_510)\n"
"type sys._osys_519 {_esys_516 sys.float64}\n"
"type sys._isys_521 {_esys_517 sys.float64 _esys_518 sys.int32}\n"
"type sys._esys_059 (sys._esys_060 sys._osys_519 sys._isys_521)\n"
"var !sys.ldexp sys._esys_059\n"
"type sys._esys_062 {}\n"
"type sys._osys_518 {_esys_515 sys.float64 _esys_516 sys.float64}\n"
"type sys._isys_520 {_esys_517 sys.float64}\n"
"type sys._esys_061 (sys._esys_062 sys._osys_518 sys._isys_520)\n"
"type sys._osys_529 {_esys_526 sys.float64 _esys_527 sys.float64}\n"
"type sys._isys_531 {_esys_528 sys.float64}\n"
"type sys._esys_061 (sys._esys_062 sys._osys_529 sys._isys_531)\n"
"var !sys.modf sys._esys_061\n"
"type sys._esys_064 {}\n"
"type sys._osys_527 {_esys_524 sys.bool}\n"
"type sys._isys_529 {_esys_525 sys.float64 _esys_526 sys.int32}\n"
"type sys._esys_063 (sys._esys_064 sys._osys_527 sys._isys_529)\n"
"type sys._osys_538 {_esys_535 sys.bool}\n"
"type sys._isys_540 {_esys_536 sys.float64 _esys_537 sys.int32}\n"
"type sys._esys_063 (sys._esys_064 sys._osys_538 sys._isys_540)\n"
"var !sys.isInf sys._esys_063\n"
"type sys._esys_066 {}\n"
"type sys._osys_536 {_esys_534 sys.bool}\n"
"type sys._isys_538 {_esys_535 sys.float64}\n"
"type sys._esys_065 (sys._esys_066 sys._osys_536 sys._isys_538)\n"
"type sys._osys_547 {_esys_545 sys.bool}\n"
"type sys._isys_549 {_esys_546 sys.float64}\n"
"type sys._esys_065 (sys._esys_066 sys._osys_547 sys._isys_549)\n"
"var !sys.isNaN sys._esys_065\n"
"type sys._esys_068 {}\n"
"type sys._osys_544 {_esys_542 sys.float64}\n"
"type sys._isys_546 {_esys_543 sys.int32}\n"
"type sys._esys_067 (sys._esys_068 sys._osys_544 sys._isys_546)\n"
"type sys._osys_555 {_esys_553 sys.float64}\n"
"type sys._isys_557 {_esys_554 sys.int32}\n"
"type sys._esys_067 (sys._esys_068 sys._osys_555 sys._isys_557)\n"
"var !sys.Inf sys._esys_067\n"
"type sys._esys_070 {}\n"
"type sys._osys_551 {_esys_550 sys.float64}\n"
"type sys._osys_562 {_esys_561 sys.float64}\n"
"type sys._esys_071 {}\n"
"type sys._esys_069 (sys._esys_070 sys._osys_551 sys._esys_071)\n"
"type sys._esys_069 (sys._esys_070 sys._osys_562 sys._esys_071)\n"
"var !sys.NaN sys._esys_069\n"
"type sys._esys_073 {}\n"
"type sys._esys_075 [sys.any] sys.any\n"
"type sys._esys_074 *sys._esys_075\n"
"type sys._osys_554 {hmap sys._esys_074}\n"
"type sys._isys_556 {keysize sys.uint32 valsize sys.uint32 keyalg sys.uint32 valalg sys.uint32 hint sys.uint32}\n"
"type sys._esys_072 (sys._esys_073 sys._osys_554 sys._isys_556)\n"
"type sys._osys_565 {hmap sys._esys_074}\n"
"type sys._isys_567 {keysize sys.uint32 valsize sys.uint32 keyalg sys.uint32 valalg sys.uint32 hint sys.uint32}\n"
"type sys._esys_072 (sys._esys_073 sys._osys_565 sys._isys_567)\n"
"var !sys.newmap sys._esys_072\n"
"type sys._esys_077 {}\n"
"type sys._osys_565 {val sys.any}\n"
"type sys._osys_576 {val sys.any}\n"
"type sys._esys_079 [sys.any] sys.any\n"
"type sys._esys_078 *sys._esys_079\n"
"type sys._isys_567 {hmap sys._esys_078 key sys.any}\n"
"type sys._esys_076 (sys._esys_077 sys._osys_565 sys._isys_567)\n"
"type sys._isys_578 {hmap sys._esys_078 key sys.any}\n"
"type sys._esys_076 (sys._esys_077 sys._osys_576 sys._isys_578)\n"
"var !sys.mapaccess1 sys._esys_076\n"
"type sys._esys_081 {}\n"
"type sys._osys_573 {val sys.any pres sys.bool}\n"
"type sys._osys_584 {val sys.any pres sys.bool}\n"
"type sys._esys_083 [sys.any] sys.any\n"
"type sys._esys_082 *sys._esys_083\n"
"type sys._isys_575 {hmap sys._esys_082 key sys.any}\n"
"type sys._esys_080 (sys._esys_081 sys._osys_573 sys._isys_575)\n"
"type sys._isys_586 {hmap sys._esys_082 key sys.any}\n"
"type sys._esys_080 (sys._esys_081 sys._osys_584 sys._isys_586)\n"
"var !sys.mapaccess2 sys._esys_080\n"
"type sys._esys_085 {}\n"
"type sys._esys_086 {}\n"
"type sys._esys_088 [sys.any] sys.any\n"
"type sys._esys_087 *sys._esys_088\n"
"type sys._isys_582 {hmap sys._esys_087 key sys.any val sys.any}\n"
"type sys._esys_084 (sys._esys_085 sys._esys_086 sys._isys_582)\n"
"type sys._isys_593 {hmap sys._esys_087 key sys.any val sys.any}\n"
"type sys._esys_084 (sys._esys_085 sys._esys_086 sys._isys_593)\n"
"var !sys.mapassign1 sys._esys_084\n"
"type sys._esys_090 {}\n"
"type sys._esys_091 {}\n"
"type sys._esys_093 [sys.any] sys.any\n"
"type sys._esys_092 *sys._esys_093\n"
"type sys._isys_588 {hmap sys._esys_092 key sys.any val sys.any pres sys.bool}\n"
"type sys._esys_089 (sys._esys_090 sys._esys_091 sys._isys_588)\n"
"type sys._isys_599 {hmap sys._esys_092 key sys.any val sys.any pres sys.bool}\n"
"type sys._esys_089 (sys._esys_090 sys._esys_091 sys._isys_599)\n"
"var !sys.mapassign2 sys._esys_089\n"
"type sys._esys_095 {}\n"
"type sys._esys_097 1 sys.any\n"
"type sys._esys_096 *sys._esys_097\n"
"type sys._osys_595 {hchan sys._esys_096}\n"
"type sys._isys_597 {elemsize sys.uint32 elemalg sys.uint32 hint sys.uint32}\n"
"type sys._esys_094 (sys._esys_095 sys._osys_595 sys._isys_597)\n"
"type sys._osys_606 {hchan sys._esys_096}\n"
"type sys._isys_608 {elemsize sys.uint32 elemalg sys.uint32 hint sys.uint32}\n"
"type sys._esys_094 (sys._esys_095 sys._osys_606 sys._isys_608)\n"
"var !sys.newchan sys._esys_094\n"
"type sys._esys_099 {}\n"
"type sys._osys_604 {elem sys.any}\n"
"type sys._osys_615 {elem sys.any}\n"
"type sys._esys_101 1 sys.any\n"
"type sys._esys_100 *sys._esys_101\n"
"type sys._isys_606 {hchan sys._esys_100}\n"
"type sys._esys_098 (sys._esys_099 sys._osys_604 sys._isys_606)\n"
"type sys._isys_617 {hchan sys._esys_100}\n"
"type sys._esys_098 (sys._esys_099 sys._osys_615 sys._isys_617)\n"
"var !sys.chanrecv1 sys._esys_098\n"
"type sys._esys_103 {}\n"
"type sys._osys_611 {elem sys.any pres sys.bool}\n"
"type sys._osys_622 {elem sys.any pres sys.bool}\n"
"type sys._esys_105 1 sys.any\n"
"type sys._esys_104 *sys._esys_105\n"
"type sys._isys_613 {hchan sys._esys_104}\n"
"type sys._esys_102 (sys._esys_103 sys._osys_611 sys._isys_613)\n"
"type sys._isys_624 {hchan sys._esys_104}\n"
"type sys._esys_102 (sys._esys_103 sys._osys_622 sys._isys_624)\n"
"var !sys.chanrecv2 sys._esys_102\n"
"type sys._esys_107 {}\n"
"type sys._osys_619 {elem sys.any pres sys.bool}\n"
"type sys._osys_630 {pres sys.bool}\n"
"type sys._esys_109 1 sys.any\n"
"type sys._esys_108 *sys._esys_109\n"
"type sys._isys_621 {hchan sys._esys_108}\n"
"type sys._esys_106 (sys._esys_107 sys._osys_619 sys._isys_621)\n"
"type sys._esys_110 *sys.any\n"
"type sys._isys_632 {hchan sys._esys_108 elem sys._esys_110}\n"
"type sys._esys_106 (sys._esys_107 sys._osys_630 sys._isys_632)\n"
"var !sys.chanrecv3 sys._esys_106\n"
"type sys._esys_111 {}\n"
"type sys._esys_112 {}\n"
"type sys._esys_114 1 sys.any\n"
"type sys._esys_113 *sys._esys_114\n"
"type sys._isys_627 {hchan sys._esys_113 elem sys.any}\n"
"type sys._esys_110 (sys._esys_111 sys._esys_112 sys._isys_627)\n"
"var !sys.chansend1 sys._esys_110\n"
"type sys._esys_116 {}\n"
"type sys._osys_632 {pres sys.bool}\n"
"type sys._esys_118 1 sys.any\n"
"type sys._esys_117 *sys._esys_118\n"
"type sys._isys_634 {hchan sys._esys_117 elem sys.any}\n"
"type sys._esys_115 (sys._esys_116 sys._osys_632 sys._isys_634)\n"
"var !sys.chansend2 sys._esys_115\n"
"type sys._esys_120 {}\n"
"type sys._esys_121 *sys.uint8\n"
"type sys._osys_640 {sel sys._esys_121}\n"
"type sys._isys_642 {size sys.uint32}\n"
"type sys._esys_119 (sys._esys_120 sys._osys_640 sys._isys_642)\n"
"var !sys.newselect sys._esys_119\n"
"type sys._esys_123 {}\n"
"type sys._osys_647 {selected sys.bool}\n"
"type sys._esys_124 *sys.uint8\n"
"type sys._esys_126 1 sys.any\n"
"type sys._esys_125 *sys._esys_126\n"
"type sys._isys_649 {sel sys._esys_124 hchan sys._esys_125 elem sys.any}\n"
"type sys._esys_122 (sys._esys_123 sys._osys_647 sys._isys_649)\n"
"var !sys.selectsend sys._esys_122\n"
"type sys._esys_128 {}\n"
"type sys._osys_656 {selected sys.bool}\n"
"type sys._esys_129 *sys.uint8\n"
"type sys._esys_131 1 sys.any\n"
"type sys._esys_130 *sys._esys_131\n"
"type sys._esys_132 *sys.any\n"
"type sys._isys_658 {sel sys._esys_129 hchan sys._esys_130 elem sys._esys_132}\n"
"type sys._esys_127 (sys._esys_128 sys._osys_656 sys._isys_658)\n"
"var !sys.selectrecv sys._esys_127\n"
"type sys._esys_134 {}\n"
"type sys._esys_113 {}\n"
"type sys._esys_115 1 sys.any\n"
"type sys._esys_114 *sys._esys_115\n"
"type sys._isys_638 {hchan sys._esys_114 elem sys.any}\n"
"type sys._esys_111 (sys._esys_112 sys._esys_113 sys._isys_638)\n"
"var !sys.chansend1 sys._esys_111\n"
"type sys._esys_117 {}\n"
"type sys._osys_643 {pres sys.bool}\n"
"type sys._esys_119 1 sys.any\n"
"type sys._esys_118 *sys._esys_119\n"
"type sys._isys_645 {hchan sys._esys_118 elem sys.any}\n"
"type sys._esys_116 (sys._esys_117 sys._osys_643 sys._isys_645)\n"
"var !sys.chansend2 sys._esys_116\n"
"type sys._esys_121 {}\n"
"type sys._esys_122 *sys.uint8\n"
"type sys._osys_651 {sel sys._esys_122}\n"
"type sys._isys_653 {size sys.uint32}\n"
"type sys._esys_120 (sys._esys_121 sys._osys_651 sys._isys_653)\n"
"var !sys.newselect sys._esys_120\n"
"type sys._esys_124 {}\n"
"type sys._osys_658 {selected sys.bool}\n"
"type sys._esys_125 *sys.uint8\n"
"type sys._esys_127 1 sys.any\n"
"type sys._esys_126 *sys._esys_127\n"
"type sys._isys_660 {sel sys._esys_125 hchan sys._esys_126 elem sys.any}\n"
"type sys._esys_123 (sys._esys_124 sys._osys_658 sys._isys_660)\n"
"var !sys.selectsend sys._esys_123\n"
"type sys._esys_129 {}\n"
"type sys._osys_667 {selected sys.bool}\n"
"type sys._esys_130 *sys.uint8\n"
"type sys._esys_132 1 sys.any\n"
"type sys._esys_131 *sys._esys_132\n"
"type sys._esys_133 *sys.any\n"
"type sys._isys_669 {sel sys._esys_130 hchan sys._esys_131 elem sys._esys_133}\n"
"type sys._esys_128 (sys._esys_129 sys._osys_667 sys._isys_669)\n"
"var !sys.selectrecv sys._esys_128\n"
"type sys._esys_135 {}\n"
"type sys._esys_136 *sys.uint8\n"
"type sys._isys_665 {sel sys._esys_136}\n"
"type sys._esys_133 (sys._esys_134 sys._esys_135 sys._isys_665)\n"
"var !sys.selectgo sys._esys_133\n"
"type sys._esys_138 {}\n"
"type sys._esys_136 {}\n"
"type sys._esys_137 *sys.uint8\n"
"type sys._isys_676 {sel sys._esys_137}\n"
"type sys._esys_134 (sys._esys_135 sys._esys_136 sys._isys_676)\n"
"var !sys.selectgo sys._esys_134\n"
"type sys._esys_139 {}\n"
"type sys._esys_140 {}\n"
"type sys._esys_137 (sys._esys_138 sys._esys_139 sys._esys_140)\n"
"var !sys.gosched sys._esys_137\n"
"type sys._esys_142 {}\n"
"type sys._esys_141 {}\n"
"type sys._esys_138 (sys._esys_139 sys._esys_140 sys._esys_141)\n"
"var !sys.gosched sys._esys_138\n"
"type sys._esys_143 {}\n"
"type sys._esys_144 {}\n"
"type sys._esys_141 (sys._esys_142 sys._esys_143 sys._esys_144)\n"
"var !sys.goexit sys._esys_141\n"
"type sys._esys_146 {}\n"
"type sys._osys_674 {_esys_671 sys.string _esys_672 sys.bool}\n"
"type sys._isys_676 {_esys_673 sys.string}\n"
"type sys._esys_145 (sys._esys_146 sys._osys_674 sys._isys_676)\n"
"var !sys.readfile sys._esys_145\n"
"type sys._esys_148 {}\n"
"type sys._osys_683 {_esys_680 sys.bool}\n"
"type sys._isys_685 {_esys_681 sys.string _esys_682 sys.string}\n"
"type sys._esys_147 (sys._esys_148 sys._osys_683 sys._isys_685)\n"
"var !sys.writefile sys._esys_147\n"
"type sys._esys_150 {}\n"
"type sys._osys_695 {_esys_690 sys.int32 _esys_691 sys.int32}\n"
"type sys._esys_151 *sys.uint8\n"
"type sys._isys_697 {_esys_692 sys._esys_151 _esys_693 sys.int32 _esys_694 sys.int32}\n"
"type sys._esys_149 (sys._esys_150 sys._osys_695 sys._isys_697)\n"
"var !sys.bytestorune sys._esys_149\n"
"type sys._esys_153 {}\n"
"type sys._osys_708 {_esys_703 sys.int32 _esys_704 sys.int32}\n"
"type sys._isys_710 {_esys_705 sys.string _esys_706 sys.int32 _esys_707 sys.int32}\n"
"type sys._esys_152 (sys._esys_153 sys._osys_708 sys._isys_710)\n"
"var !sys.stringtorune sys._esys_152\n"
"type sys._esys_155 {}\n"
"type sys._esys_145 {}\n"
"type sys._esys_142 (sys._esys_143 sys._esys_144 sys._esys_145)\n"
"var !sys.goexit sys._esys_142\n"
"type sys._esys_147 {}\n"
"type sys._osys_685 {_esys_682 sys.string _esys_683 sys.bool}\n"
"type sys._isys_687 {_esys_684 sys.string}\n"
"type sys._esys_146 (sys._esys_147 sys._osys_685 sys._isys_687)\n"
"var !sys.readfile sys._esys_146\n"
"type sys._esys_149 {}\n"
"type sys._osys_694 {_esys_691 sys.bool}\n"
"type sys._isys_696 {_esys_692 sys.string _esys_693 sys.string}\n"
"type sys._esys_148 (sys._esys_149 sys._osys_694 sys._isys_696)\n"
"var !sys.writefile sys._esys_148\n"
"type sys._esys_151 {}\n"
"type sys._osys_706 {_esys_701 sys.int32 _esys_702 sys.int32}\n"
"type sys._esys_152 *sys.uint8\n"
"type sys._isys_708 {_esys_703 sys._esys_152 _esys_704 sys.int32 _esys_705 sys.int32}\n"
"type sys._esys_150 (sys._esys_151 sys._osys_706 sys._isys_708)\n"
"var !sys.bytestorune sys._esys_150\n"
"type sys._esys_154 {}\n"
"type sys._osys_719 {_esys_714 sys.int32 _esys_715 sys.int32}\n"
"type sys._isys_721 {_esys_716 sys.string _esys_717 sys.int32 _esys_718 sys.int32}\n"
"type sys._esys_153 (sys._esys_154 sys._osys_719 sys._isys_721)\n"
"var !sys.stringtorune sys._esys_153\n"
"type sys._esys_156 {}\n"
"type sys._isys_717 {_esys_716 sys.int32}\n"
"type sys._esys_154 (sys._esys_155 sys._esys_156 sys._isys_717)\n"
"var !sys.exit sys._esys_154\n"
"type sys._esys_158 {}\n"
"type sys._esys_157 {}\n"
"type sys._isys_728 {_esys_727 sys.int32}\n"
"type sys._esys_155 (sys._esys_156 sys._esys_157 sys._isys_728)\n"
"var !sys.exit sys._esys_155\n"
"type sys._esys_159 {}\n"
"type sys._esys_160 {}\n"
"type sys._esys_157 (sys._esys_158 sys._esys_159 sys._esys_160)\n"
"type sys._esys_161 {}\n"
"type sys._esys_158 (sys._esys_159 sys._esys_160 sys._esys_161)\n"
"))\n"
;

View File

@ -1910,7 +1910,6 @@ chanop(Node *n, int top)
goto shape;
// chanrecv2(hchan *chan any) (elem any, pres bool);
t = fixchan(n->right->left->type);
if(t == T)
break;
@ -1950,19 +1949,27 @@ chanop(Node *n, int top)
break;
recv2:
// chanrecv2(hchan *chan any) (elem any, pres bool);
fatal("recv2 not yet");
// chanrecv3(hchan *chan any, *elem any) (pres bool);
t = fixchan(n->right->type);
if(t == T)
break;
a = n->right; // chan
r = a;
a = n->left; // elem
if(a == N) {
a = nil;
a = nod(OLITERAL, N, N);
a->val.ctype = CTNIL;
a->val.vval = 0;
} else
a = nod(OADDR, a, N);
on = syslook("chanrecv2", 1);
on = syslook("chanrecv3", 1);
argtype(on, t->type); // any-1
argtype(on, t->type); // any-2
r = nod(OCALL, on, r);
n->right = r;
r = n;

View File

@ -33,8 +33,6 @@ struct Hchan
uint32 elemsize;
uint32 dataqsiz; // size of the circular q
uint32 qcount; // total data in the q
uint16 eo; // vararg of element
uint16 po; // vararg of present bool
Alg* elemalg; // interface for element type
Link* senddataq; // pointer for sender
Link* recvdataq; // pointer for receiver
@ -65,9 +63,12 @@ struct Select
{
uint16 tcase; // total count of scase[]
uint16 ncase; // currently filled scase[]
Select* link; // for freelist
Scase scase[1]; // one per case
};
static Select* selfree[20];
static SudoG* dequeue(WaitQ*, Hchan*);
static void enqueue(WaitQ*, SudoG*);
static SudoG* allocsg(Hchan*);
@ -119,10 +120,6 @@ sys·newchan(uint32 elemsize, uint32 elemalg, uint32 hint,
c->dataqsiz = hint;
}
// these calculations are compiler dependent
c->eo = rnd(sizeof(c), elemsize);
c->po = rnd(c->eo+elemsize, 1);
ret = c;
FLUSH(&ret);
@ -139,216 +136,205 @@ sys·newchan(uint32 elemsize, uint32 elemalg, uint32 hint,
}
}
// chansend1(hchan *chan any, elem any);
/*
* generic single channel send/recv
* if the bool pointer is nil,
* then the full exchange will
* occur. if pres is not nil,
* then the protocol will not
* sleep but return if it could
* not complete
*/
void
sys·chansend1(Hchan* c, ...)
sendchan(Hchan *c, byte *ep, bool *pres)
{
byte *ae;
SudoG *sgr;
G* gr;
SudoG *sg;
G* gp;
ae = (byte*)&c + c->eo;
if(debug) {
prints("chansend: chan=");
sys·printpointer(c);
prints("; elem=");
c->elemalg->print(c->elemsize, ae);
c->elemalg->print(c->elemsize, ep);
prints("\n");
}
if(c->dataqsiz > 0)
goto asynch;
sgr = dequeue(&c->recvq, c);
if(sgr != nil) {
c->elemalg->copy(c->elemsize, sgr->elem, ae);
sg = dequeue(&c->recvq, c);
if(sg != nil) {
if(ep != nil)
c->elemalg->copy(c->elemsize, sg->elem, ep);
gr = sgr->g;
gr->param = sgr;
gr->status = Grunnable;
gp = sg->g;
gp->param = sg;
gp->status = Grunnable;
if(pres != nil)
*pres = true;
return;
}
sgr = allocsg(c);
c->elemalg->copy(c->elemsize, sgr->elem, ae);
if(pres != nil) {
*pres = false;
return;
}
sg = allocsg(c);
if(ep != nil)
c->elemalg->copy(c->elemsize, sg->elem, ep);
g->param = nil;
g->status = Gwaiting;
enqueue(&c->sendq, sgr);
enqueue(&c->sendq, sg);
sys·gosched();
sg = g->param;
freesg(c, sg);
return;
asynch:
while(c->qcount >= c->dataqsiz) {
sgr = allocsg(c);
sg = allocsg(c);
g->status = Gwaiting;
enqueue(&c->sendq, sgr);
enqueue(&c->sendq, sg);
sys·gosched();
}
c->elemalg->copy(c->elemsize, c->senddataq->elem, ae);
if(ep != nil)
c->elemalg->copy(c->elemsize, c->senddataq->elem, ep);
c->senddataq = c->senddataq->link;
c->qcount++;
sgr = dequeue(&c->recvq, c);
if(sgr != nil) {
gr = sgr->g;
freesg(c, sgr);
gr->status = Grunnable;
sg = dequeue(&c->recvq, c);
if(sg != nil) {
gp = sg->g;
freesg(c, sg);
gp->status = Grunnable;
}
}
static void
chanrecv(Hchan* c, byte *ep, bool* pres)
{
SudoG *sg;
G *gp;
if(debug) {
prints("chanrecv: chan=");
sys·printpointer(c);
prints("\n");
}
if(c->dataqsiz > 0)
goto asynch;
sg = dequeue(&c->sendq, c);
if(sg != nil) {
c->elemalg->copy(c->elemsize, ep, sg->elem);
gp = sg->g;
gp->param = sg;
gp->status = Grunnable;
if(pres != nil)
*pres = true;
return;
}
if(pres != nil) {
*pres = false;
return;
}
sg = allocsg(c);
g->param = nil;
g->status = Gwaiting;
enqueue(&c->recvq, sg);
sys·gosched();
sg = g->param;
c->elemalg->copy(c->elemsize, ep, sg->elem);
freesg(c, sg);
return;
asynch:
while(c->qcount <= 0) {
sg = allocsg(c);
g->status = Gwaiting;
enqueue(&c->recvq, sg);
sys·gosched();
}
c->elemalg->copy(c->elemsize, ep, c->recvdataq->elem);
c->recvdataq = c->recvdataq->link;
c->qcount--;
sg = dequeue(&c->sendq, c);
if(sg != nil) {
gp = sg->g;
freesg(c, sg);
gp->status = Grunnable;
}
}
// chansend1(hchan *chan any, elem any);
void
sys·chansend1(Hchan* c, ...)
{
int32 o;
byte *ae;
o = rnd(sizeof(c), c->elemsize);
ae = (byte*)&c + o;
sendchan(c, ae, nil);
}
// chansend2(hchan *chan any, elem any) (pres bool);
void
sys·chansend2(Hchan* c, ...)
{
int32 o;
byte *ae, *ap;
SudoG *sgr;
G *gr;
ae = (byte*)&c + c->eo;
ap = (byte*)&c + c->po;
o = rnd(sizeof(c), c->elemsize);
ae = (byte*)&c + o;
o = rnd(o+c->elemsize, 1);
ap = (byte*)&c + o;
if(debug) {
prints("chansend: chan=");
sys·printpointer(c);
prints("; elem=");
c->elemalg->print(c->elemsize, ae);
prints("\n");
}
if(c->dataqsiz > 0)
goto asynch;
sgr = dequeue(&c->recvq, c);
if(sgr != nil) {
gr = sgr->g;
c->elemalg->copy(c->elemsize, sgr->elem, ae);
gr->param = sgr;
gr->status = Grunnable;
*ap = true;
return;
}
*ap = false;
return;
asynch:
if(c->qcount >= c->dataqsiz) {
*ap = false;
return;
}
c->elemalg->copy(c->elemsize, c->senddataq->elem, ae);
c->senddataq = c->senddataq->link;
c->qcount++;
sgr = dequeue(&c->recvq, c);
if(gr != nil) {
gr = sgr->g;
freesg(c, sgr);
gr->status = Grunnable;
}
*ap = true;
sendchan(c, ae, ap);
}
// chanrecv1(hchan *chan any) (elem any);
void
sys·chanrecv1(Hchan* c, ...)
{
int32 o;
byte *ae;
SudoG *sgs;
G *gs;
ae = (byte*)&c + c->eo;
if(debug) {
prints("chanrecv1: chan=");
sys·printpointer(c);
prints("\n");
}
if(c->dataqsiz > 0)
goto asynch;
o = rnd(sizeof(c), c->elemsize);
ae = (byte*)&c + o;
sgs = dequeue(&c->sendq, c);
if(sgs != nil) {
c->elemalg->copy(c->elemsize, ae, sgs->elem);
gs = sgs->g;
gs->param = sgs;
gs->status = Grunnable;
freesg(c, sgs);
return;
}
sgs = allocsg(c);
g->status = Gwaiting;
enqueue(&c->recvq, sgs);
sys·gosched();
c->elemalg->copy(c->elemsize, ae, sgs->elem);
freesg(c, sgs);
return;
asynch:
while(c->qcount <= 0) {
sgs = allocsg(c);
g->status = Gwaiting;
enqueue(&c->recvq, sgs);
sys·gosched();
}
c->elemalg->copy(c->elemsize, ae, c->recvdataq->elem);
c->recvdataq = c->recvdataq->link;
c->qcount--;
sgs = dequeue(&c->sendq, c);
if(gs != nil) {
gs = sgs->g;
freesg(c, sgs);
gs->status = Grunnable;
}
chanrecv(c, ae, nil);
}
// chanrecv2(hchan *chan any) (elem any, pres bool);
void
sys·chanrecv2(Hchan* c, ...)
{
int32 o;
byte *ae, *ap;
SudoG *sgs;
G *gs;
ae = (byte*)&c + c->eo;
ap = (byte*)&c + c->po;
o = rnd(sizeof(c), c->elemsize);
ae = (byte*)&c + o;
o = rnd(o+c->elemsize, 1);
ap = (byte*)&c + o;
if(debug) {
prints("chanrecv2: chan=");
sys·printpointer(c);
prints("\n");
}
if(c->dataqsiz > 0)
goto asynch;
chanrecv(c, ae, ap);
}
sgs = dequeue(&c->sendq, c);
if(sgs != nil) {
c->elemalg->copy(c->elemsize, ae, sgs->elem);
gs = sgs->g;
gs->param = sgs;
gs->status = Grunnable;
freesg(c, sgs);
*ap = true;
return;
}
*ap = false;
return;
asynch:
if(c->qcount <= 0) {
*ap = false;
return;
}
c->elemalg->copy(c->elemsize, ae, c->recvdataq->elem);
c->recvdataq = c->recvdataq->link;
c->qcount--;
sgs = dequeue(&c->sendq, c);
if(sgs != nil) {
gs = sgs->g;
freesg(c, sgs);
gs->status = Grunnable;
}
*ap = true;
// chanrecv3(hchan *chan any, elem *any) (pres bool);
void
sys·chanrecv3(Hchan* c, byte* ep, byte pres)
{
chanrecv(c, ep, &pres);
}
// newselect(size uint32) (sel *byte);
@ -360,7 +346,16 @@ sys·newselect(int32 size, Select *sel)
n = 0;
if(size > 1)
n = size-1;
sel = mal(sizeof(*sel) + n*sizeof(sel->scase[0]));
sel = nil;
if(size >= 1 && size < nelem(selfree)) {
sel = selfree[size];
if(sel != nil)
selfree[size] = sel->link;
}
if(sel == nil)
sel = mal(sizeof(*sel) + n*sizeof(sel->scase[0]));
sel->tcase = size;
sel->ncase = 0;
FLUSH(&sel);
@ -419,7 +414,7 @@ sys·selectsend(Select *sel, Hchan *c, ...)
void
sys·selectrecv(Select *sel, Hchan *c, ...)
{
int32 i, epo;
int32 i, eo;
Scase *cas;
// nil cases do not compete
@ -435,11 +430,11 @@ sys·selectrecv(Select *sel, Hchan *c, ...)
cas->pc = sys·getcallerpc(&sel);
cas->chan = c;
epo = rnd(sizeof(sel), sizeof(c));
epo = rnd(epo+sizeof(c), sizeof(byte*));
cas->so = rnd(epo+sizeof(byte*), 1);
eo = rnd(sizeof(sel), sizeof(c));
eo = rnd(eo+sizeof(c), sizeof(byte*));
cas->so = rnd(eo+sizeof(byte*), 1);
cas->send = 0;
cas->u.elemp = *(byte**)((byte*)&sel + epo);
cas->u.elemp = *(byte**)((byte*)&sel + eo);
if(debug) {
prints("newselect s=");
@ -456,6 +451,8 @@ sys·selectrecv(Select *sel, Hchan *c, ...)
}
}
uint32 xxx = 0;
// selectgo(sel *byte);
void
sys·selectgo(Select *sel)
@ -468,7 +465,7 @@ sys·selectgo(Select *sel)
byte *ae, *as;
if(0) {
if(xxx) {
prints("selectgo: sel=");
sys·printpointer(sel);
prints("\n");
@ -502,20 +499,23 @@ sys·selectgo(Select *sel)
c = cas->chan;
if(c->dataqsiz > 0) {
if(cas->send)
throw("selectgo: send asynch");
else
throw("selectgo: recv asynch");
if(cas->send) {
if(c->qcount < c->dataqsiz)
goto asyns;
} else {
if(c->qcount > 0)
goto asynr;
}
}
if(cas->send) {
sg = dequeue(&c->recvq, c);
if(sg != nil)
goto gotr;
goto gots;
} else {
sg = dequeue(&c->sendq, c);
if(sg != nil)
goto gots;
goto gotr;
}
o += p;
@ -527,19 +527,39 @@ sys·selectgo(Select *sel)
for(i=0; i<sel->ncase; i++) {
cas = &sel->scase[o];
c = cas->chan;
if(c->dataqsiz > 0) {
if(cas->send) {
if(c->qcount < c->dataqsiz) {
prints("second pass asyn send\n");
goto asyns;
}
} else {
if(c->qcount > 0) {
prints("second pass asyn recv\n");
goto asynr;
}
}
}
if(cas->send) {
sg = dequeue(&c->recvq, c);
if(sg != nil)
goto gotr; // probably an error
if(sg != nil) {
prints("second pass syn send\n");
g->selgen++;
goto gots; // probably an error
}
sg = allocsg(c);
sg->offset = o;
c->elemalg->copy(c->elemsize, sg->elem, cas->u.elem);
enqueue(&c->sendq, sg);
} else {
sg = dequeue(&c->sendq, c);
if(sg != nil)
goto gots; // probably an error
if(sg != nil) {
prints("second pass syn recv\n");
g->selgen++;
goto gotr; // probably an error
}
sg = allocsg(c);
sg->offset = o;
enqueue(&c->recvq, sg);
@ -550,56 +570,44 @@ sys·selectgo(Select *sel)
o -= sel->ncase;
}
if(0) {
prints("wait: sel=");
sys·printpointer(sel);
prints("\n");
}
// send and recv paths to sleep for a rendezvous
g->status = Gwaiting;
sys·gosched();
if(0) {
prints("wait-return: sel=");
sys·printpointer(sel);
prints("\n");
}
sg = g->param;
o = sg->offset;
cas = &sel->scase[o];
c = cas->chan;
if(0) {
prints("wake: sel=");
if(xxx) {
prints("wait-return: sel=");
sys·printpointer(sel);
prints(" c=");
sys·printpointer(c);
prints(" cas=");
sys·printpointer(cas);
prints(" send=");
sys·printint(cas->send);
prints(" o=");
sys·printint(o);
prints("\n");
}
if(cas->send)
goto gots;
gotr:
if(0) {
prints("gotr: sel=");
sys·printpointer(sel);
prints(" c=");
sys·printpointer(c);
prints(" o=");
sys·printint(o);
prints("\n");
if(!cas->send) {
if(cas->u.elemp != nil)
c->elemalg->copy(c->elemsize, cas->u.elemp, sg->elem);
}
c->elemalg->copy(c->elemsize, sg->elem, cas->u.elem);
gp = sg->g;
gp->param = sg;
gp->status = Grunnable;
freesg(c, sg);
goto retc;
gots:
if(0) {
prints("gots: sel=");
asynr:
asyns:
throw("asyn");
gotr:
// recv path to wakeup the sender (sg)
if(xxx) {
prints("gotr: sel=");
sys·printpointer(sel);
prints(" c=");
sys·printpointer(c);
@ -612,9 +620,30 @@ gots:
gp = sg->g;
gp->param = sg;
gp->status = Grunnable;
freesg(c, sg);
goto retc;
gots:
// send path to wakeup the receiver (sg)
if(xxx) {
prints("gots: sel=");
sys·printpointer(sel);
prints(" c=");
sys·printpointer(c);
prints(" o=");
sys·printint(o);
prints("\n");
}
c->elemalg->copy(c->elemsize, sg->elem, cas->u.elem);
gp = sg->g;
gp->param = sg;
gp->status = Grunnable;
retc:
if(sel->ncase >= 1 && sel->ncase < nelem(selfree)) {
sel->link = selfree[sel->ncase];
selfree[sel->ncase] = sel;
}
sys·setcallerpc(&sel, cas->pc);
as = (byte*)&sel + cas->so;
*as = true;
@ -668,6 +697,8 @@ allocsg(Hchan *c)
sg = mal(sizeof(*sg));
sg->selgen = g->selgen;
sg->g = g;
sg->offset = 0;
return sg;
}