From d347207e60beab79e12a3180712d6d1cdead794a Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 10 Nov 2017 23:30:46 -0500 Subject: [PATCH] Add more prototypes in mach/proto/as Change "register i;" to "int i;" to so clang stops warning about implicit int. Use function prototypes so clang stops warning about implicitly declared functions. --- mach/proto/as/comm1.h | 49 +++++++++++++++++--- mach/proto/as/comm4.c | 97 ++++++++++++++++++++++----------------- mach/proto/as/comm5.c | 66 +++++++++++++-------------- mach/proto/as/comm6.c | 69 ++++++++++++---------------- mach/proto/as/comm7.c | 104 +++++++++++++++++++++--------------------- 5 files changed, 213 insertions(+), 172 deletions(-) diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index b3011ac97..e23e6b045 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -104,6 +104,11 @@ extern struct outhead outhead; extern int curr_token; /* forward function declarations */ +/* comm2.y */ +void yyparse(void); +/* comm4.c */ +void stop(void); +void newmodule(const char *); /* comm5.c */ int yylex(void); void putval(int); @@ -112,20 +117,52 @@ int nextchar(void); #ifdef ASLD char *readident(int); #endif -int hash(char *); -item_t *item_search(char *); +int hash(const char *); +item_t *item_search(const char *); void item_insert(item_t *, int); item_t *item_alloc(int); item_t *fb_alloc(int); item_t *fb_shift(int); +/* comm6.c */ +void newequate(item_t *, int); +void newident(item_t *, int); +void newlabel(item_t *); +void newsect(item_t *); +void newbase(valu_t); +void newcomm(item_t *, valu_t); +void switchsect(int); +void align(valu_t); +#ifdef RELOCATION +void newrelo(int, int); +#endif +long new_string(const char *); +void newsymb(const char *, int, int, valu_t); /* comm7.c */ -valu_t load(); -char *remember(); -FILE *ffcreat(); -FILE *fftemp(); +valu_t load(const item_t *); +int store(item_t *, valu_t); +char *remember(char *); +int combine(int, int, int); +#ifdef LISTING +int printx(int, valu_t); +void listline(int); +#endif +#ifdef THREE_PASS +int small(int, int); +#endif +void emit1(int); +void emit2(int); +void emit4(long); +void emitx(valu_t, int); +void emitstr(int); +void ffreopen(char *, FILE *); +FILE *ffcreat(char *); +FILE *fftemp(char *, char *); +void yyerror(const char *); +void nosect(void); void fatal(const char *, ...); void serror(const char *, ...); void warning(const char *, ...); +void nofit(void); /* ========== Machine dependent C declarations ========== */ diff --git a/mach/proto/as/comm4.c b/mach/proto/as/comm4.c index 473cb12e2..3e88c41ed 100644 --- a/mach/proto/as/comm4.c +++ b/mach/proto/as/comm4.c @@ -15,15 +15,23 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" +#include extern YYSTYPE yylval; -void setupoutput(); -void commfinish(); +static void pass_1(int, char **); +#ifdef ASLD +static void archive(void); +static int needed(void); +#endif +static void parse(char *); +static void pass_23(int); +static void setupoutput(void); +static void commfinish(void); /* ========== Machine independent C routines ========== */ -void stop() { +void stop(void) { #if DEBUG < 2 unlink(temppath); #ifdef LISTING @@ -33,11 +41,11 @@ 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 }; @@ -130,15 +138,15 @@ char **argv; /* ---------- pass 1: arguments, modules, archives ---------- */ -pass_1(argc, argv) -char **argv; +static void +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 @@ -198,7 +206,7 @@ char **argv; machfinish(PASS_1); #ifdef ASLD if (unresolved) { - register int i; + int i; nerrors++; fflush(stdout); @@ -224,8 +232,9 @@ char **argv; #ifdef ASLD -archive() { - register long offset; +static void +archive(void) { + long offset; struct ar_hdr header; char getsize[AR_TOTAL]; @@ -257,14 +266,15 @@ archive() { archmode = 0; } -needed() +static int +needed(void) { - register c, first; - register item_t *ip; - register need; + int c, first; + item_t *ip; + int need; #ifdef LISTING - register save; + int save; save = listflag; listflag = 0; #endif @@ -309,12 +319,12 @@ needed() } #endif /* ASLD */ -parse(s) -char *s; +static 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++ == '/') @@ -374,13 +384,14 @@ char *s; } } -pass_23(n) +static 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(); @@ -433,8 +444,8 @@ pass_23(n) machfinish(n); } -newmodule(s) -char *s; +void +newmodule(const char *s) { static char nmbuf[STRINGMAX]; @@ -461,13 +472,13 @@ char *s; #endif } -void -setupoutput() +static void +setupoutput(void) { - 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); @@ -497,16 +508,16 @@ setupoutput() outhead.oh_nchar = off; /* see newsymb() */ } -void -commfinish() +static void +commfinish(void) { #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); /* diff --git a/mach/proto/as/comm5.c b/mach/proto/as/comm5.c index 1fa84537d..447be2f91 100644 --- a/mach/proto/as/comm5.c +++ b/mach/proto/as/comm5.c @@ -17,7 +17,7 @@ static int inident(int); static int innumber(int); static int instring(int); static int inescape(void); -static int infbsym(char *); +static int infbsym(const char *); int yylex(void) @@ -85,9 +85,9 @@ yylex(void) 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 == (c & 0xffff)); switch (c) { @@ -163,9 +163,9 @@ putval(int 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: @@ -229,7 +229,7 @@ getval(int c) int nextchar(void) { - register c; + int c; if (peekc != -1) { c = peekc; @@ -254,7 +254,7 @@ nextchar(void) static void readcode(int n) { - register c; + int c; yylval.y_valu = 0; do { @@ -284,7 +284,7 @@ induo(int c) ('|'<<8) | '|', OP_OO, ('&'<<8) | '&', OP_AA, }; - register short *p; + short *p; c = (c<<8) | nextchar(); for (p = duo; *p; p++) @@ -299,9 +299,9 @@ static char name[NAMEMAX+1]; static 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) @@ -330,8 +330,8 @@ inident(int c) char * readident(int c) { - register n = NAMEMAX; - register char *p = name; + int n = NAMEMAX; + char *p = name; do { if (--n >= 0) @@ -347,8 +347,8 @@ readident(int c) static int innumber(int c) { - register char *p; - register radix; + char *p; + int radix; static char num[20+1]; p = num; @@ -394,8 +394,8 @@ innumber(int c) static int instring(int termc) { - register char *p; - register c; + char *p; + int c; static int maxstring = 0; if (! maxstring) { @@ -434,7 +434,7 @@ instring(int termc) static int inescape(void) { - register c, j, r; + int c, j, r; c = nextchar(); if (c >= '0' && c <= '7') { @@ -463,10 +463,10 @@ inescape(void) } static int -infbsym(char *p) +infbsym(const char *p) { - register lab; - register item_t *ip; + int lab; + item_t *ip; lab = *p++ - '0'; if ((unsigned)lab < 10) { @@ -490,10 +490,10 @@ ok: } int -hash(char *p) +hash(const char *p) { - register unsigned short h; - register c; + unsigned short h; + int c; h = 0; while (c = *p++) { @@ -504,10 +504,10 @@ hash(char *p) } item_t * -item_search(char *p) +item_search(const 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]; @@ -532,8 +532,8 @@ item_insert(item_t *ip, int h) item_t * item_alloc(int typ) { - register item_t *ip; - static nleft = 0; + item_t *ip; + static int nleft = 0; static item_t *next; if (--nleft < 0) { @@ -553,7 +553,7 @@ item_alloc(int typ) 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]; @@ -568,7 +568,7 @@ fb_alloc(int lab) item_t * fb_shift(int lab) { - register item_t *ip; + item_t *ip; ip = fb_ptr[FB_FORW+lab]; if (ip == 0) diff --git a/mach/proto/as/comm6.c b/mach/proto/as/comm6.c index fdbeb77ff..84cdbf72e 100644 --- a/mach/proto/as/comm6.c +++ b/mach/proto/as/comm6.c @@ -11,14 +11,12 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" +#include -void switchsect(); -void newsymb(); -void newident(); +static void new_common(item_t *); -newequate(ip, typ) -register item_t *ip; -register int typ; +void +newequate(item_t *ip, int typ) { typ &= ~S_EXT; if (typ & S_COM) @@ -39,10 +37,9 @@ register int typ; } void -newident(ip, typ) -register item_t *ip; +newident(item_t *ip, int typ) { - register flag; + int flag; #ifdef GENLAB static char genlab[] = GENLAB; #endif /* GENLAB */ @@ -80,12 +77,11 @@ register item_t *ip; } void -newlabel(ip) -register item_t *ip; +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 @@ -100,11 +96,11 @@ 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) { @@ -138,11 +134,11 @@ 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(); @@ -166,9 +162,8 @@ 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) @@ -190,10 +185,9 @@ valu_t val; } void -switchsect(newtyp) -int newtyp; +switchsect(int newtyp) { - register sect_t *sp; + sect_t *sp; if (sp = DOTSCT) sp->s_size = DOTVAL - sp->s_base; @@ -209,11 +203,11 @@ 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(); @@ -250,7 +244,7 @@ valu_t bytes; #ifdef RELOCATION void -newrelo(s, n) +newrelo(int s, int n) { int iscomm; struct outrelo outrelo; @@ -319,8 +313,7 @@ newrelo(s, n) #endif long -new_string(s) - char *s; +new_string(const char *s) { long r = 0; @@ -335,9 +328,7 @@ new_string(s) } void -newsymb(name, type, desc, valu) -register char *name; -valu_t valu; +newsymb(const char *name, int type, int desc, valu_t valu) { struct outname outname; @@ -357,11 +348,11 @@ valu_t valu; wr_name(&outname, 1); } -new_common(ip) - item_t *ip; +static void +new_common(item_t *ip) { - register struct common_t *cp; - static nleft = 0; + struct common_t *cp; + static int nleft = 0; static struct common_t *next; if (--nleft < 0) { diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index e95037305..ace23620b 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -11,14 +11,14 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" -#include +#include +#include valu_t -load(ip) -register item_t *ip; +load(const 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 */ @@ -37,12 +37,11 @@ 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) @@ -57,12 +56,11 @@ valu_t val; } char * -remember(s) -register char *s; +remember(char *s) { - register char *p; - register n; - static nleft = 0; + char *p; + int n; + static int nleft = 0; static char *next; p = s; @@ -85,8 +83,8 @@ register char *s; return(s); } -combine(typ1, typ2, op) -register typ1, typ2; +int +combine(int typ1, int typ2, int op) { switch (op) { case '+': @@ -122,12 +120,12 @@ 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 { @@ -140,12 +138,11 @@ valu_t val; } while (p > buf); return(ndig); } -#endif -#ifdef LISTING -listline(textline) +void +listline(int textline) { - register c; + int c; if ((listflag & 4) && (c = getc(listfile)) != '\n' && textline) { if (listcolm >= 24) @@ -176,10 +173,11 @@ 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(); @@ -231,7 +229,8 @@ small(fitsmall, gain) /* ---------- output ---------- */ -emit1(arg) +void +emit1(int arg) { static int olddottyp = -1; #ifdef LISTING @@ -269,8 +268,8 @@ emit1(arg) DOTVAL++; } -emit2(arg) -int arg; +void +emit2(int arg) { #ifdef BYTES_REVERSED emit1((arg>>8)); emit1(arg); @@ -279,8 +278,8 @@ int arg; #endif } -emit4(arg) -long arg; +void +emit4(long arg) { #ifdef WORDS_REVERSED emit2((int)(arg>>16)); emit2((int)(arg)); @@ -289,9 +288,8 @@ long arg; #endif } -emitx(val, n) -valu_t val; -int n; +void +emitx(valu_t val, int n) { switch (n) { case RELO1: @@ -315,10 +313,11 @@ int n; } } -emitstr(zero) +void +emitstr(int zero) { - register i; - register char *p; + int i; + char *p; p = stringbuf; i = stringlen; @@ -330,17 +329,15 @@ 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; +ffcreat(char *s) { FILE *f; @@ -355,10 +352,9 @@ char *s; char *tmp_dir = TMPDIR; FILE * -fftemp(path, tail) -char *path, *tail; +fftemp(char *path, char *tail) { - register char *dir; + char *dir; if ((dir = getenv("TMPDIR")) == NULL) dir = tmp_dir; @@ -369,20 +365,24 @@ char *path, *tail; /* ---------- Error handling ---------- */ -/*VARARGS*/ -yyerror(){} /* we will do our own error printing */ +/* ARGSUSED */ +void +yyerror(const char *message) +{} /* we will do our own error printing */ -nosect() +void +nosect(void) { fatal("no sections"); } -wr_fatal() +void +wr_fatal(void) { fatal("write error"); } -void diag(const char* tail, const char* s, va_list ap) +static void diag(const char* tail, const char* s, va_list ap) { fflush(stdout); if (modulename) @@ -422,6 +422,7 @@ assert1() } #endif +/* VARARGS1 */ void serror(const char* s, ...) { va_list ap; @@ -447,7 +448,8 @@ void warning(const char* s, ...) va_end(ap); } -nofit() +void +nofit(void) { if (pass == PASS_3) warning("too big");