Update generic part of the AS

This commit is contained in:
Godzil 2013-03-21 01:32:58 +01:00 committed by Manoël Trapier
parent b31c94cf32
commit a39e88ecca
7 changed files with 334 additions and 282 deletions

View File

@ -83,17 +83,21 @@ _include <stdio.h>
_include <string.h>
_include <ctype.h>
_include <signal.h>
_include <unistd.h>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <signal.h>
#include <unistd.h>
#endif
#ifdef ASLD
#include "arch.h"
#endif
#include "object.h"
#include "out.h"
#if DEBUG == 0
@ -262,5 +266,3 @@ typedef struct sect_t sect_t;
#define MACHREL_BWR (0)
#endif
#endif
extern FILE *fopen(); /* some systems don't have this in stdio.h */

View File

@ -104,17 +104,81 @@ extern struct outhead outhead;
extern int curr_token;
/* forward function declarations */
int yyparse();
/* ========== comm4.c prototypes =========== */
void stop(int signal);
int main(int argc, char *argv[]);
int pass_1(int argc, char *argv[]);
void parse(char *s);
void pass_23(int n);
void newmodule(char *s);
void setupoutput(void);
void commfinish(void);
/* ========== comm5.c prototypes =========== */
int yylex(void);
void putval(int c);
int getval(int c);
int nextchar(void);
void readcode(int n);
int induo(int c);
int inident(int c);
int innumber(int c);
int instring(int termc);
int inescape(void);
int infbsym(char *p);
int hash(char *p);
item_t *item_search(char *p);
void item_insert(item_t *ip, int h);
item_t *item_alloc(int typ);
item_t *fb_alloc(int lab);
item_t *fb_shift(int lab);
#ifdef ASLD
extern char *readident();
char *readident(int c);
#endif
extern char *remember();
extern item_t *fb_shift();
extern item_t *fb_alloc();
extern item_t *item_alloc();
extern item_t *item_search();
extern valu_t load();
extern FILE *ffcreat();
extern FILE *fftemp();
/* ========== comm6.c prototypes =========== */
void newequate(item_t *ip, int typ);
void newident(item_t *ip, int typ);
void newlabel(item_t *ip);
void newsect(item_t *ip);
void newbase(valu_t base);
void newcomm(item_t *ip, valu_t val);
void switchsect(int newtyp);
void align(valu_t bytes);
long new_string(char *s);
void newsymb(char *name, int type, int desc, valu_t valu);
void new_common(item_t *ip);
#ifdef RELOCATION
void newrelo(int s, int n);
#endif
/* ========== comm7.c prototypes =========== */
valu_t load(item_t *ip);
int store(item_t *ip, valu_t val);
char *remember(char *s);
int combine(int typ1, int typ2, int op);
int small(int fitsmall, int gain);
void emit1(int arg);
void emit2(int arg);
void emit4(long arg);
void emitx(valu_t val, int n);
void emitstr(int zero);
void ffreopen(char *s, FILE *f);
FILE *ffcreat(char *s);
FILE *fftemp(char *path, char *tail);
void yyerror(char *str);
int printx(int ndig, valu_t val);
void nosect(void);
void wr_fatal(void);
void fatal(char *s, ...);
void assert1(void);
void serror(char *s, ...);
void warning(char *s, ...);
void diag(char *tail, char *s, ...);
void nofit(void);
void listline(int textline);
/* ========== Machine dependent C declarations ========== */

View File

