cast ptrdiff_t to int for ANSI

This commit is contained in:
ceriel 1990-04-25 14:23:05 +00:00
parent 8fe53f501f
commit f2b4713c24
8 changed files with 29 additions and 9 deletions

View file

@ -462,7 +462,7 @@ if (Debug > 1) fprintf(stderr, "cost after coercions: %u\n", t);
do { do {
npos=exactmatch=0; npos=exactmatch=0;
for(rpp=reglist[propno];rp= *rpp; rpp++) for(rpp=reglist[propno];rp= *rpp; rpp++)
if (getrefcount(rp-machregs, FALSE)==0) { if (getrefcount((int)(rp-machregs), FALSE)==0) {
pos[npos++] = rp-machregs; pos[npos++] = rp-machregs;
if (eqtoken(&rp->r_contents,&token)) if (eqtoken(&rp->r_contents,&token))
exactmatch++; exactmatch++;

View file

@ -57,7 +57,7 @@ move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; {
for (i=0;i<TOKENSIZE;i++) for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i] == EV_REG && if (tdp->t_type[i] == EV_REG &&
clash(rp->r_contents.t_att[i].ar,tp2->t_att[0].ar)) { clash(rp->r_contents.t_att[i].ar,tp2->t_att[0].ar)) {
erasereg(rp-machregs); erasereg((int)(rp-machregs));
break; break;
} }
} }

View file

@ -78,7 +78,7 @@ erasereg(regno) {
rp->r_contents.t_token = 0; rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++) for (i=0;i<TOKENSIZE;i++)
rp->r_contents.t_att[i].aw = 0; rp->r_contents.t_att[i].aw = 0;
awayreg(rp-machregs); awayreg((int)(rp-machregs));
} }
#endif #endif
} }
@ -94,13 +94,13 @@ awayreg(regno) {
for (rp=machregs;rp<machregs+NREGS;rp++) { for (rp=machregs;rp<machregs+NREGS;rp++) {
if (rp->r_contents.t_token == -1) { if (rp->r_contents.t_token == -1) {
if (rp->r_contents.t_att[0].ar == regno) if (rp->r_contents.t_att[0].ar == regno)
erasereg(rp-machregs); erasereg((int)(rp-machregs));
} else if (rp->r_contents.t_token > 0) { } else if (rp->r_contents.t_token > 0) {
tdp= & tokens[rp->r_contents.t_token]; tdp= & tokens[rp->r_contents.t_token];
for (i=0;i<TOKENSIZE;i++) for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i] == EV_REG && if (tdp->t_type[i] == EV_REG &&
rp->r_contents.t_att[i].ar == regno) { rp->r_contents.t_att[i].ar == regno) {
erasereg(rp-machregs); erasereg((int)(rp-machregs));
break; break;
} }
} }

View file

@ -432,7 +432,7 @@ unsigned stackupto(limit,ply,toplevel) token_p limit; {
if (cp->c1_prop>=0) { if (cp->c1_prop>=0) {
for (rpp=reglist[cp->c1_prop]; for (rpp=reglist[cp->c1_prop];
(rp = *rpp)!=0 && (rp = *rpp)!=0 &&
getrefcount(rp-machregs, TRUE)!=0; getrefcount((int)(rp-machregs), TRUE)!=0;
rpp++) rpp++)
; ;
if (rp==0) if (rp==0)

View file

@ -12,6 +12,7 @@ static arg();
static pseudo(); static pseudo();
extern char em_flag[]; extern char em_flag[];
char C_error;
#define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR) #define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR)
@ -26,6 +27,7 @@ C_alloc()
arith C_holsize, C_bsssize; arith C_holsize, C_bsssize;
int C_holinit, C_bssinit; int C_holinit, C_bssinit;
int
C_out(p) C_out(p)
register struct e_instr *p; register struct e_instr *p;
{ {
@ -75,8 +77,11 @@ C_out(p)
DFDNAM(p->em_dnam); DFDNAM(p->em_dnam);
NL(); NL();
break; break;
default:
C_error = "Illegal EM line";
return 0;
} }
return 1;
} }
static static

View file

@ -70,7 +70,7 @@ C_flush() {
return; return;
} }
#endif #endif
if (C_opp != obuf && sys_write(C_ofp, obuf, C_opp - obuf) == 0) { if (C_opp != obuf && sys_write(C_ofp, obuf, (int)(C_opp - obuf)) == 0) {
C_ofp = 0; C_ofp = 0;
C_failed(); C_failed();
} }

View file

@ -66,6 +66,13 @@ emcode \- EM code interface for compilers
.B int C_getid() .B int C_getid()
.PP .PP
.B char *C_tmpdir; .B char *C_tmpdir;
.PP
.B #include <em.h>
.PP
.B int C_out(p)
.B struct e_instr *p;
.PP
.B char *C_error;
.fi .fi
.SH DESCRIPTION .SH DESCRIPTION
This package provides a procedural EM code interface to be used in This package provides a procedural EM code interface to be used in
@ -437,6 +444,14 @@ The user can change this by just changing
.I C_tmpdir .I C_tmpdir
before calling before calling
.IR C_open. .IR C_open.
.PP
.I C_out
accepts a structure as delivered by the
.I read_em
module, and produces code for it. It returns 1 if it succeeds, 0 if it fails
for some reason. The reason can then be found in \fIC_error\fP. The
.I C_out
routine replaces the EM_mkcalls routine.
.SH FILES .SH FILES
.nf .nf
~em/modules/h/em.h ~em/modules/h/em.h

View file

@ -70,7 +70,7 @@ do_statistics()
while (m <= &mems[NMEMS-1]) { while (m <= &mems[NMEMS-1]) {
fprintf(stderr, "mem %d: full %lx, free %lx\n", fprintf(stderr, "mem %d: full %lx, free %lx\n",
m - mems, (int)(m - mems),
(long) m->mem_full, (long) m->mem_full,
(long) m->mem_left); (long) m->mem_left);
m++; m++;