Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
97cab903
Commit
97cab903
authored
Jul 13, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chan
SVN=126959
parent
594175d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
4 deletions
+89
-4
subr.c
src/cmd/gc/subr.c
+1
-0
walk.c
src/cmd/gc/walk.c
+60
-4
chan.c
src/runtime/chan.c
+28
-0
No files found.
src/cmd/gc/subr.c
View file @
97cab903
...
...
@@ -1364,6 +1364,7 @@ deep(Type *t)
case
TPTR32
:
case
TPTR64
:
case
TCHAN
:
nt
=
shallow
(
t
);
nt
->
type
=
deep
(
t
->
type
);
break
;
...
...
src/cmd/gc/walk.c
View file @
97cab903
...
...
@@ -1700,12 +1700,16 @@ chanop(Node *n, int top)
break
;
case
OAS
:
// chansend(hchan *chan any, elem any);
cl
=
listcount
(
n
->
left
);
cr
=
listcount
(
n
->
right
);
//dump("assign1", n);
if
(
n
->
left
->
op
!=
OSEND
)
if
(
cl
==
2
&&
cr
==
1
&&
n
->
right
->
op
==
ORECV
)
goto
recv2
;
if
(
cl
!=
1
||
cr
!=
1
||
n
->
left
->
op
!=
OSEND
)
goto
shape
;
// chansend(hchan *chan any, elem any);
t
=
fixchan
(
n
->
left
->
left
->
type
);
if
(
t
==
T
)
break
;
...
...
@@ -1716,14 +1720,54 @@ chanop(Node *n, int top)
r
=
nod
(
OLIST
,
a
,
r
);
on
=
syslook
(
"chansend"
,
1
);
print
(
"type=%lT
\n
"
,
t
);
print
(
"on=%lT
\n
"
,
on
->
type
);
argtype
(
on
,
t
->
type
);
// any-1
print
(
"on=%lT
\n
"
,
on
->
type
);
argtype
(
on
,
t
->
type
);
// any-2
print
(
"on=%lT
\n
"
,
on
->
type
);
r
=
nod
(
OCALL
,
on
,
r
);
walktype
(
r
,
Erv
);
break
;
case
ORECV
:
// chanrecv1(hchan *chan any) (elem any);
t
=
fixchan
(
n
->
left
->
type
);
if
(
t
==
T
)
break
;
a
=
n
->
left
;
// chan
r
=
a
;
on
=
syslook
(
"chanrecv1"
,
1
);
argtype
(
on
,
t
->
type
);
// any-1
argtype
(
on
,
t
->
type
);
// any-2
r
=
nod
(
OCALL
,
on
,
r
);
walktype
(
r
,
Erv
);
break
;
recv2:
// chanrecv2(hchan *chan any) (elem any, pres bool);
t
=
fixchan
(
n
->
right
->
left
->
type
);
if
(
t
==
T
)
break
;
a
=
n
->
right
->
left
;
// chan
r
=
a
;
on
=
syslook
(
"chanrecv2"
,
1
);
argtype
(
on
,
t
->
type
);
// any-1
argtype
(
on
,
t
->
type
);
// any-2
r
=
nod
(
OCALL
,
on
,
r
);
n
->
right
=
r
;
r
=
n
;
walktype
(
r
,
Etop
);
break
;
}
return
r
;
...
...
@@ -1950,6 +1994,18 @@ multi:
a
=
old2new
(
nl
->
right
,
types
[
TBOOL
]);
n
=
nod
(
OLIST
,
n
,
a
);
break
;
case
ORECV
:
if
(
cl
!=
2
)
goto
badt
;
walktype
(
nr
->
left
,
Erv
);
t
=
nr
->
left
->
type
;
if
(
!
isptrto
(
t
,
TCHAN
))
goto
badt
;
a
=
old2new
(
nl
->
left
,
t
->
type
->
type
);
n
=
a
;
a
=
old2new
(
nl
->
right
,
types
[
TBOOL
]);
n
=
nod
(
OLIST
,
n
,
a
);
}
n
=
rev
(
n
);
return
n
;
...
...
src/runtime/chan.c
View file @
97cab903
...
...
@@ -73,3 +73,31 @@ sys·chansend(Hchan* c, ...)
prints
(
"
\n
"
);
}
}
// chanrecv1(hchan *chan any) (elem any);
void
sys
·
chanrecv1
(
Hchan
*
c
,
...)
{
byte
*
ae
;
ae
=
(
byte
*
)
&
c
+
c
->
eo
;
if
(
debug
)
{
prints
(
"chanrecv1: chan="
);
sys
·
printpointer
(
c
);
prints
(
"
\n
"
);
}
}
// chanrecv2(hchan *chan any) (elem any, pres bool);
void
sys
·
chanrecv2
(
Hchan
*
c
,
...)
{
byte
*
ae
;
ae
=
(
byte
*
)
&
c
+
c
->
eo
;
if
(
debug
)
{
prints
(
"chanrecv2: chan="
);
sys
·
printpointer
(
c
);
prints
(
"
\n
"
);
}
}
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