Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
12082728
Commit
12082728
authored
Jul 26, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
select/chan
R=r DELTA=517 (137 added, 98 deleted, 282 changed) OCL=13495 CL=13495
parent
949ab5c7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
396 additions
and
357 deletions
+396
-357
src/cmd/gc/sys.go
src/cmd/gc/sys.go
+1
-1
src/cmd/gc/sysimport.c
src/cmd/gc/sysimport.c
+168
-167
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+11
-4
src/runtime/chan.c
src/runtime/chan.c
+216
-185
No files found.
src/cmd/gc/sys.go
View file @
12082728
...
...
@@ -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
);
...
...
src/cmd/gc/sysimport.c
View file @
12082728
...
...
@@ -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_3
61 {_esys_359
sys._esys_003}
\n
"
"type sys._osys_3
72 {_esys_370
sys._esys_003}
\n
"
"type sys.uint32 6
\n
"
"type sys._isys_3
63 {_esys_360
sys.uint32}
\n
"
"type sys._esys_001 (sys._esys_002 sys._osys_3
61 sys._isys_363
)
\n
"
"type sys._isys_3
74 {_esys_371
sys.uint32}
\n
"
"type sys._esys_001 (sys._esys_002 sys._osys_3
72 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_3
69 {_esys_368
sys.int32}
\n
"
"type sys._esys_008 (sys._esys_009 sys._esys_010 sys._isys_3
69
)
\n
"
"type sys._isys_3
80 {_esys_379
sys.int32}
\n
"
"type sys._esys_008 (sys._esys_009 sys._esys_010 sys._isys_3
80
)
\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_3
74 {_esys_373
sys.bool}
\n
"
"type sys._esys_011 (sys._esys_012 sys._esys_013 sys._isys_3
74
)
\n
"
"type sys._isys_3
85 {_esys_384
sys.bool}
\n
"
"type sys._esys_011 (sys._esys_012 sys._esys_013 sys._isys_3
85
)
\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_3
79 {_esys_378
sys.float64}
\n
"
"type sys._esys_014 (sys._esys_015 sys._esys_016 sys._isys_3
79
)
\n
"
"type sys._isys_3
90 {_esys_389
sys.float64}
\n
"
"type sys._esys_014 (sys._esys_015 sys._esys_016 sys._isys_3
90
)
\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_3
84 {_esys_383
sys.int64}
\n
"
"type sys._esys_017 (sys._esys_018 sys._esys_019 sys._isys_3
84
)
\n
"
"type sys._isys_3
95 {_esys_394
sys.int64}
\n
"
"type sys._esys_017 (sys._esys_018 sys._esys_019 sys._isys_3
95
)
\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_4
01 {_esys_398
sys.string}
\n
"
"type sys._isys_4
03 {_esys_399 sys.string _esys_400
sys.string}
\n
"
"type sys._esys_028 (sys._esys_029 sys._osys_4
01 sys._isys_403
)
\n
"
"type sys._osys_4
12 {_esys_409
sys.string}
\n
"
"type sys._isys_4
14 {_esys_410 sys.string _esys_411
sys.string}
\n
"
"type sys._esys_028 (sys._esys_029 sys._osys_4
12 sys._isys_414
)
\n
"
"var !sys.catstring sys._esys_028
\n
"
"type sys._esys_031 {}
\n
"
"type sys._osys_4
11 {_esys_408
sys.int32}
\n
"
"type sys._isys_4
13 {_esys_409 sys.string _esys_410
sys.string}
\n
"
"type sys._esys_030 (sys._esys_031 sys._osys_4
11 sys._isys_413
)
\n
"
"type sys._osys_4
22 {_esys_419
sys.int32}
\n
"
"type sys._isys_4
24 {_esys_420 sys.string _esys_421
sys.string}
\n
"
"type sys._esys_030 (sys._esys_031 sys._osys_4
22 sys._isys_424
)
\n
"
"var !sys.cmpstring sys._esys_030
\n
"
"type sys._esys_033 {}
\n
"
"type sys._osys_4
22 {_esys_418
sys.string}
\n
"
"type sys._isys_4
24 {_esys_419 sys.string _esys_420 sys.int32 _esys_421
sys.int32}
\n
"
"type sys._esys_032 (sys._esys_033 sys._osys_4
22 sys._isys_424
)
\n
"
"type sys._osys_4
33 {_esys_429
sys.string}
\n
"
"type sys._isys_4
35 {_esys_430 sys.string _esys_431 sys.int32 _esys_432
sys.int32}
\n
"
"type sys._esys_032 (sys._esys_033 sys._osys_4
33 sys._isys_435
)
\n
"
"var !sys.slicestring sys._esys_032
\n
"
"type sys._esys_035 {}
\n
"
"type sys.uint8 2
\n
"
"type sys._osys_4
33 {_esys_430
sys.uint8}
\n
"
"type sys._isys_4
35 {_esys_431 sys.string _esys_432
sys.int32}
\n
"
"type sys._esys_034 (sys._esys_035 sys._osys_4
33 sys._isys_435
)
\n
"
"type sys._osys_4
44 {_esys_441
sys.uint8}
\n
"
"type sys._isys_4
46 {_esys_442 sys.string _esys_443
sys.int32}
\n
"
"type sys._esys_034 (sys._esys_035 sys._osys_4
44 sys._isys_446
)
\n
"
"var !sys.indexstring sys._esys_034
\n
"
"type sys._esys_037 {}
\n
"
"type sys._osys_4
42 {_esys_440
sys.string}
\n
"
"type sys._isys_4
44 {_esys_441
sys.int64}
\n
"
"type sys._esys_036 (sys._esys_037 sys._osys_4
42 sys._isys_444
)
\n
"
"type sys._osys_4
53 {_esys_451
sys.string}
\n
"
"type sys._isys_4
55 {_esys_452
sys.int64}
\n
"
"type sys._esys_036 (sys._esys_037 sys._osys_4
53 sys._isys_455
)
\n
"
"var !sys.intstring sys._esys_036
\n
"
"type sys._esys_039 {}
\n
"
"type sys._osys_4
51 {_esys_448
sys.string}
\n
"
"type sys._osys_4
62 {_esys_459
sys.string}
\n
"
"type sys._esys_040 *sys.uint8
\n
"
"type sys._isys_4
53 {_esys_449 sys._esys_040 _esys_450
sys.int32}
\n
"
"type sys._esys_038 (sys._esys_039 sys._osys_4
51 sys._isys_453
)
\n
"
"type sys._isys_4
64 {_esys_460 sys._esys_040 _esys_461
sys.int32}
\n
"
"type sys._esys_038 (sys._esys_039 sys._osys_4
62 sys._isys_464
)
\n
"
"var !sys.byteastring sys._esys_038
\n
"
"type sys._esys_042 {}
\n
"
"type sys._esys_043 <>
\n
"
"type sys._osys_4
62 {_esys_458
sys._esys_043}
\n
"
"type sys._osys_4
73 {_esys_469
sys._esys_043}
\n
"
"type sys._esys_044 *sys.uint8
\n
"
"type sys._esys_045 *sys.uint8
\n
"
"type sys._ssys_4
69
{}
\n
"
"type sys._esys_046 *sys._ssys_4
69
\n
"
"type sys._isys_4
64 {_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_4
62 sys._isys_464
)
\n
"
"type sys._ssys_4
80
{}
\n
"
"type sys._esys_046 *sys._ssys_4
80
\n
"
"type sys._isys_4
75 {_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_4
73 sys._isys_475
)
\n
"
"var !sys.mkiface sys._esys_041
\n
"
"type sys._esys_048 {}
\n
"
"type sys._osys_4
73 {_esys_472
sys.int32}
\n
"
"type sys._osys_4
84 {_esys_483
sys.int32}
\n
"
"type sys._esys_049 {}
\n
"
"type sys._esys_047 (sys._esys_048 sys._osys_4
73
sys._esys_049)
\n
"
"type sys._esys_047 (sys._esys_048 sys._osys_4
84
sys._esys_049)
\n
"
"var !sys.argc sys._esys_047
\n
"
"type sys._esys_051 {}
\n
"
"type sys._osys_4
77 {_esys_476
sys.int32}
\n
"
"type sys._osys_4
88 {_esys_487
sys.int32}
\n
"
"type sys._esys_052 {}
\n
"
"type sys._esys_050 (sys._esys_051 sys._osys_4
77
sys._esys_052)
\n
"
"type sys._esys_050 (sys._esys_051 sys._osys_4
88
sys._esys_052)
\n
"
"var !sys.envc sys._esys_050
\n
"
"type sys._esys_054 {}
\n
"
"type sys._osys_4
82 {_esys_480
sys.string}
\n
"
"type sys._isys_4
84 {_esys_481
sys.int32}
\n
"
"type sys._esys_053 (sys._esys_054 sys._osys_4
82 sys._isys_484
)
\n
"
"type sys._osys_4
93 {_esys_491
sys.string}
\n
"
"type sys._isys_4
95 {_esys_492
sys.int32}
\n
"
"type sys._esys_053 (sys._esys_054 sys._osys_4
93 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_5
01 {_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_5
12 {_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_5
08 {_esys_505
sys.float64}
\n
"
"type sys._isys_5
10 {_esys_506 sys.float64 _esys_507
sys.int32}
\n
"
"type sys._esys_059 (sys._esys_060 sys._osys_5
08 sys._isys_510
)
\n
"
"type sys._osys_5
19 {_esys_516
sys.float64}
\n
"
"type sys._isys_5
21 {_esys_517 sys.float64 _esys_518
sys.int32}
\n
"
"type sys._esys_059 (sys._esys_060 sys._osys_5
19 sys._isys_521
)
\n
"
"var !sys.ldexp sys._esys_059
\n
"
"type sys._esys_062 {}
\n
"
"type sys._osys_5
18 {_esys_515 sys.float64 _esys_516
sys.float64}
\n
"
"type sys._isys_5
20 {_esys_517
sys.float64}
\n
"
"type sys._esys_061 (sys._esys_062 sys._osys_5
18 sys._isys_520
)
\n
"
"type sys._osys_5
29 {_esys_526 sys.float64 _esys_527
sys.float64}
\n
"
"type sys._isys_5
31 {_esys_528
sys.float64}
\n
"
"type sys._esys_061 (sys._esys_062 sys._osys_5
29 sys._isys_531
)
\n
"
"var !sys.modf sys._esys_061
\n
"
"type sys._esys_064 {}
\n
"
"type sys._osys_5
27 {_esys_524
sys.bool}
\n
"
"type sys._isys_5
29 {_esys_525 sys.float64 _esys_526
sys.int32}
\n
"
"type sys._esys_063 (sys._esys_064 sys._osys_5
27 sys._isys_529
)
\n
"
"type sys._osys_5
38 {_esys_535
sys.bool}
\n
"
"type sys._isys_5
40 {_esys_536 sys.float64 _esys_537
sys.int32}
\n
"
"type sys._esys_063 (sys._esys_064 sys._osys_5
38 sys._isys_540
)
\n
"
"var !sys.isInf sys._esys_063
\n
"
"type sys._esys_066 {}
\n
"
"type sys._osys_5
36 {_esys_534
sys.bool}
\n
"
"type sys._isys_5
38 {_esys_535
sys.float64}
\n
"
"type sys._esys_065 (sys._esys_066 sys._osys_5
36 sys._isys_538
)
\n
"
"type sys._osys_5
47 {_esys_545
sys.bool}
\n
"
"type sys._isys_5
49 {_esys_546
sys.float64}
\n
"
"type sys._esys_065 (sys._esys_066 sys._osys_5
47 sys._isys_549
)
\n
"
"var !sys.isNaN sys._esys_065
\n
"
"type sys._esys_068 {}
\n
"
"type sys._osys_5
44 {_esys_542
sys.float64}
\n
"
"type sys._isys_5
46 {_esys_543
sys.int32}
\n
"
"type sys._esys_067 (sys._esys_068 sys._osys_5
44 sys._isys_546
)
\n
"
"type sys._osys_5
55 {_esys_553
sys.float64}
\n
"
"type sys._isys_5
57 {_esys_554
sys.int32}
\n
"
"type sys._esys_067 (sys._esys_068 sys._osys_5
55 sys._isys_557
)
\n
"
"var !sys.Inf sys._esys_067
\n
"
"type sys._esys_070 {}
\n
"
"type sys._osys_5
51 {_esys_550
sys.float64}
\n
"
"type sys._osys_5
62 {_esys_561
sys.float64}
\n
"
"type sys._esys_071 {}
\n
"
"type sys._esys_069 (sys._esys_070 sys._osys_5
51
sys._esys_071)
\n
"
"type sys._esys_069 (sys._esys_070 sys._osys_5
62
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_5
54
{hmap sys._esys_074}
\n
"
"type sys._isys_5
56
{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_5
54 sys._isys_556
)
\n
"
"type sys._osys_5
65
{hmap sys._esys_074}
\n
"
"type sys._isys_5
67
{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_5
65 sys._isys_567
)
\n
"
"var !sys.newmap sys._esys_072
\n
"
"type sys._esys_077 {}
\n
"
"type sys._osys_5
65
{val sys.any}
\n
"
"type sys._osys_5
76
{val sys.any}
\n
"
"type sys._esys_079 [sys.any] sys.any
\n
"
"type sys._esys_078 *sys._esys_079
\n
"
"type sys._isys_5
67
{hmap sys._esys_078 key sys.any}
\n
"
"type sys._esys_076 (sys._esys_077 sys._osys_5
65 sys._isys_567
)
\n
"
"type sys._isys_5
78
{hmap sys._esys_078 key sys.any}
\n
"
"type sys._esys_076 (sys._esys_077 sys._osys_5
76 sys._isys_578
)
\n
"
"var !sys.mapaccess1 sys._esys_076
\n
"
"type sys._esys_081 {}
\n
"
"type sys._osys_5
73
{val sys.any pres sys.bool}
\n
"
"type sys._osys_5
84
{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_5
75
{hmap sys._esys_082 key sys.any}
\n
"
"type sys._esys_080 (sys._esys_081 sys._osys_5
73 sys._isys_575
)
\n
"
"type sys._isys_5
86
{hmap sys._esys_082 key sys.any}
\n
"
"type sys._esys_080 (sys._esys_081 sys._osys_5
84 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_5
82
{hmap sys._esys_087 key sys.any val sys.any}
\n
"
"type sys._esys_084 (sys._esys_085 sys._esys_086 sys._isys_5
82
)
\n
"
"type sys._isys_5
93
{hmap sys._esys_087 key sys.any val sys.any}
\n
"
"type sys._esys_084 (sys._esys_085 sys._esys_086 sys._isys_5
93
)
\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_5
88
{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_5
88
)
\n
"
"type sys._isys_5
99
{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_5
99
)
\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_6
04
{elem sys.any}
\n
"
"type sys._osys_6
15
{elem sys.any}
\n
"
"type sys._esys_101 1 sys.any
\n
"
"type sys._esys_100 *sys._esys_101
\n
"
"type sys._isys_6
06
{hchan sys._esys_100}
\n
"
"type sys._esys_098 (sys._esys_099 sys._osys_6
04 sys._isys_606
)
\n
"
"type sys._isys_6
17
{hchan sys._esys_100}
\n
"
"type sys._esys_098 (sys._esys_099 sys._osys_6
15 sys._isys_617
)
\n
"
"var !sys.chanrecv1 sys._esys_098
\n
"
"type sys._esys_103 {}
\n
"
"type sys._osys_6
11
{elem sys.any pres sys.bool}
\n
"
"type sys._osys_6
22
{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_6
13
{hchan sys._esys_104}
\n
"
"type sys._esys_102 (sys._esys_103 sys._osys_6
11 sys._isys_613
)
\n
"
"type sys._isys_6
24
{hchan sys._esys_104}
\n
"
"type sys._esys_102 (sys._esys_103 sys._osys_6
22 sys._isys_624
)
\n
"
"var !sys.chanrecv2 sys._esys_102
\n
"
"type sys._esys_107 {}
\n
"
"type sys._osys_6
19 {elem sys.any
pres sys.bool}
\n
"
"type sys._osys_6
30 {
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_11
4 1 sys.any
\n
"
"type sys._esys_11
3 *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_11
7 *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.uint3
2}
\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_12
6 1 sys.any
\n
"
"type sys._esys_12
5 *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_13
1 1 sys.any
\n
"
"type sys._esys_13
0 *sys._esys_131
\n
"
"type sys._esys_13
2 *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_11
3 {}
\n
"
"type sys._esys_11
5 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_11
9 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_12
2}
\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_12
5 *sys.uint8
\n
"
"type sys._esys_12
7 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_13
0 *sys.uint8
\n
"
"type sys._esys_13
2 1 sys.any
\n
"
"type sys._esys_13
1 *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_1
37 (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_1
41 {}
\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_14
1 (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_14
5 {}
\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
"
;
src/cmd/gc/walk.c
View file @
12082728
...
...
@@ -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
(
"chanrecv
2
"
,
1
);
on
=
syslook
(
"chanrecv
3
"
,
1
);
argtype
(
on
,
t
->
type
);
// any-1
argtype
(
on
,
t
->
type
);
// any-2
r
=
nod
(
OCALL
,
on
,
r
);
n
->
right
=
r
;
r
=
n
;
...
...
src/runtime/chan.c
View file @
12082728
...
...
@@ -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
s
ys
·
chansend1
(
Hchan
*
c
,
...
)
s
endchan
(
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
);
gp
=
sg
->
g
;
gp
->
param
=
sg
;
gp
->
status
=
Grunnable
;
if
(
pres
!=
nil
)
*
pres
=
true
;
return
;
}
gr
=
sgr
->
g
;
gr
->
param
=
sgr
;
gr
->
status
=
Grunnable
;
if
(
pres
!=
nil
)
{
*
pres
=
false
;
return
;
}
sgr
=
allocsg
(
c
);
c
->
elemalg
->
copy
(
c
->
elemsize
,
sgr
->
elem
,
ae
);
sg
=
allocsg
(
c
);
if
(
ep
!=
nil
)
c
->
elemalg
->
copy
(
c
->
elemsize
,
sg
->
elem
,
ep
);
g
->
param
=
nil
;
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
sendq
,
sg
r
);
enqueue
(
&
c
->
sendq
,
sg
);
sys
·
gosched
();
sg
=
g
->
param
;
freesg
(
c
,
sg
);
return
;
asynch:
while
(
c
->
qcount
>=
c
->
dataqsiz
)
{
sg
r
=
allocsg
(
c
);
sg
=
allocsg
(
c
);
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
sendq
,
sg
r
);
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
;
}
}
// chansend2(hchan *chan any, elem any) (pres bool);
void
sys
·
chansend2
(
Hchan
*
c
,
...)
static
void
chanrecv
(
Hchan
*
c
,
byte
*
ep
,
bool
*
pres
)
{
byte
*
ae
,
*
ap
;
SudoG
*
sgr
;
G
*
gr
;
ae
=
(
byte
*
)
&
c
+
c
->
eo
;
ap
=
(
byte
*
)
&
c
+
c
->
po
;
SudoG
*
sg
;
G
*
gp
;
if
(
debug
)
{
prints
(
"chan
send
: chan="
);
prints
(
"chan
recv
: 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
);
sg
=
dequeue
(
&
c
->
sendq
,
c
);
if
(
sg
!=
nil
)
{
c
->
elemalg
->
copy
(
c
->
elemsize
,
ep
,
sg
->
elem
);
gr
->
param
=
sgr
;
gr
->
status
=
Grunnable
;
*
ap
=
true
;
return
;
}
*
ap
=
false
;
return
;
gp
=
sg
->
g
;
gp
->
param
=
sg
;
gp
->
status
=
Grunnable
;
asynch:
if
(
c
->
qcount
>=
c
->
dataqsiz
)
{
*
ap
=
false
;
if
(
pres
!=
nil
)
*
pres
=
true
;
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
;
}
// chanrecv1(hchan *chan any) (elem any);
void
sys
·
chanrecv1
(
Hchan
*
c
,
...)
{
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
;
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
);
if
(
pres
!=
nil
)
{
*
pres
=
false
;
return
;
}
sgs
=
allocsg
(
c
);
sg
=
allocsg
(
c
);
g
->
param
=
nil
;
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
recvq
,
sg
s
);
enqueue
(
&
c
->
recvq
,
sg
);
sys
·
gosched
();
c
->
elemalg
->
copy
(
c
->
elemsize
,
ae
,
sgs
->
elem
);
freesg
(
c
,
sgs
);
sg
=
g
->
param
;
c
->
elemalg
->
copy
(
c
->
elemsize
,
ep
,
sg
->
elem
);
freesg
(
c
,
sg
);
return
;
asynch:
while
(
c
->
qcount
<=
0
)
{
sg
s
=
allocsg
(
c
);
sg
=
allocsg
(
c
);
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
recvq
,
sg
s
);
enqueue
(
&
c
->
recvq
,
sg
);
sys
·
gosched
();
}
c
->
elemalg
->
copy
(
c
->
elemsize
,
ae
,
c
->
recvdataq
->
elem
);
c
->
elemalg
->
copy
(
c
->
elemsize
,
ep
,
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
;
sg
=
dequeue
(
&
c
->
sendq
,
c
);
if
(
sg
!=
nil
)
{
gp
=
sg
->
g
;
freesg
(
c
,
sg
);
gp
->
status
=
Grunnable
;
}
}
// chan
recv2(hchan *chan any) (elem any, pres bool
);
// chan
send1(hchan *chan any, elem any
);
void
sys
·
chanrecv2
(
Hchan
*
c
,
...)
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
*
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
;
sendchan
(
c
,
ae
,
ap
);
}
sgs
=
dequeue
(
&
c
->
sendq
,
c
);
if
(
sgs
!=
nil
)
{
c
->
elemalg
->
copy
(
c
->
elemsize
,
ae
,
sgs
->
elem
);
// chanrecv1(hchan *chan any) (elem any);
void
sys
·
chanrecv1
(
Hchan
*
c
,
...)
{
int32
o
;
byte
*
ae
;
gs
=
sgs
->
g
;
gs
->
param
=
sgs
;
gs
->
status
=
Grunnable
;
o
=
rnd
(
sizeof
(
c
),
c
->
elemsize
);
ae
=
(
byte
*
)
&
c
+
o
;
freesg
(
c
,
sgs
);
*
ap
=
true
;
return
;
}
*
ap
=
false
;
return
;
chanrecv
(
c
,
ae
,
nil
);
}
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
);
// chanrecv2(hchan *chan any) (elem any, pres bool);
void
sys
·
chanrecv2
(
Hchan
*
c
,
...)
{
int32
o
;
byte
*
ae
,
*
ap
;
gs
->
status
=
Grunnable
;
}
*
ap
=
true
;
o
=
rnd
(
sizeof
(
c
),
c
->
elemsize
);
ae
=
(
byte
*
)
&
c
+
o
;
o
=
rnd
(
o
+
c
->
elemsize
,
1
);
ap
=
(
byte
*
)
&
c
+
o
;
chanrecv
(
c
,
ae
,
ap
);
}
// 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
=
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
,
e
p
o
;
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
;
e
p
o
=
rnd
(
sizeof
(
sel
),
sizeof
(
c
));
e
po
=
rnd
(
ep
o
+
sizeof
(
c
),
sizeof
(
byte
*
));
cas
->
so
=
rnd
(
e
p
o
+
sizeof
(
byte
*
),
1
);
eo
=
rnd
(
sizeof
(
sel
),
sizeof
(
c
));
e
o
=
rnd
(
e
o
+
sizeof
(
c
),
sizeof
(
byte
*
));
cas
->
so
=
rnd
(
eo
+
sizeof
(
byte
*
),
1
);
cas
->
send
=
0
;
cas
->
u
.
elemp
=
*
(
byte
**
)((
byte
*
)
&
sel
+
e
p
o
);
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
got
r
;
goto
got
s
;
}
else
{
sg
=
dequeue
(
&
c
->
sendq
,
c
);
if
(
sg
!=
nil
)
goto
got
s
;
goto
got
r
;
}
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,39 +570,43 @@ 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
(
"wa
ke
: sel="
);
if
(
xxx
)
{
prints
(
"wa
it-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
;
if
(
!
cas
->
send
)
{
if
(
cas
->
u
.
elemp
!=
nil
)
c
->
elemalg
->
copy
(
c
->
elemsize
,
cas
->
u
.
elemp
,
sg
->
elem
);
}
freesg
(
c
,
sg
);
goto
retc
;
asynr:
asyns:
throw
(
"asyn"
);
gotr:
if
(
0
)
{
// recv path to wakeup the sender (sg)
if
(
xxx
)
{
prints
(
"gotr: sel="
);
sys
·
printpointer
(
sel
);
prints
(
" c="
);
...
...
@@ -591,14 +615,16 @@ gotr:
sys
·
printint
(
o
);
prints
(
"
\n
"
);
}
c
->
elemalg
->
copy
(
c
->
elemsize
,
sg
->
elem
,
cas
->
u
.
elem
);
if
(
cas
->
u
.
elemp
!=
nil
)
c
->
elemalg
->
copy
(
c
->
elemsize
,
cas
->
u
.
elemp
,
sg
->
elem
);
gp
=
sg
->
g
;
gp
->
param
=
sg
;
gp
->
status
=
Grunnable
;
goto
retc
;
gots:
if
(
0
)
{
// send path to wakeup the receiver (sg)
if
(
xxx
)
{
prints
(
"gots: sel="
);
sys
·
printpointer
(
sel
);
prints
(
" c="
);
...
...
@@ -607,14 +633,17 @@ gots:
sys
·
printint
(
o
);
prints
(
"
\n
"
);
}
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
);
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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment