Ansification and warning fixes.

This commit is contained in:
David Given 2017-08-06 11:58:36 +02:00
parent a1043bc5fe
commit 60e7d06d82
10 changed files with 79 additions and 101 deletions

View file

@ -19,7 +19,7 @@ struct f_info file_info;
#include <inp_pkg.body> #include <inp_pkg.body>
AtEoIF() int AtEoIF(void)
{ {
/* Make the unstacking of input streams noticable to the /* Make the unstacking of input streams noticable to the
lexical analyzer lexical analyzer
@ -28,7 +28,7 @@ AtEoIF()
return 1; return 1;
} }
AtEoIT() int AtEoIT(void)
{ {
/* Make the end of the text noticable /* Make the end of the text noticable
*/ */

View file

@ -8,7 +8,7 @@
inserted file. inserted file.
*/ */
int int
AtEoIF() AtEoIF(void)
{ {
return 0; return 0;
} }

View file

@ -8,7 +8,7 @@
inserted text. inserted text.
*/ */
int int
AtEoIT() AtEoIT(void)
{ {
return 0; return 0;
} }

View file

@ -110,7 +110,7 @@ INP_rdfile(fd, fn, size, pbuf)
int rsize; int rsize;
if ( if (
(*size = sys_filesize(fn)) < 0 ((*size = sys_filesize(fn))) < 0
|| ||
((unsigned) (*size + 1) != (*size + 1)) ((unsigned) (*size + 1) != (*size + 1))
|| ||
@ -164,7 +164,7 @@ INP_push_bh()
{ {
register struct INP_buffer_header *bh; register struct INP_buffer_header *bh;
if (bh = INP_head) { if ((bh = INP_head)) {
bh->bh_ipp = _ipp; bh->bh_ipp = _ipp;
#ifdef INP_TYPE #ifdef INP_TYPE
bh->bh_i = INP_VAR; bh->bh_i = INP_VAR;
@ -247,10 +247,10 @@ INP_mk_filename(dir, file, newname)
if (!dst) return 0; if (!dst) return 0;
*newname = dst; *newname = dst;
if (*dir) { if (*dir) {
while (*dst++ = *dir++) ; while ((*dst++ = *dir++)) ;
*(dst-1) = '/'; *(dst-1) = '/';
} }
while (*dst++ = *file++); while ((*dst++ = *file++));
return 1; return 1;
} }

View file

@ -36,7 +36,7 @@ void rd_sect(struct outsect *s, unsigned int c);
void rd_outsect(int sectno); void rd_outsect(int sectno);
void rd_emit(char *b, long c); void rd_emit(char *b, long c);
void rd_relo(struct outrelo *r, unsigned int c); void rd_relo(struct outrelo *r, unsigned int c);
void rd_rew_relo(struct outhead *head); void rd_rew_relos(struct outhead *head);
void rd_name(struct outname *n, unsigned int c); void rd_name(struct outname *n, unsigned int c);
void rd_string(char *s, long c); void rd_string(char *s, long c);
int rd_arhdr(int fd, struct ar_hdr *a); int rd_arhdr(int fd, struct ar_hdr *a);

View file

@ -40,9 +40,7 @@ static long rd_base;
static int sectionnr; static int sectionnr;
static void static void
OUTREAD(p, b, n) OUTREAD(int p, char* b, long n)
char *b;
long n;
{ {
register long l = outseek[p]; register long l = outseek[p];
@ -59,8 +57,7 @@ OUTREAD(p, b, n)
* Open the output file according to the chosen strategy. * Open the output file according to the chosen strategy.
*/ */
int int
rd_open(f) rd_open(char* f)
char *f;
{ {
if ((outfile = open(f, 0)) < 0) if ((outfile = open(f, 0)) < 0)
@ -71,7 +68,7 @@ rd_open(f)
static int offcnt; static int offcnt;
int int
rd_fdopen(fd) rd_fdopen(int fd)
{ {
register int i; register int i;
@ -89,7 +86,7 @@ rd_fdopen(fd)
} }
void void
rd_close() rd_close(void)
{ {
close(outfile); close(outfile);
@ -97,14 +94,13 @@ rd_close()
} }
int int
rd_fd() rd_fd(void)
{ {
return outfile; return outfile;
} }
void void
rd_ohead(head) rd_ohead(struct outhead* head)
register struct outhead *head;
{ {
register long off; register long off;
@ -134,8 +130,7 @@ rd_ohead(head)
} }
void void
rd_rew_relos(head) rd_rew_relos(struct outhead* head)
register struct outhead *head;
{ {
register long off = OFF_RELO(*head) + rd_base; register long off = OFF_RELO(*head) + rd_base;
@ -143,9 +138,7 @@ rd_rew_relos(head)
} }
void void
rd_sect(sect, cnt) rd_sect(struct outsect* sect, unsigned int cnt)
register struct outsect *sect;
register unsigned int cnt;
{ {
register char *c = (char *) sect + cnt * SZ_SECT; register char *c = (char *) sect + cnt * SZ_SECT;
@ -166,7 +159,7 @@ rd_sect(sect, cnt)
} }
void void
rd_outsect(s) rd_outsect(int s)
{ {
OUTSECT(s); OUTSECT(s);
sectionnr = s; sectionnr = s;
@ -176,18 +169,14 @@ rd_outsect(s)
* We don't have to worry about byte order here. * We don't have to worry about byte order here.
*/ */
void void
rd_emit(emit, cnt) rd_emit(char* emit, long cnt)
char *emit;
long cnt;
{ {
OUTREAD(PARTEMIT, emit, cnt); OUTREAD(PARTEMIT, emit, cnt);
offset[sectionnr] += cnt; offset[sectionnr] += cnt;
} }
void void
rd_relo(relo, cnt) rd_relo(struct outrelo* relo, unsigned int cnt)
register struct outrelo *relo;
register unsigned int cnt;
{ {
OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
@ -206,9 +195,7 @@ rd_relo(relo, cnt)
} }
void void
rd_name(name, cnt) rd_name(struct outname* name, unsigned int cnt)
register struct outname *name;
register unsigned int cnt;
{ {
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME); OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
@ -227,9 +214,7 @@ rd_name(name, cnt)
} }
void void
rd_string(addr, len) rd_string(char* addr, long len)
char *addr;
long len;
{ {
OUTREAD(PARTCHAR, addr, len); OUTREAD(PARTCHAR, addr, len);
@ -237,9 +222,7 @@ rd_string(addr, len)
#ifdef SYMDBUG #ifdef SYMDBUG
void void
rd_dbug(buf, size) rd_dbug(char* buf, long size)
char *buf;
long size;
{ {
OUTREAD(PARTDBUG, buf, size); OUTREAD(PARTDBUG, buf, size);
} }

View file

@ -473,8 +473,8 @@ free_saved_moduls()
* The piece of memory with index `piece' is no longer needed. * The piece of memory with index `piece' is no longer needed.
* We take care that it can be used by compact() later, if needed. * We take care that it can be used by compact() later, if needed.
*/ */
dealloc(piece) void
register int piece; dealloc(int piece)
{ {
/* /*
* Some pieces need their memory throughout the program. * Some pieces need their memory throughout the program.
@ -499,9 +499,7 @@ core_alloc(piece, size)
return address(piece, off); return address(piece, off);
} }
core_free(piece, p) void core_free(int piece, char* p)
int piece;
char *p;
{ {
char *q = address(piece, mems[piece].mem_full); char *q = address(piece, mems[piece].mem_full);

View file

@ -40,3 +40,5 @@ extern struct memory mems[];
extern ind_t core_position; extern ind_t core_position;
extern ind_t hard_alloc(); extern ind_t hard_alloc();
extern ind_t alloc(); extern ind_t alloc();
extern void dealloc(int piece);
extern void core_free(int piece, char* p);

View file

@ -10,13 +10,17 @@ static char rcsid[] = "$Id$";
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef SYMDBUG #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef SYMDBUG
#endif /* SYMDBUG */ #endif /* SYMDBUG */
#include "arch.h" #include "arch.h"
#include "out.h" #include "out.h"
#include "ranlib.h" #include "ranlib.h"
#include "object.h"
#include "const.h" #include "const.h"
#include "assert.h" #include "assert.h"
#include "memory.h" #include "memory.h"
@ -42,20 +46,21 @@ char *modulname; /* Name of object module. */
long objectsize; long objectsize;
#endif /* SYMDBUG */ #endif /* SYMDBUG */
static long align(); static long align(long size);
static char *modulbase; static char *modulbase;
static long modulsize(); static long modulsize(struct outhead* head);
static scan_modul(); static void can_modul(void);
static bool all_alloc(); static bool all_alloc(void);
static bool direct_alloc(); static bool direct_alloc(struct outhead* head);
static bool indirect_alloc(); static bool indirect_alloc(struct outhead* head);
static bool putemitindex(); static bool putemitindex(ind_t sectindex, ind_t emitoff, int allopiece);
static bool putreloindex(); static bool putreloindex(ind_t relooff, long nrelobytes);
#ifdef SYMDBUG #ifdef SYMDBUG
static bool putdbugindex(); static bool putdbugindex(ind_t dbugoff, long ndbugbytes);
#endif /* SYMDBUG */ #endif /* SYMDBUG */
static get_indirect(); static void get_indirect(struct outhead* head, struct outsect* sect);
static read_modul(); static void read_modul(void);
static void scan_modul(void);
/* /*
* Open the file with name `filename' (if necessary) and examine the first * Open the file with name `filename' (if necessary) and examine the first
@ -117,16 +122,13 @@ getfile(filename)
/* NOTREACHED */ /* NOTREACHED */
} }
/* ARGSUSED */ void closefile(char* filename)
closefile(filename)
char *filename;
{ {
if (passnumber == FIRST || !incore) if (passnumber == FIRST || !incore)
close(infile); close(infile);
} }
get_archive_header(archive_header) void get_archive_header(struct ar_hdr* archive_header)
register struct ar_hdr *archive_header;
{ {
if (passnumber == FIRST || !incore) { if (passnumber == FIRST || !incore) {
rd_arhdr(infile, archive_header); rd_arhdr(infile, archive_header);
@ -141,7 +143,7 @@ get_archive_header(archive_header)
#endif /* SYMDBUG */ #endif /* SYMDBUG */
} }
get_modul() void get_modul(void)
{ {
if (passnumber == FIRST) { if (passnumber == FIRST) {
rd_fdopen(infile); rd_fdopen(infile);
@ -157,8 +159,8 @@ get_modul()
* to keep everything in core is abandoned, but we will always put the header, * to keep everything in core is abandoned, but we will always put the header,
* the section table, and the name and string table into core. * the section table, and the name and string table into core.
*/ */
static static void
scan_modul() scan_modul(void)
{ {
bool space; bool space;
struct outhead *head; struct outhead *head;
@ -190,7 +192,7 @@ scan_modul()
* this was possible. * this was possible.
*/ */
static bool static bool
all_alloc() all_alloc(void)
{ {
struct outhead head; struct outhead head;
extern ind_t hard_alloc(); extern ind_t hard_alloc();
@ -287,10 +289,7 @@ indirect_alloc(head)
* `emitoff'. * `emitoff'.
*/ */
static bool static bool
putemitindex(sectindex, emitoff, allopiece) putemitindex(ind_t sectindex, ind_t emitoff, int allopiece)
ind_t sectindex;
ind_t emitoff;
int allopiece;
{ {
long flen; long flen;
ind_t emitindex; ind_t emitindex;
@ -330,9 +329,7 @@ putemitindex(sectindex, emitoff, allopiece)
* offset at `relooff'. * offset at `relooff'.
*/ */
static bool static bool
putreloindex(relooff, nrelobytes) putreloindex(ind_t relooff, long nrelobytes)
ind_t relooff;
long nrelobytes;
{ {
ind_t reloindex; ind_t reloindex;
extern ind_t alloc(); extern ind_t alloc();
@ -348,9 +345,7 @@ putreloindex(relooff, nrelobytes)
* Allocate space for debugging information and put the offset at `dbugoff'. * Allocate space for debugging information and put the offset at `dbugoff'.
*/ */
static bool static bool
putdbugindex(dbugoff, ndbugbytes) putdbugindex(ind_t dbugoff, long ndbugbytes)
ind_t relooff;
long ndbugbytes;
{ {
ind_t dbugindex; ind_t dbugindex;
extern ind_t alloc(); extern ind_t alloc();
@ -367,12 +362,8 @@ putdbugindex(dbugoff, ndbugbytes)
* Compute addresses and read in. Remember that the contents of the sections * Compute addresses and read in. Remember that the contents of the sections
* and also the relocation table are accessed indirectly. * and also the relocation table are accessed indirectly.
*/ */
static static void
get_indirect(head, sect) get_indirect(struct outhead* head, struct outsect* sect)
struct outhead *head; /* not register! Won't compile on
SCO Xenix 386 if it is!
*/
register struct outsect *sect;
{ {
register ind_t *emitindex; register ind_t *emitindex;
register int nsect; register int nsect;
@ -395,8 +386,7 @@ get_indirect(head, sect)
/* /*
* Set the file pointer at `pos'. * Set the file pointer at `pos'.
*/ */
seek(pos) void seek(long pos)
long pos;
{ {
if (passnumber == FIRST || !incore) if (passnumber == FIRST || !incore)
lseek(infile, pos, 0); lseek(infile, pos, 0);
@ -407,8 +397,7 @@ seek(pos)
* is not. That's why we do it here. If we don't keep everything in core, * is not. That's why we do it here. If we don't keep everything in core,
* we give the space allocated for a module back. * we give the space allocated for a module back.
*/ */
skip_modul(head) void skip_modul(struct outhead* head)
struct outhead *head;
{ {
register ind_t skip = modulsize(head); register ind_t skip = modulsize(head);
@ -425,8 +414,8 @@ skip_modul(head)
/* /*
* Read in what we need in pass 2, because we couldn't keep it in core. * Read in what we need in pass 2, because we couldn't keep it in core.
*/ */
static static void
read_modul() read_modul(void)
{ {
struct outhead *head; struct outhead *head;
register struct outsect *sects; register struct outsect *sects;
@ -524,8 +513,7 @@ static unsigned short cnt_relos;
static unsigned short relind; static unsigned short relind;
#define _RELSIZ 64 #define _RELSIZ 64
startrelo(head) void startrelo(struct outhead* head)
register struct outhead *head;
{ {
ind_t reloindex; ind_t reloindex;
@ -540,8 +528,7 @@ startrelo(head)
} }
} }
struct outrelo * struct outrelo* nextrelo(void)
nextrelo()
{ {
static struct outrelo relobuf[_RELSIZ]; static struct outrelo relobuf[_RELSIZ];
@ -615,8 +602,7 @@ getblk(totalsz, pblksz, sectindex)
return (char *) 0; return (char *) 0;
} }
endemit(emit) void endemit(char* emit)
char *emit;
{ {
core_free(ALLOMODL, emit); core_free(ALLOMODL, emit);
} }

View file

@ -15,3 +15,12 @@
#ifdef SYMDBUG #ifdef SYMDBUG
#define OFF_DBUG(x) (OFF_CHAR(x) + (x).oh_nchar) #define OFF_DBUG(x) (OFF_CHAR(x) + (x).oh_nchar)
#endif /* SYMDBUG */ #endif /* SYMDBUG */
extern void seek(long pos);
extern void closefile(char* filename);
extern void get_archive_header(struct ar_hdr* archive_header);
extern void get_modul(void);
extern void skip_modul(struct outhead* head);
extern void startrelo(struct outhead* head);
extern struct outrelo* nextrelo(void);
extern void endemit(char* emit);