@ -23,28 +23,28 @@ struct outhead outhead = {
#include "y.tab.h"
item_t keytab[] = {
0, EXTERN, 0, ".define",
0, EXTERN, 0, ".extern",
0, DOT, 0, ".",
0, DATA, 1, ".data1",
0, DATA, 2, ".data2",
0, DATA, 4, ".data4",
0, ASCII, 0, ".ascii",
0, ASCII, 1, ".asciz",
0, ALIGN, 0, ".align",
0, ASSERT, 0, ".assert",
0, SPACE, 0, ".space",
0, COMMON, 0, ".comm",
0, SECTION, 0, ".sect",
0, BASE, 0, ".base",
0, SYMB, 0, ".symb",
0, SYMD, 0, ".symd",
0, LINE, 0, ".line",
0, FILe, 0, ".file",
{ 0, EXTERN, 0, ".define" },
{ 0, EXTERN, 0, ".extern" },
{ 0, DOT, 0, "." },
{ 0, DATA, 1, ".data1" },
{ 0, DATA, 2, ".data2" },
{ 0, DATA, 4, ".data4" },
{ 0, ASCII, 0, ".ascii" },
{ 0, ASCII, 1, ".asciz" },
{ 0, ALIGN, 0, ".align" },
{ 0, ASSERT, 0, ".assert" },
{ 0, SPACE, 0, ".space" },
{ 0, COMMON, 0, ".comm" },
{ 0, SECTION, 0, ".sect" },
{ 0, BASE, 0, ".base" },
{ 0, SYMB, 0, ".symb" },
{ 0, SYMD, 0, ".symd" },
{ 0, LINE, 0, ".line" },
{ 0, FILe, 0, ".file" },
#ifdef LISTING
0, LIST, 0, ".nolist",
0, LIST, 1, ".list",
{ 0, LIST, 0, ".nolist" },
{ 0, LIST, 1, ".list" },
#endif
#include "mach3.c"
0, 0, 0, 0
{ 0, 0, 0, 0 }
};

View File

@ -11,7 +11,6 @@
* Johan Stevenson, Han Schaminee and Hans de Vries
* Philips S&I, T&M, PMDS, Eindhoven
*/
#include "comm0.h"
#include "comm1.h"
#include "y.tab.h"
@ -20,7 +19,8 @@ extern YYSTYPE yylval;
/* ========== Machine independent C routines ========== */
void stop() {
void stop(int signal)
{
#if DEBUG < 2
unlink(temppath);
#ifdef LISTING
@ -30,11 +30,10 @@ void stop() {
exit(nerrors != 0);
}
main(argc, argv)
char **argv;
int main(int argc, char *argv[])
{
register char *p;
register i;
char *p;
int i;
static char sigs[] = {
SIGHUP, SIGINT, SIGQUIT, SIGTERM, 0
};
@ -49,7 +48,7 @@ char **argv;
}
progname = *argv++; argc--;
for (p = sigs; i = *p++; )
for (p = sigs; (i = *p++); )
if (signal(i, SIG_IGN) != SIG_IGN)
signal(i, stop);
for (i = 0; i < argc; i++) {
@ -122,20 +121,20 @@ char **argv;
#endif
pass_23(PASS_3);
wr_close();
stop();
stop(0);
return 0;
}
/* ---------- pass 1: arguments, modules, archives ---------- */
pass_1(argc, argv)
char **argv;
int pass_1(int argc, char *argv[])
{
register char *p;
register item_t *ip;
char *p;
item_t *ip;
#ifdef ASLD
char armagic[2];
#else
register nfile = 0;
int nfile = 0;
#endif
#ifdef THREE_PASS
@ -195,7 +194,7 @@ char **argv;
machfinish(PASS_1);
#ifdef ASLD
if (unresolved) {
register int i;
int i;
nerrors++;
fflush(stdout);
@ -217,12 +216,14 @@ char **argv;
fatal("no source file");
*/
#endif
return 0;
}
#ifdef ASLD
archive() {
register long offset;
void archive()
{
long offset;
struct ar_hdr header;
char getsize[AR_TOTAL];
@ -254,14 +255,14 @@ archive() {
archmode = 0;
}
needed()
int needed()
{
register c, first;
register item_t *ip;
register need;
c, first;
item_t *ip;
int need;
#ifdef LISTING
register save;
int save;
save = listflag; listflag = 0;
#endif
@ -306,12 +307,11 @@ needed()
}
#endif /* ASLD */
parse(s)
char *s;
void parse(char *s)
{
register i;
register item_t *ip;
register char *p;
int i;
item_t *ip;
char *p;
for (p = s; *p; )
if (*p++ == '/')
@ -371,16 +371,16 @@ char *s;
}
}
pass_23(n)
void pass_23(int n)
{
register i;
int i;
#ifdef ASLD
register ADDR_T base = 0;
ADDR_T base = 0;
#endif
register sect_t *sp;
sect_t *sp;
if (nerrors)
stop();
stop(0);
pass = n;
#ifdef LISTING
listmode >>= 3;
@ -430,8 +430,7 @@ pass_23(n)
machfinish(n);
}
newmodule(s)
char *s;
void newmodule(char *s)
{
static char nmbuf[STRINGMAX];
@ -458,12 +457,12 @@ char *s;
#endif
}
setupoutput()
void setupoutput()
{
register sect_t *sp;
register long off;
sect_t *sp;
long off;
struct outsect outsect;
register struct outsect *pos = &outsect;
struct outsect *pos = &outsect;
if (! wr_open(aoutpath)) {
fatal("can't create %s", aoutpath);
@ -493,15 +492,15 @@ setupoutput()
outhead.oh_nchar = off; /* see newsymb() */
}
commfinish()
void commfinish()
{
#ifndef ASLD
register int i;
int i;
#endif
register struct common_t *cp;
register item_t *ip;
register sect_t *sp;
register valu_t addr;
struct common_t *cp;
item_t *ip;
sect_t *sp;
valu_t addr;
switchsect(S_UND);
/*

View File

@ -11,9 +11,9 @@
extern YYSTYPE yylval;
yylex()
int yylex()
{
register c;
int c;
if (pass == PASS_1) {
/* scan the input file */
@ -68,11 +68,11 @@ yylex()
return(c);
}
putval(c)
void putval(int c)
{
register valu_t v;
register n = 0;
register char *p = 0;
valu_t v;
int n = 0;
char *p = 0;
assert(c >= 256 && c < 256+128);
switch (c) {
@ -141,11 +141,11 @@ putval(c)
putc(*p++, tempfile);
}
getval(c)
int getval(int c)
{
register n = 0;
register valu_t v;
register char *p = 0;
int n = 0;
valu_t v;
char *p = 0;
switch (c) {
case CODE1:
@ -206,9 +206,9 @@ getval(c)
/* ---------- lexical scan in pass 1 ---------- */
nextchar()
int nextchar()
{
register c;
int c;
if (peekc != -1) {
c = peekc;
@ -230,9 +230,9 @@ nextchar()
return(c);
}
readcode(n)
void readcode(int n)
{
register c;
int c;
yylval.y_valu = 0;
do {
@ -249,8 +249,7 @@ readcode(n)
} while (--n);
}
induo(c)
register c;
int induo(int c)
{
static short duo[] = {
('='<<8) | '=', OP_EQ,
@ -262,7 +261,7 @@ register c;
('|'<<8) | '|', OP_OO,
('&'<<8) | '&', OP_AA,
};
register short *p;
short *p;
c = (c<<8) | nextchar();
for (p = duo; *p; p++)
@ -274,12 +273,11 @@ register c;
static char name[NAMEMAX+1];
inident(c)
register c;
int inident(int c)
{
register char *p = name;
register item_t *ip;
register n = NAMEMAX;
char *p = name;
item_t *ip;
int n = NAMEMAX;
do {
if (--n >= 0)
@ -305,12 +303,10 @@ register c;
}
#ifdef ASLD
char *
readident(c)
register c;
char *readident(int c)
{
register n = NAMEMAX;
register char *p = name;
int n = NAMEMAX;
char *p = name;
do {
if (--n >= 0)
@ -323,11 +319,10 @@ register c;
}
#endif
innumber(c)
register c;
int innumber(int c)
{
register char *p;
register radix;
char *p;
int radix;
static char num[20+1];
p = num;
@ -359,7 +354,7 @@ register c;
if (radix != 16 && (c == 'f' || c == 'b'))
return(infbsym(num));
yylval.y_valu = 0;
while (c = *p++) {
while ( (c = *p++) ) {
if (c > '9')
c -= ('a' - '9' - 1);
c -= '0';
@ -370,10 +365,10 @@ register c;
return(NUMBER);
}
instring(termc)
int instring(int termc)
{
register char *p;
register c;
char *p;
int c;
static int maxstring = 0;
if (! maxstring) {
@ -409,9 +404,9 @@ instring(termc)
return(STRING);
}
inescape()
int inescape()
{
register c, j, r;
int c, j, r;
c = nextchar();
if (c >= '0' && c <= '7') {
@ -439,11 +434,10 @@ inescape()
return(c);
}
infbsym(p)
register char *p;
int infbsym(char *p)
{
register lab;
register item_t *ip;
int lab;
item_t *ip;
lab = *p++ - '0';
if ((unsigned)lab < 10) {
@ -466,26 +460,23 @@ ok:
return(FBSYM);
}
hash(p)
register char *p;
int hash(char *p)
{
register unsigned short h;
register c;
unsigned short h;
int c;
h = 0;
while (c = *p++) {
while ( (c = *p++) ) {
h <<= 2;
h += c;
}
return(h % H_SIZE);
}
item_t *
item_search(p)
char *p;
item_t *item_search(char *p)
{
register h;
register item_t *ip;
int h;
item_t *ip;
for (h = hash(p); h < H_TOTAL; h += H_SIZE) {
ip = hashtab[h];
@ -500,17 +491,15 @@ done:
return(ip);
}
item_insert(ip, h)
item_t *ip;
void item_insert(item_t *ip, int h)
{
ip->i_next = hashtab[h];
hashtab[h] = ip;
}
item_t *
item_alloc(typ)
item_t *item_alloc(int typ)
{
register item_t *ip;
item_t *ip;
static nleft = 0;
static item_t *next;
@ -528,11 +517,9 @@ item_alloc(typ)
return(ip);
}
item_t *
fb_alloc(lab)
register lab;
item_t *fb_alloc(int lab)
{
register item_t *ip, *p;
item_t *ip, *p;
ip = item_alloc(S_UND);
p = fb_ptr[FB_TAIL+lab];
@ -544,18 +531,22 @@ register lab;
return(ip);
}
item_t *
fb_shift(lab)
register lab;
item_t *fb_shift(int lab)
{
register item_t *ip;
item_t *ip;
ip = fb_ptr[FB_FORW+lab];
if (ip == 0)
{
if (pass == PASS_1)
{
ip = fb_alloc(lab);
}
else
{
ip = fb_ptr[FB_HEAD+lab];
}
}
fb_ptr[FB_BACK+lab] = ip;
fb_ptr[FB_FORW+lab] = ip->i_next;
return(ip);

View File

@ -12,9 +12,7 @@
#include "comm1.h"
#include "y.tab.h"
newequate(ip, typ)
register item_t *ip;
register int typ;
void newequate(item_t *ip, int typ)
{
typ &= ~S_EXT;
if (typ & S_COM)
@ -34,10 +32,9 @@ register int typ;
newident(ip, typ);
}
newident(ip, typ)
register item_t *ip;
void newident(item_t *ip, int typ)
{
register flag;
int flag;
#ifdef GENLAB
static char genlab[] = GENLAB;
#endif /* GENLAB */
@ -74,12 +71,11 @@ register item_t *ip;
);
}
newlabel(ip)
register item_t *ip;
void newlabel(item_t *ip)
{
#if DEBUG != 0
#ifdef THREE_PASS
register ADDR_T oldval = ip->i_valu;
ADDR_T oldval = ip->i_valu;
#endif
#endif
@ -94,11 +90,10 @@ register item_t *ip;
#endif
}
newsect(ip)
register item_t *ip;
void newsect(item_t *ip)
{
register int typ;
register sect_t *sp = NULL;
int typ;
sect_t *sp = NULL;
typ = ip->i_type & S_TYP;
if (typ == S_UND) {
@ -132,11 +127,10 @@ register item_t *ip;
}
/*ARGSUSED*/
newbase(base)
valu_t base;
void newbase(valu_t base)
{
#ifdef ASLD
register sect_t *sp;
sect_t *sp;
if ((sp = DOTSCT) == NULL)
nosect();
@ -160,9 +154,7 @@ valu_t base;
* - maximum length of .comm is recorded in i_valu during PASS_1
* - i_valu is used for relocation info during PASS_3
*/
newcomm(ip, val)
register item_t *ip;
valu_t val;
void newcomm(item_t *ip, valu_t val)
{
if (pass == PASS_1) {
if (DOTSCT == NULL)
@ -183,12 +175,11 @@ valu_t val;
}
}
switchsect(newtyp)
int newtyp;
void switchsect(int newtyp)
{
register sect_t *sp;
sect_t *sp;
if (sp = DOTSCT)
if ( (sp = DOTSCT) )
sp->s_size = DOTVAL - sp->s_base;
if (newtyp == S_UND) {
DOTSCT = NULL;
@ -202,27 +193,35 @@ int newtyp;
DOTTYP = newtyp;
}
align(bytes)
valu_t bytes;
void align(valu_t bytes)
{
register valu_t gap;
register sect_t *sp;
valu_t gap;
sect_t *sp;
if ((sp = DOTSCT) == NULL)
nosect();
if (bytes == 0)
bytes = ALIGNWORD;
if (sp->s_lign % bytes)
{
if (bytes % sp->s_lign)
{
serror("illegal alignment");
}
else
{
sp->s_lign = bytes;
}
}
if (pass == PASS_1)
{
/*
* be pessimistic: biggest gap possible
*/
gap = bytes - 1;
else {
}
else
{
/*
* calculate gap correctly;
* will be the same in PASS_2 and PASS_3
@ -242,7 +241,7 @@ valu_t bytes;
}
#ifdef RELOCATION
newrelo(s, n)
void newrelo(int s, int n)
{
int iscomm;
struct outrelo outrelo;
@ -270,16 +269,19 @@ newrelo(s, n)
s &= ~S_COM;
if ((n & RELPC) == 0 && ((s & ~S_VAR) == S_ABS))
return;
if ((n & RELPC) != 0 && s == DOTTYP
#ifndef ASLD
&& ! iscomm
#endif
)
return;
if (pass != PASS_3) {
outhead.oh_nrelo++;
return;
}
s &= ~S_VAR;
outrelo.or_type = (char)n;
outrelo.or_sect = (char)DOTTYP;
@ -290,13 +292,16 @@ newrelo(s, n)
relonami = 0;
} else
#endif
if (s < S_MIN) {
if (s < S_MIN)
{
assert(s == S_ABS);
/*
* use first non existing entry (argh)
*/
outrelo.or_nami = outhead.oh_nname;
} else {
}
else
{
/*
* section symbols are at the end
*/
@ -310,9 +315,7 @@ newrelo(s, n)
}
#endif
long
new_string(s)
char *s;
long new_string(char *s)
{
long r = 0;
@ -326,9 +329,7 @@ new_string(s)
return r;
}
newsymb(name, type, desc, valu)
register char *name;
valu_t valu;
void newsymb(char *name, int type, int desc, valu_t valu)
{
struct outname outname;
@ -350,10 +351,9 @@ valu_t valu;
wr_name(&outname, 1);
}
new_common(ip)
item_t *ip;
void new_common(item_t *ip)
{
register struct common_t *cp;
struct common_t *cp;
static nleft = 0;
static struct common_t *next;

View File

@ -12,12 +12,10 @@
#include "comm1.h"
#include "y.tab.h"
valu_t
load(ip)
register item_t *ip;
valu_t load(item_t *ip)
{
#ifdef ASLD
register typ;
int typ;
typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */
@ -36,12 +34,10 @@ register item_t *ip;
#endif
}
store(ip, val)
register item_t *ip;
valu_t val;
int store(item_t *ip, valu_t val)
{
#ifdef ASLD
register typ;
int typ;
typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) >= 0)
@ -55,12 +51,10 @@ valu_t val;
return(1);
}
char *
remember(s)
register char *s;
char *remember(char *s)
{
register char *p;
register n;
char *p;
int n;
static nleft = 0;
static char *next;
@ -77,15 +71,14 @@ register char *s;
assert(nleft >= 0);
}
p = next;
while (*p++ = *s++)
while ( (*p++ = *s++) )
;
s = next;
next = p;
return(s);
}
combine(typ1, typ2, op)
register typ1, typ2;
int combine(int typ1, int typ2, int op)
{
switch (op) {
case '+':
@ -121,12 +114,11 @@ register typ1, typ2;
}
#ifdef LISTING
printx(ndig, val)
valu_t val;
int printx(int ndig, valu_t val)
{
static char buf[8];
register char *p;
register c, n;
char *p;
int c, n;
p = buf; n = ndig;
do {
@ -134,7 +126,7 @@ valu_t val;
val >>= 4;
} while (--n);
do {
c = "0123456789ABCDEF"[*--p];
c = "0123456789ABCDEF"[*(unsigned char *)--p];
putchar(c);
} while (p > buf);
return(ndig);
@ -142,9 +134,9 @@ valu_t val;
#endif
#ifdef LISTING
listline(textline)
void listline(int textline)
{
register c;
int c;
if ((listflag & 4) && (c = getc(listfile)) != '\n' && textline) {
if (listcolm >= 24)
@ -175,10 +167,10 @@ listline(textline)
#define PBITTABSZ 128
static char *pbittab[PBITTABSZ];
small(fitsmall, gain)
int small(int fitsmall, int gain)
{
register bit;
register char *p;
int bit;
char *p;
if (DOTSCT == NULL)
nosect();
@ -225,12 +217,13 @@ small(fitsmall, gain)
return(*p & bit);
}
/*NOTREACHED*/
return 0;
}
#endif
/* ---------- output ---------- */
emit1(arg)
void emit1(int arg)
{
static int olddottyp = -1;
#ifdef LISTING
@ -268,8 +261,7 @@ emit1(arg)
DOTVAL++;
}
emit2(arg)
int arg;
void emit2(int arg)
{
#ifdef BYTES_REVERSED
emit1((arg>>8)); emit1(arg);
@ -278,8 +270,7 @@ int arg;
#endif
}
emit4(arg)
long arg;
void emit4(long arg)
{
#ifdef WORDS_REVERSED
emit2((int)(arg>>16)); emit2((int)(arg));
@ -288,9 +279,7 @@ long arg;
#endif
}
emitx(val, n)
valu_t val;
int n;
void emitx(valu_t val, int n)
{
switch (n) {
case 1:
@ -314,10 +303,10 @@ int n;
}
}
emitstr(zero)
void emitstr(int zero)
{
register i;
register char *p;
int i;
char *p;
p = stringbuf;
i = stringlen;
@ -329,17 +318,13 @@ emitstr(zero)
/* ---------- Error checked file I/O ---------- */
ffreopen(s, f)
char *s;
FILE *f;
void ffreopen(char *s, FILE *f)
{
if (freopen(s, "r", f) == NULL)
fatal("can't reopen %s", s);
}
FILE *
ffcreat(s)
char *s;
FILE *ffcreat(char *s)
{
FILE *f;
@ -353,11 +338,9 @@ char *s;
#endif
char *tmp_dir = TMPDIR;
FILE *
fftemp(path, tail)
char *path, *tail;
FILE *fftemp(char *path, char *tail)
{
register char *dir;
char *dir;
if ((dir = getenv("TMPDIR")) == NULL)
dir = tmp_dir;
@ -368,72 +351,85 @@ char *path, *tail;
/* ---------- Error handling ---------- */
/*VARARGS*/
yyerror(){} /* we will do our own error printing */
nosect()
{
fatal("no sections");
}
wr_fatal()
{
fatal("write error");
}
void yyerror(char *str){} /* we will do our own error printing */
/* VARARGS1 */
fatal(s, a1, a2, a3, a4)
char *s;
{
nerrors++;
diag(" (fatal)\n", s, a1, a2, a3, a4);
stop();
}
#if DEBUG == 2
assert2(file, line)
char *file;
{
fatal("assertion failed (%s, %d)", file, line);
}
#endif
#if DEBUG == 1
assert1()
{
diag(" (fatal)\n", "assertion failed");
abort();
}
#endif
/* VARARGS1 */
serror(s, a1, a2, a3, a4)
char *s;
{
nerrors++;
diag("\n", s, a1, a2, a3, a4);
}
/* VARARGS1 */
warning(s, a1, a2, a3, a4)
char *s;
{
diag(" (warning)\n", s, a1, a2, a3, a4);
}
/* VARARGS1 */
diag(tail, s, a1, a2, a3, a4)
char *tail, *s;
static void vdiag(char *tail, char *s, va_list ap)
{
fflush(stdout);
if (modulename)
fprintf(stderr, "\"%s\", line %ld: ", modulename, lineno);
else
fprintf(stderr, "%s: ", progname);
fprintf(stderr, s, a1, a2, a3, a4);
fprintf(stderr, tail);
vfprintf(stderr, s, ap);
fprintf(stderr, "%s", tail);
}
nofit()
void nosect()
{
fatal("no sections");
}
void wr_fatal()
{
fatal("write error");
}
/* VARARGS1 */
void fatal(char *s, ...)
{
va_list ap;
nerrors++;
va_start(ap, s);
vdiag(" (fatal)\n", s, ap);
va_end(ap);
stop(0);
}
#if DEBUG == 2
void assert2(char *file, int line)
{
fatal("assertion failed (%s, %d)", file, line);
}
#endif
#if DEBUG == 1
void assert1()
{
vdiag(" (fatal)\n", "assertion failed");
abort();
}
#endif
/* VARARGS1 */
void serror(char *s, ...)
{
va_list ap;
nerrors++;
va_start(ap, s);
vdiag("\n", s, ap);
va_end(ap);
}
/* VARARGS1 */
void warning(char *s, ...)
{
va_list ap;
va_start(ap, s);
vdiag(" (warning)\n", s, ap);
va_end(ap);
}
/* VARARGS1 */
void diag(char *tail, char *s, ...)
{
va_list ap;
va_start(ap, s);
vdiag(tail, s, ap);
va_end(ap);
}
void nofit()
{
if (pass == PASS_3)
warning("too big");