Do not use '#endif/#else xxx'; it is not allowed for ANSI C
This commit is contained in:
@@ -42,16 +42,14 @@ In general, an object file consists of the following parts:
|
||||
.br
|
||||
The header of an object file has the following structure:
|
||||
.PP
|
||||
#define ushort unsigned\ short
|
||||
.PP
|
||||
.nf
|
||||
struct outhead {
|
||||
ushort oh_magic; /* magic number */
|
||||
ushort oh_stamp; /* version stamp */
|
||||
ushort oh_flags; /* several format flags */
|
||||
ushort oh_nsect; /* number of outsect structures */
|
||||
ushort oh_nrelo; /* number of outrelo structures */
|
||||
ushort oh_nname; /* number of outname structures */
|
||||
unsigned short oh_magic; /* magic number */
|
||||
unsigned short oh_stamp; /* version stamp */
|
||||
unsigned short oh_flags; /* several format flags */
|
||||
unsigned short oh_nsect; /* number of outsect structures */
|
||||
unsigned short oh_nrelo; /* number of outrelo structures */
|
||||
unsigned short oh_nname; /* number of outname structures */
|
||||
long oh_nemit; /* length of sections */
|
||||
long oh_nchar; /* size of string area */
|
||||
};
|
||||
@@ -151,7 +149,7 @@ relocatable datum. The information has the following structure:
|
||||
struct outrelo {
|
||||
char or_type; /* type of reference */
|
||||
char or_sect; /* referencing section */
|
||||
ushort or_nami; /* referenced symbol index */
|
||||
unsigned short or_nami; /* referenced symbol index */
|
||||
long or_addr; /* referencing address */
|
||||
};
|
||||
.fi
|
||||
@@ -231,8 +229,8 @@ struct outname {
|
||||
} on_u;
|
||||
#define on_mptr on_u.on_ptr
|
||||
#define on_foff on_u.on_off
|
||||
ushort on_type; /* symbol type */
|
||||
ushort on_desc; /* debug info */
|
||||
unsigned short on_type; /* symbol type */
|
||||
unsigned short on_desc; /* debug info */
|
||||
long on_valu; /* symbol value */
|
||||
};
|
||||
.fi
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
|
||||
#define assert(ex)
|
||||
|
||||
#else NASSERT
|
||||
#else /* NASSERT */
|
||||
|
||||
#define assert(ex) \
|
||||
{if (!(ex)) fatal("Assertion failed: file %s, line %d", __FILE__, __LINE__);}
|
||||
|
||||
#endif NASSERT
|
||||
#else lint
|
||||
#endif /* NASSERT */
|
||||
#else /* lint */
|
||||
|
||||
#define assert(ex)
|
||||
|
||||
#endif lint
|
||||
#endif /* lint */
|
||||
|
||||
@@ -39,8 +39,8 @@ extract()
|
||||
skip_modul(&head);
|
||||
}
|
||||
|
||||
ushort NLocals = 0; /* Number of local names to be saved. */
|
||||
ushort NGlobals = 0; /* Number of global names. */
|
||||
unsigned short NLocals = 0; /* Number of local names to be saved. */
|
||||
unsigned short NGlobals = 0; /* Number of global names. */
|
||||
|
||||
/*
|
||||
* Walk through the nametable of this module, counting the locals that must
|
||||
|
||||
@@ -14,7 +14,7 @@ static char rcsid[] = "$Header$";
|
||||
#include "scan.h"
|
||||
|
||||
extern bool incore;
|
||||
extern ushort NLocals;
|
||||
extern unsigned short NLocals;
|
||||
extern int flagword;
|
||||
extern struct outname *searchname();
|
||||
|
||||
@@ -47,7 +47,7 @@ finish()
|
||||
put_locals(names, head->oh_nname);
|
||||
#ifdef SYMDBUG
|
||||
put_dbug(OFF_DBUG(*head));
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
}
|
||||
compute_origins(sects, head->oh_nsect);
|
||||
skip_modul(head);
|
||||
@@ -80,7 +80,7 @@ adjust_names(name, head, chars)
|
||||
|
||||
do_crs(base, count)
|
||||
struct outname *base;
|
||||
unsigned short count;
|
||||
unsigned count;
|
||||
{
|
||||
register struct outname *name = base;
|
||||
|
||||
@@ -209,7 +209,7 @@ handle_relos(head, sects, names)
|
||||
static
|
||||
put_locals(name, nnames)
|
||||
struct outname *name;
|
||||
register ushort nnames;
|
||||
register unsigned nnames;
|
||||
{
|
||||
register struct outname *oname = name;
|
||||
register struct outname *iname = oname;
|
||||
@@ -233,7 +233,7 @@ put_locals(name, nnames)
|
||||
static
|
||||
compute_origins(sect, nsect)
|
||||
register struct outsect *sect;
|
||||
register ushort nsect;
|
||||
register unsigned nsect;
|
||||
{
|
||||
extern struct orig relorig[];
|
||||
register struct orig *orig = relorig;
|
||||
@@ -267,4 +267,4 @@ put_dbug(offdbug)
|
||||
dbugsize -= nbytes;
|
||||
}
|
||||
}
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
mems[ALLOGCHR].mem_left = 16 * K;
|
||||
#ifdef SYMDBUG
|
||||
mems[ALLODBUG].mem_left = 32 * K;
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
mems[ALLOSYMB].mem_left = 8 * K;
|
||||
mems[ALLOARCH].mem_left = 4 * K;
|
||||
mems[ALLOMODL].mem_left = 64 * K;
|
||||
@@ -43,7 +43,7 @@
|
||||
mems[ALLOGCHR].mem_left = 2 * K;
|
||||
#ifdef SYMDBUG
|
||||
mems[ALLODBUG].mem_left = 2 * K;
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
mems[ALLOSYMB].mem_left = 2 * K;
|
||||
mems[ALLOARCH].mem_left = 1 * K;
|
||||
mems[ALLOMODL].mem_left = 12 * K;
|
||||
|
||||
@@ -371,7 +371,7 @@ evaluate()
|
||||
change_names();
|
||||
}
|
||||
|
||||
extern ushort NGlobals, NLocals;
|
||||
extern unsigned short NGlobals, NLocals;
|
||||
|
||||
/*
|
||||
* Sect_comm[N] is the number of common bytes in section N.
|
||||
|
||||
@@ -547,14 +547,14 @@ freeze_core()
|
||||
|
||||
/*
|
||||
* To transform the various pieces of the output in core to the file format,
|
||||
* we must order the bytes in the ushorts and longs as ACK prescribes.
|
||||
* we must order the bytes in the unsigned shorts and longs as ACK prescribes.
|
||||
*/
|
||||
write_bytes()
|
||||
{
|
||||
ushort nsect;
|
||||
unsigned short nsect;
|
||||
long offchar;
|
||||
register struct memory *mem;
|
||||
extern ushort NLocals, NGlobals;
|
||||
extern unsigned short NLocals, NGlobals;
|
||||
extern long NLChars, NGChars;
|
||||
extern int flagword;
|
||||
extern struct outhead outhead;
|
||||
@@ -603,13 +603,13 @@ write_bytes()
|
||||
wr_string(mems[ALLOGCHR].mem_base + 1, (long)NGChars);
|
||||
#ifdef SYMDBUG
|
||||
wr_dbug(mems[ALLODBUG].mem_base, mems[ALLODBUG].mem_full);
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
}
|
||||
}
|
||||
|
||||
namecpy(name, nname, offchar)
|
||||
register struct outname *name;
|
||||
register ushort nname;
|
||||
register unsigned nname;
|
||||
register long offchar;
|
||||
{
|
||||
while (nname--) {
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#define ALLOGCHR (ALLOLCHR + 1) /* Strings of global names. */
|
||||
#ifdef SYMDEBUG
|
||||
#define ALLODBUG (ALLOGCHR + 1) /* Symbolic debugging info. */
|
||||
#else SYMDEBUG
|
||||
#else /* SYMDEBUG */
|
||||
#define ALLODBUG ALLOGCHR
|
||||
#endif SYMDEBUG
|
||||
#endif /* SYMDEBUG */
|
||||
#define ALLOSYMB (ALLODBUG + 1) /* Symbol table. */
|
||||
#define ALLOARCH (ALLOSYMB + 1) /* Archive positions. */
|
||||
#define ALLOMODL (ALLOARCH + 1) /* Modules. */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifdef SYMDEBUG
|
||||
Symbolic debugging information
|
||||
-----------------------------------------------
|
||||
#endif SYMDEBUG
|
||||
#endif /* SYMDEBUG */
|
||||
Symbol table *
|
||||
-----------------------------------------------
|
||||
Archive positions *
|
||||
|
||||
@@ -24,7 +24,7 @@ extern int flagword;
|
||||
*/
|
||||
beginoutput()
|
||||
{
|
||||
extern ushort NLocals, NGlobals;
|
||||
extern unsigned short NLocals, NGlobals;
|
||||
extern long NLChars, NGChars;
|
||||
extern char *outputname;
|
||||
|
||||
@@ -35,9 +35,9 @@ beginoutput()
|
||||
generate_section_names();
|
||||
|
||||
if (!(flagword & (CFLAG|RFLAG)))
|
||||
outhead.oh_nrelo = (ushort)0;
|
||||
outhead.oh_nrelo = (unsigned short)0;
|
||||
if (flagword & SFLAG) {
|
||||
outhead.oh_nname = (ushort)0;
|
||||
outhead.oh_nname = (unsigned short)0;
|
||||
outhead.oh_nchar = (long)0;
|
||||
} else {
|
||||
outhead.oh_nname = NLocals + NGlobals + outhead.oh_nsect;
|
||||
@@ -68,7 +68,7 @@ generate_section_names()
|
||||
for (sectindex = 0; sectindex < outhead.oh_nsect; sectindex++, name++) {
|
||||
name->on_foff = (long)0; /* No string name. */
|
||||
name->on_type = (S_MIN + sectindex) | S_SCT;
|
||||
name->on_desc = (ushort)0;
|
||||
name->on_desc = (unsigned short)0;
|
||||
name->on_valu = outsect[sectindex].os_base;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ getvalu(addr, type)
|
||||
char addr[];
|
||||
char type;
|
||||
{
|
||||
ushort word0, word1;
|
||||
unsigned short word0, word1;
|
||||
|
||||
switch (type & RELSZ) {
|
||||
case RELO1:
|
||||
@@ -62,7 +62,7 @@ putvalu(valu, addr, type)
|
||||
char addr[];
|
||||
char type;
|
||||
{
|
||||
ushort word0, word1;
|
||||
unsigned short word0, word1;
|
||||
|
||||
switch (type & RELSZ) {
|
||||
case RELO1:
|
||||
@@ -102,7 +102,7 @@ putvalu(valu, addr, type)
|
||||
}
|
||||
}
|
||||
|
||||
extern ushort NLocals, NGlobals;
|
||||
extern unsigned short NLocals, NGlobals;
|
||||
extern struct outsect outsect[];
|
||||
extern struct orig relorig[];
|
||||
|
||||
@@ -118,14 +118,14 @@ extern struct orig relorig[];
|
||||
* Second case: we must update the value by the change
|
||||
* in position of the section of local.
|
||||
*/
|
||||
static ushort
|
||||
static unsigned
|
||||
addrelo(relo, names, valu_out)
|
||||
struct outrelo *relo;
|
||||
struct outname *names;
|
||||
long *valu_out; /* Out variable. */
|
||||
{
|
||||
register struct outname *local = &names[relo->or_nami];
|
||||
register ushort index = NLocals;
|
||||
register unsigned short index = NLocals;
|
||||
register long valu = *valu_out;
|
||||
|
||||
if ((local->on_type & S_SCT)) {
|
||||
@@ -138,7 +138,7 @@ addrelo(relo, names, valu_out)
|
||||
register struct outname *name;
|
||||
extern int hash();
|
||||
extern struct outname *searchname();
|
||||
extern ushort indexof();
|
||||
extern unsigned indexof();
|
||||
extern struct outhead outhead;
|
||||
|
||||
name = searchname(local->on_mptr, hash(local->on_mptr));
|
||||
|
||||
@@ -27,7 +27,7 @@ savemagic()
|
||||
return;
|
||||
|
||||
if ((p = core_alloc(ALLOMODL, (long)sizeof(int))) != (char *)0) {
|
||||
*(ushort *)p = AALMAG;
|
||||
*(unsigned short *)p = AALMAG;
|
||||
core_position += sizeof(int);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ static char rcsid[] = "$Header$";
|
||||
#ifdef SYMDBUG
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
#include <arch.h>
|
||||
#include <out.h>
|
||||
#include <ranlib.h>
|
||||
@@ -25,7 +25,7 @@ static char rcsid[] = "$Header$";
|
||||
#define IND_RELO(x) (IND_EMIT(x) + (x).oh_nsect * sizeof(ind_t))
|
||||
#ifdef SYMDBUG
|
||||
#define IND_DBUG(x) (IND_RELO(x) + sizeof(ind_t))
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
|
||||
extern long lseek();
|
||||
extern char *core_alloc();
|
||||
@@ -37,7 +37,7 @@ char *archname; /* Name of archive, if reading from archive. */
|
||||
char *modulname; /* Name of object module. */
|
||||
#ifdef SYMDBUG
|
||||
long objectsize;
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
|
||||
static long align();
|
||||
static char *modulbase;
|
||||
@@ -50,7 +50,7 @@ static bool putemitindex();
|
||||
static bool putreloindex();
|
||||
#ifdef SYMDBUG
|
||||
static bool putdbugindex();
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
static get_indirect();
|
||||
static read_modul();
|
||||
|
||||
@@ -66,11 +66,11 @@ getfile(filename)
|
||||
{
|
||||
unsigned int rd_unsigned2();
|
||||
struct ar_hdr archive_header;
|
||||
ushort magic_number;
|
||||
unsigned short magic_number;
|
||||
#ifdef SYMDBUG
|
||||
struct stat statbuf;
|
||||
extern int fstat();
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
|
||||
archname = (char *)0;
|
||||
modulname = (char *)0;
|
||||
@@ -81,7 +81,7 @@ getfile(filename)
|
||||
magic_number = rd_unsigned2(infile);
|
||||
} else {
|
||||
modulbase = modulptr((ind_t)0);
|
||||
magic_number = *(ushort *)modulbase;
|
||||
magic_number = *(unsigned short *)modulbase;
|
||||
}
|
||||
|
||||
switch (magic_number) {
|
||||
@@ -92,7 +92,7 @@ getfile(filename)
|
||||
fatal("cannot stat");
|
||||
objectsize = statbuf.st_size;
|
||||
}
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
seek((long)0);
|
||||
modulname = filename;
|
||||
return PLAIN;
|
||||
@@ -135,7 +135,7 @@ get_archive_header(archive_header)
|
||||
}
|
||||
#ifdef SYMDBUG
|
||||
objectsize = archive_header.ar_size;
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
}
|
||||
|
||||
get_modul()
|
||||
@@ -175,7 +175,7 @@ scan_modul()
|
||||
ojectsize - OFF_DBUG(*head)
|
||||
);
|
||||
}
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -213,16 +213,16 @@ direct_alloc(head)
|
||||
{
|
||||
ind_t sectindex = IND_SECT(*head);
|
||||
register struct outsect *sects;
|
||||
ushort nsect = head->oh_nsect;
|
||||
unsigned short nsect = head->oh_nsect;
|
||||
long size, rest;
|
||||
extern ind_t hard_alloc();
|
||||
extern ind_t alloc();
|
||||
|
||||
#ifdef SYMDBUG
|
||||
rest = nsect * sizeof(ind_t) + sizeof(ind_t) + sizeof(ind_t);
|
||||
#else SYMDBUG
|
||||
#else /* SYMDBUG */
|
||||
rest = nsect * sizeof(ind_t) + sizeof(ind_t);
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
/*
|
||||
* We already allocated space for the header, we now need
|
||||
* the section, name an string table.
|
||||
@@ -251,8 +251,8 @@ indirect_alloc(head)
|
||||
struct outhead *head;
|
||||
{
|
||||
register int allopiece;
|
||||
ushort nsect = head->oh_nsect;
|
||||
ushort nrelo = head->oh_nrelo;
|
||||
unsigned short nsect = head->oh_nsect;
|
||||
unsigned short nrelo = head->oh_nrelo;
|
||||
ind_t sectindex = IND_SECT(*head);
|
||||
ind_t emitoff = IND_EMIT(*head);
|
||||
ind_t relooff = IND_RELO(*head);
|
||||
@@ -260,7 +260,7 @@ indirect_alloc(head)
|
||||
ind_t dbugoff = IND_DBUG(*head);
|
||||
extern long objectsize;
|
||||
long dbugsize = objectsize - OFF_DBUG(*head);
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
|
||||
assert(incore);
|
||||
for (allopiece = ALLOEMIT; allopiece < ALLOEMIT + nsect; allopiece++) {
|
||||
@@ -273,9 +273,9 @@ indirect_alloc(head)
|
||||
return putreloindex(relooff, (long)nrelo * sizeof(struct outrelo))
|
||||
&&
|
||||
putdbugindex(dbugoff, dbugsize);
|
||||
#else SYMDBUG
|
||||
#else /* SYMDBUG */
|
||||
return putreloindex(relooff, (long)nrelo * sizeof(struct outrelo));
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -358,7 +358,7 @@ putdbugindex(dbugoff, ndbugbytes)
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
|
||||
/*
|
||||
* Compute addresses and read in. Remember that the contents of the sections
|
||||
@@ -430,7 +430,7 @@ read_modul()
|
||||
struct outname *names;
|
||||
char *chars;
|
||||
ind_t sectindex, nameindex, charindex;
|
||||
ushort nsect, nname;
|
||||
unsigned short nsect, nname;
|
||||
long size;
|
||||
long nchar;
|
||||
extern ind_t hard_alloc();
|
||||
@@ -446,9 +446,9 @@ read_modul()
|
||||
nchar = head->oh_nchar; charindex = IND_CHAR(*head);
|
||||
#ifdef SYMDBUG
|
||||
size = modulsize(head) - (nsect * sizeof(ind_t) + 2 * sizeof(ind_t));
|
||||
#else SYMDBUG
|
||||
#else /* SYMDBUG */
|
||||
size = modulsize(head) - (nsect * sizeof(ind_t) + sizeof(ind_t));
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
if (hard_alloc(ALLOMODL, size) == BADOFF)
|
||||
fatal("no space for module");
|
||||
|
||||
@@ -490,7 +490,7 @@ align(size)
|
||||
* 5. the offset of the relocation table.
|
||||
#ifdef SYMDBUG
|
||||
* 6. the offset of the debugging information.
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
*/
|
||||
static long
|
||||
modulsize(head)
|
||||
@@ -504,9 +504,9 @@ modulsize(head)
|
||||
#ifdef SYMDBUG
|
||||
sizeof(ind_t) + /* 5 */
|
||||
sizeof(ind_t); /* 6 */
|
||||
#else SYMDBUG
|
||||
#else /* SYMDBUG */
|
||||
sizeof(ind_t); /* 5 */
|
||||
#endif SYMDBUG
|
||||
#endif /* SYMDBUG */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -118,7 +118,7 @@ entername(name, hashval)
|
||||
* Return the index of `name' in the symbol table in the order in which
|
||||
* it was entered. We need a REAL index, not a byte offset.
|
||||
*/
|
||||
ushort
|
||||
unsigned
|
||||
indexof(name)
|
||||
struct outname *name;
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ end_write()
|
||||
{
|
||||
register struct outname *name;
|
||||
register int sectindex;
|
||||
extern ushort NGlobals;
|
||||
extern unsigned short NGlobals;
|
||||
extern long NGChars;
|
||||
|
||||
assert(!incore);
|
||||
|
||||
Reference in New Issue
Block a user