Commit e90314d0 authored by Ken Thompson's avatar Ken Thompson

pragma textflag

fixes latent bugs in go and defer

R=r
OCL=23613
CL=23613
parent 53e69e1d
...@@ -1334,5 +1334,12 @@ praghjdicks(void) ...@@ -1334,5 +1334,12 @@ praghjdicks(void)
; ;
} }
void
pragtextflag(void)
{
while(getnsc() != '\n')
;
}
#include "../cc/lexbody" #include "../cc/lexbody"
#include "../cc/macbody" #include "../cc/macbody"
...@@ -1473,7 +1473,9 @@ gpseudo(int a, Sym *s, Node *n) ...@@ -1473,7 +1473,9 @@ gpseudo(int a, Sym *s, Node *n)
p->as = a; p->as = a;
p->from.type = D_EXTERN; p->from.type = D_EXTERN;
p->from.sym = s; p->from.sym = s;
p->from.scale = (profileflg ? 0 : NOPROF); p->from.scale = textflag;
textflag = 0;
if(s->class == CSTATIC) if(s->class == CSTATIC)
p->from.type = D_STATIC; p->from.type = D_STATIC;
naddr(n, &p->to); naddr(n, &p->to);
......
...@@ -1363,7 +1363,9 @@ gpseudo(int a, Sym *s, Node *n) ...@@ -1363,7 +1363,9 @@ gpseudo(int a, Sym *s, Node *n)
p->as = a; p->as = a;
p->from.type = D_EXTERN; p->from.type = D_EXTERN;
p->from.sym = s; p->from.sym = s;
p->from.scale = (profileflg ? 0 : NOPROF); p->from.scale = textflag;
textflag = 0;
if(s->class == CSTATIC) if(s->class == CSTATIC)
p->from.type = D_STATIC; p->from.type = D_STATIC;
naddr(n, &p->to); naddr(n, &p->to);
......
...@@ -498,7 +498,7 @@ EXTERN Term term[NTERM]; ...@@ -498,7 +498,7 @@ EXTERN Term term[NTERM];
EXTERN int nterm; EXTERN int nterm;
EXTERN int packflg; EXTERN int packflg;
EXTERN int fproundflg; EXTERN int fproundflg;
EXTERN int profileflg; EXTERN int textflag;
EXTERN int ncontin; EXTERN int ncontin;
EXTERN int canreach; EXTERN int canreach;
EXTERN int warnreach; EXTERN int warnreach;
...@@ -747,7 +747,7 @@ void arginit(void); ...@@ -747,7 +747,7 @@ void arginit(void);
void pragvararg(void); void pragvararg(void);
void pragpack(void); void pragpack(void);
void pragfpround(void); void pragfpround(void);
void pragprofile(void); void pragtextflag(void);
void pragincomplete(void); void pragincomplete(void);
/* /*
......
...@@ -450,25 +450,19 @@ pragfpround(void) ...@@ -450,25 +450,19 @@ pragfpround(void)
} }
void void
pragprofile(void) pragtextflag(void)
{ {
Sym *s; Sym *s;
profileflg = 0; textflag = 0;
s = getsym(); s = getsym();
if(s) { textflag = 7;
profileflg = atoi(s->name+1); if(s)
if(strcmp(s->name, "on") == 0 || textflag = atoi(s->name+1);
strcmp(s->name, "yes") == 0)
profileflg = 1;
}
while(getnsc() != '\n') while(getnsc() != '\n')
; ;
if(debug['f']) if(debug['f'])
if(profileflg) print("%4ld: textflag %d\n", lineno, textflag);
print("%4ld: profileflg %d\n", lineno, profileflg);
else
print("%4ld: profileflg off\n", lineno);
} }
void void
......
...@@ -75,7 +75,6 @@ main(int argc, char *argv[]) ...@@ -75,7 +75,6 @@ main(int argc, char *argv[])
ginit(); ginit();
arginit(); arginit();
profileflg = 1; /* #pragma can turn it off */
tufield = simplet((1L<<tfield->etype) | BUNSIGNED); tufield = simplet((1L<<tfield->etype) | BUNSIGNED);
ndef = 0; ndef = 0;
outfile = 0; outfile = 0;
......
...@@ -725,8 +725,8 @@ macprag(void) ...@@ -725,8 +725,8 @@ macprag(void)
pragfpround(); pragfpround();
return; return;
} }
if(s && strcmp(s->name, "profile") == 0) { if(s && strcmp(s->name, "textflag") == 0) {
pragprofile(); pragtextflag();
return; return;
} }
if(s && strcmp(s->name, "varargck") == 0) { if(s && strcmp(s->name, "varargck") == 0) {
......
...@@ -155,6 +155,7 @@ malg(int32 stacksize) ...@@ -155,6 +155,7 @@ malg(int32 stacksize)
return g; return g;
} }
#pragma textflag 7
void void
sys·newproc(int32 siz, byte* fn, byte* arg0) sys·newproc(int32 siz, byte* fn, byte* arg0)
{ {
...@@ -204,6 +205,7 @@ sys·newproc(int32 siz, byte* fn, byte* arg0) ...@@ -204,6 +205,7 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
//printf(" goid=%d\n", newg->goid); //printf(" goid=%d\n", newg->goid);
} }
#pragma textflag 7
void void
sys·deferproc(int32 siz, byte* fn, byte* arg0) sys·deferproc(int32 siz, byte* fn, byte* arg0)
{ {
...@@ -219,6 +221,7 @@ sys·deferproc(int32 siz, byte* fn, byte* arg0) ...@@ -219,6 +221,7 @@ sys·deferproc(int32 siz, byte* fn, byte* arg0)
g->defer = d; g->defer = d;
} }
#pragma textflag 7
void void
sys·deferreturn(int32 arg0) sys·deferreturn(int32 arg0)
{ {
...@@ -760,6 +763,7 @@ newstack(void) ...@@ -760,6 +763,7 @@ newstack(void)
*(int32*)345 = 123; // never return *(int32*)345 = 123; // never return
} }
#pragma textflag 7
void void
sys·morestack(uint64 u) sys·morestack(uint64 u)
{ {
......
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