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.
This commit is contained in:
George Koehler 2017-11-10 23:30:46 -05:00
parent 3463f0c944
commit d347207e60
5 changed files with 213 additions and 172 deletions

View file

@ -104,6 +104,11 @@ extern struct outhead outhead;
extern int curr_token; extern int curr_token;
/* forward function declarations */ /* forward function declarations */
/* comm2.y */
void yyparse(void);
/* comm4.c */
void stop(void);
void newmodule(const char *);
/* comm5.c */ /* comm5.c */
int yylex(void); int yylex(void);
void putval(int); void putval(int);
@ -112,20 +117,52 @@ int nextchar(void);
#ifdef ASLD #ifdef ASLD
char *readident(int); char *readident(int);
#endif #endif
int hash(char *); int hash(const char *);
item_t *item_search(char *); item_t *item_search(const char *);
void item_insert(item_t *, int); void item_insert(item_t *, int);
item_t *item_alloc(int); item_t *item_alloc(int);
item_t *fb_alloc(int); item_t *fb_alloc(int);
item_t *fb_shift(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 */ /* comm7.c */
valu_t load(); valu_t load(const item_t *);
char *remember(); int store(item_t *, valu_t);
FILE *ffcreat(); char *remember(char *);
FILE *fftemp(); 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 fatal(const char *, ...);
void serror(const char *, ...); void serror(const char *, ...);
void warning(const char *, ...); void warning(const char *, ...);
void nofit(void);
/* ========== Machine dependent C declarations ========== */ /* ========== Machine dependent C declarations ========== */

View file

@ -15,15 +15,23 @@
#include "comm0.h" #include "comm0.h"
#include "comm1.h" #include "comm1.h"
#include "y.tab.h" #include "y.tab.h"
#include <object.h>
extern YYSTYPE yylval; extern YYSTYPE yylval;
void setupoutput(); static void pass_1(int, char **);
void commfinish(); #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 ========== */ /* ========== Machine independent C routines ========== */
void stop() { void stop(void) {
#if DEBUG < 2 #if DEBUG < 2
unlink(temppath); unlink(temppath);
#ifdef LISTING #ifdef LISTING
@ -33,11 +41,11 @@ void stop() {
exit(nerrors != 0); exit(nerrors != 0);
} }
main(argc, argv) int
char **argv; main(int argc, char **argv)
{ {
register char *p; char *p;
register i; int i;
static char sigs[] = { static char sigs[] = {
SIGHUP, SIGINT, SIGQUIT, SIGTERM, 0 SIGHUP, SIGINT, SIGQUIT, SIGTERM, 0
}; };
@ -130,15 +138,15 @@ char **argv;
/* ---------- pass 1: arguments, modules, archives ---------- */ /* ---------- pass 1: arguments, modules, archives ---------- */
pass_1(argc, argv) static void
char **argv; pass_1(int argc, char **argv)
{ {
register char *p; char *p;
register item_t *ip; item_t *ip;
#ifdef ASLD #ifdef ASLD
char armagic[2]; char armagic[2];
#else #else
register nfile = 0; int nfile = 0;
#endif #endif
#ifdef THREE_PASS #ifdef THREE_PASS
@ -198,7 +206,7 @@ char **argv;
machfinish(PASS_1); machfinish(PASS_1);
#ifdef ASLD #ifdef ASLD
if (unresolved) { if (unresolved) {
register int i; int i;
nerrors++; nerrors++;
fflush(stdout); fflush(stdout);
@ -224,8 +232,9 @@ char **argv;
#ifdef ASLD #ifdef ASLD
archive() { static void
register long offset; archive(void) {
long offset;
struct ar_hdr header; struct ar_hdr header;
char getsize[AR_TOTAL]; char getsize[AR_TOTAL];
@ -257,14 +266,15 @@ archive() {
archmode = 0; archmode = 0;
} }
needed() static int
needed(void)
{ {
register c, first; int c, first;
register item_t *ip; item_t *ip;
register need; int need;
#ifdef LISTING #ifdef LISTING
register save; int save;
save = listflag; listflag = 0; save = listflag; listflag = 0;
#endif #endif
@ -309,12 +319,12 @@ needed()
} }
#endif /* ASLD */ #endif /* ASLD */
parse(s) static void
char *s; parse(char *s)
{ {
register i; int i;
register item_t *ip; item_t *ip;
register char *p; char *p;
for (p = s; *p; ) for (p = s; *p; )
if (*p++ == '/') if (*p++ == '/')
@ -374,13 +384,14 @@ char *s;
} }
} }
pass_23(n) static void
pass_23(int n)
{ {
register i; int i;
#ifdef ASLD #ifdef ASLD
register ADDR_T base = 0; ADDR_T base = 0;
#endif #endif
register sect_t *sp; sect_t *sp;
if (nerrors) if (nerrors)
stop(); stop();
@ -433,8 +444,8 @@ pass_23(n)
machfinish(n); machfinish(n);
} }
newmodule(s) void
char *s; newmodule(const char *s)
{ {
static char nmbuf[STRINGMAX]; static char nmbuf[STRINGMAX];
@ -461,13 +472,13 @@ char *s;
#endif #endif
} }
void static void
setupoutput() setupoutput(void)
{ {
register sect_t *sp; sect_t *sp;
register long off; long off;
struct outsect outsect; struct outsect outsect;
register struct outsect *pos = &outsect; struct outsect *pos = &outsect;
if (! wr_open(aoutpath)) { if (! wr_open(aoutpath)) {
fatal("can't create %s", aoutpath); fatal("can't create %s", aoutpath);
@ -497,16 +508,16 @@ setupoutput()
outhead.oh_nchar = off; /* see newsymb() */ outhead.oh_nchar = off; /* see newsymb() */
} }
void static void
commfinish() commfinish(void)
{ {
#ifndef ASLD #ifndef ASLD
register int i; int i;
#endif #endif
register struct common_t *cp; struct common_t *cp;
register item_t *ip; item_t *ip;
register sect_t *sp; sect_t *sp;
register valu_t addr; valu_t addr;
switchsect(S_UND); switchsect(S_UND);
/* /*

View file

@ -17,7 +17,7 @@ static int inident(int);
static int innumber(int); static int innumber(int);
static int instring(int); static int instring(int);
static int inescape(void); static int inescape(void);
static int infbsym(char *); static int infbsym(const char *);
int int
yylex(void) yylex(void)
@ -85,9 +85,9 @@ yylex(void)
void void
putval(int c) putval(int c)
{ {
register valu_t v; valu_t v;
register n = 0; int n = 0;
register char *p = 0; char *p = 0;
assert(c == (c & 0xffff)); assert(c == (c & 0xffff));
switch (c) { switch (c) {
@ -163,9 +163,9 @@ putval(int c)
int int
getval(int c) getval(int c)
{ {
register n = 0; int n = 0;
register valu_t v; valu_t v;
register char *p = 0; char *p = 0;
switch (c) { switch (c) {
case CODE1: case CODE1:
@ -229,7 +229,7 @@ getval(int c)
int int
nextchar(void) nextchar(void)
{ {
register c; int c;
if (peekc != -1) { if (peekc != -1) {
c = peekc; c = peekc;
@ -254,7 +254,7 @@ nextchar(void)
static void static void
readcode(int n) readcode(int n)
{ {
register c; int c;
yylval.y_valu = 0; yylval.y_valu = 0;
do { do {
@ -284,7 +284,7 @@ induo(int c)
('|'<<8) | '|', OP_OO, ('|'<<8) | '|', OP_OO,
('&'<<8) | '&', OP_AA, ('&'<<8) | '&', OP_AA,
}; };
register short *p; short *p;
c = (c<<8) | nextchar(); c = (c<<8) | nextchar();
for (p = duo; *p; p++) for (p = duo; *p; p++)
@ -299,9 +299,9 @@ static char name[NAMEMAX+1];
static int static int
inident(int c) inident(int c)
{ {
register char *p = name; char *p = name;
register item_t *ip; item_t *ip;
register n = NAMEMAX; int n = NAMEMAX;
do { do {
if (--n >= 0) if (--n >= 0)
@ -330,8 +330,8 @@ inident(int c)
char * char *
readident(int c) readident(int c)
{ {
register n = NAMEMAX; int n = NAMEMAX;
register char *p = name; char *p = name;
do { do {
if (--n >= 0) if (--n >= 0)
@ -347,8 +347,8 @@ readident(int c)
static int static int
innumber(int c) innumber(int c)
{ {
register char *p; char *p;
register radix; int radix;
static char num[20+1]; static char num[20+1];
p = num; p = num;
@ -394,8 +394,8 @@ innumber(int c)
static int static int
instring(int termc) instring(int termc)
{ {
register char *p; char *p;
register c; int c;
static int maxstring = 0; static int maxstring = 0;
if (! maxstring) { if (! maxstring) {
@ -434,7 +434,7 @@ instring(int termc)
static int static int
inescape(void) inescape(void)
{ {
register c, j, r; int c, j, r;
c = nextchar(); c = nextchar();
if (c >= '0' && c <= '7') { if (c >= '0' && c <= '7') {
@ -463,10 +463,10 @@ inescape(void)
} }
static int static int
infbsym(char *p) infbsym(const char *p)
{ {
register lab; int lab;
register item_t *ip; item_t *ip;
lab = *p++ - '0'; lab = *p++ - '0';
if ((unsigned)lab < 10) { if ((unsigned)lab < 10) {
@ -490,10 +490,10 @@ ok:
} }
int int
hash(char *p) hash(const char *p)
{ {
register unsigned short h; unsigned short h;
register c; int c;
h = 0; h = 0;
while (c = *p++) { while (c = *p++) {
@ -504,10 +504,10 @@ hash(char *p)
} }
item_t * item_t *
item_search(char *p) item_search(const char *p)
{ {
register h; int h;
register item_t *ip; item_t *ip;
for (h = hash(p); h < H_TOTAL; h += H_SIZE) { for (h = hash(p); h < H_TOTAL; h += H_SIZE) {
ip = hashtab[h]; ip = hashtab[h];
@ -532,8 +532,8 @@ item_insert(item_t *ip, int h)
item_t * item_t *
item_alloc(int typ) item_alloc(int typ)
{ {
register item_t *ip; item_t *ip;
static nleft = 0; static int nleft = 0;
static item_t *next; static item_t *next;
if (--nleft < 0) { if (--nleft < 0) {
@ -553,7 +553,7 @@ item_alloc(int typ)
item_t * item_t *
fb_alloc(int lab) fb_alloc(int lab)
{ {
register item_t *ip, *p; item_t *ip, *p;
ip = item_alloc(S_UND); ip = item_alloc(S_UND);
p = fb_ptr[FB_TAIL+lab]; p = fb_ptr[FB_TAIL+lab];
@ -568,7 +568,7 @@ fb_alloc(int lab)
item_t * item_t *
fb_shift(int lab) fb_shift(int lab)
{ {
register item_t *ip; item_t *ip;
ip = fb_ptr[FB_FORW+lab]; ip = fb_ptr[FB_FORW+lab];
if (ip == 0) if (ip == 0)

View file

@ -11,14 +11,12 @@
#include "comm0.h" #include "comm0.h"
#include "comm1.h" #include "comm1.h"
#include "y.tab.h" #include "y.tab.h"
#include <object.h>
void switchsect(); static void new_common(item_t *);
void newsymb();
void newident();
newequate(ip, typ) void
register item_t *ip; newequate(item_t *ip, int typ)
register int typ;
{ {
typ &= ~S_EXT; typ &= ~S_EXT;
if (typ & S_COM) if (typ & S_COM)
@ -39,10 +37,9 @@ register int typ;
} }
void void
newident(ip, typ) newident(item_t *ip, int typ)
register item_t *ip;
{ {
register flag; int flag;
#ifdef GENLAB #ifdef GENLAB
static char genlab[] = GENLAB; static char genlab[] = GENLAB;
#endif /* GENLAB */ #endif /* GENLAB */
@ -80,12 +77,11 @@ register item_t *ip;
} }
void void
newlabel(ip) newlabel(item_t *ip)
register item_t *ip;
{ {
#if DEBUG != 0 #if DEBUG != 0
#ifdef THREE_PASS #ifdef THREE_PASS
register ADDR_T oldval = ip->i_valu; ADDR_T oldval = ip->i_valu;
#endif #endif
#endif #endif
@ -100,11 +96,11 @@ register item_t *ip;
#endif #endif
} }
newsect(ip) void
register item_t *ip; newsect(item_t *ip)
{ {
register int typ; int typ;
register sect_t *sp = NULL; sect_t *sp = NULL;
typ = ip->i_type & S_TYP; typ = ip->i_type & S_TYP;
if (typ == S_UND) { if (typ == S_UND) {
@ -138,11 +134,11 @@ register item_t *ip;
} }
/*ARGSUSED*/ /*ARGSUSED*/
newbase(base) void
valu_t base; newbase(valu_t base)
{ {
#ifdef ASLD #ifdef ASLD
register sect_t *sp; sect_t *sp;
if ((sp = DOTSCT) == NULL) if ((sp = DOTSCT) == NULL)
nosect(); nosect();
@ -166,9 +162,8 @@ valu_t base;
* - maximum length of .comm is recorded in i_valu during PASS_1 * - maximum length of .comm is recorded in i_valu during PASS_1
* - i_valu is used for relocation info during PASS_3 * - i_valu is used for relocation info during PASS_3
*/ */
newcomm(ip, val) void
register item_t *ip; newcomm(item_t *ip, valu_t val)
valu_t val;
{ {
if (pass == PASS_1) { if (pass == PASS_1) {
if (DOTSCT == NULL) if (DOTSCT == NULL)
@ -190,10 +185,9 @@ valu_t val;
} }
void void
switchsect(newtyp) switchsect(int newtyp)
int newtyp;
{ {
register sect_t *sp; sect_t *sp;
if (sp = DOTSCT) if (sp = DOTSCT)
sp->s_size = DOTVAL - sp->s_base; sp->s_size = DOTVAL - sp->s_base;
@ -209,11 +203,11 @@ int newtyp;
DOTTYP = newtyp; DOTTYP = newtyp;
} }
align(bytes) void
valu_t bytes; align(valu_t bytes)
{ {
register valu_t gap; valu_t gap;
register sect_t *sp; sect_t *sp;
if ((sp = DOTSCT) == NULL) if ((sp = DOTSCT) == NULL)
nosect(); nosect();
@ -250,7 +244,7 @@ valu_t bytes;
#ifdef RELOCATION #ifdef RELOCATION
void void
newrelo(s, n) newrelo(int s, int n)
{ {
int iscomm; int iscomm;
struct outrelo outrelo; struct outrelo outrelo;
@ -319,8 +313,7 @@ newrelo(s, n)
#endif #endif
long long
new_string(s) new_string(const char *s)
char *s;
{ {
long r = 0; long r = 0;
@ -335,9 +328,7 @@ new_string(s)
} }
void void
newsymb(name, type, desc, valu) newsymb(const char *name, int type, int desc, valu_t valu)
register char *name;
valu_t valu;
{ {
struct outname outname; struct outname outname;
@ -357,11 +348,11 @@ valu_t valu;
wr_name(&outname, 1); wr_name(&outname, 1);
} }
new_common(ip) static void
item_t *ip; new_common(item_t *ip)
{ {
register struct common_t *cp; struct common_t *cp;
static nleft = 0; static int nleft = 0;
static struct common_t *next; static struct common_t *next;
if (--nleft < 0) { if (--nleft < 0) {

View file

@ -11,14 +11,14 @@
#include "comm0.h" #include "comm0.h"
#include "comm1.h" #include "comm1.h"
#include "y.tab.h" #include "y.tab.h"
#include <stdarg.h> #include <stdarg.h>
#include <object.h>
valu_t valu_t
load(ip) load(const item_t *ip)
register item_t *ip;
{ {
#ifdef ASLD #ifdef ASLD
register typ; int typ;
typ = ip->i_type & S_TYP; typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */ if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */
@ -37,12 +37,11 @@ register item_t *ip;
#endif #endif
} }
store(ip, val) int
register item_t *ip; store(item_t *ip, valu_t val)
valu_t val;
{ {
#ifdef ASLD #ifdef ASLD
register typ; int typ;
typ = ip->i_type & S_TYP; typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) >= 0) if ((typ -= S_MIN) >= 0)
@ -57,12 +56,11 @@ valu_t val;
} }
char * char *
remember(s) remember(char *s)
register char *s;
{ {
register char *p; char *p;
register n; int n;
static nleft = 0; static int nleft = 0;
static char *next; static char *next;
p = s; p = s;
@ -85,8 +83,8 @@ register char *s;
return(s); return(s);
} }
combine(typ1, typ2, op) int
register typ1, typ2; combine(int typ1, int typ2, int op)
{ {
switch (op) { switch (op) {
case '+': case '+':
@ -122,12 +120,12 @@ register typ1, typ2;
} }
#ifdef LISTING #ifdef LISTING
printx(ndig, val) int
valu_t val; printx(int ndig, valu_t val)
{ {
static char buf[8]; static char buf[8];
register char *p; char *p;
register c, n; int c, n;
p = buf; n = ndig; p = buf; n = ndig;
do { do {
@ -140,12 +138,11 @@ valu_t val;
} while (p > buf); } while (p > buf);
return(ndig); return(ndig);
} }
#endif
#ifdef LISTING void
listline(textline) listline(int textline)
{ {
register c; int c;
if ((listflag & 4) && (c = getc(listfile)) != '\n' && textline) { if ((listflag & 4) && (c = getc(listfile)) != '\n' && textline) {
if (listcolm >= 24) if (listcolm >= 24)
@ -176,10 +173,11 @@ listline(textline)
#define PBITTABSZ 128 #define PBITTABSZ 128
static char *pbittab[PBITTABSZ]; static char *pbittab[PBITTABSZ];
small(fitsmall, gain) int
small(int fitsmall, int gain)
{ {
register bit; int bit;
register char *p; char *p;
if (DOTSCT == NULL) if (DOTSCT == NULL)
nosect(); nosect();
@ -231,7 +229,8 @@ small(fitsmall, gain)
/* ---------- output ---------- */ /* ---------- output ---------- */
emit1(arg) void
emit1(int arg)
{ {
static int olddottyp = -1; static int olddottyp = -1;
#ifdef LISTING #ifdef LISTING
@ -269,8 +268,8 @@ emit1(arg)
DOTVAL++; DOTVAL++;
} }
emit2(arg) void
int arg; emit2(int arg)
{ {
#ifdef BYTES_REVERSED #ifdef BYTES_REVERSED
emit1((arg>>8)); emit1(arg); emit1((arg>>8)); emit1(arg);
@ -279,8 +278,8 @@ int arg;
#endif #endif
} }
emit4(arg) void
long arg; emit4(long arg)
{ {
#ifdef WORDS_REVERSED #ifdef WORDS_REVERSED
emit2((int)(arg>>16)); emit2((int)(arg)); emit2((int)(arg>>16)); emit2((int)(arg));
@ -289,9 +288,8 @@ long arg;
#endif #endif
} }
emitx(val, n) void
valu_t val; emitx(valu_t val, int n)
int n;
{ {
switch (n) { switch (n) {
case RELO1: case RELO1:
@ -315,10 +313,11 @@ int n;
} }
} }
emitstr(zero) void
emitstr(int zero)
{ {
register i; int i;
register char *p; char *p;
p = stringbuf; p = stringbuf;
i = stringlen; i = stringlen;
@ -330,17 +329,15 @@ emitstr(zero)
/* ---------- Error checked file I/O ---------- */ /* ---------- Error checked file I/O ---------- */
ffreopen(s, f) void
char *s; ffreopen(char *s, FILE *f)
FILE *f;
{ {
if (freopen(s, "r", f) == NULL) if (freopen(s, "r", f) == NULL)
fatal("can't reopen %s", s); fatal("can't reopen %s", s);
} }
FILE * FILE *
ffcreat(s) ffcreat(char *s)
char *s;
{ {
FILE *f; FILE *f;
@ -355,10 +352,9 @@ char *s;
char *tmp_dir = TMPDIR; char *tmp_dir = TMPDIR;
FILE * FILE *
fftemp(path, tail) fftemp(char *path, char *tail)
char *path, *tail;
{ {
register char *dir; char *dir;
if ((dir = getenv("TMPDIR")) == NULL) if ((dir = getenv("TMPDIR")) == NULL)
dir = tmp_dir; dir = tmp_dir;
@ -369,20 +365,24 @@ char *path, *tail;
/* ---------- Error handling ---------- */ /* ---------- Error handling ---------- */
/*VARARGS*/ /* ARGSUSED */
yyerror(){} /* we will do our own error printing */ void
yyerror(const char *message)
{} /* we will do our own error printing */
nosect() void
nosect(void)
{ {
fatal("no sections"); fatal("no sections");
} }
wr_fatal() void
wr_fatal(void)
{ {
fatal("write error"); 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); fflush(stdout);
if (modulename) if (modulename)
@ -422,6 +422,7 @@ assert1()
} }
#endif #endif
/* VARARGS1 */
void serror(const char* s, ...) void serror(const char* s, ...)
{ {
va_list ap; va_list ap;
@ -447,7 +448,8 @@ void warning(const char* s, ...)
va_end(ap); va_end(ap);
} }
nofit() void
nofit(void)
{ {
if (pass == PASS_3) if (pass == PASS_3)
warning("too big"); warning("too big");