/* one of these target operating systems must be defined */
-#define EDOS /* generate EDOS executable */
+#undef EDOS /* generate EDOS executable */
#undef MINIX /* generate Minix executable */
+#define FUZIX /* FUZIX executable */
/* these may need to be defined to suit the source processor */
#define TRUE 1
#define EXTERN extern
-#define FORWARD static
-#define PRIVATE static
#define PUBLIC
#include "config.h"
/* print list of modules and whether they are loaded */
-PUBLIC void dumpmods()
+void dumpmods(void)
{
struct modstruct *modptr;
char *s, *d;
/* print data about symbols (in loaded modules only) */
-PUBLIC void dumpsyms()
+void dumpsyms(void)
{
flags_t flags;
struct modstruct *modptr;
#define TRELBUFSIZE 1024
#ifdef REL_OUTPUT
-PRIVATE char *drelbuf; /* extra output buffer for data relocations */
-PRIVATE char *drelbufptr; /* data relocation output buffer ptr */
-PRIVATE char *drelbuftop; /* data relocation output buffer top */
+static char *drelbuf; /* extra output buffer for data relocations */
+static char *drelbufptr; /* data relocation output buffer ptr */
+static char *drelbuftop; /* data relocation output buffer top */
#endif
-PRIVATE char *errbuf; /* error buffer (actually uses STDOUT) */
-PRIVATE char *errbufptr; /* error buffer ptr */
-PRIVATE char *errbuftop; /* error buffer top */
-PRIVATE int errfil = STDOUT_FILENO;
-PRIVATE char *inbuf; /* input buffer */
-PRIVATE char *inbufend; /* input buffer top */
-PRIVATE char *inbufptr; /* end of input in input buffer */
-PRIVATE int infd; /* input file descriptor */
-PRIVATE char *inputname; /* name of current input file */
-PRIVATE char *outbuf; /* output buffer */
-PRIVATE char *outbufptr; /* output buffer ptr */
-PRIVATE char *outbuftop; /* output buffer top */
-PRIVATE int outfd; /* output file descriptor */
-PRIVATE mode_t outputperms; /* permissions of output file */
-PRIVATE char *outputname; /* name of output file */
-PRIVATE const char *refname; /* name of program for error reference */
+static char *errbuf; /* error buffer (actually uses STDOUT) */
+static char *errbufptr; /* error buffer ptr */
+static char *errbuftop; /* error buffer top */
+static int errfil = STDOUT_FILENO;
+static char *inbuf; /* input buffer */
+static char *inbufend; /* input buffer top */
+static char *inbufptr; /* end of input in input buffer */
+static int infd; /* input file descriptor */
+static char *inputname; /* name of current input file */
+static char *outbuf; /* output buffer */
+static char *outbufptr; /* output buffer ptr */
+static char *outbuftop; /* output buffer top */
+static int outfd; /* output file descriptor */
+static mode_t outputperms; /* permissions of output file */
+static char *outputname; /* name of output file */
+static const char *refname; /* name of program for error reference */
#ifdef REL_OUTPUT
-PRIVATE char *trelbuf; /* extra output buffer for text relocations */
-PRIVATE char *trelbufptr; /* text relocation output buffer ptr */
-PRIVATE char *trelbuftop; /* text relocation output buffer top */
-PRIVATE int trelfd; /* text relocation output file descriptor */
+static char *trelbuf; /* extra output buffer for text relocations */
+static char *trelbufptr; /* text relocation output buffer ptr */
+static char *trelbuftop; /* text relocation output buffer top */
+static int trelfd; /* text relocation output file descriptor */
#endif
-PRIVATE unsigned warncount; /* count of warnings */
+static unsigned warncount; /* count of warnings */
#ifdef MSDOS
#define off_t long /* NOT a typedef */
#endif
-FORWARD void errexit P((char *message));
-FORWARD void flushout P((void));
+static void errexit(char *message);
+static void flushout(void);
#ifdef REL_OUTPUT
-FORWARD void flushtrel P((void));
+static void flushtrel(void);
#endif
-FORWARD void outhexdigs P((bin_off_t num));
-FORWARD void outputerror P((char *message));
-FORWARD void put04x P((unsigned num));
-FORWARD void putstrn P((const char *message));
-FORWARD void refer P((void));
-FORWARD void stderr_out P((void));
+static void outhexdigs(bin_off_t num);
+static void outputerror(char *message);
+static void put04x(unsigned num);
+static void putstrn(const char *message);
+static void refer(void);
+static void stderr_out(void);
-PUBLIC void ioinit(char *progname)
+void ioinit(char *progname)
{
infd = ERR;
if (*progname)
#endif
}
-PUBLIC void closein(void)
+void closein(void)
{
if (infd != ERR && close(infd) < 0)
inputerror("cannot close");
infd = ERR;
}
-PUBLIC void closeout()
+void closeout()
{
#ifdef REL_OUTPUT
unsigned nbytes;
#endif
}
-PUBLIC void errtrace(char *name, int level)
+void errtrace(char *name, int level)
{
while (level-- > 0)
putbyte(' ');
putstrn(name);
}
-PUBLIC void executable(void)
+void executable(void)
{
if (errcount)
unlink(outputname);
#endif
}
-PUBLIC void flusherr(void)
+void flusherr(void)
{
if( errbufptr != errbuf )
write(errfil, errbuf, (unsigned) (errbufptr - errbuf));
errbufptr = errbuf;
}
-PRIVATE void stderr_out(void)
+static void stderr_out(void)
{
if( errfil != STDERR_FILENO )
{
}
}
-PRIVATE void flushout(void)
+static void flushout(void)
{
unsigned nbytes;
}
#ifdef REL_OUTPUT
-PRIVATE void flushtrel(void)
+static void flushtrel(void)
{
unsigned nbytes;
}
#endif
-PUBLIC void openin(char *filename)
+void openin(char *filename)
{
#if 0 /* XXX - this probably won't work with constructed lib names? */
if (infd == ERR || strcmp(inputname, filename) != 0)
}
}
-PUBLIC void openout(char *filename)
+void openout(char *filename)
{
mode_t oldmask;
#endif
}
-PRIVATE void outhexdigs(bin_off_t num)
+static void outhexdigs(bin_off_t num)
{
if (num >= 0x10)
{
putbyte(hexdigit[num]);
}
-PRIVATE void put04x(unsigned num)
+static void put04x(unsigned num)
{
putbyte(hexdigit[num / 0x1000]);
putbyte(hexdigit[(num / 0x100) & 0x0F]);
#ifdef LONG_OFFSETS
-PUBLIC void put08lx(bin_off_t num)
+void put08lx(bin_off_t num)
{
put04x(num / 0x10000);
put04x(num % 0x10000);
#else /* not LONG_OFFSETS */
-PUBLIC void put08x(bin_off_t num)
+void put08x(bin_off_t num)
{
putstr("0000");
put04x(num);
#endif /* not LONG_OFFSETS */
-PUBLIC void putbstr(unsigned width, char *str)
+void putbstr(unsigned width, char *str)
{
unsigned length;
putstr(str);
}
-PUBLIC void putbyte(int ch)
+void putbyte(int ch)
{
register char *ebuf;
errbufptr = ebuf;
}
-PUBLIC void putstr(const char *message)
+void putstr(const char *message)
{
while (*message != 0)
putbyte(*message++);
}
-PRIVATE void putstrn(char *message)
+static void putstrn(char *message)
{
putstr(message);
putbyte('\n');
flusherr(); errfil = STDOUT_FILENO;
}
-PUBLIC int readchar(void)
+int readchar(void)
{
int ch;
return ch;
}
-PUBLIC void readin(char *buf, unsigned count)
+void readin(char *buf, unsigned count)
{
int ch;
}
}
-PUBLIC bool_pt readineofok(char *buf, unsigned count)
+bool_pt readineofok(char *buf, unsigned count)
{
int ch;
return FALSE;
}
-PUBLIC void seekin(unsigned long offset)
+void seekin(unsigned long offset)
{
inbufptr = inbufend = inbuf;
if (lseek(infd, (off_t) offset, SEEK_SET) != offset)
prematureeof();
}
-PUBLIC void seekout(unsigned long offset)
+void seekout(unsigned long offset)
{
flushout();
if (lseek(outfd, (off_t) offset, SEEK_SET) != offset)
}
#ifdef REL_OUTPUT
-PUBLIC void seektrel(unsigned long offset)
+void seektrel(unsigned long offset)
{
flushtrel();
if (lseek(trelfd, (off_t) offset, SEEK_SET) != offset)
}
#endif
-PUBLIC void writechar(int ch)
+void writechar(int ch)
{
register char *obuf;
}
#ifdef REL_OUTPUT
-PUBLIC void writedrel(char *buf, unsigned count)
+void writedrel(char *buf, unsigned count)
{
register char *rbuf;
}
#endif
-PUBLIC void writeout(char *buf, unsigned count)
+void writeout(char *buf, unsigned count)
{
register char *obuf;
}
#ifdef REL_OUTPUT
-PUBLIC void writetrel(char *buf, unsigned count)
+void writetrel(char *buf, unsigned count)
{
register char *rbuf;
/* error module */
-PRIVATE void errexit(char *message)
+static void errexit(char *message)
{
putstrn(message);
exit(2);
}
-PUBLIC void fatalerror(char *message)
+void fatalerror(char *message)
{
refer();
errexit(message);
}
-PUBLIC void inputerror(char *message)
+void inputerror(char *message)
{
refer();
putstr(message);
errexit(inputname);
}
-PUBLIC void input1error(char *message)
+void input1error(char *message)
{
refer();
putstr(inputname);
errexit(message);
}
-PRIVATE void outputerror(char *message)
+static void outputerror(char *message)
{
refer();
putstr(message);
errexit(outputname);
}
-PUBLIC void outofmemory(void)
+void outofmemory(void)
{
inputerror("out of memory while processing");
}
-PUBLIC void prematureeof(void)
+void prematureeof(void)
{
inputerror("premature end of");
}
-PUBLIC void redefined(char *name, char *message, char *archentry,
+void redefined(char *name, char *message, char *archentry,
char *deffilename, char *defarchentry)
{
++warncount;
putstrn("");
}
-PUBLIC void interseg(char *fname, char *aname, char *name)
+void interseg(char *fname, char *aname, char *name)
{
++errcount;
refer();
putstrn("");
}
-PRIVATE void refer(void)
+static void refer(void)
{
stderr_out();
putstr(refname);
putstr(": ");
}
-PUBLIC void reserved(char *name)
+void reserved(char *name)
{
++errcount;
stderr_out();
putstrn(name);
}
-PUBLIC void size_error(int seg, bin_off_t count, bin_off_t size)
+void size_error(int seg, bin_off_t count, bin_off_t size)
{
refer();
putstr("seg ");
errexit("");
}
-PUBLIC void undefined(char *name)
+void undefined(char *name)
{
++errcount;
stderr_out();
putstrn(name);
}
-PUBLIC void usage(void)
+void usage(void)
{
stderr_out();
putstr("usage: ");
#endif
}
-PUBLIC void version_msg(void)
+void version_msg(void)
{
stderr_out();
#ifdef VERSION
#endif
}
-PUBLIC void use_error(char *message)
+void use_error(char *message)
{
refer();
putstrn(message);
#define NR_STDLIBS 0
#endif
-PUBLIC bin_off_t text_base_value = 0; /* XXX */
-PUBLIC bin_off_t data_base_value = 0; /* XXX */
-PUBLIC bin_off_t heap_top_value = 0; /* XXX */
-PUBLIC int headerless = 0;
+bin_off_t text_base_value = 0; /* XXX */
+bin_off_t data_base_value = 0; /* XXX */
+bin_off_t heap_top_value = 0; /* XXX */
+int headerless = 0;
#ifndef VERY_SMALL_MEMORY
-PUBLIC int v7 = 0;
+int v7 = 0;
#endif
#ifndef MSDOS
-PUBLIC int cpm86 = 0;
+int cpm86 = 0;
#endif
-PUBLIC char hexdigit[] = "0123456789abcdef";
+char hexdigit[] = "0123456789abcdef";
-PRIVATE bool_t flag[128];
-PRIVATE char *libs[MAX_LIBS] = {
+static bool_t flag[128];
+static char *libs[MAX_LIBS] = {
#ifdef MC6809
"/usr/local/lib/m09/",
#endif
0
};
-PRIVATE int lastlib = NR_STDLIBS;
+static int lastlib = NR_STDLIBS;
-FORWARD char *buildname P((char *pre, char *mid, char *suf));
-FORWARD char *expandlib P((char *fn));
+static char *buildname(char *pre, char *mid, char *suf);
+static char *expandlib(char *fn);
-PRIVATE char *buildname(char *pre, char *mid, char *suf)
+static char *buildname(char *pre, char *mid, char *suf)
{
char *name;
return name;
}
-PRIVATE char *expandlib(char *fn)
+static char *expandlib(char *fn)
{
char *path, *s;
int i;
return NUL_PTR;
}
-PUBLIC int main(int argc, char **argv)
+int main(int argc, char **argv)
{
register char *arg;
int argn;
#undef EXTERN
#include "globvar.h"
-FORWARD void linkrefs P((struct modstruct *modptr));
-PUBLIC bool_t reloc_output = 0;
+static void linkrefs(struct modstruct *modptr);
+bool_t reloc_output = 0;
/* link all symbols connected to entry symbols */
-PUBLIC void linksyms(bool_pt argreloc_output)
+void linksyms(bool_pt argreloc_output)
{
char needlink;
struct entrylist *elptr;
while (needlink);
}
-PRIVATE void linkrefs(struct modstruct *modptr)
+static void linkrefs(struct modstruct *modptr)
{
register struct symstruct **symparray;
register struct symstruct *symptr;
beginning in the module descriptor.
*/
-PRIVATE unsigned convertsize[NSEG / 4] = {0, 1, 2, 4};
-PRIVATE struct entrylist *entrylast; /* last on list of entry symbols */
-PRIVATE struct redlist *redlast; /* last on list of redefined symbols */
-PRIVATE struct modstruct *modlast; /* data for last module */
-
-FORWARD long readarheader P((char **parchentry));
-FORWARD unsigned readfileheader P((void));
-FORWARD void readmodule P((char *filename, char *archentry));
-FORWARD void reedmodheader P((void));
-FORWARD bool_pt redsym P((struct symstruct *symptr, bin_off_t value));
-FORWARD unsigned checksum P((char *string, unsigned length));
-FORWARD unsigned segbits P((unsigned seg, char *sizedesc));
+static unsigned convertsize[NSEG / 4] = {0, 1, 2, 4};
+static struct entrylist *entrylast; /* last on list of entry symbols */
+static struct redlist *redlast; /* last on list of redefined symbols */
+static struct modstruct *modlast; /* data for last module */
+
+static long readarheader(char **parchentry);
+static unsigned readfileheader(void);
+static void readmodule(char *filename, char *archentry);
+static void reedmodheader(void);
+static bool_pt redsym(struct symstruct *symptr, bin_off_t value);
+static unsigned checksum(char *string, unsigned length);
+static unsigned segbits(unsigned seg, char *sizedesc);
/* initialise object file handler */
-PUBLIC void objinit(void)
+void objinit(void)
{
modfirst = modlast = NUL_PTR;
entryfirst = entrylast = NUL_PTR;
/* read all symbol definitions in an object file */
-PUBLIC void readsyms(char *filename, bool_pt trace)
+void readsyms(char *filename, bool_pt trace)
{
char *archentry;
long filelength;
/* read archive header and return length */
-PRIVATE long readarheader(char **parchentry)
+static long readarheader(char **parchentry)
{
struct ar_hdr arheader;
char *endptr;
/* read and check file header of the object file just opened */
-PRIVATE unsigned readfileheader(void)
+static unsigned readfileheader(void)
{
struct
{
/* read the next module */
-PRIVATE void readmodule(char *filename, char *archentry)
+static void readmodule(char *filename, char *archentry)
{
struct symdstruct /* to save parts of symbol before name known */
{
/* put symbol on entry symbol list if it is not already */
-PUBLIC void entrysym(struct symstruct *symptr)
+void entrysym(struct symstruct *symptr)
{
register struct entrylist *elptr;
/* read the header of the next module */
-PRIVATE void reedmodheader(void)
+static void reedmodheader(void)
{
struct
{
modlast = modptr;
}
-PRIVATE bool_pt redsym(struct symstruct *symptr, bin_off_t value)
+static bool_pt redsym(struct symstruct *symptr, bin_off_t value)
{
register struct redlist *rlptr;
char class;
return TRUE;
}
-PRIVATE unsigned checksum(char *string, unsigned length)
+static unsigned checksum(char *string, unsigned length)
{
unsigned char sum; /* this is a 1-byte checksum */
return sum;
}
-PUBLIC bin_off_t readconvsize(unsigned countindex)
+bin_off_t readconvsize(unsigned countindex)
{
return readsize(convertsize[countindex]);
}
-PUBLIC bin_off_t readsize(unsigned count)
+bin_off_t readsize(unsigned count)
{
char buf[MAX_OFFSET_SIZE];
return cntooffset(buf, count);
}
-PRIVATE unsigned segbits(unsigned seg, char *sizedesc)
+static unsigned segbits(unsigned seg, char *sizedesc)
{
return 3 & ((unsigned) sizedesc[((NSEG - 1) - seg) / 4] >> (2 * (seg % 4)));
/* unsigned to give logical shift */
}
-PUBLIC unsigned segsizecount(unsigned seg, struct modstruct *modptr)
+unsigned segsizecount(unsigned seg, struct modstruct *modptr)
{
return convertsize[segbits(seg, modptr->segsizedesc)];
}
#include <string.h>
#include <errno.h>
-/******************************************************************************/
-
-/* EEEEyuk!! */
-
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-
#define GOLDEN 157 /* GOLDEN/HASHTABSIZE approx golden ratio */
#define HASHTABSIZE 256
-PRIVATE struct symstruct *hashtab[HASHTABSIZE]; /* hash table */
-PRIVATE char *tableptr; /* next free spot in catchall table */
-PRIVATE char *tableend; /* ptr to spot after last in table */
+static struct symstruct *hashtab[HASHTABSIZE]; /* hash table */
+static char *tableptr; /* next free spot in catchall table */
+static char *tableend; /* ptr to spot after last in table */
-PUBLIC int maxused = 0; /* Stats */
-PRIVATE int mainavail, usedtop; /* Stats */
+int maxused = 0; /* Stats */
+static int mainavail, usedtop; /* Stats */
-FORWARD struct symstruct **gethashptr P((char *name));
-FORWARD void check_used P((void));
+static struct symstruct **gethashptr(char *name);
+static void check_used(void);
/* initialise symbol table */
-PUBLIC void syminit(void)
+void syminit(void)
{
unsigned i;
/* add named symbol to end of table - initialise only name and next fields */
/* caller must not duplicate names of externals for findsym() to work */
-PUBLIC struct symstruct *addsym(char *name)
+struct symstruct *addsym(char *name)
{
struct symstruct **hashptr;
struct symstruct *oldsymptr = 0;
/* lookup named symbol */
-PUBLIC struct symstruct *findsym(char *name)
+struct symstruct *findsym(char *name)
{
struct symstruct *symptr;
/* convert name to a hash table ptr */
-PRIVATE struct symstruct **gethashptr(char *name)
+static struct symstruct **gethashptr(char *name)
{
register unsigned hashval;
/* move symbol descriptor entries to top of table (no error checking) */
-PUBLIC char *moveup(unsigned nbytes)
+char *moveup(unsigned nbytes)
{
register char *source;
register char *target;
/* our version of malloc */
-PUBLIC char *ourmalloc(unsigned nbytes)
+char *ourmalloc(unsigned nbytes)
{
char *allocptr;
/* our version of free (release from bottom of table) */
-PUBLIC void ourfree(char *cptr)
+void ourfree(char *cptr)
{
check_used();
tableptr = cptr;
/* read string from file into table at offset suitable for next symbol */
-PUBLIC char *readstring(void)
+char *readstring(void)
{
int c;
char *s;
/* release from top of table */
-PUBLIC void release(char *cptr)
+void release(char *cptr)
{
check_used();
mainavail += cptr - tableend;
tableend = cptr;
}
-PRIVATE void check_used(void)
+static void check_used(void)
{
int used;
if (used > maxused) maxused = used;
}
-PUBLIC int memory_used(void)
+int memory_used(void)
{
check_used();
return maxused;
/* allocate space for string */
-PUBLIC char *stralloc(char *s)
+char *stralloc(char *s)
{
return strcpy(ourmalloc((unsigned) strlen(s) + 1), s);
}
/* prototypes */
-#ifndef P
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
/* dump.c */
-void dumpmods P((void));
-void dumpsyms P((void));
+void dumpmods(void);
+void dumpsyms(void);
/* io.c */
-void ioinit P((char *progname));
-void closein P((void));
-void closeout P((void));
-void errtrace P((char *name, int level));
-void executable P((void));
-void flusherr P((void));
-void openin P((char *filename));
-void openout P((char *filename));
-void putstr P((char *message));
-void put08x P((bin_off_t num));
-void put08lx P((bin_off_t num));
-void putbstr P((unsigned width, char *str));
-void putbyte P((int ch));
-int readchar P((void));
-void readin P((char *buf, unsigned count));
-bool_pt readineofok P((char *buf, unsigned count));
-void seekin P((unsigned long offset));
-void seekout P((unsigned long offset));
-void seektrel P((unsigned long offset));
-void writechar P((int c));
-void writedrel P((char *buf, unsigned count));
-void writeout P((char *buf, unsigned count));
-void writetrel P((char *buf, unsigned count));
-void fatalerror P((char *message));
-void inputerror P((char *message));
-void input1error P((char *message));
-void outofmemory P((void));
-void prematureeof P((void));
-void redefined P((char *name, char *message, char *archentry,
- char *deffilename, char *defarchentry));
-void interseg P((char *fname, char *aname, char *name));
-void reserved P((char *name));
-void size_error P((int seg, bin_off_t count, bin_off_t size));
-void undefined P((char *name));
-void usage P((void));
-void version_msg P((void));
-void use_error P((char *message));
+void ioinit(char *progname);
+void closein(void);
+void closeout(void);
+void errtrace(char *name, int level);
+void executable(void);
+void flusherr(void);
+void openin(char *filename);
+void openout(char *filename);
+void putstr(char *message);
+void put08x(bin_off_t num);
+void put08lx(bin_off_t num);
+void putbstr(unsigned width, char *str);
+void putbyte(int ch);
+int readchar(void);
+void readin(char *buf, unsigned count);
+bool_pt readineofok(char *buf, unsigned count);
+void seekin(unsigned long offset);
+void seekout(unsigned long offset);
+void seektrel(unsigned long offset);
+void writechar(int c);
+void writedrel(char *buf, unsigned count);
+void writeout(char *buf, unsigned count);
+void writetrel(char *buf, unsigned count);
+void fatalerror(char *message);
+void inputerror(char *message);
+void input1error(char *message);
+void outofmemory(void);
+void prematureeof(void);
+void redefined(char *name, char *message, char *archentry,
+ char *deffilename, char *defarchentry);
+void interseg(char *fname, char *aname, char *name);
+void reserved(char *name);
+void size_error(int seg, bin_off_t count, bin_off_t size);
+void undefined(char *name);
+void usage(void);
+void version_msg(void);
+void use_error(char *message);
/* ld.c */
-int main P((int argc, char **argv));
+int main(int argc, char **argv);
/* readobj.c */
-void objinit P((void));
-void readsyms P((char *filename, bool_pt trace));
+void objinit(void);
+void readsyms(char *filename, bool_pt trace);
#ifdef OBJ_H
-void entrysym P((struct symstruct *symptr));
-unsigned segsizecount P((unsigned seg, struct modstruct *modptr));
+void entrysym(struct symstruct *symptr);
+unsigned segsizecount(unsigned seg, struct modstruct *modptr);
#endif
-bin_off_t readconvsize P((unsigned countindex));
-bin_off_t readsize P((unsigned count));
+bin_off_t readconvsize(unsigned countindex);
+bin_off_t readsize(unsigned count);
/* table.c */
-void syminit P((void));
-struct symstruct *addsym P((char *name));
-struct symstruct *findsym P((char *name));
-char *moveup P((unsigned nbytes));
-char *ourmalloc P((unsigned nbytes));
-void ourfree P((char *cptr));
-char *readstring P((void));
-void release P((char *cptr));
-int memory_used P((void));
-char *stralloc P((char *s));
+void syminit(void);
+struct symstruct *addsym(char *name);
+struct symstruct *findsym(char *name);
+char *moveup(unsigned nbytes);
+char *ourmalloc(unsigned nbytes);
+void ourfree(char *cptr);
+char *readstring(void);
+void release(char *cptr);
+int memory_used(void);
+char *stralloc(char *s);
/* typeconvert.c */
-u2_pt c2u2 P((char *buf));
-u4_t c4u4 P((char *buf));
-u2_pt cnu2 P((char *buf, unsigned count));
-u4_t cnu4 P((char *buf, unsigned count));
-void u2c2 P((char *buf, u2_pt offset));
-void u4c4 P((char *buf, u4_t offset));
-void u2cn P((char *buf, u2_pt offset, unsigned count));
-void u4cn P((char *buf, u4_t offset, unsigned count));
-bool_pt typeconv_init P((bool_pt big_endian, bool_pt long_big_endian));
+u2_pt c2u2(char *buf);
+u4_t c4u4(char *buf);
+u2_pt cnu2(char *buf, unsigned count);
+u4_t cnu4(char *buf, unsigned count);
+void u2c2(char *buf, u2_pt offset);
+void u4c4(char *buf, u4_t offset);
+void u2cn(char *buf, u2_pt offset, unsigned count);
+void u4cn(char *buf, u4_t offset, unsigned count);
+bool_pt typeconv_init(bool_pt big_endian, bool_pt long_big_endian);
/* writebin.c */
-void writebin P((char *outfilename, bool_pt argsepid, bool_pt argbits32,
- bool_pt argstripflag, bool_pt arguzp));
+void writebin(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+ bool_pt argstripflag, bool_pt arguzp);
-void write_dosemu P((char *outfilename, bool_pt argsepid, bool_pt argbits32,
- bool_pt argstripflag, bool_pt arguzp));
+void write_dosemu(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+ bool_pt argstripflag, bool_pt arguzp);
/* write_elks.c */
-void write_elks P((char *outfilename, bool_pt argsepid, bool_pt argbits32,
- bool_pt argstripflag, bool_pt arguzp, bool_pt nsym));
+void write_elks(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+ bool_pt argstripflag, bool_pt arguzp, bool_pt nsym);
/* linksym.c */
-void linksyms P((bool_pt argreloc_output));
+void linksyms(bool_pt argreloc_output);
/* mkar.c */
-void ld86r P((int argc, char ** argv));
+void ld86r(int argc, char ** argv);
static int long_off[4] = {0,1,2,3};
static int int_off[2] = {0,1};
-PUBLIC bool_pt typeconv_init(bool_pt big_endian, bool_pt long_big_endian)
+bool_pt typeconv_init(bool_pt big_endian, bool_pt long_big_endian)
{
int i;
no_swap = (!big_endian && !long_big_endian);
return 1;
}
-PUBLIC void u2c2(char *buf, u2_pt offset)
+void u2c2(char *buf, u2_pt offset)
{
#ifdef __AS386_16__
if( no_swap )
buf[int_off[1]] = (offset>>8);
}
-PUBLIC void u4c4(char *buf, u4_t offset)
+void u4c4(char *buf, u4_t offset)
{
int i;
#ifdef __AS386_16__
}
}
-PUBLIC void u4cn(char *buf, u4_t offset, unsigned count)
+void u4cn(char *buf, u4_t offset, unsigned count)
{
switch(count)
{
}
}
-PUBLIC void u2cn(char *buf, u2_pt offset, unsigned count)
+void u2cn(char *buf, u2_pt offset, unsigned count)
{
switch(count)
{
}
}
-PUBLIC u2_pt c2u2(char *buf)
+u2_pt c2u2(char *buf)
{
u2_pt res;
#ifdef __AS386_16__
return res;
}
-PUBLIC u4_t c4u4(char *buf)
+u4_t c4u4(char *buf)
{
u4_t res;
int i;
return res;
}
-PUBLIC u4_t cnu4(char *buf, unsigned count)
+u4_t cnu4(char *buf, unsigned count)
{
switch (count)
{
}
}
-PUBLIC u2_pt cnu2(char *buf, unsigned count)
+u2_pt cnu2(char *buf, unsigned count)
{
switch (count)
{
#define offsetof(struc, mem) ((int) &((struc *) 0)->mem)
#define memsizeof(struc, mem) sizeof(((struc *) 0)->mem)
-PRIVATE bool_t bits32; /* nonzero for 32-bit executable */
-PRIVATE bin_off_t combase[NSEG];/* bases of common parts of segments */
-PRIVATE bin_off_t comsz[NSEG]; /* sizes of common parts of segments */
-PRIVATE fastin_t curseg; /* current segment, 0 to $F */
-PRIVATE bin_off_t edataoffset; /* end of data */
-PRIVATE bin_off_t endoffset; /* end of bss */
-PRIVATE bin_off_t etextoffset; /* end of text */
-PRIVATE bin_off_t etextpadoff; /* end of padded text */
+static bool_t bits32; /* nonzero for 32-bit executable */
+static bin_off_t combase[NSEG];/* bases of common parts of segments */
+static bin_off_t comsz[NSEG]; /* sizes of common parts of segments */
+static fastin_t curseg; /* current segment, 0 to $F */
+static bin_off_t edataoffset; /* end of data */
+static bin_off_t endoffset; /* end of bss */
+static bin_off_t etextoffset; /* end of text */
+static bin_off_t etextpadoff; /* end of padded text */
#ifdef REL_OUTPUT
-PRIVATE unsigned ndreloc; /* number of data relocations */
+static unsigned ndreloc; /* number of data relocations */
#endif
-PRIVATE unsigned nsym; /* number of symbols written */
+static unsigned nsym; /* number of symbols written */
#ifdef REL_OUTPUT
-PRIVATE unsigned ntreloc; /* number of text relocations */
+static unsigned ntreloc; /* number of text relocations */
extern bool_t reloc_output; /* nonzero to leave reloc info in output */
#endif
-PRIVATE unsigned relocsize; /* current relocation size 1, 2 or 4 */
-PRIVATE bin_off_t segadj[NSEG]; /* adjusts (file offset - seg offset) */
+static unsigned relocsize; /* current relocation size 1, 2 or 4 */
+static bin_off_t segadj[NSEG]; /* adjusts (file offset - seg offset) */
/* depends on zero init */
-PRIVATE bin_off_t segbase[NSEG];/* bases of data parts of segments */
-PRIVATE char segboundary[9] = "__seg0DH";
+static bin_off_t segbase[NSEG];/* bases of data parts of segments */
+static char segboundary[9] = "__seg0DH";
/* name of seg boundary __seg0DL to __segfCH */
-PRIVATE bin_off_t segpos[NSEG]; /* segment positions for current module */
-PRIVATE bin_off_t segsz[NSEG]; /* sizes of data parts of segments */
+static bin_off_t segpos[NSEG]; /* segment positions for current module */
+static bin_off_t segsz[NSEG]; /* sizes of data parts of segments */
/* depends on zero init */
-PRIVATE bool_t sepid; /* nonzero for separate I & D */
-PRIVATE bool_t stripflag; /* nonzero to strip symbols */
-PRIVATE bin_off_t spos; /* position in current seg */
-PRIVATE bool_t uzp; /* nonzero for unmapped zero page */
+static bool_t sepid; /* nonzero for separate I & D */
+static bool_t stripflag; /* nonzero to strip symbols */
+static bin_off_t spos; /* position in current seg */
+static bool_t uzp; /* nonzero for unmapped zero page */
#ifdef EDOS
-FORWARD unsigned binheaderlength P((char *commandname));
-FORWARD char *idconvert P((struct entrylist *elptr, char *commandname));
-#endif
-FORWARD void linkmod P((struct modstruct *modptr));
-FORWARD void padmod P((struct modstruct *modptr));
-FORWARD void setsym P((char *name, bin_off_t value));
-FORWARD void symres P((char *name));
-FORWARD void setseg P((fastin_pt newseg));
-FORWARD void skip P((unsigned countsize));
+unsigned binheaderlength(char *commandname);
+char *idconvert(struct entrylist *elptr, char *commandname);
+#endif
+void linkmod(struct modstruct *modptr);
+void padmod(struct modstruct *modptr);
+void setsym(char *name, bin_off_t value);
+void symres(char *name);
+void setseg(fastin_pt newseg);
+void skip(unsigned countsize);
#ifdef EDOS
-FORWARD void writeheader P((char *commandname));
+void writeheader(char *commandname);
#else
-FORWARD void writeheader P((void));
+void writeheader(void);
#endif
-FORWARD void writenulls P((bin_off_t count));
+void writenulls(bin_off_t count);
/* write binary file */
#ifndef FUNCNAME
#define FUNCNAME writebin
#endif
-PUBLIC void FUNCNAME(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+void FUNCNAME(char *outfilename, bool_pt argsepid, bool_pt argbits32,
bool_pt argstripflag, bool_pt arguzp)
{
char buf4[4];
#ifdef EDOS
-PRIVATE unsigned binheaderlength(char *commandname)
+static unsigned binheaderlength(char *commandname)
{
unsigned count;
char *name;
/* the special name _main is converted to the command name first */
/* copy upper case and numerals, convert lower case to upper, ignore rest */
-PRIVATE char *idconvert(struct entrylist *elptr, char *commandname)
+static char *idconvert(struct entrylist *elptr, char *commandname)
{
char *name;
char *newname;
#endif /* EDOS */
-PRIVATE void linkmod(struct modstruct *modptr)
+static void linkmod(struct modstruct *modptr)
{
char buf[ABS_TEXT_MAX];
int command;
}
}
-PRIVATE void padmod(struct modstruct *modptr)
+static void padmod(struct modstruct *modptr)
{
bin_off_t count;
fastin_t seg;
}
}
-PRIVATE void setsym(char *name, bin_off_t value)
+static void setsym(char *name, bin_off_t value)
{
struct symstruct *symptr;
symptr->value = value;
}
-PRIVATE void symres(char *name)
+static void symres(char *name)
{
register struct symstruct *symptr;
/* set new segment */
-PRIVATE void setseg(fastin_pt newseg)
+static void setseg(fastin_pt newseg)
{
if (newseg != curseg)
{
}
}
-PRIVATE void skip(unsigned countsize)
+static void skip(unsigned countsize)
{
writenulls((bin_off_t) readsize(countsize));
}
#ifdef EDOS
-PRIVATE void writeheader(char *commandname)
+static void writeheader(char *commandname)
{
char buf[MAX_OFFSET_SIZE];
bin_off_t offset;
#ifdef MINIX
-PRIVATE void writeheader(void)
+static void writeheader(void)
{
struct exec header;
#endif /* MINIX */
-PRIVATE void writenulls(bin_off_t count)
+static void writenulls(bin_off_t count)
{
long lcount = count;
if( lcount < 0 )
#define FUNCNAME writebin
#endif
-PUBLIC void FUNCNAME(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+void FUNCNAME(char *outfilename, bool_pt argsepid, bool_pt argbits32,
bool_pt argstripflag, bool_pt arguzp)
{
char * s = "WARNING: Native a.out generation not included, sorry\n";
#define offsetof(struc, mem) ((int) &((struc *) 0)->mem)
#define memsizeof(struc, mem) sizeof(((struc *) 0)->mem)
-PRIVATE bool_t bits32; /* nonzero for 32-bit executable */
-PRIVATE bin_off_t combase[NSEG];/* bases of common parts of segments */
-PRIVATE bin_off_t comsz[NSEG]; /* sizes of common parts of segments */
-PRIVATE fastin_t curseg; /* current segment, 0 to $F */
-PRIVATE bin_off_t edataoffset; /* end of data */
-PRIVATE bin_off_t endoffset; /* end of bss */
-PRIVATE bin_off_t etextoffset; /* end of text */
-PRIVATE bin_off_t etextpadoff; /* end of padded text */
-PRIVATE unsigned nsym; /* number of symbols written */
-PRIVATE unsigned relocsize; /* current relocation size 1, 2 or 4 */
-PRIVATE bin_off_t segadj[NSEG]; /* adjusts (file offset - seg offset) */
+static bool_t bits32; /* nonzero for 32-bit executable */
+static bin_off_t combase[NSEG];/* bases of common parts of segments */
+static bin_off_t comsz[NSEG]; /* sizes of common parts of segments */
+static fastin_t curseg; /* current segment, 0 to $F */
+static bin_off_t edataoffset; /* end of data */
+static bin_off_t endoffset; /* end of bss */
+static bin_off_t etextoffset; /* end of text */
+static bin_off_t etextpadoff; /* end of padded text */
+static unsigned nsym; /* number of symbols written */
+static unsigned relocsize; /* current relocation size 1, 2 or 4 */
+static bin_off_t segadj[NSEG]; /* adjusts (file offset - seg offset) */
/* depends on zero init */
-PRIVATE bin_off_t segbase[NSEG];/* bases of data parts of segments */
-PRIVATE char segboundary[9] = "__seg0DH";
+static bin_off_t segbase[NSEG];/* bases of data parts of segments */
+static char segboundary[9] = "__seg0DH";
/* name of seg boundary __seg0DL to __segfCH */
-PRIVATE bin_off_t segpos[NSEG]; /* segment positions for current module */
-PRIVATE bin_off_t segsz[NSEG]; /* sizes of data parts of segments */
+static bin_off_t segpos[NSEG]; /* segment positions for current module */
+static bin_off_t segsz[NSEG]; /* sizes of data parts of segments */
/* depends on zero init */
-PRIVATE bool_t sepid; /* nonzero for separate I & D */
-PRIVATE bool_t stripflag; /* nonzero to strip symbols */
-PRIVATE bin_off_t spos; /* position in current seg */
-PRIVATE bool_t uzp; /* nonzero for unmapped zero page */
-PRIVATE bool_t xsym; /* extended symbol table */
-
-FORWARD void linkmod P((struct modstruct *modptr));
-FORWARD void padmod P((struct modstruct *modptr));
-FORWARD void setsym P((char *name, bin_off_t value));
-FORWARD void symres P((char *name));
-FORWARD void setseg P((fastin_pt newseg));
-FORWARD void skip P((unsigned countsize));
-FORWARD void writeheader P((void));
+static bool_t sepid; /* nonzero for separate I & D */
+static bool_t stripflag; /* nonzero to strip symbols */
+static bin_off_t spos; /* position in current seg */
+static bool_t uzp; /* nonzero for unmapped zero page */
+static bool_t xsym; /* extended symbol table */
+
+static void linkmod(struct modstruct *modptr);
+static void padmod(struct modstruct *modptr);
+static void setsym(char *name, bin_off_t value);
+static void symres(char *name);
+static void setseg(fastin_pt newseg);
+static void skip(unsigned countsize);
+static void writeheader(void);
#ifndef VERY_SMALL_MEMORY
-FORWARD void v7header P((void));
+static void v7header(void);
#endif
#ifndef MSDOS
-FORWARD void cpm86header P((void));
+static void cpm86header(void);
#endif
-FORWARD void writenulls P((bin_off_t count));
+static void writenulls(bin_off_t count);
EXTERN bool_t reloc_output;
/* write binary file */
-PUBLIC void write_elks(outfilename, argsepid, argbits32, argstripflag, arguzp, argxsym)
-char *outfilename;
-bool_pt argsepid;
-bool_pt argbits32;
-bool_pt argstripflag;
-bool_pt arguzp;
-bool_pt argxsym;
+void write_elks(char *outfilename, bool_pt argsepid, bool_pt argbits32,
+ bool_pt argstripflag, bool_pt arguzp, bool_pt argxsym)
{
char buf4[4];
char *cptr;
executable();
}
-PRIVATE void linkmod(modptr)
+static void linkmod(modptr)
struct modstruct *modptr;
{
char buf[ABS_TEXT_MAX];
}
}
-PRIVATE void padmod(modptr)
+static void padmod(modptr)
struct modstruct *modptr;
{
bin_off_t count;
}
}
-PRIVATE void setsym(name, value)
+static void setsym(name, value)
char *name;
bin_off_t value;
{
symptr->value = value;
}
-PRIVATE void symres(name)
+static void symres(name)
register char *name;
{
register struct symstruct *symptr;
/* set new segment */
-PRIVATE void setseg(newseg)
+static void setseg(newseg)
fastin_pt newseg;
{
if (newseg != curseg)
}
}
-PRIVATE void skip(countsize)
+static void skip(countsize)
unsigned countsize;
{
writenulls((bin_off_t) readsize(countsize));
}
#ifndef MSDOS
-PRIVATE void cpm86header()
+static void cpm86header()
{
struct cpm86_exec header;
memset(&header, 0, sizeof header);
}
#endif
-PRIVATE void writeheader()
+static void writeheader()
{
struct exec header;
}
#ifndef VERY_SMALL_MEMORY
-PRIVATE void v7header()
+static void v7header()
{
struct v7_exec header;
}
#endif
-PRIVATE void writenulls(count)
+static void writenulls(count)
bin_off_t count;
{
long lcount = count;