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>
AtEoIF()
int AtEoIF(void)
{
/* Make the unstacking of input streams noticable to the
lexical analyzer
@ -28,7 +28,7 @@ AtEoIF()
return 1;
}
AtEoIT()
int AtEoIT(void)
{
/* Make the end of the text noticable
*/

View file

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

View file

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

View file

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

View file

@ -36,7 +36,7 @@ void rd_sect(struct outsect *s, unsigned int c);
void rd_outsect(int sectno);
void rd_emit(char *b, long 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_string(char *s, long c);
int rd_arhdr(int fd, struct ar_hdr *a);

View file

@ -40,9 +40,7 @@ static long rd_base;
static int sectionnr;
static void
OUTREAD(p, b, n)
char *b;
long n;
OUTREAD(int p, char* b, long n)
{
register long l = outseek[p];
@ -59,8 +57,7 @@ OUTREAD(p, b, n)
* Open the output file according to the chosen strategy.
*/
int
rd_open(f)
char *f;
rd_open(char* f)
{
if ((outfile = open(f, 0)) < 0)
@ -71,7 +68,7 @@ rd_open(f)
static int offcnt;
int
rd_fdopen(fd)
rd_fdopen(int fd)
{
register int i;
@ -89,7 +86,7 @@ rd_fdopen(fd)
}
void
rd_close()
rd_close(void)
{
close(outfile);
@ -97,14 +94,13 @@ rd_close()
}
int
rd_fd()
rd_fd(void)
{
return outfile;
}
void
rd_ohead(head)
register struct outhead *head;
rd_ohead(struct outhead* head)
{
register long off;
@ -134,8 +130,7 @@ rd_ohead(head)
}
void
rd_rew_relos(head)
register struct outhead *head;
rd_rew_relos(struct outhead* head)
{
register long off = OFF_RELO(*head) + rd_base;
@ -143,9 +138,7 @@ rd_rew_relos(head)
}
void
rd_sect(sect, cnt)
register struct outsect *sect;
register unsigned int cnt;
rd_sect(struct outsect* sect, unsigned int cnt)
{
register char *c = (char *) sect + cnt * SZ_SECT;
@ -166,7 +159,7 @@ rd_sect(sect, cnt)
}
void
rd_outsect(s)
rd_outsect(int s)
{
OUTSECT(s);
sectionnr = s;
@ -176,18 +169,14 @@ rd_outsect(s)
* We don't have to worry about byte order here.
*/
void
rd_emit(emit, cnt)
char *emit;
long cnt;
rd_emit(char* emit, long cnt)
{
OUTREAD(PARTEMIT, emit, cnt);
offset[sectionnr] += cnt;
}
void
rd_relo(relo, cnt)
register struct outrelo *relo;
register unsigned int cnt;
rd_relo(struct outrelo* relo, unsigned int cnt)
{
OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
@ -206,9 +195,7 @@ rd_relo(relo, cnt)
}
void
rd_name(name, cnt)
register struct outname *name;
register unsigned int cnt;
rd_name(struct outname* name, unsigned int cnt)
{
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
@ -227,9 +214,7 @@ rd_name(name, cnt)
}
void
rd_string(addr, len)
char *addr;
long len;
rd_string(char* addr, long len)
{
OUTREAD(PARTCHAR, addr, len);
@ -237,9 +222,7 @@ rd_string(addr, len)
#ifdef SYMDBUG
void
rd_dbug(buf, size)
char *buf;
long size;
rd_dbug(char* buf, long 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.
* We take care that it can be used by compact() later, if needed.
*/
dealloc(piece)
register int piece;
void
dealloc(int piece)
{
/*
* Some pieces need their memory throughout the program.
@ -499,9 +499,7 @@ core_alloc(piece, size)
return address(piece, off);
}
core_free(piece, p)
int piece;
char *p;
void core_free(int piece, char* p)
{
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 hard_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 <stdint.h>
#include <stdbool.h>
#ifdef SYMDBUG
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef SYMDBUG
#endif /* SYMDBUG */
#include "arch.h"
#include "out.h"
#include "ranlib.h"
#include "object.h"
#include "const.h"
#include "assert.h"
#include "memory.h"
@ -42,20 +46,21 @@ char *modulname; /* Name of object module. */
long objectsize;
#endif /* SYMDBUG */
static long align();
static long align(long size);
static char *modulbase;
static long modulsize();
static scan_modul();
static bool all_alloc();
static bool direct_alloc();
static bool indirect_alloc();
static bool putemitindex();
static bool putreloindex();
static long modulsize(struct outhead* head);
static void can_modul(void);
static bool all_alloc(void);
static bool direct_alloc(struct outhead* head);
static bool indirect_alloc(struct outhead* head);
static bool putemitindex(ind_t sectindex, ind_t emitoff, int allopiece);
static bool putreloindex(ind_t relooff, long nrelobytes);
#ifdef SYMDBUG
static bool putdbugindex();
static bool putdbugindex(ind_t dbugoff, long ndbugbytes);
#endif /* SYMDBUG */
static get_indirect();
static read_modul();
static void get_indirect(struct outhead* head, struct outsect* sect);
static void read_modul(void);
static void scan_modul(void);
/*
* Open the file with name `filename' (if necessary) and examine the first
@ -117,16 +122,13 @@ getfile(filename)
/* NOTREACHED */
}
/* ARGSUSED */
closefile(filename)
char *filename;
void closefile(char* filename)
{
if (passnumber == FIRST || !incore)
close(infile);
}
get_archive_header(archive_header)
register struct ar_hdr *archive_header;
void get_archive_header(struct ar_hdr* archive_header)
{
if (passnumber == FIRST || !incore) {
rd_arhdr(infile, archive_header);
@ -141,7 +143,7 @@ get_archive_header(archive_header)
#endif /* SYMDBUG */
}
get_modul()
void get_modul(void)
{
if (passnumber == FIRST) {
rd_fdopen(infile);
@ -157,8 +159,8 @@ get_modul()
* 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.
*/
static
scan_modul()
static void
scan_modul(void)
{
bool space;
struct outhead *head;
@ -190,7 +192,7 @@ scan_modul()
* this was possible.
*/
static bool
all_alloc()
all_alloc(void)
{
struct outhead head;
extern ind_t hard_alloc();
@ -287,10 +289,7 @@ indirect_alloc(head)
* `emitoff'.
*/
static bool
putemitindex(sectindex, emitoff, allopiece)
ind_t sectindex;
ind_t emitoff;
int allopiece;
putemitindex(ind_t sectindex, ind_t emitoff, int allopiece)
{
long flen;
ind_t emitindex;
@ -330,9 +329,7 @@ putemitindex(sectindex, emitoff, allopiece)
* offset at `relooff'.
*/
static bool
putreloindex(relooff, nrelobytes)
ind_t relooff;
long nrelobytes;
putreloindex(ind_t relooff, long nrelobytes)
{
ind_t reloindex;
extern ind_t alloc();
@ -348,9 +345,7 @@ putreloindex(relooff, nrelobytes)
* Allocate space for debugging information and put the offset at `dbugoff'.
*/
static bool
putdbugindex(dbugoff, ndbugbytes)
ind_t relooff;
long ndbugbytes;
putdbugindex(ind_t dbugoff, long ndbugbytes)
{
ind_t dbugindex;
extern ind_t alloc();
@ -367,12 +362,8 @@ putdbugindex(dbugoff, ndbugbytes)
* Compute addresses and read in. Remember that the contents of the sections
* and also the relocation table are accessed indirectly.
*/
static
get_indirect(head, sect)
struct outhead *head; /* not register! Won't compile on
SCO Xenix 386 if it is!
*/
register struct outsect *sect;
static void
get_indirect(struct outhead* head, struct outsect* sect)
{
register ind_t *emitindex;
register int nsect;
@ -395,8 +386,7 @@ get_indirect(head, sect)
/*
* Set the file pointer at `pos'.
*/
seek(pos)
long pos;
void seek(long pos)
{
if (passnumber == FIRST || !incore)
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,
* we give the space allocated for a module back.
*/
skip_modul(head)
struct outhead *head;
void skip_modul(struct outhead* 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.
*/
static
read_modul()
static void
read_modul(void)
{
struct outhead *head;
register struct outsect *sects;
@ -524,8 +513,7 @@ static unsigned short cnt_relos;
static unsigned short relind;
#define _RELSIZ 64
startrelo(head)
register struct outhead *head;
void startrelo(struct outhead* head)
{
ind_t reloindex;
@ -540,8 +528,7 @@ startrelo(head)
}
}
struct outrelo *
nextrelo()
struct outrelo* nextrelo(void)
{
static struct outrelo relobuf[_RELSIZ];
@ -615,8 +602,7 @@ getblk(totalsz, pblksz, sectindex)
return (char *) 0;
}
endemit(emit)
char *emit;
void endemit(char* emit)
{
core_free(ALLOMODL, emit);
}

View file

@ -15,3 +15,12 @@
#ifdef SYMDBUG
#define OFF_DBUG(x) (OFF_CHAR(x) + (x).oh_nchar)
#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);