Merge branch 'default' into kernigh-linuxppc

This merges several fixes and improvements from upstream.  This
includes commit 5f6a773 to turn off qemuppc.  I see several failing
tests from qemuppc; this merge will hide the test failures.
This commit is contained in:
George Koehler 2017-10-14 13:50:49 -04:00
commit d6e9eac785
62 changed files with 214 additions and 264 deletions

View file

@ -1,16 +1,29 @@
language: c
matrix: matrix:
include: include:
- os: linux -
os: linux
sudo: false
dist: trusty
compiler: gcc
-
os: linux
sudo: false
dist: trusty
compiler: clang
# -
# os: osx
# env: HOMEBREW_NO_AUTO_UPDATE=1
# compiler: clang
addons: addons:
apt: apt:
packages: packages:
- ed - ed
- qemu-user
git: git:
depth: 10 depth: 10
language: c
script: script:
- make PREFIX=/tmp/acki - make PREFIX=/tmp/acki +ack

View file

@ -11,14 +11,14 @@ vars.plats = {
"linuxppc", "linuxppc",
"osx386", "osx386",
"osxppc", "osxppc",
"qemuppc", --"qemuppc",
"pc86", "pc86",
"rpi", "rpi",
} }
vars.plats_with_tests = { vars.plats_with_tests = {
"linux386", "linux386",
"linuxppc", "linuxppc",
"qemuppc", --"qemuppc",
"pc86", "pc86",
} }

View file

@ -220,7 +220,7 @@ definerule("cprogram",
commands = { commands = {
type="strings", type="strings",
default={ default={
"$(CC) -o %{outs[1]} -Wl,--start-group %{ins} -Wl,--end-group" "$(CC) -o %{outs[1]} %{ins} %{ins}"
}, },
} }
}, },

View file

@ -522,7 +522,7 @@ scanstring()
yylval.integer= genemlabel(); yylval.integer= genemlabel();
C_rom_dlb((label)i,(arith)0); C_rom_dlb((label)i,(arith)0);
C_rom_icon("9999",(arith)BEMINTSIZE); C_rom_icon("9999",(arith)BEMINTSIZE);
C_rom_icon(itoa(length),(arith)BEMINTSIZE); C_rom_icon(myitoa(length),(arith)BEMINTSIZE);
} }
#ifdef YYDEBUG #ifdef YYDEBUG
if (yydebug) print("STRVALUE found\n"); if (yydebug) print("STRVALUE found\n");

View file

@ -3,6 +3,7 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
#include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
@ -71,13 +72,5 @@ extern int dataused;
extern Linerecord *currline; extern Linerecord *currline;
extern char *itoa(); extern char *myitoa();
extern char *salloc(); extern char *salloc();
extern char *strcpy();
extern char *strcat();
#if __STDC__
#include <stdlib.h>
#else
extern char *malloc();
#endif

View file

