Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
go
Commits
97cab903
Commit
97cab903
authored
16 years ago
by
Ken Thompson
Browse files
Options
Download
Email Patches
Plain Diff
chan
SVN=126959
parent
594175d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
4 deletions
+89
-4
src/cmd/gc/subr.c
src/cmd/gc/subr.c
+1
-0
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+60
-4
src/runtime/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
;
...
...
This diff is collapsed.
Click to expand it.
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
;
...
...
This diff is collapsed.
Click to expand it.
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
"
);
}
}
This diff is collapsed.
Click to expand it.
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