Added some buffering for writes

This commit is contained in:
ceriel 1987-02-13 12:44:33 +00:00
parent 629c0a315c
commit 04d031d33d
2 changed files with 70 additions and 16 deletions

View file

@ -109,6 +109,7 @@ char **argv;
pass_23(PASS_2);
#endif
pass_23(PASS_3);
oflush();
wr_close();
stop();
}

View file

@ -236,10 +236,23 @@ valu_t bytes;
}
#ifdef RELOCATION
static int nrelo;
static struct outrelo relobuf[100];
struct outrelo *
neworelo()
{
if (nrelo == 100) {
wr_relo(relobuf, 100);
nrelo = 0;
}
return &relobuf[nrelo++];
}
newrelo(s, n)
short s;
{
struct outrelo outrelo;
register struct outrelo *outrelo;
int iscomm;
if (rflag == 0)
@ -271,12 +284,13 @@ short s;
return;
}
s &= ~S_VAR;
outrelo.or_type = (char)n;
outrelo.or_sect = (char)DOTTYP;
outrelo = neworelo();
outrelo->or_type = (char)n;
outrelo->or_sect = (char)DOTTYP;
#ifndef ASLD
if (s == S_UND || iscomm) {
assert(relonami != 0);
outrelo.or_nami = relonami-1;
outrelo->or_nami = relonami-1;
relonami = 0;
} else
#endif
@ -285,28 +299,58 @@ short s;
/*
* use first non existing entry (argh)
*/
outrelo.or_nami = outhead.oh_nname;
outrelo->or_nami = outhead.oh_nname;
} else {
/*
* section symbols are at the end
*/
outrelo.or_nami = outhead.oh_nname
outrelo->or_nami = outhead.oh_nname
- outhead.oh_nsect
+ (s - S_MIN)
;
}
outrelo.or_addr = (long)DOTVAL;
wr_relo(&outrelo, 1);
outrelo->or_addr = (long)DOTVAL;
}
#endif
static char sbuf[1024];
static char *psbuf = sbuf;
mwr_string(nm,len)
register char *nm;
{
register char *q = psbuf;
while (len--) {
*q++ = *nm++;
if (q == &sbuf[1024]) {
wr_string(sbuf,1024L);
q = sbuf;
}
}
psbuf = q;
}
static struct outname obuf[100];
static int nnames;
static struct outname *
newoname()
{
if (nnames == 100) {
wr_name(obuf,100);
nnames = 0;
}
return &obuf[nnames++];
}
newsymb(name, type, desc, valu)
register char *name;
short type;
short desc;
valu_t valu;
{
struct outname outname;
register struct outname *outname;
if (name && *name == 0)
name = 0;
@ -318,18 +362,27 @@ valu_t valu;
return;
}
nname++;
outname = newoname();
if (name) {
int len = strlen(name) + 1;
wr_string(name, len);
outname.on_foff = outhead.oh_nchar;
mwr_string(name, len);
outname->on_foff = outhead.oh_nchar;
outhead.oh_nchar += len;
} else
outname.on_foff = 0;
outname.on_type = type;
outname.on_desc = desc;
outname.on_valu = valu & ~((0xFFFFFFFF)<<(8*sizeof(valu_t)));
wr_name(&outname, 1);
outname->on_foff = 0;
outname->on_type = type;
outname->on_desc = desc;
outname->on_valu = valu & ~((0xFFFFFFFF)<<(8*sizeof(valu_t)));
}
oflush()
{
#ifdef RELOCATION
if (nrelo) wr_relo(relobuf,nrelo);
#endif
if (nnames) wr_name(obuf,nnames);
if (psbuf > sbuf) wr_string(sbuf, (long) (psbuf - sbuf));
}
new_common(ip)