@ -24,6 +24,7 @@ cprogram {
matching(filenamesof("+llgen"), "%.c$"), matching(filenamesof("+llgen"), "%.c$"),
}, },
deps = { deps = {
"./*.h",
"+llgen", "+llgen",
"+tokentab_h", "+tokentab_h",
"h+emheaders", "h+emheaders",

View file

@ -670,7 +670,7 @@ gendata()
C_df_dnam("datfdes"); C_df_dnam("datfdes");
C_rom_dnam("datfname",(arith)0); C_rom_dnam("datfname",(arith)0);
C_rom_cst((arith)1); C_rom_cst((arith)1);
C_rom_cst((arith)(itoa(strlen(datfname)))); C_rom_cst((arith)(myitoa(strlen(datfname))));
C_df_dnam("dattdes"); C_df_dnam("dattdes");
C_rom_dnam("dattyp",(arith)0); C_rom_dnam("dattyp",(arith)0);
C_rom_cst((arith)1); C_rom_cst((arith)1);

View file

@ -69,7 +69,7 @@ illegalcmd()
char *itoa(i) char *myitoa(i)
int i; int i;
{ {
static char buf[30]; static char buf[30];

View file

@ -37,7 +37,6 @@
extern char *bts2str(); extern char *bts2str();
extern char *symbol2str(); extern char *symbol2str();
extern char *strchr();
int stat_number = 9999; /* static scope number */ int stat_number = 9999; /* static scope number */
struct outdef OutDef; struct outdef OutDef;

View file

@ -24,7 +24,6 @@
extern struct idf *GetIdentifier(); extern struct idf *GetIdentifier();
extern int InputLevel; extern int InputLevel;
struct repl *ReplaceList; /* list of currently active macros */ struct repl *ReplaceList; /* list of currently active macros */
extern char *strcat(), *strcpy();
void macro2buffer(); void macro2buffer();
void getactuals(); void getactuals();

View file

@ -30,7 +30,6 @@ int LexSave = 0; /* last character read by GetChar */
extern int InputLevel; /* # of current macro expansions */ extern int InputLevel; /* # of current macro expansions */
extern char *string_token(); extern char *string_token();
extern char *strcpy();
extern arith char_constant(); extern arith char_constant();
#define FLG_ESEEN 0x01 /* possibly a floating point number */ #define FLG_ESEEN 0x01 /* possibly a floating point number */
#define FLG_DOTSEEN 0x02 /* certainly a floating point number */ #define FLG_DOTSEEN 0x02 /* certainly a floating point number */

View file

@ -21,8 +21,6 @@
#include "replace.h" #include "replace.h"
extern char *GetIdentifier(); extern char *GetIdentifier();
extern char *strcpy();
extern char *strcat();
extern int InputLevel; extern int InputLevel;
struct repl *ReplaceList; /* list of currently active macros */ struct repl *ReplaceList; /* list of currently active macros */

View file

@ -31,8 +31,8 @@ normalrule {
} }
} }
for _, f in ipairs(filenamesof("./*.H")) do for _, f in ipairs(filenamesof("./*.xh")) do
local name = replace(basename(f), "%.H$", "") local name = replace(basename(f), "%.xh$", "")
normalrule { normalrule {
name = name.."_h", name = name.."_h",
ins = { ins = {
@ -46,8 +46,8 @@ for _, f in ipairs(filenamesof("./*.H")) do
} }
end end
for _, f in ipairs(filenamesof("./*.C")) do for _, f in ipairs(filenamesof("./*.xc")) do
local name = replace(basename(f), "%.C$", "") local name = replace(basename(f), "%.xc$", "")
normalrule { normalrule {
name = name.."_c", name = name.."_c",
ins = { ins = {
@ -65,8 +65,8 @@ normalrule {
name = "next_c", name = "next_c",
ins = { ins = {
"./make.next", "./make.next",
"./*.H", "./*.xh",
"./*.C", "./*.xc",
}, },
outleaves = { "next.c" }, outleaves = { "next.c" },
commands = { commands = {

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

@ -19,11 +19,6 @@ Implementation modules and program modules must reside in files having a
.PP .PP
The name of the file in which a definition module is stored must be the same as The name of the file in which a definition module is stored must be the same as
the module-name, apart from the extension. the module-name, apart from the extension.
Also, in most Unix systems filenames are only 14 characters long.
So, given an IMPORT declaration for a module called "LongModulName",
the compiler will try to open a file called "LongModulN.def".
The requirement does not hold for implementation or program modules,
but is certainly recommended.
.SH CALLING THE COMPILER .SH CALLING THE COMPILER
The easiest way to do this is to let the \fIack\fR(1) program do it. The easiest way to do this is to let the \fIack\fR(1) program do it.
So, to compile a program module "prog.mod", just call So, to compile a program module "prog.mod", just call

View file

@ -11,6 +11,7 @@
/* $Id$ */ /* $Id$ */
#include <string.h>
#include <alloc.h> #include <alloc.h>
#include "input.h" #include "input.h"
@ -27,8 +28,6 @@ int nDEF, mDEF;
struct file_list *CurrentArg; struct file_list *CurrentArg;
extern int err_occurred; extern int err_occurred;
extern int Roption; extern int Roption;
extern char *strrchr();
extern char *strcpy(), *strcat();
char * char *
basename(s) basename(s)

View file

@ -355,7 +355,7 @@ void zgt(lab) int lab; { C_zgt((label) lab); }
void zlt(lab) int lab; { C_zlt((label) lab); } void zlt(lab) int lab; { C_zlt((label) lab); }
void zne(lab) int lab; { C_zne((label) lab); } void zne(lab) int lab; { C_zne((label) lab); }
char *itoa(i) long i; char *myitoa(i) long i;
{ {
static char a[sizeof(long)*3]; static char a[sizeof(long)*3];
sprint(a, "%ld", i); sprint(a, "%ld", i);
@ -364,7 +364,7 @@ char *itoa(i) long i;
void rom(size, c) int size; long c; void rom(size, c) int size; long c;
{ {
C_rom_icon(itoa(c), (arith) size); C_rom_icon(myitoa(c), (arith) size);
} }
void lin() void lin()

View file

@ -31,8 +31,8 @@ normalrule {
} }
} }
for _, f in ipairs(filenamesof("./*.H")) do for _, f in ipairs(filenamesof("./*.xh")) do
local name = replace(basename(f), "%.H$", "") local name = replace(basename(f), "%.xh$", "")
normalrule { normalrule {
name = name.."_h", name = name.."_h",
ins = { ins = {
@ -46,8 +46,8 @@ for _, f in ipairs(filenamesof("./*.H")) do
} }
end end
for _, f in ipairs(filenamesof("./*.C")) do for _, f in ipairs(filenamesof("./*.xc")) do
local name = replace(basename(f), "%.C$", "") local name = replace(basename(f), "%.xc$", "")
normalrule { normalrule {
name = name.."_c", name = name.."_c",
ins = { ins = {
@ -65,8 +65,8 @@ normalrule {
name = "next_c", name = "next_c",
ins = { ins = {
"./make.next", "./make.next",
"./*.H", "./*.xh",
"./*.C", "./*.xc",
}, },
outleaves = { "next.c" }, outleaves = { "next.c" },
commands = { commands = {

View file

@ -363,7 +363,8 @@ char *path, *tail;
if ((dir = getenv("TMPDIR")) == NULL) if ((dir = getenv("TMPDIR")) == NULL)
dir = tmp_dir; dir = tmp_dir;
sprintf(path, "%s/%s", dir, tail); sprintf(path, "%s/%s", dir, tail);
return(ffcreat(mktemp(path))); close(mkstemp(path));
return(ffcreat(path));
} }
/* ---------- Error handling ---------- */ /* ---------- Error handling ---------- */

View file

@ -4,5 +4,9 @@
*/ */
/* $Id$ */ /* $Id$ */
#ifndef _MODULES_H_EM_LABEL_H
#define _MODULES_H_EM_LABEL_H
typedef unsigned int label; typedef unsigned int label;
#endif

View file

@ -10,6 +10,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <em_path.h> #include <em_path.h>
#include <alloc.h> #include <alloc.h>
#include "insert.h" #include "insert.h"
@ -134,8 +135,6 @@ C_findpart(part)
return p; return p;
} }
extern char *strcpy(), *strcat(), *mktemp();
static static
swttmp() swttmp()
{ {
@ -146,7 +145,8 @@ swttmp()
strcpy(p, C_tmpdir); strcpy(p, C_tmpdir);
strcat(p, "/CodeXXXXXX"); strcat(p, "/CodeXXXXXX");
C_tmpfile = mktemp(p); close(mkstemp(p));
C_tmpfile = p;
if (! sys_open(p, OP_WRITE, &C_old_ofp)) { if (! sys_open(p, OP_WRITE, &C_old_ofp)) {
C_failed(); C_failed();
} }
@ -251,7 +251,7 @@ mkpart(part)
*/ */
register Part *p = C_findpart(part); register Part *p = C_findpart(part);
register int index = part % TABSIZ; register int index = part % TABSIZ;
if (p != 0) { if (p != 0) {
/* multiple defined part ... */ /* multiple defined part ... */
C_internal_error(); C_internal_error();

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

@ -20,7 +20,7 @@
A default one is provided, which does nothing. A default one is provided, which does nothing.
AtEoIF() : this routine is called at the end of an inserted file. AtEoIF() : this routine is called at the end of an inserted file.
A default one is provided, which does nothing. A default one is provided, which does nothing.
Imported objects are: Imported objects are:
INP_NPUSHBACK, INP_READ_IN_ONE, INP_TYPE, INP_VAR, INP_NPUSHBACK, INP_READ_IN_ONE, INP_TYPE, INP_VAR,
routines from the "alloc" package, routines from the "storage" routines from the "alloc" package, routines from the "storage"
@ -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))
|| ||
@ -140,7 +140,7 @@ _PROTOTYPE(INP_PRIVATE char * INP_pbuf, (void));
INP_PRIVATE char * INP_PRIVATE char *
INP_pbuf() INP_pbuf()
{ {
register struct INP_i_buf *ib = register struct INP_i_buf *ib =
(struct INP_i_buf *) malloc(sizeof(struct INP_i_buf)); (struct INP_i_buf *) malloc(sizeof(struct INP_i_buf));
if (!ib) return 0; if (!ib) return 0;
@ -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;
} }
@ -278,13 +278,13 @@ InsertFile(filnam, table, result)
if (!sys_open(filnam, OP_READ, &fd)) return 0; if (!sys_open(filnam, OP_READ, &fd)) return 0;
} }
else { else {
while (*table) { while (*table) {
/* look in the directory table */ /* look in the directory table */
if (!INP_mk_filename(*table++, filnam, &newfn)) { if (!INP_mk_filename(*table++, filnam, &newfn)) {
return 0; return 0;
} }
if (sys_open(newfn, OP_READ, &fd)) { if (sys_open(newfn, OP_READ, &fd)) {
/* free filnam ??? NO we don't know /* free filnam ??? NO we don't know
where it comes from! where it comes from!
*/ */
filnam = newfn; filnam = newfn;
@ -378,7 +378,7 @@ loadbuf()
*--de = *--so; *--de = *--so;
} }
#endif #endif
if ( INP_rdblock(bh->bh_fd, bh->bh_text, &(bh->bh_size)) if ( INP_rdblock(bh->bh_fd, bh->bh_text, &(bh->bh_size))
&& &&
bh->bh_size > 0 bh->bh_size > 0
) { ) {

View file

@ -6,6 +6,8 @@
#include <local.h> #include <local.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <out.h> #include <out.h>
#include <ranlib.h> #include <ranlib.h>
#include <arch.h> #include <arch.h>

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,21 +94,20 @@ 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;
OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD); OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD);
{ {
register char *c = (char *) head + (SZ_HEAD-4); register char *c = (char *) head + (SZ_HEAD-4);
head->oh_nchar = get4(c); head->oh_nchar = get4(c);
c -= 4; head->oh_nemit = get4(c); c -= 4; head->oh_nemit = get4(c);
c -= 2; head->oh_nname = uget2(c); c -= 2; head->oh_nname = uget2(c);
@ -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,19 +214,15 @@ 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);
} }
#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

@ -4,6 +4,8 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <string.h>
#include <stdlib.h>
#include "system.h" #include "system.h"
int int
@ -12,7 +14,6 @@ sys_lock(path)
{ {
char buf[1024]; char buf[1024];
char *tmpf = ".lockXXXXXX"; char *tmpf = ".lockXXXXXX";
char *strrchr(), *strcpy(), *mktemp();
char *p; char *p;
int ok, fd; int ok, fd;
@ -23,8 +24,7 @@ sys_lock(path)
} }
else else
strcpy(buf, tmpf); strcpy(buf, tmpf);
mktemp(buf); if ((fd = mkstemp(buf)) < 0)
if ((fd = creat(buf, 0)) < 0)
return 0; return 0;
close(fd); close(fd);
ok = (link(buf, path) == 0); ok = (link(buf, path) == 0);

View file

@ -25,7 +25,7 @@ return installable {
map = { map = {
["$(PLATDEP)/linuxppc/as"] = "+as", ["$(PLATDEP)/linuxppc/as"] = "+as",
["$(PLATDEP)/linuxppc/ncg"] = "+ncg", ["$(PLATDEP)/linuxppc/ncg"] = "+ncg",
["$(PLATDEP)/linuxppc/mcg"] = "+mcg", --["$(PLATDEP)/linuxppc/mcg"] = "+mcg",
["$(PLATDEP)/linuxppc/top"] = "+top", ["$(PLATDEP)/linuxppc/top"] = "+top",
["$(PLATIND)/descr/linuxppc"] = "./descr", ["$(PLATIND)/descr/linuxppc"] = "./descr",
"util/amisc+aelflod-pkg", "util/amisc+aelflod-pkg",

View file

@ -57,7 +57,6 @@ libpath(s) string s; {
register string p; register string p;
register length; register length;
p_mem alloc(); p_mem alloc();
string strcpy(), strcat();
char* libdir = getenv("LLGEN_LIB_DIR"); char* libdir = getenv("LLGEN_LIB_DIR");
if (!libdir) if (!libdir)

View file

@ -37,7 +37,6 @@ extern fatal();
extern comfatal(); extern comfatal();
extern copyfile(); extern copyfile();
extern void install(); extern void install();
extern char *mktemp();
extern char *sbrk(); extern char *sbrk();
main(argc,argv) register string argv[]; { main(argc,argv) register string argv[]; {
@ -164,8 +163,8 @@ main(argc,argv) register string argv[]; {
nc_rec_file = libpath ("nc_rec"); nc_rec_file = libpath ("nc_rec");
} }
#endif #endif
mktemp(f_temp); close(mkstemp(f_temp));
mktemp(f_pars); close(mkstemp(f_pars));
if ((fact = fopen(f_temp,"w")) == NULL) { if ((fact = fopen(f_temp,"w")) == NULL) {
fputs("Cannot create temporary\n",stderr); fputs("Cannot create temporary\n",stderr);
exit(1); exit(1);

View file

@ -17,8 +17,6 @@
char temp_name[] = "/tmp/sXXXXXX"; char temp_name[] = "/tmp/sXXXXXX";
char *tname; char *tname;
char *mktemp();
FILE *fopen();
FILE *tf; FILE *tf;
struct outhead buf; struct outhead buf;
int readerror, writeerror; int readerror, writeerror;
@ -31,12 +29,12 @@ char **argv;
signal(SIGHUP, SIG_IGN); signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN); signal(SIGQUIT, SIG_IGN);
tname = mktemp(temp_name); close(mkstemp(temp_name));
while(--argc) { while(--argc) {
if ((status = strip(argv[argc])) > 1) if ((status = strip(argv[argc])) > 1)
break; break;
} }
unlink(tname); unlink(temp_name);
exit(status); exit(status);
} }

View file

@ -106,10 +106,9 @@ char *progname;
char temp_buf[32]; char temp_buf[32];
char *temp_arch = &temp_buf[0]; char *temp_arch = &temp_buf[0];
extern char *mktemp();
extern char *ctime(); extern char *ctime();
void do_object(); void do_object(int f, long size);
void write_symdef(); void write_symdef();
void add(); void add();
@ -184,7 +183,7 @@ register int mode;
magic = rd_unsigned2(fd); magic = rd_unsigned2(fd);
if (magic != AALMAG && magic != ARMAG) if (magic != AALMAG && magic != ARMAG)
error(TRUE, "%s is not in ar format\n", name); error(TRUE, "%s is not in ar format\n", name);
return fd; return fd;
} }
@ -206,7 +205,7 @@ char *argv[];
if (argc < 3) if (argc < 3)
usage(); usage();
for (ptr = argv[1]; *ptr; ptr++) { for (ptr = argv[1]; *ptr; ptr++) {
switch (*ptr) { switch (*ptr) {
case 't' : case 't' :
@ -268,7 +267,7 @@ char *argv[];
if (app_fl + ex_fl + del_fl + rep_fl + show_fl + pr_fl != 1) if (app_fl + ex_fl + del_fl + rep_fl + show_fl + pr_fl != 1)
usage(); usage();
if (u_fl && ! rep_fl) if (u_fl && ! rep_fl)
usage(); usage();
@ -277,7 +276,7 @@ char *argv[];
|| app_fl || app_fl
#endif #endif
) { ) {
mktemp(temp_arch); close(mkstemp(temp_arch));
} }
#ifdef AAL #ifdef AAL
tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib)); tab = (struct ranlib *) malloc(512 * sizeof(struct ranlib));
@ -289,7 +288,7 @@ char *argv[];
signal(SIGINT, catch); signal(SIGINT, catch);
get(argc, argv); get(argc, argv);
return 0; return 0;
} }
@ -678,7 +677,7 @@ write_symdef()
} }
/* /*
* Return whether the bytes in `buf' form a good object header. * Return whether the bytes in `buf' form a good object header.
* The header is put in `headp'. * The header is put in `headp'.
*/ */
int int
@ -689,9 +688,7 @@ is_outhead(headp)
return !BADMAGIC(*headp) && headp->oh_nname != 0; return !BADMAGIC(*headp) && headp->oh_nname != 0;
} }
void void do_object(int f, long size)
do_object(f, size)
long size;
{ {
struct outhead headbuf; struct outhead headbuf;

View file

@ -1,3 +1,4 @@
#include <stdlib.h>
#include <signal.h> #include <signal.h>
#include "defs.h" #include "defs.h"
@ -56,10 +57,6 @@ char *rassoc;
short **derives; short **derives;
char *nullable; char *nullable;
extern char *mktemp();
extern char *getenv();
done(k) done(k)
int k; int k;
{ {
@ -253,9 +250,9 @@ create_file_names()
text_file_name[len + 5] = 't'; text_file_name[len + 5] = 't';
union_file_name[len + 5] = 'u'; union_file_name[len + 5] = 'u';
mktemp(action_file_name); close(mkstemp(action_file_name));
mktemp(text_file_name); close(mkstemp(text_file_name));
mktemp(union_file_name); close(mkstemp(union_file_name));
len = strlen(file_prefix); len = strlen(file_prefix);

View file

@ -58,10 +58,7 @@ static const struct
#define MAXARGS 1024 /* mar # of args */ #define MAXARGS 1024 /* mar # of args */
#define NTEMPS 4 /* # of temporary files; not tunable */ #define NTEMPS 4 /* # of temporary files; not tunable */
extern char* mktemp(); static char tmpbase[] = TMP_DIR "/ego.XXXXXX";
extern char* strcpy(), *strcat();
extern char* strrchr();
static char ddump[128] = TMP_DIR; /* data label dump file */ static char ddump[128] = TMP_DIR; /* data label dump file */
static char pdump[128] = TMP_DIR; /* procedure name dump file */ static char pdump[128] = TMP_DIR; /* procedure name dump file */
static char tmpbufs[NTEMPS * 2][128] = { static char tmpbufs[NTEMPS * 2][128] = {
@ -119,6 +116,8 @@ cleanup()
if (pdump[0] != '\0') if (pdump[0] != '\0')
(void)unlink(pdump); (void)unlink(pdump);
} }
(void)unlink(tmpbase);
} }
/*VARARGS1*/ /*VARARGS1*/
@ -204,9 +203,8 @@ new_outfiles()
char** dst = &phargs[NTEMPS + 1]; char** dst = &phargs[NTEMPS + 1];
if (!Bindex) if (!Bindex)
{ Bindex = strlen(tmpbufs[0]) - 2;
Bindex = strrchr(tmpbufs[0], 'B') - tmpbufs[0];
}
for (i = 1; i <= NTEMPS; i++) for (i = 1; i <= NTEMPS; i++)
{ {
*dst = tmpbufs[tmpindex]; *dst = tmpbufs[tmpindex];
@ -284,7 +282,7 @@ static void
phargs[argc++] = "-M"; phargs[argc++] = "-M";
phargs[argc++] = descr_file; phargs[argc++] = descr_file;
} }
for (i=0; i<nphase_args; i++) for (i=0; i<nphase_args; i++)
phargs[argc++] = phase_args[i]; phargs[argc++] = phase_args[i];
@ -407,25 +405,25 @@ int main(int argc, char* argv[])
fatal("no correct -P flag given"); fatal("no correct -P flag given");
} }
close(mkstemp(tmpbase));
strcpy(ddump, tmpbase);
strcpy(pdump, tmpbase);
strcpy(tmpbufs[0], tmpbase);
if (keeptemps) if (keeptemps)
{ {
(void)strcpy(ddump, "."); (void)strcpy(ddump, ".");
(void)strcpy(pdump, "."); (void)strcpy(pdump, ".");
(void)strcpy(tmpbufs[0], "."); (void)strcpy(tmpbufs[0], ".");
} }
(void)strcat(ddump, "/ego.dd.XXXXXX"); (void)strcat(ddump, "dd");
(void)mktemp(ddump); (void)strcat(pdump, "pd");
(void)strcat(pdump, "/ego.pd.XXXXXX");
(void)mktemp(pdump);
(void)strcat(tmpbufs[0], "/ego.XXXXXX"); (void)strcat(tmpbufs[0], "A.BB");
(void)mktemp(tmpbufs[0]); for (i=1; i<(2 * NTEMPS); i++)
(void)strcat(tmpbufs[0], ".A.BB");
for (i = 2 * NTEMPS - 1; i >= 1; i--)
{
(void)strcpy(tmpbufs[i], tmpbufs[0]); (void)strcpy(tmpbufs[i], tmpbufs[0]);
}
i = strrchr(tmpbufs[0], 'A') - tmpbufs[0]; i = strlen(tmpbufs[0]) - 4;
tmpbufs[0][i] = 'p'; tmpbufs[0][i] = 'p';
tmpbufs[NTEMPS + 0][i] = 'p'; tmpbufs[NTEMPS + 0][i] = 'p';
tmpbufs[1][i] = 'd'; tmpbufs[1][i] = 'd';
@ -434,6 +432,7 @@ int main(int argc, char* argv[])
tmpbufs[NTEMPS + 2][i] = 'l'; tmpbufs[NTEMPS + 2][i] = 'l';
tmpbufs[3][i] = 'b'; tmpbufs[3][i] = 'b';
tmpbufs[NTEMPS + 3][i] = 'b'; tmpbufs[NTEMPS + 3][i] = 'b';
run_phase(IC); run_phase(IC);
run_phase(CF); run_phase(CF);
while (*Ophase) while (*Ophase)

View file

@ -26,8 +26,6 @@ prc_p prochash[NPROCHASH];
num_p numhash[NNUMHASH]; num_p numhash[NNUMHASH];
char *lastname; char *lastname;
extern char *strcpy();
#define newsym() (sym_p) newstruct(sym) #define newsym() (sym_p) newstruct(sym)
#define newprc() (prc_p) newstruct(prc) #define newprc() (prc_p) newstruct(prc)
#define newnum() (num_p) newstruct(num) #define newnum() (num_p) newstruct(num)

View file

@ -334,10 +334,10 @@ char* argv[];
strcat(ccname, "/ego.i2.XXXXXX"); strcat(ccname, "/ego.i2.XXXXXX");
strcat(sname, "/ego.i3.XXXXXX"); strcat(sname, "/ego.i3.XXXXXX");
strcat(cname2, "/ego.i4.XXXXXX"); strcat(cname2, "/ego.i4.XXXXXX");
mktemp(cname); close(mkstemp(cname));
mktemp(ccname); close(mkstemp(ccname));
mktemp(sname); close(mkstemp(sname));
mktemp(cname2); close(mkstemp(cname2));
pass1(files->lname_in, files->bname_in, cname); /* grep calls, analyse procedures */ pass1(files->lname_in, files->bname_in, cname); /* grep calls, analyse procedures */
space = total_size * space / 100; space = total_size * space / 100;
pass2(cname, space); /* select calls to be expanded */ pass2(cname, space); /* select calls to be expanded */

View file

@ -6,7 +6,7 @@
* *
* This code is derived from software contributed to Berkeley by * This code is derived from software contributed to Berkeley by
* Vern Paxson. * Vern Paxson.
* *
* The United States Government has rights in this work pursuant * The United States Government has rights in this work pursuant
* to contract no. DE-AC03-76SF00098 between the United States * to contract no. DE-AC03-76SF00098 between the United States
* Department of Energy and the University of California. * Department of Energy and the University of California.
@ -38,6 +38,7 @@ static char rcsid[] =
#endif #endif
#include <stdlib.h>
#include "flexdef.h" #include "flexdef.h"
static char flex_version[] = "2.3"; static char flex_version[] = "2.3";
@ -394,7 +395,7 @@ char **argv;
{ {
int i, sawcmpflag; int i, sawcmpflag;
char *arg, *flex_gettime(), *mktemp(); char *arg, *flex_gettime();
printstats = syntaxerror = trace = spprdflt = interactive = caseins = false; printstats = syntaxerror = trace = spprdflt = interactive = caseins = false;
backtrack_report = performance_report = ddebug = fulltbl = fullspd = false; backtrack_report = performance_report = ddebug = fulltbl = fullspd = false;
@ -611,7 +612,7 @@ get_next_arg: /* used by -C and -S flags in lieu of a "continue 2" control */
#else #else
(void) strcpy( temp_action_file_name, "flexXXXXXX.tmp" ); (void) strcpy( temp_action_file_name, "flexXXXXXX.tmp" );
#endif #endif
(void) mktemp( temp_action_file_name ); close(mkstemp(temp_action_file_name));
action_file_name = temp_action_file_name; action_file_name = temp_action_file_name;
} }

View file

@ -20,8 +20,6 @@ static char rcsid[] = "$Id$";
#define ENDLIB ((long)0) #define ENDLIB ((long)0)
extern ind_t hard_alloc();
static struct ar_hdr arhdr; static struct ar_hdr arhdr;
/* /*

View file

@ -10,6 +10,7 @@ static char rcsid[] = "$Id$";
* led - linkage editor for ACK assemblers output format * led - linkage editor for ACK assemblers output format
*/ */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@ -298,6 +299,7 @@ static uint32_t sect_base[MAXSECT];
static char lignmap[MAXSECT / WIDTH]; static char lignmap[MAXSECT / WIDTH];
static uint32_t sect_lign[MAXSECT]; static uint32_t sect_lign[MAXSECT];
/*
/* /*
* Set the alignment of section `sectno' to `lign', if this doesn't * Set the alignment of section `sectno' to `lign', if this doesn't
* conflict with earlier alignment. * conflict with earlier alignment.
@ -305,6 +307,8 @@ static uint32_t sect_lign[MAXSECT];
static void static void
setlign(int sectno, uint32_t lign) setlign(int sectno, uint32_t lign)
{ {
extern bool setbit();
if (setbit(sectno, lignmap) && sect_lign[sectno] != lign) if (setbit(sectno, lignmap) && sect_lign[sectno] != lign)
fatal("section has different alignments"); fatal("section has different alignments");
if (lign == (long)0) if (lign == (long)0)
@ -319,6 +323,8 @@ setlign(int sectno, uint32_t lign)
static void static void
setbase(int sectno, uint32_t base) setbase(int sectno, uint32_t base)
{ {
extern bool setbit();
if (setbit(sectno, basemap) && sect_base[sectno] != base) if (setbit(sectno, basemap) && sect_base[sectno] != base)
fatal("section has different bases"); fatal("section has different bases");
sect_base[sectno] = base; sect_base[sectno] = base;

View file

@ -25,15 +25,17 @@ static char rcsid[] = "$Id$";
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h>
#include <out.h> #include <out.h>
#include "const.h" #include "const.h"
#include "assert.h" #include "assert.h"
#include "debug.h" #include "debug.h"
#include "memory.h" #include "memory.h"
#include "object.h"
static copy_down(); static void copy_down(struct memory* mem, ind_t dist);
static copy_up(); static void copy_up(struct memory* mem, ind_t dist);
static free_saved_moduls(); static void free_saved_moduls(void);
struct memory mems[NMEMS]; struct memory mems[NMEMS];
@ -45,8 +47,7 @@ ind_t core_position = (ind_t)0; /* Index of current module. */
static char *BASE; static char *BASE;
static ind_t refused; static ind_t refused;
sbreak(incr) static int sbreak(ind_t incr)
ind_t incr;
{ {
unsigned int inc; unsigned int inc;
@ -69,12 +70,11 @@ sbreak(incr)
* Initialize some pieces of core. We hope that this will be our last * Initialize some pieces of core. We hope that this will be our last
* real allocation, meaning we've made the right choices. * real allocation, meaning we've made the right choices.
*/ */
init_core() void init_core(void)
{ {
register char *base; register char *base;
register ind_t total_size; register ind_t total_size;
register struct memory *mem; register struct memory *mem;
extern char *sbrk();
#include "mach.h" #include "mach.h"
#define ALIGN 8 /* minimum alignment for pieces */ #define ALIGN 8 /* minimum alignment for pieces */
@ -175,9 +175,7 @@ extern int passnumber;
* enough bytes, the first or the second time. * enough bytes, the first or the second time.
*/ */
static bool static bool
compact(piece, incr, flag) compact(int piece, ind_t incr, int flag)
register int piece;
register ind_t incr;
#define NORMAL 0 #define NORMAL 0
#define FREEZE 1 #define FREEZE 1
#define FORCED 2 #define FORCED 2
@ -315,10 +313,8 @@ compact(piece, incr, flag)
* overlap with the old area, but we do not want to overwrite them before they * overlap with the old area, but we do not want to overwrite them before they
* are copied. * are copied.
*/ */
static static void
copy_down(mem, dist) copy_down(struct memory* mem, ind_t dist)
register struct memory *mem;
ind_t dist;
{ {
register char *old; register char *old;
register char *new; register char *new;
@ -338,10 +334,7 @@ copy_down(mem, dist)
* overlap with the old area, but we do not want to overwrite them before they * overlap with the old area, but we do not want to overwrite them before they
* are copied. * are copied.
*/ */
static static void copy_up(struct memory* mem, ind_t dist)
copy_up(mem, dist)
register struct memory *mem;
ind_t dist;
{ {
register char *old; register char *old;
register char *new; register char *new;
@ -364,10 +357,7 @@ static int alloctype = NORMAL;
* how many times the area is moved, because of another allocate, this offset * how many times the area is moved, because of another allocate, this offset
* remains valid. * remains valid.
*/ */
ind_t ind_t alloc(int piece, long size)
alloc(piece, size)
int piece;
register long size;
{ {
register ind_t incr = 0; register ind_t incr = 0;
ind_t left = mems[piece].mem_left; ind_t left = mems[piece].mem_left;
@ -405,9 +395,7 @@ alloc(piece, size)
* attempt fails, release the space occupied by other pieces and try again. * attempt fails, release the space occupied by other pieces and try again.
*/ */
ind_t ind_t
hard_alloc(piece, size) hard_alloc(int piece, long size)
register int piece;
register long size;
{ {
register ind_t ret; register ind_t ret;
register int i; register int i;
@ -452,8 +440,8 @@ hard_alloc(piece, size)
* at the start of the piece allocated for module contents, thereby * at the start of the piece allocated for module contents, thereby
* overwriting the saved modules, and release its space. * overwriting the saved modules, and release its space.
*/ */
static static void
free_saved_moduls() free_saved_moduls(void)
{ {
register ind_t size; register ind_t size;
register char *old, *new; register char *old, *new;
@ -473,8 +461,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 +487,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);
@ -553,7 +539,7 @@ freeze_core()
* To transform the various pieces of the output in core to the file format, * To transform the various pieces of the output in core to the file format,
* we must order the bytes in the unsigned shorts and longs as ACK prescribes. * we must order the bytes in the unsigned shorts and longs as ACK prescribes.
*/ */
write_bytes() void write_bytes(void)
{ {
unsigned short nsect; unsigned short nsect;
long offchar; long offchar;
@ -611,10 +597,7 @@ write_bytes()
} }
} }
namecpy(name, nname, offchar) void namecpy(struct outname* name, unsigned nname, long offchar)
register struct outname *name;
register unsigned nname;
register long offchar;
{ {
while (nname--) { while (nname--) {
if (name->on_foff) if (name->on_foff)

View file

@ -38,5 +38,10 @@ extern struct memory mems[];
#define int_align(sz) (((sz)+(sizeof(int)-1))&~(int)(sizeof(int)-1)) #define int_align(sz) (((sz)+(sizeof(int)-1))&~(int)(sizeof(int)-1))
extern ind_t core_position; extern ind_t core_position;
extern ind_t hard_alloc(); extern void init_core(void);
extern ind_t alloc(); extern ind_t hard_alloc(int piece, long size);
extern ind_t alloc(int piece, long size);
extern void dealloc(int piece);
extern void core_free(int piece, char* p);
extern void write_bytes(void);
extern void namecpy(struct outname* name, unsigned nname, long offchar);

View file

@ -68,8 +68,6 @@ savechar(piece, off)
{ {
register long len; register long len;
register ind_t newoff; register ind_t newoff;
extern ind_t alloc();
extern ind_t hard_alloc();
if (off == (ind_t)0) if (off == (ind_t)0)
return 0; return 0;

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,10 +192,9 @@ 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();
if (hard_alloc(ALLOMODL, (long)sizeof(struct outhead)) == BADOFF) if (hard_alloc(ALLOMODL, (long)sizeof(struct outhead)) == BADOFF)
fatal("no space for module header"); fatal("no space for module header");
@ -218,8 +219,6 @@ direct_alloc(head)
register struct outsect *sects; register struct outsect *sects;
unsigned short nsect = head->oh_nsect; unsigned short nsect = head->oh_nsect;
long size, rest; long size, rest;
extern ind_t hard_alloc();
extern ind_t alloc();
#ifdef SYMDBUG #ifdef SYMDBUG
rest = nsect * sizeof(ind_t) + sizeof(ind_t) + sizeof(ind_t); rest = nsect * sizeof(ind_t) + sizeof(ind_t) + sizeof(ind_t);
@ -287,14 +286,10 @@ 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;
extern ind_t alloc();
static long zeros[MAXSECT]; static long zeros[MAXSECT];
register long zero = zeros[allopiece - ALLOEMIT]; register long zero = zeros[allopiece - ALLOEMIT];
@ -330,12 +325,9 @@ 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();
if ((reloindex = alloc(ALLORELO, nrelobytes)) != BADOFF) { if ((reloindex = alloc(ALLORELO, nrelobytes)) != BADOFF) {
*(ind_t *)modulptr(relooff) = reloindex; *(ind_t *)modulptr(relooff) = reloindex;
@ -348,12 +340,9 @@ 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();
if ((dbugindex = alloc(ALLODBUG, ndbugbytes)) != BADOFF) { if ((dbugindex = alloc(ALLODBUG, ndbugbytes)) != BADOFF) {
*(ind_t *)modulptr(dbugoff) = dbugindex; *(ind_t *)modulptr(dbugoff) = dbugindex;
@ -367,12 +356,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 +380,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 +391,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 +408,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;
@ -436,7 +419,6 @@ read_modul()
unsigned short nsect, nname; unsigned short nsect, nname;
long size; long size;
long nchar; long nchar;
extern ind_t hard_alloc();
assert(passnumber == SECOND); assert(passnumber == SECOND);
assert(!incore); assert(!incore);
@ -524,8 +506,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 +521,7 @@ startrelo(head)
} }
} }
struct outrelo * struct outrelo* nextrelo(void)
nextrelo()
{ {
static struct outrelo relobuf[_RELSIZ]; static struct outrelo relobuf[_RELSIZ];
@ -615,8 +595,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);

View file

@ -100,7 +100,6 @@ entername(name, hashval)
register struct symbol *sym; register struct symbol *sym;
struct outname *newname; struct outname *newname;
extern ind_t savechar(); extern ind_t savechar();
extern ind_t hard_alloc();
debug("entername %s %d %x %x", modulptr((ind_t)name->on_foff), hashval, name->on_type, name->on_desc); debug("entername %s %d %x %x", modulptr((ind_t)name->on_foff), hashval, name->on_type, name->on_desc);
savindex = savechar(ALLOGCHR, (ind_t)name->on_foff); savindex = savechar(ALLOGCHR, (ind_t)name->on_foff);

View file

@ -136,7 +136,7 @@ int main(int argc, char* argv[])
exit(1); exit(1);
} }
} }
emitheader(); emitheader();
registerterminals(); registerterminals();
@ -1074,7 +1074,7 @@ static bool find_child_index(Tree node, const char* name, int* index, Tree* foun
return true; return true;
return false; return false;
} }
static void emit_predicate_expr(Rule r, struct expr* p) static void emit_predicate_expr(Rule r, struct expr* p)
{ {
bool first = true; bool first = true;
@ -1254,10 +1254,10 @@ static void emitinsndata(Rule rules)
int index = 0; int index = 0;
emit_input_regs(r->pattern, &index); emit_input_regs(r->pattern, &index);
} }
emit_output_constraints(r); emit_output_constraints(r);
emit_input_constraints(r); emit_input_constraints(r);
while (f) while (f)
{ {
char* data = strdup(f->data); char* data = strdup(f->data);
@ -1276,10 +1276,10 @@ static void emitinsndata(Rule rules)
{ {
Tree node; Tree node;
int index = 0; int index = 0;
Nonterm nt;
if (!find_child_index(r->pattern, label, &index, &node)) if (!find_child_index(r->pattern, label, &index, &node))
label_not_found(r, label); label_not_found(r, label);
Nonterm nt = node->op;
if (nt->kind == NONTERM) if (nt->kind == NONTERM)
{ {
if (nt->is_fragment) if (nt->is_fragment)
@ -1310,7 +1310,7 @@ static void emitinsndata(Rule rules)
assert(f->data[1] == 0); assert(f->data[1] == 0);
print("%1data->emit_eoi();\n"); print("%1data->emit_eoi();\n");
break; break;
default: default:
print("%1data->emit_string(\"%s\");\n", f->data); print("%1data->emit_string(\"%s\");\n", f->data);
} }

View file

@ -57,13 +57,12 @@ flags(s) register char *s; {
} }
fileinit() { fileinit() {
char *mktemp();
short readshort(); short readshort();
if (readshort() != (short) sp_magic) if (readshort() != (short) sp_magic)
error("wrong input file"); error("wrong input file");
if (Lflag) { if (Lflag) {
outfile = fopen(mktemp(template),"w"); outfile = fdopen(mkstemp(template),"w");
if (outfile == NULL) if (outfile == NULL)
error("can't create %s",template); error("can't create %s",template);
} else { } else {