thread switching O(1), not O(n), with
respect to the number of threads */
extern int weaving; /* whether to weave newly created threads */
-#define NEXTTHREAD if(ick_printflow) printf("[%d:%lx]",ick_lineno,(unsigned long)\
- ickmt_cur); \
- if(setjmp(ick_cjb) == 0) \
- nextthread(ick_cjb, ick_lineno, 3);
+#define NEXTTHREAD if(ick_printflow) fprintf(stderr,"[%d:%lx]",ick_lineno, \
+ (unsigned long)ickmt_cur); \
+ if(setjmp(ick_cjb) == 0) \
+ nextthread(ick_cjb, ick_lineno, 3);
extern void nextthread(jmp_buf pc, int errlineno, int flags);
extern void killthread(void);
}
fprintf(fp,"\t""%s;} else goto CCF%d;\n",
multithread?"NEXTTHREAD":useprintflow?
- "if(ick_printflow) printf(\"[%d]\",ick_lineno)":"",
+ "if(ick_printflow) fprintf(stderr,\"[%d]\",ick_lineno)":"",
compucomecount);
break;
(void) fprintf(fp, "if(0) {C%ld: %s;%s}\n", (long)(tn-tuples+1),
tn->type==NEXTFROMLABEL ? "ick_pushnext(truelineno+1)":"",
multithread?" NEXTTHREAD;":!useprintflow?""
- :" if(ick_printflow) printf(\"[%d]\",ick_lineno);");
+ :" if(ick_printflow) "
+ "fprintf(stderr,\"[%d]\",ick_lineno);");
/* AIS: Changed so all COME_FROMs have unique labels even if two
of them aim at the same line, and added the NEXT FROM case (which
involves hiding COME FROM labels in an unreachable if()). */
thread in a multithread program. */
if(multithread) (void) fputs(" NEXTTHREAD;\n", fp);
else if(useprintflow)
- (void) fputs(" if(ick_printflow) printf(\"[%d]\",ick_lineno);\n",fp);
+ (void) fputs(" if(ick_printflow) fprintf(stderr,"
+ "\"[%d]\",ick_lineno);\n",fp);
}
/* AIS: Generate prototypes for slat expressions, args to UNKNOWN */
procedure is longjmped to. */
auto volatile int nextlevel = ick_nextindex;
if(ick_printflow&&linelabel<=65535&&isnext)
- printf("[next:%lu]",linelabel);
+ fprintf(stderr,"[next:%lu]",linelabel);
ick_global_checkmode = 2; /* look for linelabels */
ick_global_linelabel = linelabel;
/* If there was a FORGET earlier, implement it now, by removing the relevant
if(!isnext)
{
if(ick_printflow&&ick_forgetamount)
- printf("[forget:%d]",ick_forgetamount);
+ fprintf(stderr,"[forget:%d]",ick_forgetamount);
else if(ick_printflow&&linelabel<=65535)
- printf("[goto:%lu]",linelabel);
+ fprintf(stderr,"[goto:%lu]",linelabel);
nextlevel = ick_nextindex -= ick_forgetamount + 1;
ick_forgetamount = 0;
if(ick_nextindex < 0) ick_nextindex = 0;
/* Resume to a previous NEXT stack entry. */
/*@noreturn@*/ void ick_doresume(unsigned short amount, int emitlineno)
{
- if(ick_printflow) printf("[resume:%hu]",amount);
+ if(ick_printflow) fprintf(stderr,"[resume:%hu]",amount);
if(ick_forgetamount) ick_lose(IE778, emitlineno, (char *)NULL);
if(!amount) ick_lose(IE621, emitlineno, (char *)NULL);
ick_nextindex -= amount;
/* If this was a COME FROM, goto it. */
if(ick_global_checkmode == 1)
{
- if(ick_printflow) printf("[comefrom:%lu]",ick_global_linelabel);
+ if(ick_printflow) fprintf(stderr,"[comefrom:%lu]",ick_global_linelabel);
ick_dogoto(ick_global_goto,-1,0); /* GOTO */
}
else if(ick_global_checkmode == 3)
{
- if(ick_printflow) printf("[nextfrom:%lu]",ick_global_linelabel);
+ if(ick_printflow) fprintf(stderr,"[nextfrom:%lu]",ick_global_linelabel);
ick_dogoto(ick_global_goto,-1,1); /* NEXT */
return; /* we were RESUMEd to */
}
/* Printflow debugging output */
static void fluputs(char* s)
{
- printf("%s",s);
- (void) fflush(stdout);
+ fprintf(stderr,"%s",s);
+ (void) fflush(stderr);
}
/**********************************************************************