Commit 44b8934d authored by Ken Thompson's avatar Ken Thompson

back out last chan fix

allow print of pointers

SVN=127548
parent 90da10d7
......@@ -13,7 +13,7 @@ func printbool(bool);
func printfloat(double);
func printint(int64);
func printstring(string);
func printpointer(*byte);
func printpointer(*any);
func catstring(string, string) string;
func cmpstring(string, string) int32;
......
This diff is collapsed.
......@@ -1179,6 +1179,8 @@ prcompat(Node *n)
loop:
if(l == N) {
if(r == N)
return nod(OBAD, N, N);
walktype(r, Etop);
return r;
}
......@@ -1186,28 +1188,33 @@ loop:
w = whatis(l);
switch(w) {
default:
badtype(n->op, l->type, T);
l = listnext(&save);
goto loop;
if(!isptr[l->type->etype]) {
badtype(n->op, l->type, T);
l = listnext(&save);
goto loop;
}
on = syslook("printpointer", 1);
argtype(on, l->type->type); // any-1
break;
case Wlitint:
case Wtint:
name = "printint";
on = syslook("printint", 0);
break;
case Wlitfloat:
case Wtfloat:
name = "printfloat";
on = syslook("printfloat", 0);
break;
case Wlitbool:
case Wtbool:
name = "printbool";
on = syslook("printbool", 0);
break;
case Wlitstr:
case Wtstr:
name = "printstring";
on = syslook("printstring", 0);
break;
}
on = syslook(name, 0);
t = *getinarg(on->type);
if(t != nil)
t = t->type;
......
......@@ -15,8 +15,7 @@ struct Hchan
uint32 dataqsiz; // size of the circular q
uint32 qcount; // total data in the q
uint32 eo; // vararg of element
uint32 po1; // vararg of present bool in next structure
uint32 po2; // vararg of present bool in same structure
uint32 po; // vararg of present bool
Alg* elemalg; // interface for element type
Link* senddataq; // pointer for sender
Link* recvdataq; // pointer for receiver
......@@ -75,8 +74,7 @@ sys·newchan(uint32 elemsize, uint32 elemalg, uint32 hint,
// these calculations are compiler dependent
c->eo = rnd(sizeof(c), elemsize);
c->po1 = rnd(c->eo+elemsize, 8); // next structure
c->po2 = rnd(c->eo+elemsize, 1); // same structure
c->po = rnd(c->eo+elemsize, 1);
ret = c;
FLUSH(&ret);
......@@ -146,7 +144,7 @@ sys·chansend2(Hchan* c, ...)
G *gr;
ae = (byte*)&c + c->eo;
ap = (byte*)&c + c->po1;
ap = (byte*)&c + c->po;
if(debug) {
prints("chansend: chan=");
......@@ -232,7 +230,7 @@ sys·chanrecv2(Hchan* c, ...)
G *gs;
ae = (byte*)&c + c->eo;
ap = (byte*)&c + c->po2;
ap = (byte*)&c + c->po;
if(debug) {
prints("chanrecv2: chan=");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment