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
mach/proto/as

View file

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

View file

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