From 1c4e04de3aef27c978e58cdfdbe531b1f21cc237 Mon Sep 17 00:00:00 2001 From: Godzil Date: Wed, 20 Mar 2013 01:58:06 +0100 Subject: [PATCH] Next batch of changes! --- modules/src/object/object.h | 1 + util/amisc/aelflod.c | 4 ++++ util/amisc/anm.c | 8 ++++++-- util/amisc/ashow.c | 2 +- util/amisc/asize.c | 2 +- util/amisc/aslod.c | 4 ++++ util/amisc/astrip.c | 13 +++++++++---- util/led/archive.c | 5 +---- util/led/archive.h | 13 +++++++++++++ util/led/error.c | 7 +++---- util/led/extract.c | 4 ---- util/led/finish.c | 12 +++++------- util/led/main.c | 4 ---- util/led/memory.c | 19 +++++++++---------- util/led/output.c | 6 ++---- util/led/read.c | 4 ---- util/led/relocate.c | 4 ---- util/led/save.c | 4 ---- util/led/scan.c | 9 +++------ util/led/sym.c | 4 ---- util/led/write.c | 10 ++++++---- util/topgen/LLlex.c | 1 + util/topgen/hash.c | 4 +++- util/topgen/hash.h | 13 +++++++++++++ util/topgen/main.c | 11 +++++++++-- util/topgen/main.h | 14 ++++++++++++++ util/topgen/pattern.h | 13 +++++++++++++ util/topgen/symtab.c | 9 +++++---- util/topgen/topgen.g | 3 +++ 29 files changed, 129 insertions(+), 78 deletions(-) create mode 100644 util/led/archive.h create mode 100644 util/topgen/hash.h create mode 100644 util/topgen/main.h create mode 100644 util/topgen/pattern.h diff --git a/modules/src/object/object.h b/modules/src/object/object.h index ed4facece..63560e857 100644 --- a/modules/src/object/object.h +++ b/modules/src/object/object.h @@ -51,5 +51,6 @@ _PROTOTYPE(unsigned int rd_unsigned2, (int fd)); _PROTOTYPE(long rd_long, (int fd)); _PROTOTYPE(void rd_bytes, (int fd, char *buf, long l)); _PROTOTYPE(int rd_fd, (void)); +_PROTOTYPE(void rd_rew_relos, (struct outhead *head)); #endif /* __OBJECT_INCLUDED__ */ diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c index 2174943d5..657800e39 100644 --- a/util/amisc/aelflod.c +++ b/util/amisc/aelflod.c @@ -22,6 +22,10 @@ #include #include +#include +#include +#include +#include #include #include #include diff --git a/util/amisc/anm.c b/util/amisc/anm.c index 1eece0e34..e3b7efba1 100644 --- a/util/amisc/anm.c +++ b/util/amisc/anm.c @@ -15,9 +15,15 @@ #include #include +#include +#include +#include +#include + #include "out.h" #include "arch.h" #include "ranlib.h" +#include "object.h" int numsort_flg; int sectsort_flg; @@ -98,8 +104,6 @@ int main(int argc, char *argv[]) exit(0); } -int rd_unsigned2(int fd); - void process(int fd) { unsigned int magic; diff --git a/util/amisc/ashow.c b/util/amisc/ashow.c index e8ec12a9e..906683f47 100644 --- a/util/amisc/ashow.c +++ b/util/amisc/ashow.c @@ -1,4 +1,3 @@ -static char rcsid[] = "$Id$"; /* * show - make the contents of an ACK object file human readable. */ @@ -9,6 +8,7 @@ static char rcsid[] = "$Id$"; #include #include #include +#include "object.h" #define OK 0 /* Return value of gethead if Orl Korekt. */ #define BMASK 0xFF /* To extract least significant 8 bits from an int. */ diff --git a/util/amisc/asize.c b/util/amisc/asize.c index 998be441d..9c4bf3771 100644 --- a/util/amisc/asize.c +++ b/util/amisc/asize.c @@ -7,7 +7,7 @@ #include #include #include "out.h" - +#include "object.h" /* asize -- determine object size diff --git a/util/amisc/aslod.c b/util/amisc/aslod.c index e436438ba..871398b17 100644 --- a/util/amisc/aslod.c +++ b/util/amisc/aslod.c @@ -21,6 +21,10 @@ #include #include +#include +#include +#include +#include #include #include #include "out.h" diff --git a/util/amisc/astrip.c b/util/amisc/astrip.c index 83b059dcc..0870707dc 100644 --- a/util/amisc/astrip.c +++ b/util/amisc/astrip.c @@ -6,9 +6,13 @@ #include #include +#include +#include +#include +#include #include #include "out.h" - +#include "object.h" /* astrip -- remove symbols and relocation bits @@ -17,12 +21,13 @@ char temp_name[] = "/tmp/sXXXXXX"; char *tname; -char *mktemp(); -FILE *fopen(); FILE *tf; struct outhead buf; int readerror, writeerror; +int strip(char *name); +int copy(char *fnam, char *tnam, long size, int fr, int fw); + int main(int argc, char *argv[]) { int status; @@ -113,7 +118,7 @@ int strip(char *name) int copy(char *fnam, char *tnam, long size, int fr, int fw) { - int s, n; + int s/*, n*/; char lbuf[512]; while(size != (long)0) { diff --git a/util/led/archive.c b/util/led/archive.c index 82fd8de10..3dc056aaf 100644 --- a/util/led/archive.c +++ b/util/led/archive.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include #include "arch.h" @@ -15,6 +11,7 @@ static char rcsid[] = "$Id$"; #include "debug.h" #include "memory.h" #include "defs.h" +#include "object.h" #define ENDLIB ((long)0) diff --git a/util/led/archive.h b/util/led/archive.h new file mode 100644 index 000000000..6f6bf83ec --- /dev/null +++ b/util/led/archive.h @@ -0,0 +1,13 @@ +/* + * The Amsterdam Compiler Kit + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_LED_ARCHIVE_H +#define UTIL_LED_ARCHIVE_H + +/* util/led/archive.c */ +void arch(void); +void arch2(void); + +#endif /* UTIL_LED_ARCHIVE_H */ + diff --git a/util/led/error.c b/util/led/error.c index d89cc89fe..6da2ef2b5 100644 --- a/util/led/error.c +++ b/util/led/error.c @@ -2,16 +2,15 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include #include +#include #include #include "const.h" + + static short nerrors = 0; static void diag(char *, char *, va_list); diff --git a/util/led/extract.c b/util/led/extract.c index 70aa7c63a..5bf5c41c0 100644 --- a/util/led/extract.c +++ b/util/led/extract.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include #include "arch.h" diff --git a/util/led/finish.c b/util/led/finish.c index 0785db7e5..132b958f2 100644 --- a/util/led/finish.c +++ b/util/led/finish.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include "const.h" #include "arch.h" @@ -13,6 +9,7 @@ static char rcsid[] = "$Id$"; #include "defs.h" #include "orig.h" #include "scan.h" +#include "object.h" extern bool incore; extern unsigned short NLocals; @@ -22,8 +19,9 @@ static void adjust_names(struct outname *name, struct outhead *head, char *chars static void handle_relos(struct outhead *head, struct outsect *sects, struct outname *names); static void put_locals(struct outname *name, unsigned int nnames); static void compute_origins(struct outsect *sect, unsigned int nsect); - -static put_dbug(long offdbug); +#ifdef SYMDBUG +static void put_dbug(long offdbug); +#endif /* * We know all there is to know about the current module. * Now we relocate the values in the emitted bytes and write @@ -235,7 +233,7 @@ static void compute_origins(struct outsect *sect, unsigned int nsect) * Write out what is after the string area. This is likely to be * debugging information. */ -static put_dbug(long offdbug) +static void put_dbug(long offdbug) { char buf[512]; int nbytes; diff --git a/util/led/main.c b/util/led/main.c index 319e56423..82bec89a8 100644 --- a/util/led/main.c +++ b/util/led/main.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - /* * led - linkage editor for ACK assemblers output format */ diff --git a/util/led/memory.c b/util/led/memory.c index 82ab20cff..742de35d0 100644 --- a/util/led/memory.c +++ b/util/led/memory.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - /* * Memory manager. Memory is divided into NMEMS pieces. There is a struct * for each piece telling where it is, how many bytes are used, and how may @@ -22,6 +18,7 @@ static char rcsid[] = "$Id$"; */ #include +#include #include #include "const.h" #include "assert.h" @@ -29,6 +26,9 @@ static char rcsid[] = "$Id$"; #include "arch.h" #include "memory.h" #include "defs.h" +#include "object.h" + +#include static ind_t move_up(int piece, ind_t incr); static bool compact(int piece, ind_t incr, int flag); @@ -56,7 +56,7 @@ int sbreak(ind_t incr) if ((refused && refused < incr) || (sizeof(char *) < sizeof(long) && (inc != incr || BASE + inc < BASE)) || - brk(BASE + incr) == -1) { + brk(BASE + incr) == (void *)-1) { if (!refused || refused > incr) refused = incr; return -1; @@ -74,17 +74,16 @@ void init_core() char *base; ind_t total_size; struct memory *mem; - extern char *sbrk(); #include "mach.c" #define ALIGN 8 /* minimum alignment for pieces */ #define AT_LEAST (ind_t)2*ALIGN /* See comment about string areas. */ total_size = (ind_t)0; /* Will accumulate the sizes. */ - BASE = base = sbrk(0); /* First free. */ + BASE = base = (char *)sbrk(0); /* First free. */ if ((int)base % ALIGN) { - base = sbrk(ALIGN - (int)base % ALIGN); - BASE = base = sbrk(0); + base = (char *)sbrk(ALIGN - (int)base % ALIGN); + BASE = base = (char *)sbrk(0); } /* * String areas are special-cased. The first byte is unused as a way to @@ -537,7 +536,7 @@ void write_bytes() extern int flagword; extern struct outhead outhead; extern struct outsect outsect[]; - extern char *outputname; + /* extern char *outputname; */ int sectionno = 0; nsect = outhead.oh_nsect; diff --git a/util/led/output.c b/util/led/output.c index 49fc470ea..2703a1b47 100644 --- a/util/led/output.c +++ b/util/led/output.c @@ -2,13 +2,11 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include "const.h" #include "memory.h" +#include "object.h" +#include "defs.h" static void generate_section_names(); diff --git a/util/led/read.c b/util/led/read.c index bd3e154b3..bacff5da6 100644 --- a/util/led/read.c +++ b/util/led/read.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include #include "const.h" diff --git a/util/led/relocate.c b/util/led/relocate.c index 76319b8fa..12758efd3 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include #include "out.h" diff --git a/util/led/save.c b/util/led/save.c index a0eab4a73..c3bf3379d 100644 --- a/util/led/save.c +++ b/util/led/save.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - /* * If everything is kept in core, we must save some things for the second pass. */ diff --git a/util/led/scan.c b/util/led/scan.c index d07995829..b4afcbd8a 100644 --- a/util/led/scan.c +++ b/util/led/scan.c @@ -2,17 +2,13 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include #include -#ifdef SYMDBUG +#include +#include #include #include -#endif /* SYMDBUG */ #include "arch.h" #include "out.h" #include "ranlib.h" @@ -22,6 +18,7 @@ static char rcsid[] = "$Id$"; #include "scan.h" #include "debug.h" #include "defs.h" +#include "object.h" #define READ 0 diff --git a/util/led/sym.c b/util/led/sym.c index 78ae0e787..be0a4c68a 100644 --- a/util/led/sym.c +++ b/util/led/sym.c @@ -2,10 +2,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - /* * Symbol table management. */ diff --git a/util/led/write.c b/util/led/write.c index 009a0d817..4d97af8ea 100644 --- a/util/led/write.c +++ b/util/led/write.c @@ -2,19 +2,21 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#ifndef lint -static char rcsid[] = "$Id$"; -#endif - #include #include #include +#include +#include +#include +#include #include "out.h" #include "const.h" #include "assert.h" #include "memory.h" #include "arch.h" #include "defs.h" +#include "object.h" + extern struct outhead outhead; extern struct outsect outsect[]; extern int flagword; diff --git a/util/topgen/LLlex.c b/util/topgen/LLlex.c index 541f301a2..649528555 100644 --- a/util/topgen/LLlex.c +++ b/util/topgen/LLlex.c @@ -13,6 +13,7 @@ # include "tunable.h" # include "token.h" # include "Lpars.h" +# include "main.h" struct token dot; /* current token */ static struct token aside; /* to put currrent token aside, when a token diff --git a/util/topgen/hash.c b/util/topgen/hash.c index edefc2aa1..f7b918c21 100644 --- a/util/topgen/hash.c +++ b/util/topgen/hash.c @@ -14,6 +14,8 @@ #include #include "misc.h" + + struct hlist { /* linear list of pattern numbers */ int h_patno; struct hlist *h_next; @@ -76,7 +78,7 @@ void printhashtable() * pointers to them */ int i; - struct hlist *p; + /*struct hlist *p;*/ for (i = 1; i <= 128; i++) { fprintf(genc,"int hash%d[] = { ",i); diff --git a/util/topgen/hash.h b/util/topgen/hash.h new file mode 100644 index 000000000..99ea923fe --- /dev/null +++ b/util/topgen/hash.h @@ -0,0 +1,13 @@ +/* + * The Amsterdam Compiler Kit + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_TOPGEN_HASH_H +#define UTIL_TOPGEN_HASH_H + +/* util/topgen/hash.c */ +void addtohashtable(char *s, int n); +void printhashtable(void); + +#endif /* UTIL_TOPGEN_HASH_H */ + diff --git a/util/topgen/main.c b/util/topgen/main.c index 4847ef6a5..0bb36d343 100644 --- a/util/topgen/main.c +++ b/util/topgen/main.c @@ -11,6 +11,7 @@ #include #include +#include extern int lineno, newline; @@ -19,6 +20,9 @@ static int nerrors; char *linedir = "#line %d \"%s\"\n"; /* format of line directive */ char *inpfile; +/* From Lexer */ +void LLparse(void); + int main(int argc, char *argv[]) { newline = 1; @@ -44,11 +48,14 @@ int main(int argc, char *argv[]) } /* VARARGS1 */ -void error(char *s, char *s1) +void error(char *s, ...) { + va_list va; nerrors++; fprintf(stderr,"\"%s\", line %d: ",inpfile,lineno); - fprintf(stderr,s,s1); + va_start(va, s); + vfprintf(stderr, s, va); + va_end(va); putc('\n',stderr); } diff --git a/util/topgen/main.h b/util/topgen/main.h new file mode 100644 index 000000000..ad5c9975c --- /dev/null +++ b/util/topgen/main.h @@ -0,0 +1,14 @@ +/* + * The Amsterdam Compiler Kit + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_TOPGEN_MAIN_H +#define UTIL_TOPGEN_MAIN_H + +/* util/topgen/main.c */ +int main(int argc, char *argv[]); +void error(char *s, ...); +int onlyspace(char *s); + +#endif /* UTIL_TOPGEN_MAIN_H */ + diff --git a/util/topgen/pattern.h b/util/topgen/pattern.h new file mode 100644 index 000000000..2774a3b91 --- /dev/null +++ b/util/topgen/pattern.h @@ -0,0 +1,13 @@ +/* + * The Amsterdam Compiler Kit + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +#ifndef UTIL_TOPGEN_PATTERN_H +#define UTIL_TOPGEN_PATTERN_H + +/* util/topgen/pattern.c */ +void addpattern(char *str, int l, int np, int nr); +void printpatterns(void); + +#endif /* UTIL_TOPGEN_PATTERN_H */ + diff --git a/util/topgen/symtab.c b/util/topgen/symtab.c index b5511d0dc..8310e6f99 100644 --- a/util/topgen/symtab.c +++ b/util/topgen/symtab.c @@ -12,19 +12,20 @@ #include #include #include "symtab.h" +#include "main.h" struct symtab *idtable, *deftable; -struct symtab * -findident(s, mode, table) char *s; struct symtab **table; { +struct symtab *findident(char *s, int mode, struct symtab **table) +{ /* * Look for identifier s in the symboltable referred to by *table. * If mode = LOOKING, no new entry's will be made. * If mode = ENTERING, a new entry will be made if s is not in the * table yet, otherwise an error results */ - register struct symtab *p; - register n; + struct symtab *p; + int n; if (!*table) { /* No entry for this symbol */ if (mode == LOOKING) return (struct symtab *) 0; diff --git a/util/topgen/topgen.g b/util/topgen/topgen.g index 45c573e94..5d39ed5c7 100644 --- a/util/topgen/topgen.g +++ b/util/topgen/topgen.g @@ -21,6 +21,9 @@ #include "token.h" #include "symtab.h" #include "misc.h" +#include "main.h" +#include "pattern.h" +#include "hash.h" char idbuf[BUFSIZ], buf[BUFSIZ]; int countid; /* # of variables */ -- 2.34.1