Merge pull request #69 from kernigh/kernigh-stdc

use libc assert, strcmp; declare more functions; fewer clang warnings
This commit is contained in:
David Given 2017-11-19 12:00:40 +01:00 committed by GitHub
commit 6d91bdbbbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
191 changed files with 1433 additions and 1898 deletions

View file

@ -92,7 +92,9 @@ definerule("cppfile",
local hdrpaths = {}
for _, t in pairs(e.deps) do
hdrpaths[#hdrpaths+1] = "-I"..t.dir
if t.dir then
hdrpaths[#hdrpaths+1] = "-I"..t.dir
end
end
hdrpaths = uniquify(hdrpaths)

View file

@ -4,6 +4,9 @@
*/
/* $Id$ */
#ifndef __CGG_CG_H_INCLUDED
#define __CGG_CG_H_INCLUDED
/* offsets of interesting fields in EM-pattern */
#define PO_HASH 0
@ -165,3 +168,5 @@ typedef struct { /* one to one coercions */
if ((a=((*(b)++)&BMASK)) >= 128) {\
a = ((a-128)<<BSHIFT) | (*(b)++&BMASK); \
}
#endif /* __CGG_CG_H_INCLUDED */

View file

@ -237,6 +237,7 @@ float_cst(str, sz, buf)
#endif /* USE_FLT */
#ifdef CODE_GENERATOR
void
con_float()
{
char buf[8];

View file

@ -5,6 +5,7 @@
/* $Id$ */
/* L E X I C A L A N A L Y Z E R */
#include <assert.h>
#include <alloc.h>
#include "parameters.h"
#include "input.h"
@ -15,7 +16,6 @@
#include "LLlex.h"
#include "Lpars.h"
#include "class.h"
#include "assert.h"
#include "sizes.h"
#include "specials.h" /* registration of special identifiers */
@ -61,15 +61,15 @@ void skipcomment();
*/
PushLex()
{
ASSERT(LexSP < MAX_LL_DEPTH);
ASSERT(ASIDE == 0); /* ASIDE = 0; */
assert(LexSP < MAX_LL_DEPTH);
assert(ASIDE == 0); /* ASIDE = 0; */
GetToken(&ahead);
LexStack[LexSP++] = dot;
}
PopLex()
{
ASSERT(LexSP > 0);
assert(LexSP > 0);
dot = LexStack[--LexSP];
}
#endif /* NOPP */
@ -765,7 +765,7 @@ struct token *ptok;
int uns_flg = 0, lng_flg = 0, malformed = 0, ovfl = 0;
int fund;
ASSERT(*cp != '-');
assert(*cp != '-');
if (*cp == '0') {
cp++;
if (*cp == 'x' || *cp == 'X') {
@ -828,7 +828,7 @@ struct token *ptok;
if (val >= 0) fund = LONG;
else fund = ULONG;
} else { /* sizeof(arith) is greater than long_size */
ASSERT(arith_size > long_size);
assert(arith_size > long_size);
lexwarning("constant too large for target machine");
/* cut the size to prevent further complaints */
val &= full_mask[(int)long_size];

View file

@ -11,6 +11,7 @@
semantics of C is a mess.
*/
#include <assert.h>
#include "parameters.h"
#include <alloc.h>
#include <flt_arith.h>
@ -23,7 +24,6 @@
#include "Lpars.h"
#include "field.h"
#include "mes.h"
#include "assert.h"
extern char *symbol2str();
extern char options[];
@ -250,7 +250,7 @@ any2arith(expp, oper)
switch (fund = (*expp)->ex_type->tp_fund) {
case CHAR:
case SHORT:
ASSERT((*expp)->ex_type->tp_size <= int_type->tp_size);
assert((*expp)->ex_type->tp_size <= int_type->tp_size);
if ((*expp)->ex_type->tp_unsigned
&& (*expp)->ex_type->tp_size == int_type->tp_size) {

View file

@ -1,26 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
/* A S S E R T I O N M A C R O D E F I N I T I O N */
/* At some points in the program, it must be sure that some condition
holds true, due to further, successful, processing. As long as
there is no reasonable method to prove that a program is 100%
correct, these assertions are needed in some places.
*/
#include "parameters.h"
#ifdef DEBUG
/* Note: this macro uses parameter substitution inside strings */
#define ASSERT(exp) (exp || crash("in %s, %u: assertion %s failed", \
__FILE__, __LINE__, "exp"))
#define NOTREACHED() crash("in %s, %u: unreachable statement reached", \
__FILE__, __LINE__)
#else
#define ASSERT(exp)
#define NOTREACHED()
#endif /* DEBUG */

View file

@ -138,7 +138,12 @@ cprogram {
matching(filenamesof("+llgen"), "%.c$"),
},
deps = {
"./*.h",
"./LLlex.h", "./align.h", "./arith.h", "./atw.h",
"./class.h", "./decspecs.h", "./file_info.h",
"./input.h", "./interface.h", "./l_class.h",
"./l_comment.h", "./l_em.h", "./l_lint.h",
"./label.h", "./level.h", "./mes.h", "./sizes.h",
"./specials.h", "./tokenname.h",
"+llgen",
"+nextlib",
"+parameters",

View file

@ -5,6 +5,7 @@
/* $Id$ */
/* S E M A N T I C A N A L Y S I S -- C H A P T E R 3.3 */
#include <assert.h>
#include "parameters.h"
#include <flt_arith.h>
#include "arith.h"
@ -16,7 +17,6 @@
#include "expr.h"
#include "def.h"
#include "Lpars.h"
#include "assert.h"
#include "file_info.h"
extern char options[];
@ -119,7 +119,7 @@ ch3sel(expp, oper, idf)
struct oper *op = &(exp->ex_object.ex_oper);
if (op->op_oper == '.' || op->op_oper == ARROW) {
ASSERT(is_cp_cst(op->op_right));
assert(is_cp_cst(op->op_right));
op->op_right->VL_VALUE += sd->sd_offset;
exp->ex_type = sd->sd_type;
exp->ex_lvalue = exp->ex_type->tp_fund != ARRAY;
@ -528,7 +528,7 @@ legal_mixture(tp, otp, diag)
register struct proto *prot;
int fund;
ASSERT( (pl != 0) ^ (opl != 0));
assert( (pl != 0) ^ (opl != 0));
if (pl) {
prot = pl;
} else {
@ -592,7 +592,7 @@ int qual;
{
register struct sdef *sdf;
ASSERT(tp);
assert(tp);
if (tp->tp_typequal & qual) return 1;
switch(tp->tp_fund) {

View file

@ -5,6 +5,7 @@
/* $Id$ */
/* C O D E - G E N E R A T I N G R O U T I N E S */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
@ -32,7 +33,6 @@
#include "Lpars.h"
#include "specials.h"
#include "atw.h"
#include "assert.h"
#include "LLlex.h"
#include "align.h"
#ifdef LINT
@ -545,7 +545,7 @@ loc_init(expr, id)
static arith tmpoffset = 0;
static arith unknownsize = 0;
ASSERT(df->df_sc != STATIC);
assert(df->df_sc != STATIC);
switch (tp->tp_fund) {
case ARRAY:
if (tp->tp_size == (arith) -1)

View file

@ -5,6 +5,7 @@
/* $Id$ */
/* C O N S T A N T E X P R E S S I O N H A N D L I N G */
#include <assert.h>
#include "parameters.h"
#include <flt_arith.h>
#include "arith.h"
@ -13,7 +14,6 @@
#include "expr.h"
#include "sizes.h"
#include "Lpars.h"
#include "assert.h"
/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
arith full_mask[MAXSIZE + 1];
@ -34,7 +34,7 @@ cstbin(expp, oper, expr)
register arith o2 = expr->VL_VALUE;
int uns = (*expp)->ex_type->tp_unsigned;
ASSERT(is_ld_cst(*expp) && is_cp_cst(expr));
assert(is_ld_cst(*expp) && is_cp_cst(expr));
switch (oper) {
case '*':
o1 *= o2;
@ -144,7 +144,7 @@ cut_size(expr)
int uns = expr->ex_type->tp_unsigned;
int size = (int) expr->ex_type->tp_size;
ASSERT(expr->ex_class == Value);
assert(expr->ex_class == Value);
if (expr->ex_type->tp_fund == POINTER) {
/* why warn on "ptr-3" ?
This quick hack fixes it

View file

@ -5,7 +5,7 @@
/* $Id$ */
/* D E C L A R A T I O N S P E C I F I E R C H E C K I N G */
#include "assert.h"
#include <assert.h>
#include "Lpars.h"
#include "decspecs.h"
#include "arith.h"
@ -28,7 +28,7 @@ do_decspecs(ds)
*/
register struct type *tp = ds->ds_type;
ASSERT(level != L_FORMAL1);
assert(level != L_FORMAL1);
if ( level == L_GLOBAL &&
(ds->ds_sc == AUTO || ds->ds_sc == REGISTER)

View file

@ -5,7 +5,9 @@
/* $Id$ */
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
#include <stdlib.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include "idf.h"
#include "arith.h"
@ -15,7 +17,6 @@
#include "replace.h"
#ifndef NOPP
#include "assert.h"
#include <alloc.h>
#include "class.h"
#include "macro.h"
@ -263,7 +264,7 @@ int to_endif;
else SkipToNewLine();
break;
case K_ENDIF:
ASSERT(nestlevel > nestlow);
assert(nestlevel > nestlow);
if (nestlevel == skiplevel) {
if (SkipToNewLine()) {
if (!options['o'])
@ -383,7 +384,7 @@ do_define()
}
/* read the replacement text if there is any */
ch = skipspaces(ch,0); /* find first character of the text */
ASSERT(ch != EOI);
assert(ch != EOI);
/* UnGetChar() is not right when replacement starts with a '/' */
ChPushBack(ch);
repl_text = get_text((nformals > 0) ? formals : 0, &length);

View file

@ -8,6 +8,7 @@
#ifdef DEBUG
#include "parameters.h"
#include <ack_string.h>
#include <alloc.h>
#include <flt_arith.h>
#include "arith.h"
@ -455,8 +456,6 @@ p1_expr(lvl, expr)
break;
case String:
{
char *bts2str();
print(
"\"%s\"\n",
bts2str(expr->SG_VALUE, expr->SG_LEN-1,

View file

@ -8,6 +8,8 @@
#include "parameters.h"
#ifndef LINT
#include <assert.h>
#include <ack_string.h>
#include <em.h>
#include <em_reg.h>
#include <alloc.h>
@ -17,7 +19,6 @@
#include "type.h"
#include "label.h"
#include "code.h"
#include "assert.h"
#include "def.h"
#include "expr.h"
#include "sizes.h"
@ -32,7 +33,6 @@
#define CRASH() crash("EVAL: CRASH at line %u", __LINE__)
char *symbol2str();
char *long2str();
arith NewLocal(); /* util.c */
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
extern int err_occurred; /* error.c */
@ -83,7 +83,7 @@ EVAL(expr, val, code, true_label, false_label)
/* can only result from ','-expressions with
constant right-hand sides ???
*/
ASSERT(is_cp_cst(expr));
assert(is_cp_cst(expr));
C_bra(expr->VL_VALUE == 0 ? false_label : true_label);
}
else load_val(expr, val);
@ -254,7 +254,7 @@ EVAL(expr, val, code, true_label, false_label)
break;
case '%':
operands(expr, gencode);
ASSERT(tp->tp_fund==INT || tp->tp_fund==LONG);
assert(tp->tp_fund==INT || tp->tp_fund==LONG);
if (gencode)
if (tp->tp_unsigned)
C_rmu(tp->tp_size);
@ -554,7 +554,7 @@ EVAL(expr, val, code, true_label, false_label)
fp_used = 1;
EVAL(left, oper == '.' ? LVAL : RVAL, gencode,
NO_LABEL, NO_LABEL);
ASSERT(is_cp_cst(right));
assert(is_cp_cst(right));
if (gencode) {
C_adp(right->VL_VALUE);
}
@ -877,7 +877,7 @@ store_val(vl, tp)
}
}
else {
ASSERT(df->df_sc != STATIC);
assert(df->df_sc != STATIC);
if (inword || indword)
StoreLocal(df->df_address + val, tp->tp_size);
else {
@ -889,7 +889,7 @@ store_val(vl, tp)
else {
label dlb = vl->vl_data.vl_lbl;
ASSERT(vl->vl_class == Label);
assert(vl->vl_class == Label);
if (inword)
C_ste_dlb(dlb, val);
else
@ -964,12 +964,12 @@ load_val(expr, rlval)
register struct def *df = id->id_def;
int fund = df->df_type->tp_fund;
ASSERT(ISNAME(expr));
assert(ISNAME(expr));
if (fund == FUNCTION) {
/* the previous statement tried to catch a function
identifier, which may be cast to a pointer to a
function.
ASSERT(!(rvalue)); ???
assert(!(rvalue)); ???
*/
C_lpi(id->id_text);
}
@ -995,7 +995,7 @@ load_val(expr, rlval)
}
}
else {
/* ASSERT(df->df_sc != STATIC); */
/* assert(df->df_sc != STATIC); */
if (rvalue) {
if (inword || indword)
LoadLocal(df->df_address + val, tp->tp_size);

View file

@ -5,9 +5,9 @@
/* $Id$ */
/* EXPRESSION TREE HANDLING */
#include <assert.h>
#include <stdlib.h>
#include "parameters.h"
#include "assert.h"
#include <alloc.h>
#include <flt_arith.h>
#include "idf.h"
@ -251,7 +251,7 @@ float2expr(expr)
expr->ex_class = Float;
flt_str2flt(dot.tk_fval, &(expr->FL_ARITH));
free(dot.tk_fval);
ASSERT(flt_status != FLT_NOFLT);
assert(flt_status != FLT_NOFLT);
if (flt_status == FLT_OVFL)
expr_warning(expr,"internal floating point overflow");
}

View file

@ -10,6 +10,7 @@
#ifndef NOBITFIELD
#include <assert.h>
#include <em.h>
#include <em_reg.h>
#include <flt_arith.h>
@ -17,7 +18,6 @@
#include "type.h"
#include "label.h"
#include "code.h"
#include "assert.h"
#include "expr.h"
#include "sizes.h"
#include "align.h"
@ -55,12 +55,12 @@ eval_field(expr, code)
: word_type;
/* First some assertions to be sure that the rest is legal */
ASSERT(atype->tp_size == word_size); /* make sure that C_loc() is legal */
ASSERT(leftop->ex_type->tp_fund == FIELD);
assert(atype->tp_size == word_size); /* make sure that C_loc() is legal */
assert(leftop->ex_type->tp_fund == FIELD);
leftop->ex_type = atype; /* this is cheating but it works... */
if (op == '=') {
/* F = E: f = ((E & mask)<<shift) | (~(mask<<shift) & f) */
ASSERT(tp == rightop->ex_type);
assert(tp == rightop->ex_type);
EVAL(rightop, RVAL, TRUE, NO_LABEL, NO_LABEL);
conversion(tp, atype);
store_field(fd, tp->tp_unsigned, code, leftop, (arith) 0);

View file

@ -6,8 +6,8 @@
/* C O N S T A N T E X P R E S S I O N H A N D L I N G */
/* F O R F L O A T I N G P O I N T N U M B E R S */
#include <assert.h>
#include "parameters.h"
#include "assert.h"
#include <alloc.h>
#include <flt_arith.h>
#include "arith.h"
@ -34,7 +34,7 @@ fltcstbin(expp, oper, expr)
o1 = (*expp)->FL_ARITH;
o2 = expr->FL_ARITH;
ASSERT(is_fp_cst(*expp) && is_fp_cst(expr));
assert(is_fp_cst(*expp) && is_fp_cst(expr));
switch (oper) {
case '*':
flt_mul(&o1, &o2, &o1);

View file

@ -5,6 +5,7 @@
/* $Id$ */
/* IDENTIFIER FIDDLING & SYMBOL TABLE HANDLING */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
@ -25,7 +26,6 @@
#include "decspecs.h"
#include "sizes.h"
#include "Lpars.h"
#include "assert.h"
extern char options[];
extern arith NewLocal();
@ -88,7 +88,7 @@ declare_idf(ds, dc, lvl)
if (ds->ds_type == 0) {
/* at the L_FORMAL1 level there is no type specified yet
*/
ASSERT(lvl == L_FORMAL1);
assert(lvl == L_FORMAL1);
type = int_type; /* may change at L_FORMAL2 */
}
else {
@ -224,7 +224,7 @@ declare_idf(ds, dc, lvl)
So here we hand out local addresses only.
*/
if (lvl >= L_LOCAL) {
ASSERT(sc);
assert(sc);
switch (sc) {
case REGISTER:
case AUTO:
@ -380,7 +380,7 @@ good_formal(def, idf)
error("%s not in parameter list", idf->id_text);
return 0;
}
ASSERT(def->df_sc == FORMAL); /* CJ */
assert(def->df_sc == FORMAL); /* CJ */
return 1;
}

View file

@ -6,3 +6,11 @@
#define PRIVATE static /* or not */
#define IMPORT extern
#define EXPORT
/* Here to avoid creating another header "notreached.h" */
#ifndef NDEBUG
#define NOTREACHED() crash("in %s, %u: unreachable statement reached", \
__FILE__, __LINE__)
#else
#define NOTREACHED()
#endif /* NDEBUG */

View file

@ -6,6 +6,7 @@
/* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */
{
#include <assert.h>
#include <stdlib.h>
#include "parameters.h"
#ifndef LINT
@ -14,6 +15,7 @@
#include "l_em.h"
#include "l_lint.h"
#endif /* LINT */
#include <ack_string.h>
#include <alloc.h>
#include <assert.h>
#include <flt_arith.h>
@ -25,7 +27,6 @@
#include "proto.h"
#include "struct.h"
#include "field.h"
#include "assert.h"
#include "Lpars.h"
#include "sizes.h"
#include "align.h"
@ -38,7 +39,6 @@
#define con_nullbyte() C_con_ucon("0", (arith)1)
#define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT)
char *long2str();
char *strncpy();
extern char options[];
static int gen_error;
@ -548,7 +548,7 @@ check_ival(expp, tp)
C_con_dnam(idf->id_text, expr->VL_VALUE);
}
else {
ASSERT(expr->VL_CLASS == Label);
assert(expr->VL_CLASS == Label);
C_con_dlb(expr->VL_LBL, expr->VL_VALUE);
}
break;
@ -625,7 +625,7 @@ ch_array(tpp, ex)
register int length = ex->SG_LEN, i;
register char *to, *from, *s;
ASSERT(ex->ex_class == String);
assert(ex->ex_class == String);
if (tp->tp_size == (arith)-1) {
/* set the dimension */
tp = *tpp = construct_type(ARRAY, tp->tp_up, 0, (arith)length, NO_PROTO);
@ -696,7 +696,7 @@ put_bf(tp, val)
register struct sdef *sd = fd->fd_sdef;
static struct expr exp;
ASSERT(sd);
assert(sd);
if (offset == (arith)-1) {
/* first bitfield in this field */
offset = sd->sd_offset;
@ -737,7 +737,7 @@ valid_type(tp, str)
struct type *tp;
char *str;
{
ASSERT(tp!=(struct type *)0);
assert(tp!=(struct type *)0);
if (tp->tp_size < 0) {
error("size of %s unknown", str);
return 0;
@ -750,7 +750,7 @@ con_int(ex)
{
register struct type *tp = ex->ex_type;
ASSERT(is_cp_cst(ex));
assert(is_cp_cst(ex));
if (tp->tp_unsigned)
C_con_ucon(long2str((long)ex->VL_VALUE, -10), tp->tp_size);
else if (tp->tp_size == word_size)

View file

@ -11,7 +11,6 @@
#include <alloc.h> /* for st_free */
#include "interface.h"
#include "assert.h"
#ifdef ANSI
#include <flt_arith.h>
#endif /* ANSI */

View file

@ -9,9 +9,9 @@
#ifdef LINT
#include <assert.h>
#include <alloc.h> /* for st_free */
#include "interface.h"
#include "assert.h"
#ifdef ANSI
#include <flt_arith.h>
#endif /* ANSI */
@ -365,7 +365,7 @@ add_expr_state(value, to_state, espp)
{
register struct expr_state *esp = *espp;
ASSERT(value.vl_class == Name);
assert(value.vl_class == Name);
/* try to find the esp */
while ( esp

View file

@ -9,13 +9,14 @@
#ifdef LINT
#include <assert.h>
#include <ack_string.h>
#include <alloc.h>
#include "interface.h"
#ifdef ANSI
#include <flt_arith.h>
#endif /* ANSI */
#include "arith.h"
#include "assert.h"
#include "type.h"
#include "proto.h"
#include "declar.h"
@ -35,7 +36,6 @@
#include "l_outdef.h"
#include "l_class.h"
extern char *bts2str();
extern char *symbol2str();
int stat_number = 9999; /* static scope number */
@ -384,7 +384,7 @@ outargs(arg, n)
register struct argument *tmp;
while (n--) {
ASSERT(arg);
assert(arg);
outarg(arg);
tmp = arg;
arg = arg->next;

View file

@ -9,9 +9,9 @@
#ifdef LINT
#include <assert.h>
#include <alloc.h> /* for st_free */
#include "interface.h"
#include "assert.h"
#ifdef ANSI
#include <flt_arith.h>
#endif /* ANSI */
@ -179,7 +179,7 @@ lint_end_global(stl)
register struct stack_entry *se = stl->sl_entry;
dbg_lint_stack("lint_end_global");
ASSERT(level == L_GLOBAL);
assert(level == L_GLOBAL);
while (se) {
register struct idf *idf = se->se_idf;
register struct def *def = idf->id_def;
@ -275,7 +275,7 @@ change_state(idf, to_state)
register struct def *def = idf->id_def;
register struct auto_def *a = top_ls->ls_current->st_auto_list;
ASSERT(def);
assert(def);
switch (to_state) {
case SET:
@ -300,7 +300,7 @@ change_state(idf, to_state)
while (br && br->br_count > def->df_firstbrace) {
br = br->next;
}
ASSERT(br && def->df_minlevel >= br->br_level);
assert(br && def->df_minlevel >= br->br_level);
def->df_minlevel = br->br_level;
}
@ -340,7 +340,7 @@ add_auto(idf) /* to current state on top of lint_stack */
*/
register struct def *def = idf->id_def;
ASSERT(def);
assert(def);
switch (def->df_sc) {
register struct auto_def *a;
@ -369,7 +369,7 @@ check_autos()
*/
register struct auto_def *a = top_ls->ls_current->st_auto_list;
ASSERT(!(a && a->ad_def->df_level > level));
assert(!(a && a->ad_def->df_level > level));
while (a && a->ad_def->df_level == level) {
struct idf *idf = a->ad_idf;
struct def *def = idf->id_def;
@ -401,7 +401,7 @@ lint_end_formals()
register struct stack_entry *se = local_level->sl_entry;
dbg_lint_stack("lint_end_formals");
ASSERT(level == L_FORMAL1);
assert(level == L_FORMAL1);
while (se) {
register struct def *def = se->se_idf->id_def;
@ -581,10 +581,10 @@ merge_autos(a1, a2, lvl, mode)
a = a2; /* pointer to the result */
while (a1) {
ASSERT(a2);
assert(a2);
/* merge the auto_defs for one idf */
ASSERT(a1->ad_idf == a2->ad_idf);
assert(a1->ad_idf == a2->ad_idf);
if (a1->ad_used)
a2->ad_used = 1;
@ -605,7 +605,7 @@ merge_autos(a1, a2, lvl, mode)
a1 = a1->next;
a2 = a2->next;
}
ASSERT(!a2);
assert(!a2);
return a;
}
@ -806,7 +806,7 @@ end_loop_body()
register struct lint_stack_entry *lse = find_wdf();
dbg_lint_stack("end_loop_body");
ASSERT(lse == top_ls);
assert(lse == top_ls);
if (!lse->ls_current->st_notreached)
cont_merge(lse);
}
@ -816,7 +816,7 @@ end_loop_stmt()
register struct lint_stack_entry *lse = find_wdf();
dbg_lint_stack("end_loop_stmt");
ASSERT(lse == top_ls);
assert(lse == top_ls);
if (lse->LS_TEST != TEST_TRUE)
break_merge(lse);
@ -958,7 +958,7 @@ lint_case_stmt(dflt)
break;
case CASE:
ASSERT(top_ls->ls_previous->ls_class == SWITCH);
assert(top_ls->ls_previous->ls_class == SWITCH);
if (dflt) {
cs_entry->ls_previous->LS_DEFAULT_MET = 1;
}
@ -1079,7 +1079,7 @@ lint_end_function()
* These auto_defs must be freed and the state must be filled
* with zeros.
*/
ASSERT(!top_ls->ls_previous);
assert(!top_ls->ls_previous);
free_auto_list(top_ls->ls_current->st_auto_list);
top_ls->ls_current->st_auto_list = 0;
top_ls->ls_current->st_notreached = 0;

View file

@ -5,7 +5,9 @@
/* $Id$ */
/* MAIN PROGRAM */
#include <string.h>
#include "parameters.h"
#include <ack_string.h>
#include <system.h>
#include "idf.h"
#include "input.h"
@ -22,7 +24,6 @@
#include "sizes.h"
#include "align.h"
#include "macro.h"
#include "assert.h"
extern struct tokenname tkidf[];
extern char *symbol2str();
@ -443,7 +444,6 @@ preprocess()
case STRING:
{
char sbuf[1024]; /* a transient buffer */
char *bts2str();
print("\"%s\" ", bts2str(dot.tk_bts, dot.tk_len -
1, sbuf));

View file

@ -5,6 +5,7 @@
/* $Id$ */
/* P R O T O T Y P E F I D D L I N G */
#include <assert.h>
#include "parameters.h"
#include <alloc.h>
#include "idf.h"
@ -22,7 +23,6 @@
#include "declar.h"
#include "decspecs.h"
#include "proto.h"
#include "assert.h"
extern char options[];
@ -65,7 +65,7 @@ add_proto(pl, ds, dc, lvl)
register struct type *type;
char formal_array = 0;
ASSERT(ds->ds_type != (struct type *)0);
assert(ds->ds_type != (struct type *)0);
pl->pl_flag = PL_FORMAL;
type = declare_type(ds->ds_type, dc);

View file

@ -5,12 +5,14 @@
/* $Id$ */
/* M A C R O R E P L A C E M E N T */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#ifndef NOPP
#include <ack_string.h>
#include <alloc.h>
#include "idf.h"
#include "input.h"
@ -18,7 +20,6 @@
#include "arith.h"
#include "LLlex.h"
#include "class.h"
#include "assert.h"
#include "replace.h"
extern struct idf *GetIdentifier();
@ -85,7 +86,7 @@ EnableMacros()
{
register struct repl *r = ReplaceList, *prev = 0;
ASSERT(Unstacked > 0);
assert(Unstacked > 0);
while(r) {
struct repl *nxt = r->next;
@ -131,7 +132,7 @@ expand_macro(repl, idf)
if (mac->mc_nps != -1) { /* with parameter list */
if (mac->mc_flag & FUNC) {
/* the following assertion won't compile:
ASSERT(!strcmp("defined", idf->id_text));
assert(!strcmp("defined", idf->id_text));
expand the assert macro by hand (??? dirty, temporary)
*/
#ifdef DEBUG
@ -199,7 +200,7 @@ expand_defined(repl)
}
ChPushBack(ch);
id = GetIdentifier(0);
ASSERT(id || class(ch) == STELL);
assert(id || class(ch) == STELL);
ch = GetChar();
ch = skipspaces(ch, 0);
if (parens && ch != ')') error(") missing");
@ -514,7 +515,6 @@ macro_func(idef)
*/
register struct macro *mac = idef->id_macro;
static char FilNamBuf[PATHLENGTH];
char *long2str();
switch (idef->id_text[2]) {
case 'F': /* __FILE__ */
@ -571,7 +571,7 @@ macro2buffer(repl, idf, args)
int func = idf->id_macro->mc_nps != -1;
char *stringify();
ASSERT(ptr[idf->id_macro->mc_length] == '\0');
assert(ptr[idf->id_macro->mc_length] == '\0');
while (*ptr) {
if (*ptr == '\'' || *ptr == '"') {
register int delim = *ptr;
@ -624,7 +624,7 @@ macro2buffer(repl, idf, args)
register int n = *ptr++ & 0177;
register char *p;
ASSERT(n > 0);
assert(n > 0);
p = args->a_rawvec[n-1];
if (p) { /* else macro argument missing */
while (is_wsp(*p)) p++;
@ -660,7 +660,7 @@ macro2buffer(repl, idf, args)
register int n = *ptr++ & 0177;
register char *p, *q;
ASSERT(n > 0);
assert(n > 0);
/* This is VERY dirty, we look ahead for the
## operator. If it's found we use the raw
@ -718,7 +718,7 @@ stringify(repl, ptr, args)
register int n = *ptr++ & 0177;
register char *p;
ASSERT(n != 0);
assert(n != 0);
p = args->a_rawvec[n-1];
add2repl(repl, '"');
while (*p) {
@ -761,7 +761,7 @@ add2repl(repl, ch)
{
register int index = repl->r_ptr - repl->r_text;
ASSERT(index < repl->r_size);
assert(index < repl->r_size);
if (index + 2 >= repl->r_size) {
repl->r_text = Realloc(repl->r_text, (unsigned) (repl->r_size <<= 1));
repl->r_ptr = repl->r_text + index;
@ -785,7 +785,7 @@ stash(repl, ch, stashraw)
register int index = args->a_expptr - args->a_expbuf;
if (stashraw >= 0) {
ASSERT(index < args->a_expsize);
assert(index < args->a_expsize);
if (index + 1 >= args->a_expsize) {
args->a_expbuf = Realloc(args->a_expbuf,
(unsigned) (args->a_expsize <<= 1));
@ -796,7 +796,7 @@ stash(repl, ch, stashraw)
if (stashraw) {
index = args->a_rawptr - args->a_rawbuf;
ASSERT(index < args->a_rawsize);
assert(index < args->a_rawsize);
if (index + 1 >= args->a_rawsize) {
args->a_rawbuf = Realloc(args->a_rawbuf,
(unsigned)(args->a_rawsize <<= 1));

View file

@ -19,7 +19,6 @@
#include "Lpars.h"
#include "align.h"
#include "level.h"
#include "assert.h"
#include "sizes.h"
/* Type of previous selector declared with a field width specified,

View file

@ -5,12 +5,14 @@
/* $Id$ */
/* S W I T C H - S T A T E M E N T A D M I N I S T R A T I O N */
#include <assert.h>
#include "parameters.h"
#ifndef LINT
#include <em.h>
#else
#include "l_em.h"
#endif /* LINT */
#include <ack_string.h>
#include <alloc.h>
#include "Lpars.h"
#include "label.h"
@ -18,7 +20,6 @@
#include "arith.h"
#include "switch.h"
#include "code.h"
#include "assert.h"
#include "expr.h"
#include "type.h"
#include "sizes.h"
@ -84,8 +85,6 @@ code_startswitch(expp)
C_bra(l_table); /* goto start of switch_table */
}
extern char *long2str();
code_endswitch()
{
register struct switch_hdr *sh = switch_stack;
@ -123,7 +122,7 @@ code_endswitch()
size);
ce = sh->sh_entries;
for (val = sh->sh_lowerbd; val <= sh->sh_upperbd; val++) {
ASSERT(ce);
assert(ce);
if (val == ce->ce_value) {
C_rom_ilb(ce->ce_label);
ce = ce->next;
@ -167,7 +166,7 @@ code_case(expr)
register struct case_entry *ce;
register struct switch_hdr *sh = switch_stack;
ASSERT(is_cp_cst(expr));
assert(is_cp_cst(expr));
if (sh == 0) {
error("case statement not in switch");
return;
@ -220,7 +219,7 @@ code_case(expr)
}
}
else {
ASSERT(c2);
assert(c2);
ce->next = (struct case_entry *) 0;
c2->next = ce;
}

View file

@ -7,6 +7,7 @@
#include "parameters.h"
#include <string.h>
#include <alloc.h>
#include "input.h"
#include "arith.h"

View file

@ -89,6 +89,9 @@ cprogram {
"+tabgen_c"
),
deps = {
"./LLlex.h", "./arith.h", "./bits.h", "./class.h",
"./file_info.h", "./idf.h", "./input.h",
"./parameters.h",
"+llgen",
"+macro_h",
"+replace_h",

View file

@ -5,7 +5,9 @@
/* $Id$ */
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
#include <stdlib.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "arith.h"
#include "LLlex.h"
#include "Lpars.h"
@ -13,7 +15,6 @@
#include "input.h"
#include "parameters.h"
#include <assert.h>
#include <alloc.h>
#include "class.h"
#include "macro.h"

View file

@ -5,11 +5,12 @@
/* $Id$ */
/* MAIN PROGRAM */
#include <stdlib.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "parameters.h"
#include <alloc.h>
#include <assert.h>
#include <system.h>
#include "arith.h"
#include "file_info.h"

View file

@ -5,10 +5,12 @@
/* $Id$ */
/* M A C R O R E P L A C E M E N T */
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ack_string.h>
#include "parameters.h"
#include "alloc.h"
#include "idf.h"
@ -17,7 +19,6 @@
#include "arith.h"
#include "LLlex.h"
#include "class.h"
#include "assert.h"
#include "replace.h"
extern char *GetIdentifier();
@ -506,7 +507,6 @@ macro_func(idef)
*/
register struct macro *mac = idef->id_macro;
static char FilNamBuf[PATHLENGTH];
char *long2str();
switch (idef->id_text[2]) {
case 'F': /* __FILE__ */

View file

@ -17,7 +17,7 @@
#include <em_arith.h>
#include <em_label.h>
#include <stdlib.h>
#include <astring.h>
#include <string.h>
#include "LLlex.h"
#include "Lpars.h"
@ -59,15 +59,24 @@ char*
return "";
}
STATIC
STATIC int
GetFile(name) char* name;
{
/* Try to find a file with basename "name" and extension ".def",
in the directories mentioned in "DEFPATH".
*/
char* buf = aprintf("%s.def", name);
size_t len;
int found;
char *buf;
len = strlen(name);
buf = Malloc(len + 5);
memcpy(buf, name, len);
memcpy(buf + len, ".def", 5);
DEFPATH[0] = WorkingDir;
if (!InsertFile(buf, DEFPATH, &(FileName)))
found = InsertFile(buf, DEFPATH, &(FileName));
free(buf);
if (!found)
{
error("could not find a DEFINITION MODULE for \"%s\"", name);
return 0;

View file

@ -13,6 +13,7 @@
#include "debug.h"
#include <assert.h>
#include <ack_string.h>
#include <alloc.h>
#include <em_arith.h>
#include <em_label.h>
@ -455,7 +456,6 @@ genrck(tp)
arith lb, ub;
register label ol;
arith size = tp->tp_size;
extern char *long2str();
register t_type *btp = BaseType(tp);
if (size < word_size) size = word_size;

View file

@ -5,6 +5,7 @@
#include "parameters.h"
#include "debug.h"
#include <ack_string.h>
#include <alloc.h>
#include <assert.h>
#include <em_arith.h>
@ -475,7 +476,7 @@ CutSize(expr)
InitCst()
{
extern char *long2str(), *Salloc();
extern char *Salloc();
register int i = 0;
register arith bt = (arith)0;

View file

@ -5,6 +5,7 @@
/* next line DEBUG */
#include "debug.h"
#include <stddef.h>
#include <alloc.h>
#include <assert.h>
#include <em_arith.h>
@ -21,7 +22,7 @@
#include "scope.h"
#include "type.h"
#define PC_BUFSIZ (sizeof(struct file) - (int)((struct file *)0)->bufadr)
#define PC_BUFSIZ (sizeof(struct file) - offsetof(struct file, bufadr))
int proclevel = 0; /* nesting level of procedures */
int parlevel = 0; /* nesting level of parametersections */

View file

@ -1,5 +1,6 @@
/* H I G H L E V E L S Y M B O L E N T R Y */
#include <string.h>
#include <alloc.h>
#include <assert.h>
#include <em_arith.h>

View file

@ -1,5 +1,6 @@
/* S T A T E M E N T S */
{
#include <string.h>
#include "parameters.h"
#include <alloc.h>
#include <em.h>

View file

@ -15,6 +15,7 @@ static char rcs_mh[]= ID_MH ;
* machine dependent back end routines for the Intel 80386
*/
void
con_part(sz,w) register sz; word w; {
while (part_size % sz)
@ -32,6 +33,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz;
}
void
con_mult(sz) word sz; {
long l;
@ -92,6 +94,7 @@ long si_off;
long di_off;
int firstreg;
int
regscore(off, size, typ, score, totyp)
long off;
{
@ -104,6 +107,7 @@ regscore(off, size, typ, score, totyp)
return score;
}
void
i_regsave()
{
si_off = -1;
@ -111,6 +115,7 @@ i_regsave()
firstreg = 0;
}
void
f_regsave()
{
if (si_off != di_off) {
@ -133,8 +138,9 @@ f_regsave()
fprintf(codefile, "mov edi,%ld(ebp)\n", di_off);
}
void
regsave(regstr, off, size)
char *regstr;
const char *regstr;
long off;
{
if (strcmp(regstr, "esi") == 0) {
@ -147,6 +153,7 @@ regsave(regstr, off, size)
}
}
void
regreturn()
{
if (firstreg == 1) {
@ -165,6 +172,7 @@ regreturn()
static int gdb_flag = 0;
static char *fp_hook_nam;
void
mach_option(s)
char *s;
{

View file

@ -12,6 +12,9 @@ static char rcsid[]= "$Id$" ;
* machine dependent back end routines for the Intel 8080.
*/
#include <stdlib.h> /* atol */
void
con_part(sz,w) register sz; word w; {
while (part_size % sz)
@ -30,8 +33,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz;
}
long atol();
void
con_mult(sz) word sz; {
if (argval != 4)
@ -39,6 +41,7 @@ con_mult(sz) word sz; {
fprintf(codefile,".data4\t%ld\n",atol(str));
}
void
con_float() {
static int warning_given;
int i = argval;

View file

@ -13,6 +13,7 @@ static char rcs_mh[]= ID_MH ;
* machine dependent back end routines for the Intel 8086
*/
void
con_part(sz,w) register sz; word w; {
while (part_size % sz)
@ -31,6 +32,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz;
}
void
con_mult(sz) word sz; {
long l;
@ -83,6 +85,7 @@ long si_off;
long di_off;
int firstreg;
int
regscore(off, size, typ, score, totyp)
long off;
{
@ -95,6 +98,7 @@ regscore(off, size, typ, score, totyp)
return score;
}
void
i_regsave()
{
si_off = -1;
@ -102,6 +106,7 @@ i_regsave()
firstreg = 0;
}
void
f_regsave()
{
if (si_off != di_off) {
@ -130,8 +135,9 @@ f_regsave()
fprintf(codefile, "mov si,%ld(bp)\n", si_off);
}
void
regsave(regstr, off, size)
char *regstr;
const char *regstr;
long off;
{
if (strcmp(regstr, "si") == 0) {
@ -144,6 +150,7 @@ regsave(regstr, off, size)
}
}
void
regreturn()
{
if (firstreg == 1) {

View file

@ -17,6 +17,7 @@
#include <stb.h>
void
con_part(sz,w) register sz; word w; {
while (part_size % sz)
@ -43,6 +44,7 @@ con_part(sz,w) register sz; word w; {
part_size += sz;
}
void
con_mult(sz) word sz; {
if (sz != 4)
@ -57,6 +59,7 @@ con_mult(sz) word sz; {
#define FL_MSB_AT_LOW_ADDRESS 1
#include <con_float>
int
regscore(off,size,typ,score,totyp)
long off;
{
@ -93,6 +96,7 @@ struct regsav_t {
int regnr;
void
i_regsave()
{
regnr = 0;
@ -100,6 +104,7 @@ i_regsave()
full nlocals;
void
regreturn()
{
register struct regsav_t *p;
@ -127,6 +132,7 @@ regreturn()
fputs("unlk a6\nrts\n", codefile);
}
void
f_regsave()
{
register struct regsav_t *p;
@ -176,8 +182,9 @@ f_regsave()
}
}
void
regsave(s,off,size)
char *s;
const char *s;
long off;
{
assert (regnr < 9);
@ -196,6 +203,7 @@ prolog(n) full n; {
#ifdef MACH_OPTIONS
static int gdb_flag = 0;
void
mach_option(s)
char *s;
{

View file

@ -13,6 +13,7 @@
static long framesize;
void
con_part(int sz, word w)
{
while (part_size % sz)
@ -34,6 +35,7 @@ con_part(int sz, word w)
part_size += sz;
}
void
con_mult(word sz)
{
@ -146,6 +148,7 @@ regscore(long offset, int size, int type, int frequency, int totype)
/* Initialise regvar system for one function. */
void
i_regsave(void)
{
int i;
@ -163,6 +166,7 @@ i_regsave(void)
/* Mark a register as being saved. */
void
regsave(const char* regname, long offset, int size)
{
int regnum = atoi(regname + 1);
@ -223,6 +227,7 @@ saveloadregs(const char* ops, const char* opm, const char *opf)
}
}
void
f_regsave(void)
{
int reg;
@ -248,6 +253,7 @@ f_regsave(void)
/* Restore all saved registers. */
void
regreturn(void)
{
saveloadregs("lwz", "lmw", "lfd");

View file

@ -21,6 +21,8 @@ definerule("build_as",
srcs = { "mach/proto/as/comm2.y" },
outleaf = "comm2.y",
deps = {
"mach/proto/as/comm0.h",
"mach/proto/as/comm1.h",
"h+emheaders",
archlib,
},

View file

@ -105,16 +105,16 @@ _include "out.h"
#include "out.h"
#endif
#if DEBUG == 0
#define assert(ex) /* nothing */
/*
* Define assert(). Disable assertions if DEBUG == 0.
*/
#if DEBUG == 0 && !defined(NDEBUG)
#define NDEBUG
#endif
#if DEBUG == 1
#define assert(ex) {if (!(ex)) assert1();}
#endif
#if DEBUG == 2
#define assert(ex) {if (!(ex)) assert2(__FILE__, __LINE__);}
#ifdef _include
_include <assert.h>
#else
#include <assert.h>
#endif
#define CTRL(x) ((x) & 037)

View file

@ -104,6 +104,11 @@ extern struct outhead outhead;
extern int curr_token;
/* forward function declarations */
/* comm2.y */
int 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 ========== */

View file

@ -15,15 +15,23 @@
#include "comm0.h"
#include "comm1.h"
#include "y.tab.h"
#include <object.h>
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);
/*

View file

@ -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 {
@ -283,8 +283,9 @@ induo(int c)
('>'<<8) | '>', OP_RR,
('|'<<8) | '|', OP_OO,
('&'<<8) | '&', OP_AA,
0 /* terminates array */
};
register short *p;
short *p;
c = (c<<8) | nextchar();
for (p = duo; *p; p++)
@ -299,9 +300,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 +331,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 +348,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 +395,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 +435,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 +464,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 +491,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 +505,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 +533,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 +554,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 +569,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)

View file

@ -11,14 +11,12 @@
#include "comm0.h"
#include "comm1.h"
#include "y.tab.h"
#include <object.h>
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,13 +77,10 @@ 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;
#endif
#if defined(THREE_PASS) && !defined(NDEBUG)
ADDR_T oldval = ip->i_valu;
#endif
if (DOTSCT == NULL)
@ -100,11 +94,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 +132,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 +160,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 +183,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 +201,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 +242,7 @@ valu_t bytes;
#ifdef RELOCATION
void
newrelo(s, n)
newrelo(int s, int n)
{
int iscomm;
struct outrelo outrelo;
@ -319,8 +311,7 @@ newrelo(s, n)
#endif
long
new_string(s)
char *s;
new_string(const char *s)
{
long r = 0;
@ -335,9 +326,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 +346,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) {

View file

@ -11,14 +11,14 @@
#include "comm0.h"
#include "comm1.h"
#include "y.tab.h"
#include <stdarg.h>
#include <stdarg.h>
#include <object.h>
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)
@ -406,22 +406,7 @@ void fatal(const char* s, ...)
va_end(ap);
}
#if DEBUG == 2
assert2(file, line)
char *file;
{
fatal("assertion failed (%s, %d)", file, line);
}
#endif
#if DEBUG == 1
assert1()
{
fatal("assertion failed");
abort();
}
#endif
/* VARARGS1 */
void serror(const char* s, ...)
{
va_list ap;
@ -447,7 +432,8 @@ void warning(const char* s, ...)
va_end(ap);
}
nofit()
void
nofit(void)
{
if (pass == PASS_3)
warning("too big");

View file

@ -1,12 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
#undef NDEBUG
#ifndef NDEBUG
#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__)
#else
#define assert(x) /* nothing */
#endif

View file

@ -11,7 +11,15 @@ definerule("build_ncg",
name = e.name.."/headers",
srcs = {},
hdrs = {
"mach/proto/ncg/*.h",
"mach/proto/ncg/data.h",
"mach/proto/ncg/equiv.h",
"mach/proto/ncg/glosym.h",
"mach/proto/ncg/label.h",
"mach/proto/ncg/param.h",
"mach/proto/ncg/regvar.h",
"mach/proto/ncg/result.h",
"mach/proto/ncg/state.h",
"mach/proto/ncg/types.h",
"mach/"..e.arch.."/ncg/mach.c",
"mach/"..e.arch.."/ncg/*.h",
}

View file

@ -2,9 +2,9 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
@ -14,6 +14,9 @@ static char rcsid[] = "$Id$";
#include "state.h"
#include "equiv.h"
#include "extern.h"
#ifdef REGVARS
#include "regvar.h" /* regreturn */
#endif
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
@ -27,13 +30,6 @@ static char rcsid[] = "$Id$";
byte startupcode[] = { DO_NEXTEM };
byte* nextem();
unsigned costcalc();
unsigned docoerc();
unsigned stackupto();
string tostring();
string ad2str();
#ifdef NDEBUG
#define DEBUG(string)
#else
@ -124,7 +120,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
byte* bp;
int n;
unsigned mindistance, dist;
register i;
int i;
int cindex;
int npos, pos[MAXRULE];
unsigned mincost, t;
@ -295,8 +291,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
DEBUG("XXMATCH");
case DO_XMATCH:
{
register i;
int temp;
int i, temp;
DEBUG("XMATCH");
tokpatlen = (codep[-1] >> 5) & 07;
@ -306,8 +301,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
}
case DO_MATCH:
{
register i;
int j;
int i, j;
unsigned mincost, t;
token_p tp;
int size, lsize;
@ -603,8 +597,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
case DO_KILLREG:
case DO_RREMOVE:
{ /* register remove */
register i;
int nodeno;
int i, nodeno;
token_p tp;
tkdef_p tdp;
result_t result;
@ -650,7 +643,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
}
case DO_DEALLOCATE:
{
register i;
int i;
tkdef_p tdp;
int tinstno;
token_t token;
@ -684,8 +677,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
}
case DO_ALLOCATE:
{
register i;
int j;
int i, j;
int tinstno;
int npos, npos2, pos[NREGS], pos2[NREGS];
unsigned mincost, t;
@ -844,8 +836,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
}
case DO_INSTR:
{
register i;
int n;
int i, n;
int tinstno;
token_t token;
int stringno;
@ -933,7 +924,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
}
case DO_TOKREPLACE:
{
register i;
int i;
int tinstno;
int repllen;
token_t reptoken[MAXREPLLEN];
@ -969,8 +960,7 @@ unsigned codegen(byte* codep, int ply, int toplevel, unsigned costlimit, int for
}
case DO_EMREPLACE:
{
register i;
int j;
int i, j;
int nodeno;
result_t result[MAXEMREPLLEN];
int emrepllen, eminstr;
@ -1093,10 +1083,10 @@ doreturn:
return (totalcost);
}
readcodebytes()
void readcodebytes(void)
{
#ifndef CODEINC
register fd;
int fd;
extern int ncodebytes;
if ((fd = open("code", 0)) < 0)
@ -1108,13 +1098,12 @@ readcodebytes()
error("Short read from code");
}
close(fd);
#endif
#endif /* CODEINC */
}
#ifdef TABLEDEBUG
initlset(f) char* f;
void initlset(char *f)
{
extern char* myalloc();
set_flag = f;
if ((set_fd = open(f + 1, 2)) < 0)
@ -1124,7 +1113,7 @@ initlset(f) char* f;
read(set_fd, set_val, set_size);
}
termlset()
void termlset(void)
{
if (set_fd)
@ -1134,7 +1123,7 @@ termlset()
close(set_fd);
if (set_flag[0] == 'u')
{
register i;
int i;
fprintf(stderr, "Unused code rules:\n\n");
for (i = 0; i < 8 * set_size; i++)
@ -1143,4 +1132,4 @@ termlset()
}
}
}
#endif
#endif /* TABLEDEBUG */

View file

@ -2,10 +2,10 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
@ -35,7 +35,7 @@ static char rcsid[] = "$Id$";
#define LLDEF LLEAF|LDEF
#define RLDEF RLEAF|RDEF
char opdesc[] = {
static const char opdesc[] = {
0, /* EX_TOKFIELD */
0, /* EX_ARG */
0, /* EX_CON */
@ -87,10 +87,8 @@ char opdesc[] = {
#endif
};
string salloc(),strcpy(),strcat();
string mycat(s1,s2) register string s1,s2; {
register string s;
static string mycat(string s1, string s2) {
string s;
if (s1==0 || *s1=='\0') return(s2);
if (s2==0 || *s2=='\0') return(s1);
@ -101,7 +99,7 @@ string mycat(s1,s2) register string s1,s2; {
return(s);
}
string mystrcpy(s) register string s; {
string mystrcpy(string s) {
register string r;
r=salloc(strlen(s));
@ -109,9 +107,9 @@ string mystrcpy(s) register string s; {
return(r);
}
char digstr[21][15];
static char digstr[21][15];
string tostring(n) register word n; {
string tostring(word n) {
char buf[25];
if (n>=-20 && n<=20 && (n&1)==0) {
@ -123,10 +121,9 @@ string tostring(n) register word n; {
return(mystrcpy(buf));
}
void
compute(node, presult) register node_p node; register result_t *presult; {
void compute(node_p node, result_t *presult) {
result_t leaf1,leaf2;
register token_p tp;
token_p tp;
int desc;
long mask,tmp;
int i,tmpreg;

View file

@ -4,6 +4,8 @@
*/
/* $Id$ */
#include <cgg_cg.h> /* set_p, c3_p */
typedef struct cost {
short ct_space;
short ct_time;
@ -69,3 +71,32 @@ typedef struct {
int rl_n; /* number in list */
int rl_list[NREGS];
} rl_t,*rl_p;
/* gencode.c */
void genstr(int);
string ad2str(address_t);
void gennl(void);
void prtoken(token_p, int);
#ifdef USE_TES
void printlabel(int);
#endif
/* move.c */
int move(token_p, token_p, int, int, unsigned);
void setcc(token_p);
int test(token_p, int, int, unsigned);
/* subr.c */
int match(token_p, set_p, int);
void instance(int, token_p);
int eqtoken(token_p, token_p);
int distance(int);
unsigned costcalc(cost_t);
int ssize(int);
int tsize(token_p);
void tref(token_p, int);
int in_stack(int);
#ifdef MAXSPLIT
int split(token_p, int *, int, int);
#endif
unsigned docoerc(token_p, c3_p, int, int, int);
unsigned stackupto(token_p, int, int);
c3_p findcoerc(token_p, set_p);

View file

@ -2,15 +2,15 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "equiv.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cgg_cg.h>
#include "data.h"
#include "equiv.h"
#include "result.h"
#include "extern.h"
@ -21,21 +21,18 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren
*/
extern string myalloc();
static int rar[MAXCREG];
static rl_p *lar;
static int maxindex;
static int regclass[NREGS];
static struct perm *perms;
int rar[MAXCREG];
rl_p *lar;
int maxindex;
int regclass[NREGS];
struct perm *perms;
static void permute(int);
void permute();
struct perm *
tuples(regls,nregneeded) rl_p *regls; {
struct perm *tuples(rl_p *regls, int nregneeded) {
int class=0;
register i,j;
register struct reginfo *rp;
int i,j;
struct reginfo *rp;
/*
* First compute equivalence classes of registers.
@ -66,11 +63,10 @@ tuples(regls,nregneeded) rl_p *regls; {
return(perms);
}
void
permute(index) {
register struct perm *pp;
register rl_p rlp;
register i,j;
static void permute(int index) {
struct perm *pp;
rl_p rlp;
int i,j;
if (index == maxindex) {
for (pp=perms; pp != 0; pp=pp->p_next) {

View file

@ -10,3 +10,5 @@ struct perm {
struct perm *p_next;
int p_rar[MAXCREG];
};
struct perm *tuples(rl_p *, int);

View file

@ -54,6 +54,3 @@ extern int *rvnumbers[]; /* lists of numbers */
#endif
extern FILE *codefile;
extern void error(const char *s, ...);
extern void fatal(const char *s, ...);

View file

@ -2,10 +2,10 @@
static char rcsid2[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "assert.h"
#include <em_spec.h>
#include <em_pseu.h>
#include <em_flag.h>
@ -17,6 +17,7 @@ static char rcsid2[] = "$Id$";
#include "types.h"
#include <cgg_cg.h>
#include "data.h"
#include "glosym.h"
#include "result.h"
#ifdef REGVARS
#include "regvar.h"
@ -55,50 +56,60 @@ Read the documentation.
#define SEGROM 2
#define SEGBSS 3
long con();
#define get8() getc(emfile)
FILE *emfile;
static FILE *emfile;
int nextispseu,savetab1;
int opcode;
int offtyp;
long argval;
int dlbval;
char *str,argstr[128],labstr[128];
unsigned int maxstrsiz;
int strsiz;
int holno=0;
int procno=0;
int curseg= -1;
int part_size=0;
word part_word=0;
static int nextispseu,savetab1;
static int opcode;
static int offtyp;
static long argval;
static int dlbval;
static char *str,argstr[128],labstr[128];
static unsigned int maxstrsiz;
static int strsiz;
static int holno=0;
static int procno=0;
static int curseg= -1;
static int part_size=0;
static word part_word=0;
#ifdef REGVARS
int regallowed=0;
static int regallowed=0;
#endif
extern char em_flag[];
extern short em_ptyp[];
extern double atof();
/* machine dependent */
void con_part(int, word);
void con_mult(word);
void con_float(void);
void prolog(full nlocals);
void mes();
void bss();
void savelab();
void dumplab();
void part_flush();
void xdumplab();
void switchseg();
void mes(word);
static int getarg(int);
static int table1(void);
static int table2(void);
static int table3(int);
static int get16(void);
static long get32(void);
static void getstring(void);
static string strarg(int);
static void bss(full, int, int);
static long con(int);
static void switchseg(int);
static void savelab(void);
static void dumplab(void);
static void xdumplab(void);
static void part_flush(void);
static string holstr(word);
/* Own version of atol that continues computing on overflow.
We don't know that about the ANSI C one.
*/
long our_atol(s)
register char *s;
{
register long total = 0;
register unsigned digit;
static long our_atol(char *s) {
long total = 0;
unsigned digit;
int minus = 0;
while (*s == ' ' || *s == '\t') s++;
@ -117,14 +128,7 @@ register char *s;
#define sp_cstx sp_cst2
string tostring();
string holstr();
string strarg();
string mystrcpy();
string myalloc();
long get32();
in_init(filename) char *filename; {
void in_init(char *filename) {
emfile = stdin;
if (filename && (emfile=freopen(filename,"r",stdin))==NULL)
@ -134,19 +138,18 @@ in_init(filename) char *filename; {
str = myalloc(maxstrsiz=256);
}
in_start() {
void in_start(void) {
#ifdef modhead
fprintf(codefile,"%s",modhead) ;
#endif
}
in_finish() {
static void in_finish(void) {
}
void
fillemlines() {
register int t,i;
register struct emline *lp;
void fillemlines(void) {
int t,i;
struct emline *lp;
while ((emlines+nemlines)-emp<MAXEMLINES-5) {
assert(nemlines<MAXEMLINES);
@ -236,18 +239,17 @@ fillemlines() {
void
dopseudo() {
register b,t;
register full n;
register long save;
int b,t;
full n;
long save;
word romcont[MAXROM+1];
int nromwords;
int rombit,rommask;
unsigned stackupto();
if (nextispseu==0 || nemlines>0)
error("No table entry for %d",emlines[0].em_instr);
nextispseu=0;
switch(savetab1) {
switch (savetab1) {
#ifndef USE_TES
case sp_ilb1:
case sp_ilb2:
@ -439,8 +441,8 @@ dopseudo() {
/* ----- input ----- */
int getarg(typset) {
register t,argtyp;
static int getarg(int typset) {
int t,argtyp;
argtyp = t = table2();
if (t == EOF)
@ -452,8 +454,8 @@ int getarg(typset) {
return(argtyp);
}
int table1() {
register i;
static int table1(void) {
int i;
i = get8();
if (i < sp_fmnem+sp_nmnem && i >= sp_fmnem) {
@ -471,8 +473,8 @@ int table1() {
return(table3(i));
}
int table2() {
register i;
static int table2(void) {
int i;
i = get8();
if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) {
@ -482,7 +484,7 @@ int table2() {
return(table3(i));
}
int table3(i) {
static int table3(int i) {
word consiz;
switch(i) {
@ -525,8 +527,8 @@ int table3(i) {
return(i);
}
int get16() {
register int l_byte, h_byte;
static int get16(void) {
int l_byte, h_byte;
l_byte = get8();
h_byte = get8();
@ -534,9 +536,9 @@ int get16() {
return l_byte | (h_byte*256) ;
}
long get32() {
register long l;
register int h_byte;
static long get32(void) {
long l;
int h_byte;
l = get8();
l |= ((unsigned) get8())*256 ;
@ -546,9 +548,9 @@ long get32() {
return l | (h_byte*256L*256*256L) ;
}
getstring() {
register char *p;
register n;
static void getstring(void) {
char *p;
int n;
getarg(cst_ptyp);
if (argval < 0)
@ -565,8 +567,8 @@ getstring() {
*p++ = '\0';
}
char *strarg(t) {
register char *p;
static string strarg(int t) {
char *p;
switch (t) {
case sp_ilb1:
@ -613,9 +615,8 @@ char *strarg(t) {
return(mystrcpy(argstr));
}
void
bss(n,t,b) full n; {
register long s = 0;
static void bss(full n, int t, int b) {
long s = 0;
if (n % TEM_WSIZE)
fatal("bad BSS size");
@ -637,8 +638,8 @@ bss(n,t,b) full n; {
fatal("bad BSS initializer");
}
long con(t) {
register i;
static long con(int t) {
int i;
strarg(t);
switch (t) {
@ -682,12 +683,11 @@ long con(t) {
extern char *segname[];
swtxt() {
void swtxt(void) {
switchseg(SEGTXT);
}
void
switchseg(s) {
static void switchseg(int s) {
if (s == curseg)
return;
@ -696,8 +696,7 @@ switchseg(s) {
fprintf(codefile,"%s\n",segname[s]);
}
void
savelab() {
static void savelab(void) {
register char *p,*q;
part_flush();
@ -711,8 +710,7 @@ savelab() {
;
}
void
dumplab() {
static void dumplab(void) {
if (labstr[0] == 0)
return;
@ -721,8 +719,7 @@ dumplab() {
labstr[0] = 0;
}
void
xdumplab() {
static void xdumplab(void) {
if (labstr[0] == 0)
return;
@ -730,8 +727,7 @@ xdumplab() {
newdlb(labstr);
}
void
part_flush() {
static void part_flush(void) {
/*
* Each new data fragment and each data label starts at
@ -744,7 +740,7 @@ part_flush() {
part_word = 0;
}
string holstr(n) word n; {
static string holstr(word n) {
sprintf(str,hol_off,n,holno);
return(mystrcpy(str));

View file

@ -2,8 +2,9 @@
static char rcsid[] = "$Id$";
#endif
#include "assert.h"
#include <assert.h>
#include <stdio.h>
#include <unistd.h> /* isatty */
#include "param.h"
#include "tables.h"
#include "types.h"
@ -22,12 +23,9 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren
*/
string mystrcpy();
FILE *codefile;
extern FILE *freopen();
out_init(filename) char *filename; {
void out_init(char *filename) {
#ifndef NDEBUG
static char stderrbuff[BUFSIZ];
@ -48,7 +46,7 @@ out_init(filename) char *filename; {
#endif
}
out_finish() {
void out_finish(void) {
#ifndef NDEBUG
if (Debug)
@ -61,18 +59,18 @@ out_finish() {
#endif
}
tstoutput() {
void tstoutput(void) {
if (ferror(codefile))
error("Write error on output");
}
genstr(stringno) {
void genstr(int stringno) {
fputs(codestrings[stringno],codefile);
}
string ad2str(ad) address_t ad; {
string ad2str(address_t ad) {
static char buf[100];
if (ad.ea_str==0)
@ -87,7 +85,7 @@ string ad2str(ad) address_t ad; {
return(mystrcpy(buf));
}
praddr(ad) address_t ad; {
static void praddr(address_t ad) {
if (ad.ea_str==0 || *(ad.ea_str) == '\0')
fprintf(codefile,WRD_FMT,ad.ea_off);
@ -104,15 +102,14 @@ praddr(ad) address_t ad; {
}
}
gennl() {
void gennl(void) {
putc('\n',codefile);
}
void
prtoken(tp,leadingchar) token_p tp; {
register c;
register char *code;
register tkdef_p tdp;
void prtoken(token_p tp, int leadingchar) {
int c;
char *code;
tkdef_p tdp;
putc(leadingchar,codefile);
if (tp->t_token == -1) {
@ -145,9 +142,7 @@ prtoken(tp,leadingchar) token_p tp; {
}
#ifdef USE_TES
printlabel(labnum)
int labnum;
{
void printlabel(int labnum) {
newilb(dollar[labnum].e_v.e_addr.ea_str);
}
#endif

View file

@ -16,13 +16,11 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren
*/
extern string myalloc();
static glosym_p glolist= (glosym_p) 0;
glosym_p glolist= (glosym_p) 0;
enterglo(name,romp) string name; word *romp; {
register glosym_p gp;
register i;
void enterglo(string name, word *romp) {
glosym_p gp;
int i;
gp = (glosym_p) myalloc(sizeof *gp);
gp->gl_next = glolist;
@ -33,8 +31,8 @@ enterglo(name,romp) string name; word *romp; {
glolist = gp;
}
glosym_p lookglo(name) string name; {
register glosym_p gp;
glosym_p lookglo(string name) {
glosym_p gp;
for (gp=glolist;gp != (glosym_p) 0; gp=gp->gl_next)
if (strcmp(gp->gl_name,name)==0)

View file

@ -10,4 +10,5 @@ typedef struct glosym {
word gl_rom[MAXROM+1];
} glosym_t,*glosym_p;
glosym_p lookglo();
void enterglo(string, word *);
glosym_p lookglo(string);

View file

@ -5,12 +5,10 @@
#include "label.h"
static label_p label_list = (label_p)0;
extern char *myalloc();
void
add_label(num, height, flth)
void add_label(num, height, flth)
{
register label_p lbl = (label_p)0;
label_p lbl = (label_p)0;
if (height <= 0) return;
if (flth != TRUE && flth != FALSE)
@ -24,10 +22,9 @@ add_label(num, height, flth)
label_list = lbl;
}
label_p get_label(num)
register word num;
label_p get_label(word num)
{
register label_p tmp = label_list;
label_p tmp = label_list;
while (tmp != (label_p)0) {
if (tmp->lb_number == num) return tmp;
@ -36,7 +33,7 @@ register word num;
return (label_p)0;
}
kill_labels()
void kill_labels(void)
{
label_p tmp;

View file

@ -14,4 +14,6 @@ struct label {
short lb_fallthrough;
};
extern label_p get_label();
void add_label(int, int, int);
label_p get_label(word);
void kill_labels(void);

View file

@ -2,8 +2,10 @@
static char rcsid[] = "$Id$";
#endif
#include <stdlib.h> /* atoi */
#include "param.h"
#include "tables.h"
#include "types.h"
#include "mach.h"
/*
@ -14,18 +16,18 @@ static char rcsid[] = "$Id$";
*/
char *progname;
extern char startupcode[];
extern unsigned codegen();
extern byte startupcode[]; /* codegen.c */
int maxply=1;
#ifndef NDEBUG
int Debug=0;
char *strtdebug="";
#endif
main(argc,argv) char **argv; {
register unsigned n;
extern unsigned cc1,cc2,cc3,cc4;
unsigned ggd();
static unsigned ggd(unsigned, unsigned);
int main(int argc, char **argv) {
unsigned n;
extern unsigned cc1,cc2,cc3,cc4; /* tables.c */
progname = argv[0];
while (--argc && **++argv == '-') {
@ -84,8 +86,8 @@ main(argc,argv) char **argv; {
error("Bombed out of codegen");
}
unsigned ggd(a,b) register unsigned a,b; {
register unsigned c;
unsigned ggd(unsigned a, unsigned b) {
unsigned c;
do {
c = a%b; a=b; b=c;

View file

@ -2,9 +2,9 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
@ -20,13 +20,12 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren
*/
move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; {
register move_p mp;
int move(token_p tp1, token_p tp2, int ply, int toplevel, unsigned maxcost) {
move_p mp;
unsigned t;
register struct reginfo *rp;
register byte *tdpb;
struct reginfo *rp;
byte *tdpb;
int i;
unsigned codegen();
if (eqtoken(tp1,tp2))
return(0);
@ -97,15 +96,14 @@ move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; {
#define cocoreg machregs[0].r_contents
setcc(tp) token_p tp; {
void setcc(token_p tp) {
cocoreg = *tp;
}
test(tp,ply,toplevel,maxcost) token_p tp; unsigned maxcost; {
register test_p mp;
int test(token_p tp, int ply, int toplevel, unsigned maxcost) {
test_p mp;
unsigned t;
unsigned codegen();
if (cocoreg.t_token!=0) {
if (eqtoken(tp,&cocoreg))

View file

@ -2,11 +2,11 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <em_spec.h>
#include <em_flag.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
@ -27,8 +27,10 @@ static char rcsid[] = "$Id$";
extern char em_mnem[][4];
#endif
byte *trypat(bp,len) register byte *bp; {
register patlen,i;
static int argtyp(int);
static byte *trypat(byte *bp, int len) {
int patlen,i;
result_t result;
getint(patlen,bp);
@ -39,7 +41,7 @@ byte *trypat(bp,len) register byte *bp; {
if (patlen != len)
return(0);
}
for(i=0;i<patlen;i++)
for (i=0;i<patlen;i++)
if (emp[i].em_instr != (*bp++&BMASK))
return(0);
for (i=0;i<patlen;i++)
@ -85,7 +87,7 @@ byte *trypat(bp,len) register byte *bp; {
extern char em_flag[];
argtyp(mn) {
static int argtyp(int mn) {
/* op_lab is a special opcode which represents a label definition. It's
* not actually a real EM instruction. Therefore if we try to look it
@ -94,7 +96,7 @@ argtyp(mn) {
if (mn == op_lab)
return EV_UNDEF;
switch(em_flag[mn-sp_fmnem]&EM_PAR) {
switch (em_flag[mn-sp_fmnem]&EM_PAR) {
case PAR_W:
case PAR_S:
case PAR_Z:
@ -110,13 +112,13 @@ argtyp(mn) {
}
}
byte *nextem(toplevel) {
register i;
byte *nextem(int toplevel) {
int i;
short hash[3];
register byte *bp;
byte *bp;
byte *cp;
int index;
register struct emline *ep;
struct emline *ep;
if (toplevel) {
if (nemlines && emp>emlines) {

View file

@ -2,9 +2,9 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
@ -20,10 +20,10 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren
*/
chrefcount(regno,amount,tflag) {
register struct reginfo *rp;
void chrefcount(int regno, int amount, int tflag) {
struct reginfo *rp;
#if MAXMEMBERS != 0
register i, tmp;
int i, tmp;
#endif
rp= &machregs[regno];
@ -42,10 +42,10 @@ chrefcount(regno,amount,tflag) {
#endif
}
getrefcount(regno, tflag) {
register struct reginfo *rp;
int getrefcount(int regno, int tflag) {
struct reginfo *rp;
#if MAXMEMBERS != 0
register i,maxcount, tmp;
int i,maxcount, tmp;
#endif
rp= &machregs[regno];
@ -66,10 +66,10 @@ getrefcount(regno, tflag) {
#endif
}
erasereg(regno) {
register struct reginfo *rp = &machregs[regno];
register int i;
register byte *tdpb;
void erasereg(int regno) {
struct reginfo *rp = &machregs[regno];
int i;
byte *tdpb;
#if MAXMEMBERS==0
rp->r_contents.t_token = 0;
@ -108,7 +108,7 @@ erasereg(regno) {
}
#else
extern short clashlist[];
register short *sp = &clashlist[rp->r_iclash];
short *sp = &clashlist[rp->r_iclash];
rp->r_contents.t_token = 0;
while (*sp) {
@ -151,9 +151,9 @@ erasereg(regno) {
#endif
}
cleanregs() {
register struct reginfo *rp;
register i;
void cleanregs(void) {
struct reginfo *rp;
int i;
for (rp=machregs;rp<machregs+NREGS;rp++) {
rp->r_contents.t_token = 0;
@ -163,9 +163,9 @@ cleanregs() {
}
#ifndef NDEBUG
inctcount(regno) {
register struct reginfo *rp;
register i;
static void inctcount(int regno) {
struct reginfo *rp;
int i;
rp = &machregs[regno];
#if MAXMEMBERS!=0
@ -181,10 +181,10 @@ inctcount(regno) {
#endif
}
chkregs() {
register struct reginfo *rp;
register token_p tp;
register byte *tdpb;
void chkregs(void) {
struct reginfo *rp;
token_p tp;
byte *tdpb;
int i;
for (rp=machregs+1;rp<machregs+NREGS;rp++) {

View file

@ -1,6 +1,6 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
@ -24,12 +24,10 @@ static char rcsid[] = "$Id$";
*
* Author: Hans van Staveren
*/
extern string myalloc();
struct regvar *rvlist;
static struct regvar *rvlist;
struct regvar *
linkreg(long of, int sz, int tp, int sc) {
register struct regvar *rvlp;
struct regvar *linkreg(long of, int sz, int tp, int sc) {
struct regvar *rvlp;
rvlp= (struct regvar *) myalloc(sizeof *rvlp);
rvlp->rv_next = rvlist;
@ -42,11 +40,10 @@ linkreg(long of, int sz, int tp, int sc) {
return(rvlp);
}
void
tryreg(struct regvar *rvlp, int typ) {
void tryreg(struct regvar *rvlp, int typ) {
int score;
register i;
register struct regassigned *ra;
int i;
struct regassigned *ra;
struct regvar *save;
if (typ != reg_any && nregvar[typ]!=0) {
@ -100,8 +97,7 @@ tryreg(struct regvar *rvlp, int typ) {
}
}
void
fixregvars(int saveall) {
void fixregvars(int saveall) {
struct reginfo *rp, *rp2;
struct regvar *rv;
int i, regno, rvtyp;
@ -146,9 +142,8 @@ fixregvars(int saveall) {
f_regsave();
}
int
isregvar(long off) {
register struct regvar *rvlp;
int isregvar(long off) {
struct regvar *rvlp;
for(rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next)
if(rvlp->rv_off == off)
@ -157,8 +152,7 @@ isregvar(long off) {
}
#ifdef REGLAP
int
isregvar_size(long off, int size) {
int isregvar_size(long off, int size) {
int regno = isregvar(off);
/*
* A reg_float may have two sizes. If this register has the
@ -176,29 +170,27 @@ isregvar_size(long off, int size) {
}
#endif /* REGLAP */
int
isregtyp(long off) {
register struct regvar *rvlp;
int isregtyp(long off) {
struct regvar *rvlp;
for(rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next)
if(rvlp->rv_off == off)
for (rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next)
if (rvlp->rv_off == off)
return(rvlp->rv_reg ? rvlp->rv_type+1 : 0);
return(-1);
}
void
unlinkregs(void) {
register struct regvar *rvlp,*t;
register struct regassigned *ra;
void unlinkregs(void) {
struct regvar *rvlp,*t;
struct regassigned *ra;
int rvtyp,i;
for(rvlp=rvlist;rvlp!=0;rvlp=t) {
for (rvlp=rvlist;rvlp!=0;rvlp=t) {
t=rvlp->rv_next;
myfree((string)rvlp);
}
rvlist=0;
for (rvtyp=reg_any;rvtyp<=reg_float;rvtyp++) {
for(i=0;i<nregvar[rvtyp];i++) {
for (i=0;i<nregvar[rvtyp];i++) {
ra= &regassigned[rvtyp][i];
ra->ra_rv = 0;
ra->ra_score = 0;

View file

@ -18,7 +18,6 @@ struct regassigned {
int ra_score;
};
extern struct regvar *rvlist;
extern int nregvar[];
extern struct regassigned *regassigned[];
@ -37,3 +36,10 @@ void unlinkregs(void);
#else
#define PICK_REGVAR(off, size) isregvar(off)
#endif
/* machine dependent */
int regscore(long, int, int, int, int);
void i_regsave(void);
void regsave(const char *, long, int);
void f_regsave(void);
void regreturn(void);

View file

@ -19,3 +19,6 @@ struct result {
#define EV_ADDR 3
typedef struct result result_t;
/* compute.c */
void compute(node_p, result_t *);

View file

@ -2,9 +2,9 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
@ -32,10 +32,10 @@ static char rcsid[] = "$Id$";
char *stab[MAXSTAB];
int nstab=0;
void chkstr();
static void chkstr(string, char *);
string myalloc(size) {
register string p;
string p;
p = (string) calloc((unsigned)size, 1);
if (p==0)
@ -43,21 +43,21 @@ string myalloc(size) {
return(p);
}
myfree(p) string p; {
void myfree(string p) {
free(p);
}
popstr(nnstab) {
register i;
void popstr(int nnstab) {
int i;
for (i=nnstab;i<nstab;i++)
myfree(stab[i]);
nstab = nnstab;
}
char *salloc(size) {
register char *p;
char *salloc(int size) {
char *p;
if (nstab==MAXSTAB)
fatal("String table overflow");
@ -66,7 +66,9 @@ char *salloc(size) {
return(p);
}
compar(p1,p2) char **p1,**p2; {
static int compar(const void *v1, const void *v2) {
char *const *p1 = v1;
char *const *p2 = v2;
assert(*p1 != *p2);
if (*p1 < *p2)
@ -74,14 +76,13 @@ compar(p1,p2) char **p1,**p2; {
return(1);
}
void
garbage_collect() {
register i;
void garbage_collect(void) {
int i;
struct emline *emlp;
token_p tp;
tkdef_p tdp;
struct reginfo *rp;
register char **fillp,**scanp;
char **fillp,**scanp;
char used[MAXSTAB]; /* could be bitarray */
if (nstab<THRESHOLD)
@ -89,7 +90,7 @@ garbage_collect() {
qsort((char *)stab,nstab,sizeof (char *),compar);
for (i=0;i<nstab;i++)
used[i]= FALSE;
for(emlp=emlines;emlp<emlines+nemlines;emlp++)
for (emlp=emlines;emlp<emlines+nemlines;emlp++)
chkstr(emlp->em_soper,used);
for (tp= fakestack;tp<&fakestack[stackheight];tp++) {
if (tp->t_token== -1)
@ -119,9 +120,9 @@ garbage_collect() {
nstab = fillp-stab;
}
void
chkstr(str,used) string str; char used[]; {
register low,middle,high;
static void
chkstr(string str, char *used) {
int low,middle,high;
low=0; high=nstab-1;
while (high>low) {

View file

@ -2,9 +2,9 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
@ -23,9 +23,9 @@ static char rcsid[] = "$Id$";
extern int nstab; /* salloc.c */
void bmove();
static void bmove(short *, short *, int);
savestatus(sp) register state_p sp; {
void savestatus(state_p sp) {
sp->st_sh = stackheight;
bmove((short *)fakestack,(short *)sp->st_fs,stackheight*sizeof(token_t));
@ -42,7 +42,7 @@ savestatus(sp) register state_p sp; {
sp->st_ns = nstab;
}
restorestatus(sp) register state_p sp; {
void restorestatus(state_p sp) {
stackheight = sp->st_sh;
bmove((short *)sp->st_fs,(short *)fakestack,stackheight*sizeof(token_t));
@ -59,8 +59,7 @@ restorestatus(sp) register state_p sp; {
popstr(sp->st_ns);
}
void
bmove(from,to,nbytes) register short *from,*to; register nbytes; {
static void bmove(short *from, short *to, int nbytes) {
if (nbytes<=0)
return;

View file

@ -20,3 +20,7 @@ typedef struct state {
int st_tl; /* tokpatlen */
int st_ns; /* nstab */
} state_t,*state_p;
/* state.c */
void savestatus(state_p);
void restorestatus(state_p);

View file

@ -2,10 +2,11 @@
static char rcsid[] = "$Id$";
#endif
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "assert.h"
#include <string.h> /* strcmp */
#include "param.h"
#include "tables.h"
#include "types.h"
@ -24,11 +25,13 @@ static char rcsid[] = "$Id$";
* Author: Hans van Staveren
*/
string myalloc();
unsigned codegen();
static int from_stack(set_p);
#ifdef TABLEDEBUG
static void ruletrace(void);
#endif
match(tp,tep,optexp) register token_p tp; register set_p tep; {
register bitno;
int match(token_p tp, set_p tep, int optexp) {
int bitno;
token_p ct;
result_t result;
@ -53,11 +56,10 @@ match(tp,tep,optexp) register token_p tp; register set_p tep; {
return(result.e_v.e_con);
}
void
instance(instno,token) register token_p token; {
register inst_p inp;
void instance(int instno, token_p token) {
inst_p inp;
int i;
register token_p tp;
token_p tp;
#if MAXMEMBERS != 0
struct reginfo *rp;
#endif
@ -71,7 +73,7 @@ instance(instno,token) register token_p token; {
return;
}
inp= &tokeninstances[instno];
switch(inp->in_which) {
switch (inp->in_which) {
default:
assert(FALSE);
case IN_COPY:
@ -152,9 +154,8 @@ instance(instno,token) register token_p token; {
}
}
void
cinstance(instno,token,tp,regno) register token_p token,tp; {
register inst_p inp;
static void cinstance(int instno, token_p token, token_p tp, int regno) {
inst_p inp;
int i;
#if MAXMEMBERS != 0
struct reginfo *rp;
@ -164,7 +165,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
assert(instno!=0);
inp= &tokeninstances[instno];
switch(inp->in_which) {
switch (inp->in_which) {
default:
assert(FALSE);
case IN_COPY:
@ -250,9 +251,9 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
}
}
eqtoken(tp1,tp2) token_p tp1,tp2; {
register i;
register tkdef_p tdp;
int eqtoken(token_p tp1, token_p tp2) {
int i;
tkdef_p tdp;
if (tp1->t_token!=tp2->t_token)
return(0);
@ -286,10 +287,10 @@ eqtoken(tp1,tp2) token_p tp1,tp2; {
return(1);
}
distance(cindex) {
register char *bp;
register i;
register token_p tp;
int distance(int cindex) {
char *bp;
int i;
token_p tp;
int tokexp,tpl;
int expsize,toksize,exact;
int xsekt=0;
@ -302,7 +303,7 @@ distance(cindex) {
getint(i,bp);
}
#endif
switch( (*bp)&037 ) {
switch ( (*bp)&037 ) {
default:
return(stackheight==0 ? 0 : 100);
case DO_MATCH:
@ -363,31 +364,29 @@ distance(cindex) {
return(20-2*exact+fromstackneeded);
}
extern set_t unstackset;
extern set_t unstackset; /* tables.c */
int from_stack(s1)
register set_p s1;
{
register set_p s2 = &unstackset;
register int i;
static int from_stack(set_p s1) {
set_p s2 = &unstackset;
int i;
for (i = 0; i < SETSIZE; i++) {
if ((s1->set_val[i] & s2->set_val[i]) != 0) return 1;
}
return 0;
}
unsigned costcalc(cost) cost_t cost; {
extern unsigned cc1,cc2,cc3,cc4;
unsigned costcalc(cost_t cost) {
extern unsigned cc1,cc2,cc3,cc4; /* tables.c */
return(cost.ct_space*cc1/cc2 + cost.ct_time*cc3/cc4);
}
ssize(tokexpno) {
int ssize(int tokexpno) {
return(machsets[tokexpno].set_size);
}
tsize(tp) register token_p tp; {
int tsize(token_p tp) {
if (tp->t_token==-1)
return(machregs[tp->t_att[0].ar].r_size);
@ -395,12 +394,12 @@ tsize(tp) register token_p tp; {
}
#ifdef MAXSPLIT
instsize(tinstno,tp) token_p tp; {
static int instsize(int tinstno, token_p tp) {
inst_p inp;
struct reginfo *rp;
inp = &tokeninstances[tinstno];
switch(inp->in_which) {
switch (inp->in_which) {
default:
assert(FALSE);
case IN_COPY:
@ -428,9 +427,9 @@ instsize(tinstno,tp) token_p tp; {
}
#endif /* MAXSPLIT */
tref(tp,amount) register token_p tp; {
register i;
register byte *tdpb;
void tref(token_p tp, int amount) {
int i;
byte *tdpb;
if (tp->t_token==-1)
chrefcount(tp->t_att[0].ar,amount,FALSE);
@ -447,10 +446,10 @@ tref(tp,amount) register token_p tp; {
restore it and check whether a certain register is present in the
saved stack
*/
token_t aside[MAXSAVE] ;
int aside_length = -1 ;
static token_t aside[MAXSAVE] ;
static int aside_length = -1 ;
save_stack(tp) register token_p tp ; {
static void save_stack(token_p tp) {
int i ;
token_p tmp = &fakestack[stackheight - 1];
@ -468,10 +467,10 @@ save_stack(tp) register token_p tp ; {
stackheight -= aside_length;
}
in_stack(reg) {
register token_p tp ;
register i ;
register tkdef_p tdp ;
int in_stack(int reg) {
token_p tp ;
int i ;
tkdef_p tdp ;
for ( i=0, tp=aside ; i<aside_length ; i++, tp++ )
if (tp->t_token==-1) {
@ -494,8 +493,8 @@ gotone:
return 1 ;
}
rest_stack() {
register int i ;
static void rest_stack(void) {
int i ;
assert(aside_length!= -1);
#ifndef NDEBUG
@ -509,11 +508,11 @@ rest_stack() {
}
#ifdef MAXSPLIT
split(tp,ip,ply,toplevel) token_p tp; register int *ip; {
register c2_p cp;
int split(token_p tp, int *ip, int ply, int toplevel) {
c2_p cp;
token_t savestack[MAXSAVE];
int ok;
register i;
int i;
int diff;
token_p stp;
int tpl;
@ -543,7 +542,7 @@ found:
}
#endif /* MAXSPLIT */
unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; register c3_p cp; {
unsigned docoerc(token_p tp, c3_p cp, int ply, int toplevel, int forced) {
unsigned cost;
int tpl; /* saved tokpatlen */
@ -557,15 +556,15 @@ unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; register c3_p cp; {
return(cost);
}
unsigned stackupto(limit,ply,toplevel) token_p limit; {
unsigned stackupto(token_p limit, int ply, int toplevel) {
token_t savestack[MAXFSTACK];
token_p stp;
int i,diff;
int tpl; /* saved tokpatlen */
int nareg; /* saved nareg */
int areg[MAXALLREG];
register c1_p cp;
register token_p tp;
c1_p cp;
token_p tp;
unsigned totalcost=0;
struct reginfo *rp,**rpp;
@ -621,11 +620,11 @@ unsigned stackupto(limit,ply,toplevel) token_p limit; {
return(totalcost);
}
c3_p findcoerc(tp,tep) token_p tp; set_p tep; {
register c3_p cp;
c3_p findcoerc(token_p tp, set_p tep) {
c3_p cp;
token_t rtoken;
register i;
register struct reginfo **rpp;
int i;
struct reginfo **rpp;
for (cp=c3coercs;cp->c3_texpno>=0; cp++) {
if (tp!=(token_p) 0) {
@ -658,8 +657,8 @@ c3_p findcoerc(tp,tep) token_p tp; set_p tep; {
return(0); /* nothing found */
}
itokcost() {
register tkdef_p tdp;
void itokcost(void) {
tkdef_p tdp;
for(tdp=tokens+1;tdp->t_size!=0;tdp++)
tdp->t_cost.ct_space = costcalc(tdp->t_cost);
@ -696,8 +695,8 @@ void fatal(const char *s, ...) {
#ifdef TABLEDEBUG
ruletrace() {
register i;
static void ruletrace(void) {
int i;
extern int tablelines[MAXTDBUG];
extern int ntableline;
extern char *tablename;
@ -712,11 +711,4 @@ ruletrace() {
i--;
}
}
#endif
#ifndef NDEBUG
badassertion(asstr,file,line) char *asstr, *file; {
fatal("\"%s\", line %d:Assertion \"%s\" failed",file,line,asstr);
}
#endif
#endif /* TABLEDEBUG */

View file

@ -28,3 +28,45 @@ typedef char * string;
#ifndef WRD_FMT
#define WRD_FMT "%ld"
#endif /* WRD_FMT */
/* codegen.c */
unsigned codegen(byte *, int, int, unsigned, int);
void readcodebytes(void);
#ifdef TABLEDEBUG
void initlset(char *);
void termlset(void);
#endif
/* compute.c */
string mystrcpy(string);
string tostring(word);
/* fillem.c */
void in_init(char *);
void in_start(void);
void fillemlines(void);
void swtxt(void);
/* gencode.c */
void out_init(char *);
void out_finish(void);
void tstoutput(void);
/* nextem.c */
byte *nextem(int);
/* reg.c */
void chrefcount(int, int, int);
int getrefcount(int, int);
void erasereg(int);
void cleanregs(void);
void chkregs(void);
/* salloc.c */
string myalloc(int);
void myfree(string);
void popstr(int);
char *salloc(int);
void garbage_collect(void);
/* subr.c */
void itokcost(void);
void error(const char *s, ...);
void fatal(const char *s, ...);
#ifdef MACH_OPTIONS
void mach_option(char *); /* machine dependent */
#endif

View file

@ -12,7 +12,7 @@ int framesize;
/* Write out a constant data section. */
con_part(int sz, word w)
void con_part(int sz, word w)
{
while (part_size % sz)
part_size++;
@ -29,7 +29,7 @@ con_part(int sz, word w)
part_size += sz;
}
con_mult(word sz)
void con_mult(word sz)
{
if (argval != 4)
fatal("bad icon/ucon size");
@ -49,7 +49,7 @@ void prolog(full nlocals)
fprintf(codefile, "push fp, lr\n");
fprintf(codefile, "mov fp, sp\n");
if (nlocals > 0)
fprintf(codefile, "sub sp, #%d\n", nlocals);
fprintf(codefile, "sub sp, #%ld\n", nlocals);
framesize = nlocals;
}

View file

@ -1,42 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* _BadAssertion: used for debugging purposes. It should give an error message
indicated by the parameters, and then give a core dump
*/
#include <string.h>
#include <system.h>
static
wr_num(fd, n)
File *fd;
int n;
{
char s[2];
s[1] = '\0';
if (n >= 10) {
wr_num(fd, n/10);
}
s[0] = (n % 10) + '0';
sys_write(fd, s, 1);
}
int
_BadAssertion(file, lineno, assertion)
char *file, *assertion;
int lineno;
{
sys_write(STDERR, file, strlen(file));
sys_write(STDERR, ", line ", 7);
wr_num(STDERR, lineno);
sys_write(STDERR, ": assertion \"", 13);
sys_write(STDERR, assertion, strlen(assertion));
sys_write(STDERR, "\" failed\n", 9);
sys_stop(S_ABORT);
return 0;
}

View file

@ -1,61 +0,0 @@
.TH ASSERT 3 "$Revision$"
.ad
.SH NAME
assert \- program verification
.SH SYNOPSIS
.B #include <assert.h>
.PP
.B assert(expression)
.PP
.B _BadAssertion(fn, lino, ass)
.br
char *fn, *ass;
.br
unsigned int lino;
.SH DESCRIPTION
.PP
.I Assert
is a macro that indicates
.I expression
is expected to be true at this point in the program.
It causes a call to
.I _BadAssertion
when
.I expression
is false (0).
.PP
The routine
.I_BadAssertion
accepts three parameters:
a filename, a linenumber,
and a string representing a failed assertion.
It causes a
.IR sys_stop (S_ABORT)
with a diagnostic comment on standard error.
.PP
The assertions are disabled by defining the preprocessor constant NDEBUG.
.SH DIAGNOSTICS
.IR fn ,
line
.IR lino :
assertion
.I ass
failed.
.br
.I fn
is the source file,
.I lino
is the source line number,
and
.I ass
is the assertion
of the
.I assert
statement.
.SH MODULES
system(3)
.SH FILES
.nf
~em/modules/h/assert.h
~em/modules/lib/libassert.a
.fi

View file

@ -1,24 +0,0 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
/* A S S E R T I O N M A C R O D E F I N I T I O N */
/* This 'assert' definition can be used in a ,-expression. */
#ifndef NDEBUG
#if __STDC__
int _BadAssertion(char *, int, char *);
#define assert(exp) ((void)((exp) || _BadAssertion(__FILE__, __LINE__, #exp)))
#else
/* Note: this macro uses parameter substitution inside strings */
#define assert(exp) ((exp) || _BadAssertion(__FILE__, __LINE__, "exp"))
#endif
#else
#if __STDC__
#define assert(exp) ((void)0)
#else
#define assert(exp) (0)
#endif
#endif /* NDEBUG */

View file

@ -1,7 +0,0 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
hdrs = { "./assert.h" },
}

View file

@ -13,22 +13,22 @@ struct outrelo;
struct outsect;
struct ranlib;
int wr_open(char *f);
int wr_open(const char *f);
void wr_close(void);
void wr_ohead(struct outhead *h);
void wr_sect(struct outsect *s, unsigned int c);
void wr_ohead(const struct outhead *h);
void wr_sect(const struct outsect *s, unsigned int c);
void wr_outsect(int sectno);
void wr_emit(char *b, long c);
void wr_emit(const char *b, long c);
void wr_putc(int c);
void wr_relo(struct outrelo *r, unsigned int c);
void wr_name(struct outname *n, unsigned int c);
void wr_string(char *s, long c);
void wr_relo(const struct outrelo *r, unsigned int c);
void wr_name(const struct outname *n, unsigned int c);
void wr_string(const char *s, long c);
void wr_arhdr(int fd, struct ar_hdr *a);
void wr_ranlib(int fd, struct ranlib *r, long cnt);
void wr_int2(int fd, int i);
void wr_long(int fd, long l);
void wr_bytes(int fd, char *buf, long l);
int rd_open(char *f);
void wr_bytes(int fd, const char *buf, long l);
int rd_open(const char *f);
int rd_fdopen(int f);
void rd_close(void);
void rd_ohead(struct outhead *h);

View file

@ -3,6 +3,7 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <fcntl.h>
#include "obj.h"
/*
@ -57,7 +58,7 @@ OUTREAD(int p, char* b, long n)
* Open the output file according to the chosen strategy.
*/
int
rd_open(char* f)
rd_open(const char* f)
{
if ((outfile = open(f, 0)) < 0)

View file

@ -11,6 +11,7 @@
* part. In this case #define OUTSEEK.
*/
#include <fcntl.h>
#include "obj.h"
/*
@ -28,8 +29,7 @@ int __sectionnr;
static int offcnt;
void
__wr_flush(ptr)
register struct fil *ptr;
__wr_flush(struct fil *ptr)
{
#ifdef OUTSEEK
/* seek to correct position even if we aren't going to write now */
@ -53,14 +53,12 @@ __wr_flush(ptr)
}
static void
OUTWRITE(p, b, n)
int p; /* part number */
register char *b; /* buffer pointer */
long n; /* write count */
OUTWRITE(int p, const char *b, long n)
/* p = part number, b = buffer pointer, n = write count */
{
register struct fil *ptr = &__parts[p];
register char *pn = ptr->pnow;
register int i;
struct fil *ptr = &__parts[p];
char *pn = ptr->pnow;
int i;
long m;
i = ptr->cnt;
@ -119,11 +117,10 @@ OUTWRITE(p, b, n)
}
static void
BEGINSEEK(p, o)
int p; /* part number */
long o; /* offset in file */
BEGINSEEK(int p, long o)
/* p = part number, o = offset in file */
{
register struct fil *ptr = &__parts[p];
struct fil *ptr = &__parts[p];
#ifdef OUTSEEK
ptr->fd = outfile;
@ -143,10 +140,9 @@ BEGINSEEK(p, o)
* Open the output file according to the chosen strategy.
*/
int
wr_open(f)
char *f;
wr_open(const char *f)
{
register struct fil *fdp;
struct fil *fdp;
close(creat(f, 0666));
#ifdef OUTSEEK
@ -165,7 +161,7 @@ wr_open(f)
void
wr_close()
{
register struct fil *ptr;
struct fil *ptr;
for (ptr = &__parts[PARTEMIT]; ptr < &__parts[NPARTS]; ptr++) {
__wr_flush(ptr);
@ -181,11 +177,10 @@ wr_close()
}
void
wr_ohead(head)
register struct outhead *head;
wr_ohead(const struct outhead *head)
{
{
register long off = OFF_RELO(*head);
long off = OFF_RELO(*head);
BEGINSEEK(PARTEMIT, 0L);
BEGINSEEK(PARTRELO, off);
@ -202,7 +197,7 @@ wr_ohead(head)
{
char buf[SZ_HEAD];
register char *c = &buf[0];
char *c = &buf[0];
put2(head->oh_magic, c); c += 2;
put2(head->oh_stamp, c); c += 2;
@ -217,11 +212,9 @@ wr_ohead(head)
}
void
wr_sect(sect, cnt)
register struct outsect *sect;
register unsigned int cnt;
wr_sect(const struct outsect *sect, unsigned int cnt)
{
{ register unsigned int i = cnt;
{ unsigned int i = cnt;
while (i--) {
if (offcnt >= 1 && offcnt < SECTCNT) {
@ -234,8 +227,8 @@ wr_sect(sect, cnt)
}
while (cnt)
{
register char *c;
register unsigned int i;
char *c;
unsigned int i;
i = __parts[PARTEMIT].cnt/SZ_SECT;
c = __parts[PARTEMIT].pnow;
@ -258,10 +251,10 @@ wr_sect(sect, cnt)
}
void
wr_outsect(s)
int s; /* section number */
wr_outsect(int s)
/* s = section number */
{
register struct fil *ptr = &__parts[PARTEMIT + getsect(sectionnr)];
struct fil *ptr = &__parts[PARTEMIT + getsect(sectionnr)];
if (s != sectionnr && s >= (SECTCNT-1) && sectionnr >= (SECTCNT-1)) {
#ifdef OUTSEEK
@ -291,23 +284,19 @@ wr_outsect(s)
* We don't have to worry about byte order here.
*/
void
wr_emit(emit, cnt)
char *emit;
long cnt;
wr_emit(const char *emit, long cnt)
{
OUTWRITE(PARTEMIT + getsect(sectionnr) , emit, cnt);
}
void
wr_relo(relo, cnt)
register struct outrelo *relo;
unsigned int cnt;
wr_relo(const struct outrelo *relo, unsigned int cnt)
{
while (cnt)
{
register char *c;
register unsigned int i;
char *c;
unsigned int i;
i = __parts[PARTRELO].cnt/SZ_RELO;
c = __parts[PARTRELO].pnow;
@ -329,14 +318,12 @@ wr_relo(relo, cnt)
}
void
wr_name(name, cnt)
register struct outname *name;
unsigned int cnt;
wr_name(const struct outname *name, unsigned int cnt)
{
while (cnt)
{
register char *c;
register unsigned int i;
char *c;
unsigned int i;
i = __parts[PARTNAME].cnt/SZ_NAME;
c = __parts[PARTNAME].pnow;
@ -356,11 +343,8 @@ wr_name(name, cnt)
}
void
wr_string(addr, len)
char *addr;
long len;
wr_string(const char *addr, long len)
{
OUTWRITE(PARTCHAR, addr, len);
}

View file

@ -12,19 +12,17 @@
You have to put it in an int!
*/
static int maxchunk = MAXCHUNK;
static const int maxchunk = MAXCHUNK;
/*
* Just write "cnt" bytes to file-descriptor "fd".
*/
void
wr_bytes(fd, string, cnt)
register char *string;
register long cnt;
wr_bytes(int fd, const char *string, long cnt)
{
while (cnt) {
register int n = cnt >= maxchunk ? maxchunk : cnt;
int n = cnt >= maxchunk ? maxchunk : cnt;
if (write(fd, string, n) != n)
wr_fatal();

View file

@ -6,11 +6,12 @@
#include "obj.h"
extern int __sectionnr;
void __wr_flush(struct fil *);
void
wr_putc(ch)
wr_putc(int ch)
{
register struct fil *ptr = &__parts[PARTEMIT+getsect(__sectionnr)];
struct fil *ptr = &__parts[PARTEMIT+getsect(__sectionnr)];
if (ptr->cnt == 0) __wr_flush(ptr);
ptr->cnt--; *ptr->pnow++ = ch;

View file

@ -1,12 +1,13 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
srcs = {
"./doprnt.c", "./format.c", "./fprint.c", "./print.c",
"./sprint.c",
},
hdrs = { "./print.h" },
deps = {
"modules+headers",
"./param.h",
"modules/src/string+lib",
"modules/src/system+lib",
"./*.h"
}
}

View file

@ -16,10 +16,7 @@
%d = int
$ */
void
doprnt(fp, fmt, argp)
File *fp;
char *fmt;
va_list argp;
doprnt(File *fp, char *fmt, va_list argp)
{
char buf[SSIZE];

View file

@ -5,13 +5,12 @@
/* $Id$ */
#include <string.h>
#include <ack_string.h>
#include <system.h>
#include "print.h"
extern char *long2str();
static int
integral(c)
integral(int c)
{
switch (c) {
case 'b':
@ -36,9 +35,7 @@ integral(c)
%d = int
$ */
int
_format(buf, fmt, argp)
char *buf, *fmt;
register va_list argp;
_format(char *buf, char *fmt, va_list argp)
{
register char *pf = fmt;
register char *pb = buf;

View file

@ -17,27 +17,12 @@
$ */
/*VARARGS*/
void
fprint
#if __STDC__
(File *fp, char *fmt, ...)
fprint(File *fp, char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
File *fp;
char *fmt;
#endif
va_list args;
char buf[SSIZE];
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
fp = va_arg(args, File *);
fmt = va_arg(args, char *);
#endif
sys_write(fp, buf, _format(buf, fmt, args));
va_end(args);
}

View file

@ -17,25 +17,12 @@
$ */
/*VARARGS*/
void
print
#if __STDC__
(char *fmt, ...)
print(char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
char *fmt;
#endif
va_list args;
char buf[SSIZE];
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
fmt = va_arg(args, char *);
#endif
sys_write(STDOUT, buf, _format(buf, fmt, args));
va_end(args);
}

View file

@ -7,17 +7,12 @@
#ifndef __PRINT_INCLUDED__
#define __PRINT_INCLUDED__
#include <ansi.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
_PROTOTYPE(void print, (char *fmt, ...));
_PROTOTYPE(void fprint, (File *f, char *fmt, ...));
_PROTOTYPE(void doprnt, (File *f, char *fmt, va_list ap));
_PROTOTYPE(int _format, (char *buf, char *fmt, va_list ap));
_PROTOTYPE(char *sprint, (char *buf, char *fmt, ...));
void print(char *fmt, ...);
void fprint(File *f, char *fmt, ...);
void doprnt(File *f, char *fmt, va_list ap);
int _format(char *buf, char *fmt, va_list ap);
char *sprint(char *buf, char *fmt, ...);
#endif /* __PRINT_INCLUDED__ */

View file

@ -17,25 +17,11 @@
$ */
/*VARARGS*/
char *
sprint
#if __STDC__
(char *buf, char *fmt, ...)
sprint(char *buf, char *fmt, ...)
{
#else
(va_alist)
va_dcl
{
char *buf, *fmt;
#endif
va_list args;
#if __STDC__
va_start(args, fmt);
#else
va_start(args);
buf = va_arg(args, char *);
fmt = va_arg(args, char *);
#endif
buf[_format(buf, fmt, args)] = '\0';
va_end(args);
return buf;

View file

@ -1,4 +1,3 @@
normalrule {
name = "c_mnem_narg_h",
ins = {
@ -53,6 +52,7 @@ local function variant(name, cflags)
"modules/src/alloc+lib",
"modules/src/em_code+headers",
"modules/src/em_data+lib",
"modules/src/string+lib",
"modules/src/system+lib",
"./*.h",
}
@ -61,4 +61,3 @@ end
variant("lib_ev", {})
variant("lib_kv", { "-DCOMPACT" })

View file

@ -10,6 +10,7 @@
#include <ctype.h>
#include <string.h>
#include <ack_string.h>
/* #define XXX_YYY /* only for early debugging */
@ -283,7 +284,6 @@ getnumber(c, ap)
register char *p = str;
int n;
int expsign;
long str2long();
ap->ema_argtype = cst_ptyp;
expsign = 0;

View file

@ -7,25 +7,16 @@
#ifndef __ACK_STRING_INCLUDED__
#define __ACK_STRING_INCLUDED__
#include <ansi.h>
_PROTOTYPE(char *strcpy, (char *s1, const char *s2));
_PROTOTYPE(char *strncpy, (char *s1, const char *s2, size_t n));
_PROTOTYPE(char *strcat, (char *s1, const char *s2));
_PROTOTYPE(char *strncat, (char *s1, const char *s2, size_t n));
_PROTOTYPE(int strcmp, (const char *s1, const char *s2));
_PROTOTYPE(int strncmp, (const char *s1, const char *s2, size_t n));
_PROTOTYPE(_SIZET strlen, (const char *s));
_PROTOTYPE(char *strindex, (char *s, int c));
_PROTOTYPE(char *strrindex, (char *s, int c));
_PROTOTYPE(char *strzero, (char *s));
_PROTOTYPE(char *str2bts, (char *s, char *b, int *n));
_PROTOTYPE(char *long2str, (long l, int b));
_PROTOTYPE(long str2long, (char *s, int b));
_PROTOTYPE(char *btscpy, (char *s1, char *s2, int n));
_PROTOTYPE(char *btscat, (char *s1, int n1, char *s2, int n2));
_PROTOTYPE(int btscmp, (char *s1, int n1, char *s2, int n2));
_PROTOTYPE(char *btszero, (char *b, int n));
_PROTOTYPE(char *bts2str, (char *b, int n, char *s));
char *strindex(char *s, int c);
char *strrindex(char *s, int c);
char *strzero(char *s);
char *str2bts(char *s, char *b, int *n);
char *long2str(long l, int b);
long str2long(char *s, int b);
char *btscpy(char *s1, char *s2, int n);
char *btscat(char *s1, int n1, char *s2, int n2);
int btscmp(char *s1, int n1, char *s2, int n2);
char *btszero(char *b, int n);
char *bts2str(char *b, int n, char *s);
#endif /* __ACK_STRING_INCLUDED__ */

View file

@ -1,10 +1,10 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
deps = {
"modules+headers",
"./*.h"
srcs = {
"./bts2str.c", "./btscat.c", "./btscmp.c",
"./btscpy.c", "./btszero.c", "./long2str.c",
"./str2bts.c", "./str2long.c", "./strindex.c",
"./strrindex.c", "./strzero.c",
},
hdrs = { "./ack_string.h", },
}

View file

@ -1,24 +0,0 @@
/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* append t to s
*/
#include "ack_string.h"
char *
strcat(s, t)
register char *s;
register _CONST char *t;
{
register char *b = s;
while (*s++)
;
s--;
while (*s++ = *t++)
;
return b;
}

Some files were not shown because too many files have changed in this diff Show more