diff --git a/first/build.lua b/first/build.lua index 20eab73c8..b9fa0ab1f 100644 --- a/first/build.lua +++ b/first/build.lua @@ -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) diff --git a/h/cgg_cg.h b/h/cgg_cg.h index 6cc04b007..b71685feb 100644 --- a/h/cgg_cg.h +++ b/h/cgg_cg.h @@ -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)< #include #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]; diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index 317107a43..b402e4b35 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -11,6 +11,7 @@ semantics of C is a mess. */ +#include #include "parameters.h" #include #include @@ -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) { diff --git a/lang/cem/cemcom.ansi/assert.h b/lang/cem/cemcom.ansi/assert.h deleted file mode 100644 index da650dad3..000000000 --- a/lang/cem/cemcom.ansi/assert.h +++ /dev/null @@ -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 */ diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index 670c73abf..35ecbe3ef 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -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", diff --git a/lang/cem/cemcom.ansi/ch3.c b/lang/cem/cemcom.ansi/ch3.c index eef806776..535426937 100644 --- a/lang/cem/cemcom.ansi/ch3.c +++ b/lang/cem/cemcom.ansi/ch3.c @@ -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 #include "parameters.h" #include #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) { diff --git a/lang/cem/cemcom.ansi/code.c b/lang/cem/cemcom.ansi/code.c index abfd2b2b2..a6a898ab7 100644 --- a/lang/cem/cemcom.ansi/code.c +++ b/lang/cem/cemcom.ansi/code.c @@ -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 #include #include #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) diff --git a/lang/cem/cemcom.ansi/cstoper.c b/lang/cem/cemcom.ansi/cstoper.c index f904d9180..a63103ba3 100644 --- a/lang/cem/cemcom.ansi/cstoper.c +++ b/lang/cem/cemcom.ansi/cstoper.c @@ -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 #include "parameters.h" #include #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 diff --git a/lang/cem/cemcom.ansi/decspecs.c b/lang/cem/cemcom.ansi/decspecs.c index f7093daee..bef0c0d2b 100644 --- a/lang/cem/cemcom.ansi/decspecs.c +++ b/lang/cem/cemcom.ansi/decspecs.c @@ -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 #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) diff --git a/lang/cem/cemcom.ansi/domacro.c b/lang/cem/cemcom.ansi/domacro.c index d0fe7a96d..b1c4f5df3 100644 --- a/lang/cem/cemcom.ansi/domacro.c +++ b/lang/cem/cemcom.ansi/domacro.c @@ -5,7 +5,9 @@ /* $Id$ */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ -#include +#include +#include +#include #include "parameters.h" #include "idf.h" #include "arith.h" @@ -15,7 +17,6 @@ #include "replace.h" #ifndef NOPP -#include "assert.h" #include #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); diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index 849354bd3..e5d6d0941 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -8,6 +8,7 @@ #ifdef DEBUG #include "parameters.h" +#include #include #include #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, diff --git a/lang/cem/cemcom.ansi/eval.c b/lang/cem/cemcom.ansi/eval.c index f678682c2..0ec25dac6 100644 --- a/lang/cem/cemcom.ansi/eval.c +++ b/lang/cem/cemcom.ansi/eval.c @@ -8,6 +8,8 @@ #include "parameters.h" #ifndef LINT +#include +#include #include #include #include @@ -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); diff --git a/lang/cem/cemcom.ansi/expr.c b/lang/cem/cemcom.ansi/expr.c index 3a7e3c494..7b686c3fe 100644 --- a/lang/cem/cemcom.ansi/expr.c +++ b/lang/cem/cemcom.ansi/expr.c @@ -5,9 +5,9 @@ /* $Id$ */ /* EXPRESSION TREE HANDLING */ +#include #include #include "parameters.h" -#include "assert.h" #include #include #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"); } diff --git a/lang/cem/cemcom.ansi/field.c b/lang/cem/cemcom.ansi/field.c index 1514942e2..f5635d1fe 100644 --- a/lang/cem/cemcom.ansi/field.c +++ b/lang/cem/cemcom.ansi/field.c @@ -10,6 +10,7 @@ #ifndef NOBITFIELD +#include #include #include #include @@ -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)<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); diff --git a/lang/cem/cemcom.ansi/fltcstoper.c b/lang/cem/cemcom.ansi/fltcstoper.c index de4d26e51..7b48fc725 100644 --- a/lang/cem/cemcom.ansi/fltcstoper.c +++ b/lang/cem/cemcom.ansi/fltcstoper.c @@ -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 #include "parameters.h" -#include "assert.h" #include #include #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); diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index 4edc88456..54727221e 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -5,6 +5,7 @@ /* $Id$ */ /* IDENTIFIER FIDDLING & SYMBOL TABLE HANDLING */ +#include #include #include #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; } diff --git a/lang/cem/cemcom.ansi/interface.h b/lang/cem/cemcom.ansi/interface.h index 4967e557e..72c106463 100644 --- a/lang/cem/cemcom.ansi/interface.h +++ b/lang/cem/cemcom.ansi/interface.h @@ -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 */ diff --git a/lang/cem/cemcom.ansi/ival.g b/lang/cem/cemcom.ansi/ival.g index 757bb721b..e867aad86 100644 --- a/lang/cem/cemcom.ansi/ival.g +++ b/lang/cem/cemcom.ansi/ival.g @@ -6,6 +6,7 @@ /* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */ { +#include #include #include "parameters.h" #ifndef LINT @@ -14,6 +15,7 @@ #include "l_em.h" #include "l_lint.h" #endif /* LINT */ +#include #include #include #include @@ -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) diff --git a/lang/cem/cemcom.ansi/l_ev_ord.c b/lang/cem/cemcom.ansi/l_ev_ord.c index c5d7550a3..fe43a83cd 100644 --- a/lang/cem/cemcom.ansi/l_ev_ord.c +++ b/lang/cem/cemcom.ansi/l_ev_ord.c @@ -11,7 +11,6 @@ #include /* for st_free */ #include "interface.h" -#include "assert.h" #ifdef ANSI #include #endif /* ANSI */ diff --git a/lang/cem/cemcom.ansi/l_lint.c b/lang/cem/cemcom.ansi/l_lint.c index 5f95cb0fa..e2a5ea8eb 100644 --- a/lang/cem/cemcom.ansi/l_lint.c +++ b/lang/cem/cemcom.ansi/l_lint.c @@ -9,9 +9,9 @@ #ifdef LINT +#include #include /* for st_free */ #include "interface.h" -#include "assert.h" #ifdef ANSI #include #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 diff --git a/lang/cem/cemcom.ansi/l_outdef.c b/lang/cem/cemcom.ansi/l_outdef.c index aab98a5b2..5317546fc 100644 --- a/lang/cem/cemcom.ansi/l_outdef.c +++ b/lang/cem/cemcom.ansi/l_outdef.c @@ -9,13 +9,14 @@ #ifdef LINT +#include +#include #include #include "interface.h" #ifdef ANSI #include #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; diff --git a/lang/cem/cemcom.ansi/l_states.c b/lang/cem/cemcom.ansi/l_states.c index 74d31b359..506b3e450 100644 --- a/lang/cem/cemcom.ansi/l_states.c +++ b/lang/cem/cemcom.ansi/l_states.c @@ -9,9 +9,9 @@ #ifdef LINT +#include #include /* for st_free */ #include "interface.h" -#include "assert.h" #ifdef ANSI #include #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; diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index 1bb72ae85..f521453ba 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -5,7 +5,9 @@ /* $Id$ */ /* MAIN PROGRAM */ +#include #include "parameters.h" +#include #include #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)); diff --git a/lang/cem/cemcom.ansi/proto.c b/lang/cem/cemcom.ansi/proto.c index b237f3433..ff99ba98c 100644 --- a/lang/cem/cemcom.ansi/proto.c +++ b/lang/cem/cemcom.ansi/proto.c @@ -5,6 +5,7 @@ /* $Id$ */ /* P R O T O T Y P E F I D D L I N G */ +#include #include "parameters.h" #include #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); diff --git a/lang/cem/cemcom.ansi/replace.c b/lang/cem/cemcom.ansi/replace.c index 11908e51b..a1c53f32b 100644 --- a/lang/cem/cemcom.ansi/replace.c +++ b/lang/cem/cemcom.ansi/replace.c @@ -5,12 +5,14 @@ /* $Id$ */ /* M A C R O R E P L A C E M E N T */ +#include #include #include #include "parameters.h" #ifndef NOPP +#include #include #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)); diff --git a/lang/cem/cemcom.ansi/struct.c b/lang/cem/cemcom.ansi/struct.c index 505107cc8..a36b11e20 100644 --- a/lang/cem/cemcom.ansi/struct.c +++ b/lang/cem/cemcom.ansi/struct.c @@ -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, diff --git a/lang/cem/cemcom.ansi/switch.c b/lang/cem/cemcom.ansi/switch.c index 3cce2c622..77a9dcef3 100644 --- a/lang/cem/cemcom.ansi/switch.c +++ b/lang/cem/cemcom.ansi/switch.c @@ -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 #include "parameters.h" #ifndef LINT #include #else #include "l_em.h" #endif /* LINT */ +#include #include #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; } diff --git a/lang/cem/cpp.ansi/LLlex.c b/lang/cem/cpp.ansi/LLlex.c index 5b25a49d4..a0ec21a0f 100644 --- a/lang/cem/cpp.ansi/LLlex.c +++ b/lang/cem/cpp.ansi/LLlex.c @@ -7,6 +7,7 @@ #include "parameters.h" +#include #include #include "input.h" #include "arith.h" diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua index be124530f..7383d50ce 100644 --- a/lang/cem/cpp.ansi/build.lua +++ b/lang/cem/cpp.ansi/build.lua @@ -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", diff --git a/lang/cem/cpp.ansi/domacro.c b/lang/cem/cpp.ansi/domacro.c index 306ed32cc..193610a6f 100644 --- a/lang/cem/cpp.ansi/domacro.c +++ b/lang/cem/cpp.ansi/domacro.c @@ -5,7 +5,9 @@ /* $Id$ */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ -#include +#include +#include +#include #include "arith.h" #include "LLlex.h" #include "Lpars.h" @@ -13,7 +15,6 @@ #include "input.h" #include "parameters.h" -#include #include #include "class.h" #include "macro.h" diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index 225562be0..be8a7cd82 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -5,11 +5,12 @@ /* $Id$ */ /* MAIN PROGRAM */ -#include +#include +#include +#include #include "parameters.h" #include -#include #include #include "arith.h" #include "file_info.h" diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index 284b49524..270cd36c2 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -5,10 +5,12 @@ /* $Id$ */ /* M A C R O R E P L A C E M E N T */ +#include #include #include #include +#include #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__ */ diff --git a/lang/m2/comp/defmodule.c b/lang/m2/comp/defmodule.c index 0ecb1dd2a..b778d7cb2 100644 --- a/lang/m2/comp/defmodule.c +++ b/lang/m2/comp/defmodule.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #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; diff --git a/lang/m2/comp/type.c b/lang/m2/comp/type.c index 5912771fe..cfb00f599 100644 --- a/lang/m2/comp/type.c +++ b/lang/m2/comp/type.c @@ -13,6 +13,7 @@ #include "debug.h" #include +#include #include #include #include @@ -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; diff --git a/lang/pc/comp/cstoper.c b/lang/pc/comp/cstoper.c index c4196e522..a756b351b 100644 --- a/lang/pc/comp/cstoper.c +++ b/lang/pc/comp/cstoper.c @@ -5,6 +5,7 @@ #include "parameters.h" #include "debug.h" +#include #include #include #include @@ -475,7 +476,7 @@ CutSize(expr) InitCst() { - extern char *long2str(), *Salloc(); + extern char *Salloc(); register int i = 0; register arith bt = (arith)0; diff --git a/lang/pc/comp/declar.g b/lang/pc/comp/declar.g index 4ee1fcf89..54f488fe0 100644 --- a/lang/pc/comp/declar.g +++ b/lang/pc/comp/declar.g @@ -5,6 +5,7 @@ /* next line DEBUG */ #include "debug.h" +#include #include #include #include @@ -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 */ diff --git a/lang/pc/comp/enter.c b/lang/pc/comp/enter.c index 80e99f4c7..6eda97fdc 100644 --- a/lang/pc/comp/enter.c +++ b/lang/pc/comp/enter.c @@ -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 #include #include #include diff --git a/lang/pc/comp/statement.g b/lang/pc/comp/statement.g index 686e20682..a77f6ee96 100644 --- a/lang/pc/comp/statement.g +++ b/lang/pc/comp/statement.g @@ -1,5 +1,6 @@ /* S T A T E M E N T S */ { +#include #include "parameters.h" #include #include diff --git a/mach/i386/ncg/mach.c b/mach/i386/ncg/mach.c index 7514d6775..34a4b6f16 100644 --- a/mach/i386/ncg/mach.c +++ b/mach/i386/ncg/mach.c @@ -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; { diff --git a/mach/i80/ncg/mach.c b/mach/i80/ncg/mach.c index 9f952f0d9..89d7b0149 100644 --- a/mach/i80/ncg/mach.c +++ b/mach/i80/ncg/mach.c @@ -12,6 +12,9 @@ static char rcsid[]= "$Id$" ; * machine dependent back end routines for the Intel 8080. */ +#include /* 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; diff --git a/mach/i86/ncg/mach.c b/mach/i86/ncg/mach.c index a305d6d9a..d93eaba3d 100644 --- a/mach/i86/ncg/mach.c +++ b/mach/i86/ncg/mach.c @@ -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) { diff --git a/mach/m68020/ncg/mach.c b/mach/m68020/ncg/mach.c index 915b4f6e2..f230761c4 100644 --- a/mach/m68020/ncg/mach.c +++ b/mach/m68020/ncg/mach.c @@ -17,6 +17,7 @@ #include +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 +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; { diff --git a/mach/powerpc/ncg/mach.c b/mach/powerpc/ncg/mach.c index 6e0eef98b..b67903b0a 100644 --- a/mach/powerpc/ncg/mach.c +++ b/mach/powerpc/ncg/mach.c @@ -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"); diff --git a/mach/proto/as/build.lua b/mach/proto/as/build.lua index 6d846682e..9782b4b4b 100644 --- a/mach/proto/as/build.lua +++ b/mach/proto/as/build.lua @@ -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, }, diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 2d00c8e45..60fb172b4 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -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 +#else +#include #endif #define CTRL(x) ((x) & 037) diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index b3011ac97..7ea697015 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -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 ========== */ diff --git a/mach/proto/as/comm4.c b/mach/proto/as/comm4.c index 473cb12e2..3e88c41ed 100644 --- a/mach/proto/as/comm4.c +++ b/mach/proto/as/comm4.c @@ -15,15 +15,23 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" +#include 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); /* diff --git a/mach/proto/as/comm5.c b/mach/proto/as/comm5.c index 1fa84537d..e7d45c7fb 100644 --- a/mach/proto/as/comm5.c +++ b/mach/proto/as/comm5.c @@ -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) diff --git a/mach/proto/as/comm6.c b/mach/proto/as/comm6.c index fdbeb77ff..8aca81e8a 100644 --- a/mach/proto/as/comm6.c +++ b/mach/proto/as/comm6.c @@ -11,14 +11,12 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" +#include -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) { diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index e95037305..b75794d88 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -11,14 +11,14 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" -#include +#include +#include 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"); diff --git a/mach/proto/ncg/assert.h b/mach/proto/ncg/assert.h deleted file mode 100644 index 2fda064d1..000000000 --- a/mach/proto/ncg/assert.h +++ /dev/null @@ -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 diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua index e2345ca0c..1210382fc 100644 --- a/mach/proto/ncg/build.lua +++ b/mach/proto/ncg/build.lua @@ -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", } diff --git a/mach/proto/ncg/codegen.c b/mach/proto/ncg/codegen.c index 95a3c012d..3a2d60d1a 100644 --- a/mach/proto/ncg/codegen.c +++ b/mach/proto/ncg/codegen.c @@ -2,9 +2,9 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include -#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 */ diff --git a/mach/proto/ncg/compute.c b/mach/proto/ncg/compute.c index 41e159f04..aa97329a4 100644 --- a/mach/proto/ncg/compute.c +++ b/mach/proto/ncg/compute.c @@ -2,10 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include #include -#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; diff --git a/mach/proto/ncg/data.h b/mach/proto/ncg/data.h index ddd232b98..06779d730 100644 --- a/mach/proto/ncg/data.h +++ b/mach/proto/ncg/data.h @@ -4,6 +4,8 @@ */ /* $Id$ */ +#include /* 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); diff --git a/mach/proto/ncg/equiv.c b/mach/proto/ncg/equiv.c index ace068882..01a518bd4 100644 --- a/mach/proto/ncg/equiv.c +++ b/mach/proto/ncg/equiv.c @@ -2,15 +2,15 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include -#include "assert.h" -#include "equiv.h" #include "param.h" #include "tables.h" #include "types.h" #include #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) { diff --git a/mach/proto/ncg/equiv.h b/mach/proto/ncg/equiv.h index fcd7971da..85a5ad52c 100644 --- a/mach/proto/ncg/equiv.h +++ b/mach/proto/ncg/equiv.h @@ -10,3 +10,5 @@ struct perm { struct perm *p_next; int p_rar[MAXCREG]; }; + +struct perm *tuples(rl_p *, int); diff --git a/mach/proto/ncg/extern.h b/mach/proto/ncg/extern.h index e289eb8af..330e2c68e 100644 --- a/mach/proto/ncg/extern.h +++ b/mach/proto/ncg/extern.h @@ -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, ...); diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index e2ad5028c..07e6c9331 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -2,10 +2,10 @@ static char rcsid2[] = "$Id$"; #endif +#include #include #include #include -#include "assert.h" #include #include #include @@ -17,6 +17,7 @@ static char rcsid2[] = "$Id$"; #include "types.h" #include #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)-emp0) 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)); diff --git a/mach/proto/ncg/gencode.c b/mach/proto/ncg/gencode.c index 68676868e..5b092340f 100644 --- a/mach/proto/ncg/gencode.c +++ b/mach/proto/ncg/gencode.c @@ -2,8 +2,9 @@ static char rcsid[] = "$Id$"; #endif -#include "assert.h" +#include #include +#include /* 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 diff --git a/mach/proto/ncg/glosym.c b/mach/proto/ncg/glosym.c index 4052c1bfe..fe763b13c 100644 --- a/mach/proto/ncg/glosym.c +++ b/mach/proto/ncg/glosym.c @@ -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) diff --git a/mach/proto/ncg/glosym.h b/mach/proto/ncg/glosym.h index 1449b9b1b..89322319b 100644 --- a/mach/proto/ncg/glosym.h +++ b/mach/proto/ncg/glosym.h @@ -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); diff --git a/mach/proto/ncg/label.c b/mach/proto/ncg/label.c index 0c192589c..bb7fdad20 100644 --- a/mach/proto/ncg/label.c +++ b/mach/proto/ncg/label.c @@ -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; diff --git a/mach/proto/ncg/label.h b/mach/proto/ncg/label.h index 96c290be6..fc79cb838 100644 --- a/mach/proto/ncg/label.h +++ b/mach/proto/ncg/label.h @@ -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); diff --git a/mach/proto/ncg/main.c b/mach/proto/ncg/main.c index 7f214f349..0b3a40f86 100644 --- a/mach/proto/ncg/main.c +++ b/mach/proto/ncg/main.c @@ -2,8 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include /* 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; diff --git a/mach/proto/ncg/move.c b/mach/proto/ncg/move.c index 17669c956..c3b7bea5c 100644 --- a/mach/proto/ncg/move.c +++ b/mach/proto/ncg/move.c @@ -2,9 +2,9 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include -#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)) diff --git a/mach/proto/ncg/nextem.c b/mach/proto/ncg/nextem.c index 75f0d0fec..6ff6e8260 100644 --- a/mach/proto/ncg/nextem.c +++ b/mach/proto/ncg/nextem.c @@ -2,11 +2,11 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include #include #include -#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;iemlines) { diff --git a/mach/proto/ncg/reg.c b/mach/proto/ncg/reg.c index 0ce218982..bcbcf19a6 100644 --- a/mach/proto/ncg/reg.c +++ b/mach/proto/ncg/reg.c @@ -2,9 +2,9 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include -#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;rpr_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 #include #include -#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;ira_rv = 0; ra->ra_score = 0; diff --git a/mach/proto/ncg/regvar.h b/mach/proto/ncg/regvar.h index 089bd72b1..06c3e1207 100644 --- a/mach/proto/ncg/regvar.h +++ b/mach/proto/ncg/regvar.h @@ -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); diff --git a/mach/proto/ncg/result.h b/mach/proto/ncg/result.h index fdb9e16e1..82cf970ce 100644 --- a/mach/proto/ncg/result.h +++ b/mach/proto/ncg/result.h @@ -19,3 +19,6 @@ struct result { #define EV_ADDR 3 typedef struct result result_t; + +/* compute.c */ +void compute(node_p, result_t *); diff --git a/mach/proto/ncg/salloc.c b/mach/proto/ncg/salloc.c index 7ce1287bb..71fe20c3d 100644 --- a/mach/proto/ncg/salloc.c +++ b/mach/proto/ncg/salloc.c @@ -2,9 +2,9 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include -#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;iem_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) { diff --git a/mach/proto/ncg/state.c b/mach/proto/ncg/state.c index 4656ba872..45288546f 100644 --- a/mach/proto/ncg/state.c +++ b/mach/proto/ncg/state.c @@ -2,9 +2,9 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include -#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; diff --git a/mach/proto/ncg/state.h b/mach/proto/ncg/state.h index 962fd35f8..dafdebe0d 100644 --- a/mach/proto/ncg/state.h +++ b/mach/proto/ncg/state.h @@ -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); diff --git a/mach/proto/ncg/subr.c b/mach/proto/ncg/subr.c index fd6b72718..0feb54f30 100644 --- a/mach/proto/ncg/subr.c +++ b/mach/proto/ncg/subr.c @@ -2,10 +2,11 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include #include -#include "assert.h" +#include /* 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 ; it_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 */ diff --git a/mach/proto/ncg/types.h b/mach/proto/ncg/types.h index 50fc1aecd..35b848e82 100644 --- a/mach/proto/ncg/types.h +++ b/mach/proto/ncg/types.h @@ -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 diff --git a/mach/vc4/ncg/mach.c b/mach/vc4/ncg/mach.c index 8832f744f..16ca94f35 100644 --- a/mach/vc4/ncg/mach.c +++ b/mach/vc4/ncg/mach.c @@ -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; } diff --git a/modules/src/assert/BadAssert.c b/modules/src/assert/BadAssert.c deleted file mode 100644 index 3584221fd..000000000 --- a/modules/src/assert/BadAssert.c +++ /dev/null @@ -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 -#include - -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; -} diff --git a/modules/src/assert/assert.3 b/modules/src/assert/assert.3 deleted file mode 100644 index 8f5f6ecb7..000000000 --- a/modules/src/assert/assert.3 +++ /dev/null @@ -1,61 +0,0 @@ -.TH ASSERT 3 "$Revision$" -.ad -.SH NAME -assert \- program verification -.SH SYNOPSIS -.B #include -.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 diff --git a/modules/src/assert/assert.h b/modules/src/assert/assert.h deleted file mode 100644 index 2b610defb..000000000 --- a/modules/src/assert/assert.h +++ /dev/null @@ -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 */ diff --git a/modules/src/assert/build.lua b/modules/src/assert/build.lua deleted file mode 100644 index bd1230bfe..000000000 --- a/modules/src/assert/build.lua +++ /dev/null @@ -1,7 +0,0 @@ -clibrary { - name = "lib", - srcs = { "./*.c" }, - hdrs = { "./assert.h" }, -} - - diff --git a/modules/src/object/object.h b/modules/src/object/object.h index 54e20e26c..cf6ac476a 100644 --- a/modules/src/object/object.h +++ b/modules/src/object/object.h @@ -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); diff --git a/modules/src/object/rd.c b/modules/src/object/rd.c index 54610a0dc..bad012844 100644 --- a/modules/src/object/rd.c +++ b/modules/src/object/rd.c @@ -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 #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) diff --git a/modules/src/object/wr.c b/modules/src/object/wr.c index 20e5132f2..7b382c0c6 100644 --- a/modules/src/object/wr.c +++ b/modules/src/object/wr.c @@ -11,6 +11,7 @@ * part. In this case #define OUTSEEK. */ +#include #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); } diff --git a/modules/src/object/wr_bytes.c b/modules/src/object/wr_bytes.c index 768a5d6ba..278d1d369 100644 --- a/modules/src/object/wr_bytes.c +++ b/modules/src/object/wr_bytes.c @@ -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(); diff --git a/modules/src/object/wr_putc.c b/modules/src/object/wr_putc.c index 34c550a30..f28f2ea04 100644 --- a/modules/src/object/wr_putc.c +++ b/modules/src/object/wr_putc.c @@ -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; diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua index 67c873b69..745c622dc 100644 --- a/modules/src/print/build.lua +++ b/modules/src/print/build.lua @@ -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" } } - - diff --git a/modules/src/print/doprnt.c b/modules/src/print/doprnt.c index 90a2794a1..a77b7d2c1 100644 --- a/modules/src/print/doprnt.c +++ b/modules/src/print/doprnt.c @@ -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]; diff --git a/modules/src/print/format.c b/modules/src/print/format.c index e207eaa02..2ad920bc8 100644 --- a/modules/src/print/format.c +++ b/modules/src/print/format.c @@ -5,13 +5,12 @@ /* $Id$ */ #include +#include #include #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; diff --git a/modules/src/print/fprint.c b/modules/src/print/fprint.c index ae08e97a9..c401858a9 100644 --- a/modules/src/print/fprint.c +++ b/modules/src/print/fprint.c @@ -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); } diff --git a/modules/src/print/print.c b/modules/src/print/print.c index bb1211687..cd9346e98 100644 --- a/modules/src/print/print.c +++ b/modules/src/print/print.c @@ -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); } diff --git a/modules/src/print/print.h b/modules/src/print/print.h index 3b511b600..56372376a 100644 --- a/modules/src/print/print.h +++ b/modules/src/print/print.h @@ -7,17 +7,12 @@ #ifndef __PRINT_INCLUDED__ #define __PRINT_INCLUDED__ -#include -#if __STDC__ #include -#else -#include -#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__ */ diff --git a/modules/src/print/sprint.c b/modules/src/print/sprint.c index 614997c32..d88b47e69 100644 --- a/modules/src/print/sprint.c +++ b/modules/src/print/sprint.c @@ -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; diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua index 7c147dfc0..86794b036 100644 --- a/modules/src/read_em/build.lua +++ b/modules/src/read_em/build.lua @@ -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" }) - diff --git a/modules/src/read_em/reade.c b/modules/src/read_em/reade.c index f8bf157f8..22737ec37 100644 --- a/modules/src/read_em/reade.c +++ b/modules/src/read_em/reade.c @@ -10,6 +10,7 @@ #include #include +#include /* #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; diff --git a/modules/src/string/ack_string.h b/modules/src/string/ack_string.h index c43b19b56..56b646e4c 100644 --- a/modules/src/string/ack_string.h +++ b/modules/src/string/ack_string.h @@ -7,25 +7,16 @@ #ifndef __ACK_STRING_INCLUDED__ #define __ACK_STRING_INCLUDED__ -#include - -_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__ */ diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua index b2aa4b9c3..da63ed613 100644 --- a/modules/src/string/build.lua +++ b/modules/src/string/build.lua @@ -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", }, } - - diff --git a/modules/src/string/strcat.c b/modules/src/string/strcat.c deleted file mode 100644 index a1d3085b8..000000000 --- a/modules/src/string/strcat.c +++ /dev/null @@ -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; -} diff --git a/modules/src/string/strcmp.c b/modules/src/string/strcmp.c deleted file mode 100644 index f6ba8bfa7..000000000 --- a/modules/src/string/strcmp.c +++ /dev/null @@ -1,20 +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". - */ -/* return negative, zero or positive value if - resp. s < t, s == t or s > t -*/ - -#include "ack_string.h" - -int -strcmp(s, t) - register _CONST char *s, *t; -{ - while (*s == *t++) - if (*s++ == '\0') - return 0; - return *s - *--t; -} diff --git a/modules/src/string/strcpy.c b/modules/src/string/strcpy.c deleted file mode 100644 index 220cf9687..000000000 --- a/modules/src/string/strcpy.c +++ /dev/null @@ -1,21 +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". - */ -/* Copy t into s -*/ - -#include "ack_string.h" - -char * -strcpy(s, t) - register char *s; - register _CONST char *t; -{ - register char *b = s; - - while (*s++ = *t++) - ; - return b; -} diff --git a/modules/src/string/string.3 b/modules/src/string/string.3 index 22bfd71a9..8d1877a22 100644 --- a/modules/src/string/string.3 +++ b/modules/src/string/string.3 @@ -1,8 +1,7 @@ .TH STRING 3 "$Revision$" .ad .SH NAME -strcpy, strncpy, strcat, strncat, strcmp, strncmp, -strlen, strindex, strrindex, strzero, str2bts, +strindex, strrindex, strzero, str2bts, long2str, str2long, btscpy, btscat, btscmp, btszero, bts2str \- operations on and conversions between strings and row of bytes @@ -10,27 +9,6 @@ conversions between strings and row of bytes .nf .B #include .PP -.B char *strcpy(s1, s2) -.B char *s1, *s2; -.PP -.B char *strncpy(s1, s2, n) -.B char *s1, *s2; -.PP -.B char *strcat(s1, s2) -.B char *s1, *s2; -.PP -.B char *strncat(s1, s2, n) -.B char *s1, *s2; -.PP -.B int strcmp(s1, s2) -.B char *s1, *s2; -.PP -.B int strncmp(s1, s2, n) -.B char *s1, *s2; -.PP -.B int strlen(s) -.B char *s; -.PP .B char *strindex(s, c) .B char *s, c; .PP @@ -82,56 +60,6 @@ functions operate on variable-length rows of bytes, regardless of null bytes. Neither of these functions check for overflow of any receiving area. .PP -.I Strcpy -copies string -.I s2 -to -.I s1, -stopping after the null character has been moved. -.I Strncpy -copies exactly -.I n -characters, -truncating or null-padding -.I s2; -the target may not be null-terminated if the length -of -.I s2 -is -.I n -or more. -Both return -.IR s1 . -.PP -.I Strcat -appends a copy of string -.I s2 -to the end of string -.IR s1 . -.I Strncat -copies at most -.I n -characters. -Both return a pointer to the null-terminated result -.IR s1 . -.PP -.I Strcmp -compares its arguments and returns an integer -greater than, equal to, or less than 0, if -.I s1 -is lexicographically greater than, equal to, or -less than -.IR s2 , -respectively. -.I Strncmp -makes the same comparison but checks at most -.I n -characters. -.PP -.I Strlen -returns the number of characters before the null-character. -.IR s . -.PP .I Strindex .RI ( strrindex ) returns a pointer to the first (last) diff --git a/modules/src/string/strlen.c b/modules/src/string/strlen.c deleted file mode 100644 index 8e429f261..000000000 --- a/modules/src/string/strlen.c +++ /dev/null @@ -1,20 +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". - */ -/* return length of s -*/ - -#include "ack_string.h" - -_SIZET -strlen(s) - _CONST char *s; -{ - register _CONST char *b = s; - - while (*b++) - ; - return b - s - 1; -} diff --git a/modules/src/string/strncat.c b/modules/src/string/strncat.c deleted file mode 100644 index c6ecd31ed..000000000 --- a/modules/src/string/strncat.c +++ /dev/null @@ -1,25 +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, upto n characters -*/ - -#include "ack_string.h" - -char * -strncat(s, t, n) - register char *s; - register _CONST char *t; - register _SIZET n; -{ - register char *b = s; - - while (*s++) - ; - s--; - while ((n-- > 0) && (*s++ = *t++)) - ; - return b; -} diff --git a/modules/src/string/strncmp.c b/modules/src/string/strncmp.c deleted file mode 100644 index c9464765c..000000000 --- a/modules/src/string/strncmp.c +++ /dev/null @@ -1,26 +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". - */ -/* return negative, zero or positive value if - resp. s < t, s == t or s > t; compare at most n characters -*/ - -#include "ack_string.h" - -int -strncmp(s, t, n) - register _CONST char *s, *t; - register _SIZET n; -{ - while (n-- > 0) { - if (*s == *t++) { - if (*s++ == '\0') - return 0; - } - else - return *s - *--t; - } - return 0; -} diff --git a/modules/src/string/strncpy.c b/modules/src/string/strncpy.c deleted file mode 100644 index a12f80c64..000000000 --- a/modules/src/string/strncpy.c +++ /dev/null @@ -1,22 +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". - */ -/* Copy t into s, upto n characters -*/ - -#include "ack_string.h" - -char * -strncpy(s, t, n) - register char *s; - register _CONST char *t; - register _SIZET n; -{ - register char *b = s; - - while ((n-- > 0) && (*s++ = *t++)) - ; - return b; -} diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua index cecae7d5e..c9eba2979 100644 --- a/modules/src/system/build.lua +++ b/modules/src/system/build.lua @@ -1,11 +1,13 @@ clibrary { name = "lib", - srcs = { "./*.c" }, - hdrs = { "./system.h" }, - deps = { - "modules+headers", - "./*.h" + srcs = { + "./access.c", "./break.c", "./chmode.c", "./close.c", + "./create.c", "./filesize.c", + --"./lock.c", + "./modtime.c", "./open.c", "./read.c", "./remove.c", + "./rename.c", "./seek.c", "./stop.c", "./system.c", + --"./unlock.c", + "./write.c", }, + hdrs = { "./system.h" }, } - - diff --git a/modules/src/system/system.h b/modules/src/system/system.h index 8a5825173..f596defe4 100644 --- a/modules/src/system/system.h +++ b/modules/src/system/system.h @@ -6,8 +6,6 @@ #ifndef __SYSTEM_INCLUDED__ #define __SYSTEM_INCLUDED__ -#include - struct _sys_fildes { int o_fd; /* UNIX filedescriptor */ int o_flags; /* flags for open; 0 if not used */ @@ -33,24 +31,24 @@ extern File _sys_ftab[]; #define S_EXIT 1 #define S_ABORT 2 -_PROTOTYPE(int sys_open, (char *, int, File **)); -_PROTOTYPE(void sys_close, (File *)); -_PROTOTYPE(int sys_read, (File *, char *, int, int *)); -_PROTOTYPE(int sys_write, (File *, char *, int)); -_PROTOTYPE(int sys_seek, (File *, long, int, long *)); -_PROTOTYPE(int sys_reset, (File *)); -_PROTOTYPE(int sys_access, (char *, int)); -_PROTOTYPE(int sys_remove, (char *)); -_PROTOTYPE(int sys_rename, (char *, char *)); -_PROTOTYPE(long sys_filesize, (char *)); -_PROTOTYPE(int sys_chmode, (char *, int)); +int sys_open(char *, int, File **); +void sys_close(File *); +int sys_read(File *, char *, int, int *); +int sys_write(File *, char *, int); +int sys_seek(File *, long, int, long *); +int sys_reset(File *); +int sys_access(char *, int); +int sys_remove(char *); +int sys_rename(char *, char *); +long sys_filesize(char *); +int sys_chmode(char *, int); #if 0 -_PROTOTYPE(int sys_lock, (char *)); -_PROTOTYPE(int sys_unlock, (char *)); +int sys_lock(char *); +int sys_unlock(char *); #endif -_PROTOTYPE(char *sys_break, (int)); -_PROTOTYPE(void sys_stop, (int)); -_PROTOTYPE(long sys_modtime, (char *)); +char *sys_break(int); +void sys_stop(int); +long sys_modtime(char *); /* standard file decsriptors */ #define STDIN &_sys_ftab[0] diff --git a/util/LLgen/src/name.c b/util/LLgen/src/name.c index 4d34097fb..2b9ba11fb 100644 --- a/util/LLgen/src/name.c +++ b/util/LLgen/src/name.c @@ -17,6 +17,7 @@ * initialising routine. */ +#include # include "types.h" # include "extern.h" # include "assert.h" diff --git a/util/LLgen/src/tokens.c b/util/LLgen/src/tokens.c index 6526ec1a3..096c50951 100644 --- a/util/LLgen/src/tokens.c +++ b/util/LLgen/src/tokens.c @@ -77,6 +77,7 @@ extern LLnc_recover(); # line 20 "tokens.g" +#include # include "types.h" # include "io.h" # include "extern.h" @@ -101,7 +102,7 @@ STATIC string vallookup(); STATIC void copyact(); static int nparams; -# line 75 "tokens.g" +# line 76 "tokens.g" /* @@ -419,7 +420,8 @@ unput(c) { backupc = c; } -void skipcomment(flag) { +void +skipcomment(flag) { /* * Skip comment. If flag != 0, the comment is inside a fragment * of C-code, so keep it. diff --git a/util/LLgen/src/tokens.g b/util/LLgen/src/tokens.g index 51b83fcb3..bc39d22ad 100644 --- a/util/LLgen/src/tokens.g +++ b/util/LLgen/src/tokens.g @@ -18,6 +18,7 @@ */ { +#include # include "types.h" # include "io.h" # include "extern.h" diff --git a/util/ack/files.c b/util/ack/files.c index e149b90f7..413395438 100644 --- a/util/ack/files.c +++ b/util/ack/files.c @@ -5,6 +5,7 @@ */ #include +#include #include "ack.h" #include "list.h" #include "trans.h" diff --git a/util/ack/rmach.c b/util/ack/rmach.c index 13f904a38..1a4cd03a1 100644 --- a/util/ack/rmach.c +++ b/util/ack/rmach.c @@ -6,6 +6,7 @@ #include #include +#include #include "ack.h" #include #include "list.h" diff --git a/util/cmisc/build.lua b/util/cmisc/build.lua index b7c2b474a..8bd0012f6 100644 --- a/util/cmisc/build.lua +++ b/util/cmisc/build.lua @@ -18,7 +18,7 @@ definerule("tabgen", }, outleaves = { symname..".c" }, commands = { - "%{ins[1]} -f%{ins[2]} > %{outs} || rm %{outs}" + "%{ins[1]} -f%{ins[2]} > %{outs}" } } end diff --git a/util/cmisc/tabgen.c b/util/cmisc/tabgen.c index 4cbcf8b34..c88794f4f 100644 --- a/util/cmisc/tabgen.c +++ b/util/cmisc/tabgen.c @@ -9,8 +9,9 @@ Many mods by Ceriel Jacobs */ -#include +#include #include +#include #include #ifndef NORCSID @@ -30,8 +31,18 @@ char *ProgCall; /* callname of this program */ int TabSize = 128; /* default size of generated table */ char *InitialValue; /* initial value of all table entries */ -main(argc, argv) - char *argv[]; +void option(char *); +void option_F(char *); +void InitTable(char *); +void PrintTable(void); +int process(char *, int); +int c_proc(char *, char *); +int setval(int, char *); +int quoted(char **); +void DoFile(char *); + +int +main(int argc, char *argv[]) { ProgCall = *argv++; @@ -51,23 +62,19 @@ main(argc, argv) } char * -Salloc(s) - char *s; +Salloc(char *s) { - char *ns = malloc((unsigned)strlen(s) + 1); + char *ns = strdup(s); - if (ns) { - strcpy(ns, s); - } - else { + if (!ns) { fprintf(stderr, "%s: out of memory\n", ProgCall); exit(1); } return ns; } -option(str) - char *str; +void +option(char *str) { /* note that *str indicates the source of the option: either COMCOM (from command line) or FILECOM (from a file). @@ -89,7 +96,7 @@ option(str) DoFile(str); break; case 'F': /* new output format string */ - sprintf(OutputForm, "%s\n", ++str); + option_F(++str); break; case 'T': /* insert text literally */ printf("%s\n", ++str); @@ -124,8 +131,31 @@ option(str) } } -InitTable(ival) - char *ival; +void +option_F(char *form) +{ + int len; + char *cp; + + /* + * The format string must have one '%s' and no other '%'. + * Don't allow '%99$s', '%ls', '%n'. + */ + cp = strchr(form, '%'); + if (!cp || cp[1] != 's' || strchr(cp + 1, '%')) + goto bad; + len = snprintf(OutputForm, sizeof(OutputForm), "%s\n", form); + if (len < 0 && len >= sizeof(OutputForm)) + goto bad; + return; + +bad: + fprintf(stderr, "%s: -F: bad format %s\n", ProgCall, form); + exit(1); +} + +void +InitTable(char *ival) { int i; @@ -138,7 +168,8 @@ InitTable(ival) } } -PrintTable() +void +PrintTable(void) { int i; @@ -156,8 +187,7 @@ PrintTable() } int -process(str, format) - char *str; +process(char *str, int format) { char *cstr = str; char *Name = cstr; /* overwrite original string! */ @@ -189,12 +219,10 @@ process(str, format) return 0; } -c_proc(str, Name) - char *str; - char *Name; +int +c_proc(char *str, char *Name) { int ch, ch2; - int quoted(); char *name = Salloc(Name); while (*str) { @@ -209,8 +237,8 @@ c_proc(str, Name) ch2 = quoted(&str); } else { - if (ch2 = (*str++ & 0377)); - else str--; + ch2 = (*str++ & 0377); + if (!ch2) str--; } if (ch > ch2) { fprintf(stderr, "%s: bad range\n", ProgCall); @@ -229,8 +257,7 @@ c_proc(str, Name) } int -setval(ch, nm) - char *nm; +setval(int ch, char *nm) { char **p = &Table[ch]; @@ -246,8 +273,7 @@ setval(ch, nm) } int -quoted(pstr) - char **pstr; +quoted(char **pstr) { int ch; int i; @@ -291,9 +317,7 @@ quoted(pstr) } char * -getln(s, n, fp) - char *s; - FILE *fp; +getln(char *s, int n, FILE *fp) { int c = getc(fp); char *str = s; @@ -316,8 +340,8 @@ getln(s, n, fp) #define BUFSIZE 1024 -DoFile(name) - char *name; +void +DoFile(char *name) { char text[BUFSIZE]; FILE *fp; diff --git a/util/ego/bo/bo.c b/util/ego/bo/bo.c index 9024e7b56..0c317a80a 100644 --- a/util/ego/bo/bo.c +++ b/util/ego/bo/bo.c @@ -304,10 +304,9 @@ STATIC bo_cleanproc(p) } } -void -bo_optimize(p) - proc_p p; +void bo_optimize(void *vp) { + proc_p p = vp; bblock_p b; if (IS_ENTERED_WITH_GTO(p)) return; diff --git a/util/ego/cj/cj.c b/util/ego/cj/cj.c index 1447af8a7..015d554c5 100644 --- a/util/ego/cj/cj.c +++ b/util/ego/cj/cj.c @@ -289,9 +289,7 @@ STATIC bool try_pred(b) -void -cj_optimize(p) - proc_p p; +void cj_optimize(void *vp) { /* Perform cross jumping for procedure p. * In case cases a cross-jumping optimization which give @@ -300,6 +298,7 @@ cj_optimize(p) * untill we find no further optimizations. */ + proc_p p = vp; bblock_p b; bool changes = TRUE; diff --git a/util/ego/cs/cs.c b/util/ego/cs/cs.c index df651c9c4..dfcccbbf7 100644 --- a/util/ego/cs/cs.c +++ b/util/ego/cs/cs.c @@ -34,11 +34,11 @@ STATIC cs_clear() start_valnum(); } -STATIC void cs_optimize(p) - proc_p p; +STATIC void cs_optimize(void *vp) { /* Optimize all basic blocks of one procedure. */ + proc_p p = vp; register bblock_p rbp, bdone; if (IS_ENTERED_WITH_GTO(p)) return; diff --git a/util/ego/cs/cs_alloc.c b/util/ego/cs/cs_alloc.c index 6a1128286..e3c368857 100644 --- a/util/ego/cs/cs_alloc.c +++ b/util/ego/cs/cs_alloc.c @@ -8,43 +8,38 @@ #include "../share/alloc.h" #include "cs.h" -occur_p newoccur(l1, l2, b) - line_p l1, l2; - bblock_p b; +occur_p newoccur(line_p l1, line_p l2, bblock_p b) { /* Allocate a new struct occur and initialize it. */ - register occur_p rop; + occur_p rop; rop = (occur_p) newcore(sizeof(struct occur)); rop->oc_lfirst = l1; rop->oc_llast = l2; rop->oc_belongs = b; return rop; } -oldoccur(ocp) - occur_p ocp; +void oldoccur(occur_p ocp) { - oldcore((char *) ocp, sizeof(struct occur)); + oldcore(ocp, sizeof(struct occur)); } -avail_p newavail() +avail_p newavail(void) { return (avail_p) newcore(sizeof(struct avail)); } -oldavail(avp) - avail_p avp; +void oldavail(avail_p avp) { - oldcore((char *) avp, sizeof(struct avail)); + oldcore(avp, sizeof(struct avail)); } -entity_p newentity() +entity_p newentity(void) { return (entity_p) newcore(sizeof(struct entity)); } -oldentity(enp) - entity_p enp; +void oldentity(entity_p enp) { - oldcore((char *) enp, sizeof(struct entity)); + oldcore(enp, sizeof(struct entity)); } diff --git a/util/ego/cs/cs_alloc.h b/util/ego/cs/cs_alloc.h index 46ed002a0..cfd67a413 100644 --- a/util/ego/cs/cs_alloc.h +++ b/util/ego/cs/cs_alloc.h @@ -3,27 +3,28 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -extern occur_p newoccur(); /* (line_p l1, l2; bblock_p b) +occur_p newoccur(line_p l1, line_p l2, bblock_p b); + /* * Returns a pointer to a new struct occur * and initializes it. */ -extern oldoccur(); /* (occur_p ocp) +void oldoccur(occur_p ocp); /* * Release the struct occur ocp points to. */ -extern avail_p newavail(); /* () +avail_p newavail(void); /* * Return a pointer to a new struct avail. */ -extern oldavail(); /* (avail_p avp) +void oldavail(avail_p avp); /* * Release the struct avail avp points to. */ -extern entity_p newentity(); /* () +entity_p newentity(void); /* * Return a pointer to a new struct entity. */ -extern oldentity(); /* (entity_p enp) +void oldentity(entity_p enp); /* * Release the struct entity enp points to. */ diff --git a/util/ego/cs/cs_elim.c b/util/ego/cs/cs_elim.c index 281a53de5..0a253830f 100644 --- a/util/ego/cs/cs_elim.c +++ b/util/ego/cs/cs_elim.c @@ -191,7 +191,7 @@ STATIC set_replace(avp, tmp) register lset s = avp->av_occurs; for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i, s)) { - OUTVERBOSE("eliminate duplicate", 0); + OUTVERBOSE("eliminate duplicate", 0, 0); SHOWOCCUR(occ_elem(i)); Scs++; delete(occ_elem(i), avp->av_before); @@ -275,7 +275,7 @@ eliminate(pp) if (ravp->av_saveloc != (entity_p) 0) { tmp = ravp->av_saveloc->en_loc; mes = find_mesreg(tmp); - OUTVERBOSE("re-using %ld(LB)", tmp); + OUTVERBOSE("re-using %ld(LB)", tmp, 0); } else { tmp = tmplocal(pp, ravp->av_size); mes = gen_mesreg(tmp, ravp, pp); diff --git a/util/ego/cs/cs_profit.c b/util/ego/cs/cs_profit.c index 67eb713ed..259a6114d 100644 --- a/util/ego/cs/cs_profit.c +++ b/util/ego/cs/cs_profit.c @@ -4,6 +4,7 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ #include +#include #include #include #include "../share/types.h" @@ -64,9 +65,9 @@ STATIC choose_cset(f, s_p, max) Cdeleteset(cs1); Cdeleteset(cs2); } -cs_machinit(f) - FILE *f; +void cs_machinit(void *vp) { + FILE *f = vp; char s[100]; int time, space; @@ -193,8 +194,7 @@ STATIC bool okay_lines(avp, ocp) return TRUE; } -bool desirable(avp) - avail_p avp; +bool desirable(avail_p avp) { register Lindex i, next; diff --git a/util/ego/cs/cs_profit.h b/util/ego/cs/cs_profit.h index 463ac4d15..7ec5e3c17 100644 --- a/util/ego/cs/cs_profit.h +++ b/util/ego/cs/cs_profit.h @@ -3,11 +3,11 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -extern cs_machinit(); /* (FILE *f) +void cs_machinit(void *vp); /* (FILE *f) * Read phase-specific information from f. */ -extern bool desirable(); /* (avail_p avp) +bool desirable(avail_p avp); /* * Return whether it is desirable to eliminate * the recurrences of the expression in avp. * At the same time delete the recurrences diff --git a/util/ego/il/il.c b/util/ego/il/il.c index 8313cb93e..6ae0fbce2 100644 --- a/util/ego/il/il.c +++ b/util/ego/il/il.c @@ -299,8 +299,10 @@ Sdiagnostics() } #endif -il_flags(p) char* p; +void il_flags(void *vp) { + char *p = vp; + switch (*p++) { case 's': diff --git a/util/ego/il/il1_cal.c b/util/ego/il/il1_cal.c index 1d0a2dc95..854370697 100644 --- a/util/ego/il/il1_cal.c +++ b/util/ego/il/il1_cal.c @@ -26,9 +26,7 @@ STATIC actual_p acts, *app; #define INIT_ACTS() {acts = (actual_p) 0; app = &acts;} #define APPEND_ACTUAL(a) {*app = a; app = &a->ac_next;} -STATIC make_actual(l1,l2,size) - line_p l1,l2; - offset size; +STATIC void make_actual(line_p l1, line_p l2, offset size) { /* Allocate a struct for a new actual parameter * expression, the code of which extends from diff --git a/util/ego/il/il2_aux.c b/util/ego/il/il2_aux.c index 01a13f0fc..14bf6d80d 100644 --- a/util/ego/il/il2_aux.c +++ b/util/ego/il/il2_aux.c @@ -326,7 +326,7 @@ STATIC bool is_dispensable(callee,ccf) (complete_program || (callee->p_flags1 & PF_EXTERNAL) == 0) && (callee->p_flags1 & PF_LPI) == 0) { DISPENSABLE(callee); - OUTVERBOSE("dispensable: procedure %d can be removed",callee->p_id); + OUTVERBOSE("dispensable: procedure %d can be removed",callee->p_id,0); #ifdef VERBOSE Spremoved++; #endif @@ -475,7 +475,7 @@ STATIC singles(cals) DISPENSABLE(c->cl_proc); CHANGED(c->cl_caller); OUTVERBOSE("singles: procedure %d can be removed", - c->cl_proc->p_id); + c->cl_proc->p_id, 0); #ifdef VERBOSE Spremoved++; #endif diff --git a/util/ego/il/il_aux.c b/util/ego/il/il_aux.c index d35120eb4..2d6917ed1 100644 --- a/util/ego/il/il_aux.c +++ b/util/ego/il/il_aux.c @@ -222,7 +222,7 @@ call_p getcall(cf) m = getshort(); act->ac_size = getoff(); act->ac_inl = getbyte(); - act->ac_exp = getlines(cf,m,&voided); + act->ac_exp = getlines(cf,m,&voided,FALSE); *app = act; app = &act->ac_next; } diff --git a/util/ego/lv/lv.c b/util/ego/lv/lv.c index 6a640a1cb..116df01c4 100644 --- a/util/ego/lv/lv.c +++ b/util/ego/lv/lv.c @@ -447,7 +447,9 @@ STATIC use(l,mesgflag) -STATIC nothing() { } /* No action to be undertaken at level 0 of parser */ +/* ARGSUSED */ +STATIC void nothing(line_p l1, line_p l2, offset size) +{ } /* No action to be undertaken at level 0 of parser */ STATIC rem_code(l1,l2,b) line_p l1,l2; @@ -580,9 +582,10 @@ STATIC lv_cleanup(p) } } -lv_flags(p) - char *p; +void lv_flags(void *vp) { + char *p = vp; + switch(*p) { case 'N': mesgflag = TRUE; @@ -591,10 +594,10 @@ lv_flags(p) } -void -lv_optimize(p) - proc_p p; +void lv_optimize(void *vp) { + proc_p p = vp; + if (IS_ENTERED_WITH_GTO(p)) return; locals = (local_p *) 0; lv_extend(p); diff --git a/util/ego/ra/makeitems.c b/util/ego/ra/makeitems.c index 1f84aa95d..bd9cf35f4 100644 --- a/util/ego/ra/makeitems.c +++ b/util/ego/ra/makeitems.c @@ -6,6 +6,7 @@ #include #include +#include /* MAKE ITEMS TABLE * diff --git a/util/ego/ra/ra.c b/util/ego/ra/ra.c index fd05cdef0..643831f8d 100644 --- a/util/ego/ra/ra.c +++ b/util/ego/ra/ra.c @@ -10,6 +10,7 @@ #include #include +#include #include #include "../share/types.h" #include "../share/debug.h" @@ -103,10 +104,10 @@ get_otab(f,tab) -STATIC ra_machinit(f) - FILE *f; +STATIC void ra_machinit(void *vp) { /* Read target machine dependent information for this phase */ + FILE *f = vp; char s[100]; for (;;) { @@ -343,16 +344,16 @@ STATIC cleanitems(list) } -ra_initialize() +/* ARGSUSED */ +void ra_initialize(void *null) { init_replacements(ps,ws); } -void -ra_optimize(p) - proc_p p; +void ra_optimize(void *vp) { + proc_p p = vp; item_p itemlist; alloc_p alloclist,packed,unpacked; offset locls; diff --git a/util/ego/share/alloc.c b/util/ego/share/alloc.c index 6e638f09a..2bd309b81 100644 --- a/util/ego/share/alloc.c +++ b/util/ego/share/alloc.c @@ -17,28 +17,25 @@ #include "alloc.h" -char * myalloc(); +void *myalloc(size_t); #ifdef DEBUG -STATIC unsigned maxuse, curruse; +STATIC size_t maxuse, curruse; -char *newcore(size) - int size; +void *newcore(size_t size) { - if ((curruse += (unsigned) (size+2)) > maxuse) maxuse = curruse; + if ((curruse += (size+2)) > maxuse) maxuse = curruse; return myalloc(size); } -oldcore(p,size) - char *p; - int size; +void oldcore(void *p, size_t size) { curruse -= (size+2); free(p); } -coreusage() +void coreusage(void) { fprintf(stderr,"Maximal core usage (excl. buffers):%u\n",maxuse); } @@ -115,33 +112,33 @@ int asizetab[] = { * PART 1 */ -line_p newline(optyp) int optyp; { - register line_p lnp; - register kind=optyp; +line_p newline(byte optyp) { + line_p lnp; + int kind=optyp; lnp = (line_p) newcore(lsizetab[kind]); TYPE(lnp) = optyp; return(lnp); } -oldline(lnp) register line_p lnp; { - register kind=TYPE(lnp)&BMASK; +void oldline(line_p lnp) { + int kind=TYPE(lnp)&BMASK; if (kind == OPLIST) oldargs(ARG(lnp)); - oldcore((char *) lnp,lsizetab[kind]); + oldcore(lnp, lsizetab[kind]); } -arg_p newarg(kind) int kind; { - register arg_p ap; +arg_p newarg(byte kind) { + arg_p ap; ap = (arg_p) newcore(asizetab[kind]); ap->a_type = kind; return(ap); } -oldargs(ap) register arg_p ap; { - register arg_p next; +void oldargs(arg_p ap) { + arg_p next; while (ap != (arg_p) 0) { next = ap->a_next; @@ -155,49 +152,49 @@ oldargs(ap) register arg_p ap; { oldargb(ap->a_a.a_con.ac_con.ab_next); break; } - oldcore((char *) ap,asizetab[ap->a_type]); + oldcore(ap, asizetab[ap->a_type]); ap = next; } } -oldargb(abp) register argb_p abp; { - register argb_p next; +void oldargb(argb_p abp) { + argb_p next; while (abp != (argb_p) 0) { next = abp->ab_next; - oldcore((char *) abp,sizeof (argb_t)); + oldcore(abp, sizeof (argb_t)); abp = next; } } -oldobjects(op) register obj_p op; { - register obj_p next; +void oldobjects(obj_p op) { + obj_p next; while (op != (obj_p) 0) { next = op->o_next; - oldcore((char *) op, sizeof(struct obj)); + oldcore(op, sizeof(struct obj)); op = next; } } -olddblock(dbl) dblock_p dbl; { +void olddblock(dblock_p dbl) { oldobjects(dbl->d_objlist); oldargs(dbl->d_values); - oldcore((char *) dbl, sizeof(struct dblock)); + oldcore(dbl, sizeof(struct dblock)); } -short **newmap(length) short length; { +short **newmap(short length) { return((short **) newcore((length+1) * sizeof(short *))); } /*ARGSUSED1*/ -oldmap(mp,length) short **mp, length; { - oldcore((char *) mp, (length+1) * sizeof(short *)); +void oldmap(short **mp, short length) { + oldcore(mp, (length+1) * sizeof(short *)); } -cset newbitvect(n) short n; { +cset newbitvect(short n) { return((cset) newcore((n-1)*sizeof(int) + sizeof(struct bitvector))); /* sizeof(struct bitvector) equals to the size of a struct with * one short, followed by one ALLIGNED int. So the above statement @@ -206,38 +203,39 @@ cset newbitvect(n) short n; { } /*ARGSUSED1*/ -oldbitvect(s,n) cset s; short n; { - oldcore((char *) s, (n-1)*sizeof(int) + sizeof(struct bitvector)); +void oldbitvect(cset s, short n) { + oldcore(s, (n-1)*sizeof(int) + sizeof(struct bitvector)); } -short *newtable(length) short length; { +short *newtable(short length) { return((short *) newcore((length+1) * sizeof(short))); } /*ARGSUSED1*/ -oldtable(mp,length) short **mp, length; { - oldcore((char *) mp, (length+1) * sizeof(short)); +void oldtable(short **mp, short length) { + oldcore(mp, (length+1) * sizeof(short)); } -cond_p newcondtab(l) int l; +cond_p newcondtab(int l) { return (cond_p) newcore(l * (sizeof (struct cond_tab))); } -oldcondtab(tab) cond_p tab; +void oldcondtab(cond_p tab) { int i; - for (i = 0; tab[i].mc_cond != DEFAULT; i++); - oldcore((char *) tab,((i+1) * sizeof (struct cond_tab))); + for (i = 0; tab[i].mc_cond != DEFAULT; i++) + continue; + oldcore(tab, ((i+1) * sizeof (struct cond_tab))); } -char *myalloc(size) register size; { - register char *p; +void *myalloc(size_t size) { + void *p; p = calloc((unsigned) size, 1); - if (p == 0) + if (p == NULL) error("out of memory"); return(p); } diff --git a/util/ego/share/alloc.h b/util/ego/share/alloc.h index f2e1ebef0..17b32b483 100644 --- a/util/ego/share/alloc.h +++ b/util/ego/share/alloc.h @@ -8,36 +8,39 @@ * C O R E A L L O C A T I O N A N D D E A L L O C A T I O N */ +#include + #ifdef DEBUG -extern char *newcore(); -extern oldcore(); +void *newcore(size_t); +void oldcore(void *, size_t); +void coreusage(void); #else -extern char *myalloc(); +void *myalloc(size_t); #define newcore(size) myalloc(size) -#define oldcore(p,size) free((char *)p) +#define oldcore(p,size) free(p) #endif -#define newstruct(t) ((struct t *) newcore (sizeof (struct t))) -#define oldstruct(t,p) oldcore((char *) p,sizeof (struct t)) +#define newstruct(t) ((struct t *) newcore(sizeof (struct t))) +#define oldstruct(t,p) oldcore(p, sizeof (struct t)) -extern line_p newline(); /* (byte optype) */ -extern arg_p newarg(); /* (byte argtype) */ -extern short **newmap(); /* (short length) */ -extern cset newbitvect(); /* (short nrbytes) */ -extern cond_p newcondtab(); +line_p newline(byte optype); +arg_p newarg(byte argtyp); +short **newmap(short length); +cset newbitvect(short nrbytes); +cond_p newcondtab(int length); -extern oldline() ; -extern oldargs() ; -extern oldargb() ; -extern oldobjects() ; -extern olddblock() ; -extern oldmap(); -extern oldbitvect(); /* (cset s, short nrbytes) */ -extern oldcondtab(); +void oldline(line_p); +void oldargs(arg_p); +void oldargb(argb_p); +void oldobjects(obj_p); +void olddblock(dblock_p); +void oldmap(short **mp, short length); +void oldbitvect(cset s, short nrbytes); +void oldcondtab(cond_p); -extern short *newtable(); -extern oldtable(); +short *newtable(short length); +void oldtable(short **mp, short length); #define newdblock() (dblock_p) newstruct(dblock) #define newobject() (obj_p) newstruct(obj) diff --git a/util/ego/share/aux.c b/util/ego/share/aux.c index 42a8475c3..589a72288 100644 --- a/util/ego/share/aux.c +++ b/util/ego/share/aux.c @@ -19,8 +19,7 @@ #include "map.h" #include "lset.h" -offset off_set(lnp) - line_p lnp; +offset off_set(line_p lnp) { switch(lnp->l_optype) { case OPSHORT: @@ -36,8 +35,7 @@ offset off_set(lnp) -offset aoff(ap,n) - register arg_p ap; +offset aoff(arg_p ap, int n) { while (n>0) { if (ap != (arg_p) 0) @@ -52,9 +50,7 @@ offset aoff(ap,n) } -offset tmplocal(p,size) - proc_p p; - offset size; +offset tmplocal(proc_p p, offset size) { /* Allocate a new local variable in the stack frame of p */ @@ -65,8 +61,7 @@ offset tmplocal(p,size) -line_p int_line(off) - offset off; +line_p int_line(offset off) { /* Allocate a line struct of type OPSHORT or OPOFFSET, * whichever one fits best. @@ -87,10 +82,7 @@ line_p int_line(off) -line_p reg_mes(tmp,size,typ,score) - offset tmp; - short size; - int typ,score; +line_p reg_mes(offset tmp, short size, int typ, int score) { /* Generate a register message */ @@ -111,8 +103,7 @@ line_p reg_mes(tmp,size,typ,score) } -bool dom(b1,b2) - bblock_p b1,b2; +bool dom(bblock_p b1, bblock_p b2) { /* See if b1 dominates b2. Note that a block always * dominates itself. @@ -130,8 +121,7 @@ bool dom(b1,b2) } -bblock_p common_dom(a,b) - bblock_p a,b; +bblock_p common_dom(bblock_p a, bblock_p b) { /* find a basic block that dominates a as well as b; * note that a basic block also dominates itself. @@ -152,8 +142,7 @@ bblock_p common_dom(a,b) #define R time_space_ratio -short add_timespace(time,space) - short time,space; +short add_timespace(short time, short space) { /* Add together a time and space, using the time_space_ratio * parameter that may be set by the user, indicating the need @@ -165,9 +154,7 @@ short add_timespace(time,space) -rm_line(l,b) - line_p l; - bblock_p b; +void rm_line(line_p l, bblock_p b) { if (b->b_start == l) { b->b_start = l->l_next; @@ -183,8 +170,7 @@ rm_line(l,b) -appnd_line(l1,l2) - line_p l1,l2; +void appnd_line(line_p l1, line_p l2) { /* Put l1 after l2 */ @@ -198,8 +184,7 @@ appnd_line(l1,l2) -line_p last_instr(b) - bblock_p b; +line_p last_instr(bblock_p b) { /* Determine the last line of a list */ @@ -213,8 +198,7 @@ line_p last_instr(b) -line_p find_mesreg(off) - offset off; +line_p find_mesreg(offset off) { /* Find the register message for the local with the given offset */ @@ -229,17 +213,14 @@ line_p find_mesreg(off) } -bool is_regvar(off) - offset off; +bool is_regvar(offset off) { return find_mesreg(off) != (line_p) 0; } -offset regv_arg(off,n) - offset off; - int n; +offset regv_arg(offset off, int n) { /* fetch the n'th argument of the register message of the * local variable at offset off; diff --git a/util/ego/share/aux.h b/util/ego/share/aux.h index 99079ff64..6a6770469 100644 --- a/util/ego/share/aux.h +++ b/util/ego/share/aux.h @@ -10,61 +10,68 @@ */ -extern offset off_set(); /* (line_p lnp) +offset off_set(line_p lnp); /* * lnp has a SHORT or OFFSET operand. Return * the value of this operand as an offset. */ -extern offset aoff(); /* (arg_p list; int n) +offset aoff(arg_p list, int n); /* * Determine the offset field of the * n'th argument in the list (this argument * must have type ARGOFF). Start counting at 0. */ -extern offset tmplocal(); /* (proc_p p, offset size) +offset tmplocal(proc_p p, offset size); + /* * Allocate a new local variable in the * stack frame of p. */ -line_p int_line(); /* (offset off) +line_p int_line(offset off); /* * Allocate a line struct of type OPSHORT * or OPOFFSET, whichever one fits best. - */ -extern line_p reg_mes(); /* (offset tmp; short size; int typ,score) + */ +line_p reg_mes(offset tmp, short size, int typ, int score); + /* * Generate a register message with the * given arguments. */ -extern bool dom(); /* (bblock_p b1,b2) - /* See if b1 dominates b2. Note that a +bool dom(bblock_p b1, bblock_p b2); + /* + * See if b1 dominates b2. Note that a * block always * dominates itself. */ -extern bblock_p common_dom(); /* (bblock_p a,b) - * find a basic block that dominates a as - * well as b; note that a basic block also +bblock_p common_dom(bblock_p a, bblock_p b); + /* + * Find a basic block that dominates a as + * well as b; note that a basic block also * dominates itself. */ -extern short add_timespace(); /* (short time,space) - * Add together a time and space, using - * the time_space_ratio parameter that +short add_timespace(short time, short space); + /* + * Add together a time and space, using + * the time_space_ratio parameter that * may be set by the user. */ -extern rm_line(); /* ( line_p l; bblock_p b) +void rm_line(line_p l, bblock_p b); + /* * Remove line l from b basic block b. */ - -extern appnd_line(); /* ( line_p l1,l2) +void appnd_line(line_p l1, line_p l2); + /* * Put line l1 after l2. */ -extern line_p last_instr(); /* ( bblock_p b) +line_p last_instr(bblock_p b); /* * Determine the last line of a basic block. */ -extern line_p find_mesreg(); /* (offset off) - * Find the register message for the local +line_p find_mesreg(offset off); /* + * Find the register message for the local * with the given offset. */ -extern bool is_regvar(); /* (offset off) +bool is_regvar(offset off); /* * See if there is a 'register message' * for the local variable with the * given offset. */ -extern offset regv_arg(); /* (offset off; int n) +offset regv_arg(offset off, int n); + /* * Fetch the n'th argument of the * register message of the local with * the given offset. diff --git a/util/ego/share/cset.c b/util/ego/share/cset.c index 2bce12994..7825b7057 100644 --- a/util/ego/share/cset.c +++ b/util/ego/share/cset.c @@ -37,8 +37,7 @@ -cset Cempty_set(n) - short n; +cset Cempty_set(short n) { cset s; @@ -48,9 +47,7 @@ cset Cempty_set(n) } -bool Cis_elem(x,s) - Celem_t x; - cset s; +bool Cis_elem(Celem_t x, cset s) { short n; int mask; @@ -67,9 +64,7 @@ bool Cis_elem(x,s) -Cadd(x,s_p) - Celem_t x; - cset *s_p; +void Cadd(Celem_t x, cset *s_p) { cset s; short n; @@ -83,9 +78,7 @@ Cadd(x,s_p) } -Cremove(x,s_p) - Celem_t x; - cset *s_p; +void Cremove(Celem_t x, cset *s_p) { cset s; short n; @@ -117,16 +110,13 @@ Cremove(x,s_p) * be used very often. */ -Cindex Cfirst(s) - cset s; +Cindex Cfirst(cset s) { return Cnext((Cindex) 0,s); } -Cindex Cnext(i,s) - Cindex i; - cset s; +Cindex Cnext(Cindex i, cset s) { register short n; @@ -139,16 +129,14 @@ Cindex Cnext(i,s) } -Celem_t Celem(i) - Cindex i; +Celem_t Celem(Cindex i) { return (Celem_t) i; } -Cjoin(s1,s2_p) - cset s1, *s2_p; +void Cjoin(cset s1, cset *s2_p) { /* Two sets are joined by or-ing their bitvectors, * word by word. @@ -168,8 +156,7 @@ Cjoin(s1,s2_p) -Cintersect(s1,s2_p) - cset s1, *s2_p; +void Cintersect(cset s1, cset *s2_p) { /* Two sets are intersected by and-ing their bitvectors, * word by word. @@ -188,15 +175,13 @@ Cintersect(s1,s2_p) } -Cdeleteset(s) - cset s; +void Cdeleteset(cset s) { oldbitvect(s,DIVWL(s->v_size - 1) + 1); } -bool Cis_subset(s1,s2) - cset s1,s2; +bool Cis_subset(cset s1, cset s2) { /* See if s1 is a subset of s2 */ @@ -213,8 +198,7 @@ bool Cis_subset(s1,s2) } -Cclear_set(s_p) - cset *s_p; +void Cclear_set(cset *s_p) { cset s; register short i; @@ -227,8 +211,7 @@ Cclear_set(s_p) } -Ccopy_set(s1,s2_p) - cset s1, *s2_p; +void Ccopy_set(cset s1, cset *s2_p) { cset s2; register short i; @@ -241,8 +224,7 @@ Ccopy_set(s1,s2_p) } -Csubtract(s1,s2_p) - cset s1, *s2_p; +void Csubtract(cset s1, cset *s2_p) { cset s2; register short i; @@ -255,8 +237,7 @@ Csubtract(s1,s2_p) } -bool Cequal(s1,s2) - cset s1, s2; +bool Cequal(cset s1, cset s2) { register short i; @@ -267,8 +248,7 @@ bool Cequal(s1,s2) return TRUE; } -short Cnrelems(s) - cset s; +short Cnrelems(cset s) { register short n, cnt; diff --git a/util/ego/share/cset.h b/util/ego/share/cset.h index 6ad144394..83f4566ab 100644 --- a/util/ego/share/cset.h +++ b/util/ego/share/cset.h @@ -8,19 +8,19 @@ */ -extern cset Cempty_set(); /* (short) */ -extern bool Cis_elem(); /* (Celem, cset) */ -extern Cadd(); /* (Celem, *cset) */ -extern Cremove(); /* (Celem, *cset) */ -extern Cindex Cfirst(); /* (cset) */ -extern Cindex Cnext(); /* (Cindex, cset) */ -extern Celem_t Celem(); /* (Cindex) */ -extern Cjoin(); /* (cset, *cset) */ -extern Cintersect(); /* (cset, *cset) */ -extern Cdeleteset(); /* (cset) */ -extern bool Cis_subset(); /* (cset, cset) */ -extern Cclearset(); /* (cset, *cset) */ -extern Ccopy_set(); /* (cset, *cset) */ -extern Csubtract(); /* (cset, *cset) */ -extern bool Cequal(); /* (cset, cset) */ -extern short Cnrelems(); /* (cset) */ +cset Cempty_set(short); +bool Cis_elem(Celem_t, cset); +void Cadd(Celem_t, cset *); +void Cremove(Celem_t, cset *); +Cindex Cfirst(cset); +Cindex Cnext(Cindex, cset); +Celem_t Celem(Cindex); +void Cjoin(cset, cset *); +void Cintersect(cset, cset *); +void Cdeleteset(cset); +bool Cis_subset(cset, cset); +void Cclearset(cset, cset *); +void Ccopy_set(cset, cset *); +void Csubtract(cset, cset *); +bool Cequal(cset, cset); +short Cnrelems(cset); diff --git a/util/ego/share/debug.c b/util/ego/share/debug.c index b16d488a2..81080f7cf 100644 --- a/util/ego/share/debug.c +++ b/util/ego/share/debug.c @@ -9,8 +9,9 @@ */ -#include +#include #include +#include #include #include "types.h" #include "def.h" @@ -23,14 +24,17 @@ int linecount; /* # lines in this file */ bool verbose_flag = FALSE; /* generate verbose output ? */ /* VARARGS1 */ -error(s,a) char *s,*a; { +void error(const char *s, ...) +{ + va_list ap; + va_start(ap, s); fprintf(stderr,"error on line %u",linecount); if (filename != (char *) 0) { fprintf(stderr," file %s",filename); } fprintf(stderr,": "); - fprintf(stderr,s,a); + vfprintf(stderr,s,ap); fprintf(stderr,"\n"); abort(); exit(-1); @@ -38,21 +42,17 @@ error(s,a) char *s,*a; { #ifdef TRACE /* VARARGS1 */ -OUTTRACE(s,n) - char *s; - int n; +void OUTTRACE(const char *s, int n) { fprintf(stderr,"> "); - fprintf(stderr,s,n); + vfprintf(stderr,s,n); fprintf(stderr,"\n"); } #endif #ifdef VERBOSE /* VARARGS1 */ -OUTVERBOSE(s,n1,n2) - char *s; - int n1,n2; +void OUTVERBOSE(const char *s, int n1, int n2) { if (verbose_flag) { fprintf(stderr,"optimization: "); @@ -65,14 +65,9 @@ OUTVERBOSE(s,n1,n2) #ifdef DEBUG -badassertion(file,line) char *file; unsigned line; { - - fprintf(stderr,"assertion failed file %s, line %u\n",file,line); - error("assertion"); -} /* Valid Address */ -VA(a) short *a; { +void VA(short *a) { if (a == (short *) 0) error("VA: 0 argument"); if ( ((unsigned) a & 01) == 01) { /* MACHINE DEPENDENT TEST */ @@ -83,14 +78,14 @@ VA(a) short *a; { /* Valid Instruction code */ -VI(i) short i; { +void VI(short i) { if (i > ps_last) error("VI: illegal instr: %d", i); } /* Valid Line */ -VL(l) line_p l; { +void VL(line_p l) { byte instr, optype; VA((short *) l); @@ -106,7 +101,7 @@ VL(l) line_p l; { /* Valid Data block */ -VD(d) dblock_p d; { +void VD(dblock_p d) { byte pseudo; VA((short *) d); @@ -119,7 +114,7 @@ VD(d) dblock_p d; { /* Valid Object */ -VO(o) obj_p o; { +void VO(obj_p o) { offset off; VA((short *) o); @@ -133,7 +128,7 @@ VO(o) obj_p o; { /* Valid Proc */ -VP(p) proc_p p; { +void VP(proc_p p) { proc_id pid; int nrlabs; diff --git a/util/ego/share/debug.h b/util/ego/share/debug.h index 9cb5cac51..98cb6e868 100644 --- a/util/ego/share/debug.h +++ b/util/ego/share/debug.h @@ -12,16 +12,16 @@ extern int linecount; /* # lines in this file */ extern bool verbose_flag; /* generate verbose output ? */ /* VARARGS 1 */ -extern error(); +void error(const char *, ...); #ifdef TRACE -extern OUTTRACE(); +void OUTTRACE(const char *, int); #else #define OUTTRACE(s,n) #endif #ifdef VERBOSE -extern OUTVERBOSE(); +void OUTVERBOSE(const char *, int, int); #else #define OUTVERBOSE(s,n1,n2) #endif @@ -34,20 +34,17 @@ extern OUTVERBOSE(); #define STATIC -#define assert(x) if(!(x)) badassertion(__FILE__,__LINE__) - -extern VI(); -extern VL(); -extern VD(); -extern VA(); -extern VO(); -extern VP(); - - +void VI(short); +void VL(line_p); +void VD(dblock_p); +void VA(short *); +void VO(obj_p); +void VP(proc_p); #else /*DEBUG*/ -#define assert(b) +#define STATIC static +#define NDEBUG /* disable assert() */ #define VI(i) #define VL(l) @@ -56,6 +53,6 @@ extern VP(); #define VO(o) #define VP(p) - -#define STATIC static #endif + +#include diff --git a/util/ego/share/files.c b/util/ego/share/files.c index 644819307..e45f9b7fb 100644 --- a/util/ego/share/files.c +++ b/util/ego/share/files.c @@ -47,7 +47,7 @@ struct files* findfiles(int argc, const char** argv) return &files; } -FILE *openfile(char* name, char* mode) +FILE *openfile(const char *name, const char *mode) { FILE *f; diff --git a/util/ego/share/files.h b/util/ego/share/files.h index 72deae081..46b19917a 100644 --- a/util/ego/share/files.h +++ b/util/ego/share/files.h @@ -37,9 +37,10 @@ struct files int argc; }; -extern struct files* findfiles(int argc, const char** argv); +struct files* findfiles(int argc, const char** argv); -extern FILE *openfile(); /* (char *name, *mode) +FILE *openfile(const char *name, const char *mode); + /* * Open a file with the given name * and mode; aborts if the file * cannot be opened. diff --git a/util/ego/share/get.c b/util/ego/share/get.c index 00f1cc4da..94c7aabe2 100644 --- a/util/ego/share/get.c +++ b/util/ego/share/get.c @@ -33,7 +33,7 @@ lab_id lastlabid; /* last label identifier */ * appear in the input. */ -bblock_p freshblock() +bblock_p freshblock(void) { bblock_p b; b = newbblock(); @@ -42,7 +42,7 @@ bblock_p freshblock() } -lab_id freshlabel() +lab_id freshlabel(void) { curproc->p_nrlabels++; return ++lastlabid; @@ -51,7 +51,7 @@ lab_id freshlabel() #define getmark() getbyte() -short getshort() { +short getshort(void) { register int l_byte, h_byte; l_byte = getbyte(); @@ -61,7 +61,7 @@ short getshort() { } -offset getoff() { +offset getoff(void) { register long l; register int h_byte; @@ -73,7 +73,7 @@ offset getoff() { return l | (h_byte*256L*256*256L) ; } -STATIC int getint() +STATIC int getint(void) { /* Read an integer from the input file. This routine is * only used when reading a bitvector-set. We expect an @@ -90,8 +90,7 @@ STATIC int getint() /* getptable */ -loop_p getloop(id) - loop_id id; +STATIC void *getloop(loop_id id) { /* Map a loop identifier onto a loop struct. * If no struct was alocated yet for this identifier then @@ -107,8 +106,7 @@ loop_p getloop(id) return (lpmap[id]); } -bblock_p getblock(id) - block_id id; +STATIC void *getblock(block_id id) { /* Map a basic block identifier onto a block struct * If no struct was alocated yet for this identifier then @@ -126,8 +124,7 @@ bblock_p getblock(id) } -lset getlset(p) - char *((*p) ()); +STATIC lset getlset(void *(*p)(short)) { /* Read a 'long' set. Such a set is represented externally * as a sequence of identifying numbers terminated by a 0. @@ -146,7 +143,7 @@ lset getlset(p) } -cset getcset() +STATIC cset getcset() { /* Read a 'compact' set. Such a set is represented externally * a row of bytes (its bitvector) preceded by its length. @@ -163,8 +160,7 @@ cset getcset() } -proc_p getptable(pname) - char *pname; +proc_p getptable(const char *pname) { short i; proc_p head, p, *pp; @@ -216,8 +212,7 @@ proc_p getptable(pname) /* getdtable */ -dblock_p getdtable(dname) - char *dname; +dblock_p getdtable(const char *dname) { /* Read the data block table. Every data block may * have a list of objects and a list of values (arguments), @@ -290,9 +285,7 @@ dblock_p getdtable(dname) /* getbblocks */ -STATIC argstring(length,abp) - short length; - register argb_p abp; +STATIC argstring(short length, argb_p abp) { while (length--) { @@ -304,7 +297,7 @@ STATIC argstring(length,abp) -STATIC arg_p readargs() +STATIC arg_p readargs(void) { /* Read a list of arguments and allocate structures * for them. Return a pointer to the head of the list. @@ -363,8 +356,7 @@ STATIC arg_p readargs() } -line_p read_line(p_out) - proc_p *p_out; +line_p read_line(proc_p *p_out) { /* Read a line of EM code (i.e. one instruction) * and its arguments (if any). @@ -426,8 +418,7 @@ line_p read_line(p_out) } -message(lnp) - line_p lnp; +void message(line_p lnp) { /* See if lnp is some useful message. * (e.g. a message telling that a certain local variable @@ -456,11 +447,7 @@ message(lnp) -line_p getlines(lf,n,p_out,collect_mes) - FILE *lf; - int n; - proc_p *p_out; - bool collect_mes; +line_p getlines(FILE *lf, int n, proc_p *p_out, bool collect_mes) { /* Read n lines of EM text and doubly link them. * Also process messages. @@ -486,13 +473,8 @@ line_p getlines(lf,n,p_out,collect_mes) -bool getunit(gf,lf,kind_out,g_out,l_out,p_out,collect_mes) - FILE *gf,*lf; - short *kind_out; - bblock_p *g_out; - line_p *l_out; - proc_p *p_out; - bool collect_mes; +bool getunit(FILE *gf, FILE *lf, short *kind_out, bblock_p *g_out, + line_p *l_out, proc_p *p_out, bool collect_mes) { /* Read control flow graph (gf) and EM text (lf) of the next procedure. * A pointer to the proctable entry of the read procedure is diff --git a/util/ego/share/get.h b/util/ego/share/get.h index 00eae42c7..1b9dcdef7 100644 --- a/util/ego/share/get.h +++ b/util/ego/share/get.h @@ -10,44 +10,44 @@ extern block_id lastbid; /* block identifying number */ extern lab_id lastlabid; /* last label identifier */ #define getbyte() getc(curinp) -extern short getshort(); /* () +short getshort(void); /* * Read a short from curinp */ -extern offset getoff(); /* () +offset getoff(void); /* * Read an offset from curinp */ -extern line_p read_line(); /* ( proc_p *p_out) +line_p read_line(proc_p *p_out); /* * Read a line of EM code (i.e. one * instruction) and its arguments * (if any). If the instruction is a * 'pro' pseudo, set p_out. */ -extern line_p getlines(); /* ( FILE *lf; int n; proc_p *p_out; - * bool collect_mes) +line_p getlines(FILE *lf, int n, proc_p *p_out, bool collect_mes); + /* * Read n lines of EM text and doubly * link them. Also process messages * if required. */ -extern bblock_p freshblock(); /* () +bblock_p freshblock(void); /* * Allocate a bblock struct and assign * it a brand new block_id. */ -extern lab_id freshlabel(); /* () +lab_id freshlabel(void); /* * Get a brand new lab_id. */ -extern dblock_p getdtable(); /* (char *dname) +dblock_p getdtable(const char *dname); /* * Read the data block table from * the file with the given name. */ -extern proc_p getptable(); /* (char *pname) +proc_p getptable(const char *pname); /* * Read the proc table from * the file with the given name. */ -extern bool getunit(); /* (FILE *gf,*lf; short kind_out; - * bblock_p g_out; line_p l_out; - * proc_p *p_out; bool collect_mes) +bool getunit(FILE *gf, FILE *lf, short *kind_out, bblock_p *g_out, + line_p *l_out, proc_p *p_out, bool collect_mes); + /* * Read the control flow graph * (from file gf) and the EM text * (from lf). If collect_mes is TRUE, @@ -56,8 +56,8 @@ extern bool getunit(); /* (FILE *gf,*lf; short kind_out; * variable 'mesregs'. The proc read * is returned in p_out. */ -extern message(); /* (line_p lnp) - * See if lnp is some useful message. +void message(line_p lnp); /* + * See if lnp is some useful message. * (e.g. a message telling that a * certain local variable will never be * referenced indirectly, so it may be diff --git a/util/ego/share/go.c b/util/ego/share/go.c index 53c6bb456..9a2107d3d 100644 --- a/util/ego/share/go.c +++ b/util/ego/share/go.c @@ -27,7 +27,7 @@ STATIC bool report_flag = FALSE; /* report #optimizations found? */ STATIC bool core_flag = FALSE; /* report core usage? */ #endif -static mach_init(char* machfile, int (*phase_machinit)()) +STATIC void mach_init(char* machfile, void (*phase_machinit)(void *)) { /* Read target machine dependent information */ @@ -43,7 +43,8 @@ static mach_init(char* machfile, int (*phase_machinit)()) } void go(int argc, const char** argv, - int (*initialize)(), int (*optimize)(), int (*phase_machinit)(), int (*proc_flag)()) + void (*initialize)(void *), void (*optimize)(void *), + void (*phase_machinit)(void *), void (*proc_flag)(void *)) { struct files* files = findfiles(argc, argv); FILE* f, *gf, *f2, *gf2; /* The EM input and output and @@ -100,7 +101,7 @@ void go(int argc, const char** argv, time_space_ratio = (time_opt ? 100 : 0); fproc = getptable(files->pname_in); /* proc table */ fdblock = getdtable(files->dname_in); /* data block table */ - (*initialize)(); + (*initialize)(NULL); if (optimize == no_action) return; f = openfile(files->lname_in, "r"); @@ -143,7 +144,8 @@ void go(int argc, const char** argv, core_usage(); } -int no_action() {} +/* ARGSUSED */ +void no_action(void *vp) {} void core_usage(void) { diff --git a/util/ego/share/go.h b/util/ego/share/go.h index 8657c0d67..3bb8c1f54 100644 --- a/util/ego/share/go.h +++ b/util/ego/share/go.h @@ -22,20 +22,22 @@ * and 'optimize' is called with the current procedure * as parameter. */ -extern void go(int argc, const char** argv, - int (*initialize)(), int (*optimize)(), - int (*phase_machinit)(), int (*proc_flag)()); +void go(int argc, const char** argv, + void (*initialize)(void *null), + void (*optimize)(void *), /* (proc_p *p) */ + void (*phase_machinit)(void *), /* (FILE *f) */ + void (*proc_flag)(void *)); /* (char *flag) */ /* * Parameter to be supplied for e.g. 'initialize' if * no action is required. */ -extern int no_action(); +void no_action(void *); /* Report core usage, if core_flag is set. */ -extern void core_usage(void); +void core_usage(void); /* Report number of optimizations found, if * report_flag is set */ -extern void report(char* s, int n); +void report(char* s, int n); diff --git a/util/ego/share/init_glob.c b/util/ego/share/init_glob.c index a70e78e48..214f629ba 100644 --- a/util/ego/share/init_glob.c +++ b/util/ego/share/init_glob.c @@ -19,7 +19,8 @@ extern short nrglobals; -init_globals() +/* ARGSUSED */ +void init_globals(void *vp) { /* Assign a 'global variable number (o_globnr) to * every global variable for which we want to diff --git a/util/ego/share/init_glob.h b/util/ego/share/init_glob.h index 4623d83e2..0593bcd2a 100644 --- a/util/ego/share/init_glob.h +++ b/util/ego/share/init_glob.h @@ -10,6 +10,6 @@ * */ -extern init_globals(); /* Assign a 'global variable number (o_globnr) +void init_globals(void *null); /* Assign a 'global variable number (o_globnr) * to every global variable. */ diff --git a/util/ego/share/locals.c b/util/ego/share/locals.c index 7da423b7f..7cca77660 100644 --- a/util/ego/share/locals.c +++ b/util/ego/share/locals.c @@ -29,12 +29,8 @@ short nrglobals; short nrlocals; local_p *locals; /* dynamic array */ -STATIC void localvar(off,size,locs,reg,score) - offset off; - short size; - local_p *locs; - bool reg; - offset score; +STATIC void localvar(offset off, short size, local_p *locs, bool reg, + offset score) { /* process a reference to a local variable. * A local is characterized by a (offset,size) pair. @@ -72,9 +68,7 @@ STATIC void localvar(off,size,locs,reg,score) -STATIC check_message(l,locs) - line_p l; - local_p *locs; +STATIC check_message(line_p l, local_p *locs) { /* See if l is a register message */ @@ -90,9 +84,7 @@ STATIC check_message(l,locs) -STATIC void check_local_use(l,locs) - line_p l; - local_p *locs; +STATIC void check_local_use(line_p l, local_p *locs) { short sz; @@ -126,8 +118,7 @@ STATIC void check_local_use(l,locs) } -make_localtab(p) - proc_p p; +void make_localtab(proc_p p) { /* Make a table of local variables. * This table is used to associate a @@ -186,10 +177,7 @@ make_localtab(p) -void find_local(off,nr_out,found_out) - offset off; - short *nr_out; - bool *found_out; +void find_local(offset off, short *nr_out, bool *found_out) { /* Try to find the local variable at the given * offset. Return its local-number. @@ -211,10 +199,7 @@ void find_local(off,nr_out,found_out) -void var_nr(l,nr_out,found_out) - line_p l; - short *nr_out; - bool *found_out; +void var_nr(line_p l, short *nr_out, bool *found_out) { /* Determine the number of the variable referenced * by EM instruction l. diff --git a/util/ego/share/locals.h b/util/ego/share/locals.h index 60792372f..c4d235602 100644 --- a/util/ego/share/locals.h +++ b/util/ego/share/locals.h @@ -11,17 +11,19 @@ extern local_p *locals; /* table of locals, index is local-number */ extern short nrlocals; /* number of locals for which we keep ud-info */ -extern make_localtab(); /* (proc_p p) +void make_localtab(proc_p p); /* * Analyse the text of procedure p to determine * which local variable p has. Make a table of * these variables ('locals') and count them * ('nrlocals'). Also collect register messages. */ -extern void var_nr(); /* (line_p l; short *nr_out;bool *found_out) +void var_nr(line_p l, short *nr_out, bool *found_out); + /* * Compute the 'variable number' of the * variable referenced by EM instruction l. */ -extern void find_local(); /* (offset off; short *nr_out; bool *found_out) +void find_local(offset off, short *nr_out, bool *found_out); + /* * Try to find the local variable at the given * offset. Return its local-number. */ diff --git a/util/ego/share/lset.c b/util/ego/share/lset.c index 682494a77..912036527 100644 --- a/util/ego/share/lset.c +++ b/util/ego/share/lset.c @@ -30,15 +30,13 @@ */ -lset Lempty_set() +lset Lempty_set(void) { return ((lset) 0); } -bool Lis_elem(x,s) - register Lelem_t x; - register lset s; +bool Lis_elem(Lelem_t x, lset s) { /* Search the list to see if x is an element of s */ @@ -52,9 +50,7 @@ bool Lis_elem(x,s) } -Ladd(x,s_p) - Lelem_t x; - lset *s_p; +void Ladd(Lelem_t x, lset *s_p) { /* add x to a set. Note that the set is given as in-out * parameter, because it may be changed. @@ -71,9 +67,7 @@ Ladd(x,s_p) } -Lremove(x,s_p) - Lelem_t x; - lset *s_p; +void Lremove(Lelem_t x, lset *s_p) { /* Remove x from a set. If x was not an element of * the set, nothing happens. @@ -109,8 +103,7 @@ Lremove(x,s_p) */ -Lindex Lfirst(s) - lset s; +Lindex Lfirst(lset s) { return ((Lindex) s); /* Note that an index for long sets is just @@ -120,25 +113,21 @@ Lindex Lfirst(s) /*ARGSUSED1*/ -Lindex Lnext(i,s) - Lindex i; - lset s; +Lindex Lnext(Lindex i, lset s) { assert(i != (Lindex) 0); return (i->e_next); } -Lelem_t Lelem(i) - Lindex i; +Lelem_t Lelem(Lindex i) { return (i->e_elem); } -Ljoin(s1,s2_p) - lset s1,*s2_p; +void Ljoin(lset s1, lset *s2_p) { /* Join two sets, assign the result to the second set * and delete the first set (i.e. the value of the @@ -173,8 +162,7 @@ Ljoin(s1,s2_p) } -Ldeleteset(s) - lset s; +void Ldeleteset(lset s) { register elem_p ep, next; @@ -185,8 +173,7 @@ Ldeleteset(s) } -bool Lis_subset(s1,s2) - lset s1,s2; +bool Lis_subset(lset s1, lset s2) { /* See if s1 is a subset of s2 */ @@ -199,8 +186,7 @@ bool Lis_subset(s1,s2) } -short Lnrelems(s) - lset s; +short Lnrelems(lset s) { /* Compute the number of elements of a set */ diff --git a/util/ego/share/lset.h b/util/ego/share/lset.h index a11cc237b..72ce35814 100644 --- a/util/ego/share/lset.h +++ b/util/ego/share/lset.h @@ -8,14 +8,14 @@ */ -extern lset Lempty_set(); /* () */ -extern bool Lis_elem(); /* (Lelem_t, lset) */ -extern Ladd(); /* (Lelem_t, *lset) */ -extern Lremove(); /* (Lelem_t, *lset) */ -extern Lindex Lfirst(); /* (lset) */ -extern Lindex Lnext(); /* (Lindex, lset) */ -extern Lelem_t Lelem(); /* (Lindex) */ -extern Ljoin(); /* (lset, *lset) */ -extern Ldeleteset(); /* (lset) */ -extern bool Lis_subset(); /* (lset, lset) */ -extern short Lnrelems(); /* (lset) */ +lset Lempty_set(void); +bool Lis_elem(Lelem_t, lset); +void Ladd(Lelem_t, lset *); +void Lremove(Lelem_t, lset *); +Lindex Lfirst(lset); +Lindex Lnext(Lindex, lset); +Lelem_t Lelem(Lindex); +void Ljoin(lset, lset *); +void Ldeleteset(lset); +bool Lis_subset(lset, lset); +short Lnrelems(lset); diff --git a/util/ego/share/makecldef.c b/util/ego/share/makecldef.c index ff22f68f1..a89d30538 100644 --- a/util/ego/share/makecldef.c +++ b/util/ego/share/makecldef.c @@ -6,6 +6,7 @@ #include #include +#include /* MAKECLASSDEF * diff --git a/util/ego/share/parser.c b/util/ego/share/parser.c index adda87a66..19ede3d1b 100644 --- a/util/ego/share/parser.c +++ b/util/ego/share/parser.c @@ -41,9 +41,7 @@ typedef struct class *class_p; * generated automatically from the file classdefs.src. */ -STATIC bool classes(instr,src_out,res_out) - int instr; - int *src_out, *res_out; +STATIC bool classes(int instr, int *src_out, int *res_out) { /* Determine the classes of the given instruction */ @@ -59,8 +57,7 @@ STATIC bool classes(instr,src_out,res_out) -STATIC bool uses_arg(class) - int class; +STATIC bool uses_arg(int class) { /* See if a member of the given class uses * an argument. @@ -82,8 +79,7 @@ STATIC bool uses_arg(class) -STATIC bool uses_2args(class) - int class; +STATIC bool uses_2args(int class) { /* See if a member of the given class uses * 2 arguments. @@ -93,9 +89,7 @@ STATIC bool uses_2args(class) } -STATIC bool parse_locs(l,c1_out,c2_out) - line_p l; - offset *c1_out, *c2_out; +STATIC bool parse_locs(line_p l, offset *c1_out, offset *c2_out) { if (INSTR(l) == op_loc && INSTR(PREV(l)) == op_loc) { *c1_out = off_set(l); @@ -107,10 +101,8 @@ STATIC bool parse_locs(l,c1_out,c2_out) -STATIC bool check_args(l,src_class,res_class,arg1_out,arg2_out) - line_p l; - int src_class,res_class; - offset *arg1_out, *arg2_out; +STATIC bool check_args(line_p l, int src_class, int res_class, + offset *arg1_out, offset *arg2_out) { /* Several EM instructions have an argument * giving the size of the operand(s) of @@ -144,9 +136,7 @@ STATIC bool check_args(l,src_class,res_class,arg1_out,arg2_out) -STATIC offset nrbytes(class,arg1,arg2) - int class; - offset arg1,arg2; +STATIC offset nrbytes(int class, offset arg1, offset arg2) { /* Determine the number of bytes of the given * arguments and class. @@ -185,9 +175,8 @@ STATIC offset nrbytes(class,arg1,arg2) -STATIC attrib(l,expect_out,srcb_out,resb_out) - line_p l; - offset *expect_out, *srcb_out, *resb_out; +STATIC void attrib(line_p l, offset *expect_out, offset *srcb_out, + offset *resb_out) { /* Determine a number of attributes of an EM * instruction appearing in an expression. @@ -215,11 +204,8 @@ STATIC attrib(l,expect_out,srcb_out,resb_out) -bool parse(l,nbytes,l_out,level,action0) - line_p l, *l_out; - offset nbytes; - int level; - int (*action0) (); +bool parse(line_p l, offset nbytes, line_p *l_out, int level, + void (*action0)(line_p, line_p, offset)) { /* This is a recursive descent parser for * EM expressions. diff --git a/util/ego/share/parser.h b/util/ego/share/parser.h index 41066fdb5..a8b35a335 100644 --- a/util/ego/share/parser.h +++ b/util/ego/share/parser.h @@ -3,8 +3,9 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -bool parse(); /* (line_p l, *l_out; offset nbytes; - * int level; int (*action0) ()) +bool parse(line_p l, offset nbytes, line_p *l_out, int level, + void (*action0)(line_p l1, line_p l2, offset size)); + /* * This is a recursive descent parser for * EM expressions. * It tries to recognize EM code that loads exactly diff --git a/util/ego/share/put.c b/util/ego/share/put.c index 9cbfe7339..30c382bfa 100644 --- a/util/ego/share/put.c +++ b/util/ego/share/put.c @@ -15,6 +15,7 @@ #include "def.h" #include "map.h" #include "lset.h" +#include "cset.h" #include "alloc.h" #include "put.h" @@ -31,12 +32,11 @@ FILE *curoutp; /* putlines */ -STATIC putstr(); -STATIC outlab(); -STATIC outobject(); +STATIC void putstr(argb_p); +STATIC void outlab(lab_id); +STATIC void outobject(obj_p); -STATIC putargs(ap) - register arg_p ap; +STATIC void putargs(arg_p ap) { while (ap != (arg_p) 0) { outbyte((byte) ap->a_type & BMASK); @@ -70,9 +70,9 @@ STATIC putargs(ap) -STATIC putstr(abp) register argb_p abp; { - register argb_p tbp; - register length; +STATIC void putstr(argb_p abp) { + argb_p tbp; + int length; length = 0; tbp = abp; @@ -89,22 +89,21 @@ STATIC putstr(abp) register argb_p abp; { } -outoff(off) offset off; { +void outoff(offset off) { outshort( (short) (off&0177777L) ); outshort( (short) (off>>16) ); } -outshort(i) short i; { +void outshort(short i) { outbyte( (byte) (i&BMASK) ); outbyte( (byte) (i>>8) ); } -STATIC outint(i) - int i; +STATIC void outint(int i) { /* Write an integer to the output file. This routine is * only used when outputting a bitvector-set. We expect an @@ -119,24 +118,22 @@ STATIC outint(i) } } -STATIC outlab(lid) lab_id lid; { +STATIC void outlab(lab_id lid) { outshort((short) lid); } -STATIC outobject(obj) obj_p obj; { +STATIC void outobject(obj_p obj) { outshort((short) obj->o_id); } -outproc(p) proc_p p; { +void outproc(proc_p p) { outshort((short) p->p_id); } -short putlines(l,lf) - line_p l; - FILE *lf; +short putlines(line_p l, FILE *lf) { /* Output the list of em instructions headed by l. * Return the number of instruction written. @@ -189,8 +186,7 @@ short putlines(l,lf) #define outmark(m) outbyte((byte) m) -STATIC putobjects(obj) - register obj_p obj; +STATIC void putobjects(obj_p obj) { while (obj != (obj_p) 0) { outmark(MARK_OBJ); @@ -203,8 +199,7 @@ STATIC putobjects(obj) -STATIC putvalues(arg) - register arg_p arg; +STATIC void putvalues(arg_p arg) { while (arg != (arg_p) 0) { assert(arg->a_type == ARGOFF); @@ -213,9 +208,7 @@ STATIC putvalues(arg) arg = arg->a_next; } } -putdtable(head,df) - dblock_p head; - FILE *df; +void putdtable(dblock_p head, FILE *df) { /* Write the datablock table to the data block file df. */ @@ -257,8 +250,7 @@ putdtable(head,df) -STATIC outcset(s) - cset s; +STATIC void outcset(cset s) { /* A 'compact' set is represented externally as a row of words * (its bitvector) preceded by its length. @@ -274,10 +266,7 @@ STATIC outcset(s) -putptable(head,pf,all) - proc_p head; - FILE *pf; - bool all; +void putptable(proc_p head, FILE *pf, bool all) { register proc_p p; proc_p next; @@ -328,16 +317,18 @@ putptable(head,pf,all) /* putunit */ -STATIC outloop(l) - loop_p l; +STATIC void outloop(void *vp) { + loop_p l = vp; + outshort((short) l->lp_id); } -STATIC outblock(b) - bblock_p b; +STATIC void outblock(void *vp) { + bblock_p b = vp; + if (b == (bblock_p) 0) { outshort((short) 0); } else { @@ -346,20 +337,7 @@ STATIC outblock(b) } -STATIC outid(e,p) - Lelem_t e; - int (*p) (); -{ - /* Auxiliary routine used by outlset. */ - - /* NOSTRICT */ - (*p) (e); -} - - -STATIC outlset(s,p) - lset s; - int (*p) (); +STATIC void outlset(lset s, void (*p)(void *)) { /* A 'long' set is represented externally as a * a sequence of elements terminated by a 0 word. @@ -370,19 +348,14 @@ STATIC outlset(s,p) register Lindex i; for (i = Lfirst(s); i != (Lindex) 0; i = Lnext(i,s)) { - outid(Lelem(i),p); + (*p)(Lelem(i)); } outshort((short) 0); } -void -putunit(kind,p,l,gf,lf) - short kind; - proc_p p; - line_p l; - FILE *gf, *lf; +void putunit(short kind, proc_p p, line_p l, FILE *gf, FILE *lf) { register bblock_p b; register short n = 0; diff --git a/util/ego/share/put.h b/util/ego/share/put.h index c6287cdaf..95e726497 100644 --- a/util/ego/share/put.h +++ b/util/ego/share/put.h @@ -9,27 +9,29 @@ extern FILE *curoutp; /* current output file */ #define outbyte(b) putc(b,curoutp) -extern outshort(); /* (short i) +void outshort(short i); /* * Write a short to curoutp */ -extern outoff(); /* (offset off) +void outoff(offset off); /* * Write an offset to curoutp */ -extern outproc(); /* (proc_p p) +void outproc(proc_p p); /* * Write a procid to curoutp */ -extern putdtable(); /* (dblock_p head, FILE *df) +void putdtable(dblock_p head, FILE *df); + /* * Write the data block table to file df, * preceded by its length. */ -extern putptable(); /* (proc_p head, FILE *pf, bool all) +void putptable(proc_p head, FILE *pf, bool all); + /* * Write the proc table to file pf, * preceded by its length. If all=false, * the fields computed by CF will not be * written (used by the IC phase). */ -extern void putunit(); /* (short kind; proc_p p; line_p l; - * FILE *gf, *lf) +void putunit(short kind, proc_p p, line_p l, FILE *gf, FILE *lf); + /* * If kind = LTEXT, then write * the control flow graph to file gf, * preceded by its length (#basic blocks); @@ -40,7 +42,8 @@ extern void putunit(); /* (short kind; proc_p p; line_p l; * list of instructions (data declarations) * to lf. */ -extern short putlines(); /* (line_p l; FILE *lf) +short putlines(line_p l, FILE *lf); + /* * Output the list of em instructions * headed by l. Return the number of * instructions written. diff --git a/util/ego/share/stack_chg.c b/util/ego/share/stack_chg.c index c5a5691d8..5d5c332d7 100644 --- a/util/ego/share/stack_chg.c +++ b/util/ego/share/stack_chg.c @@ -17,9 +17,7 @@ #define IS_LOC(l) (l!=(line_p) 0 && INSTR(l)==op_loc && TYPE(l)==OPSHORT) -int stack_change(l,sign) - line_p l; - char sign; +STATIC int stack_change(line_p l, char sign) { /* Interpret the string in the third column of the em_table file */ @@ -91,10 +89,7 @@ int stack_change(l,sign) -line_change(l,ok_out,pop_out,push_out) - line_p l; - bool *ok_out; - int *pop_out,*push_out; +void line_change(line_p l, bool *ok_out, int *pop_out, int *push_out) { short pop,push; diff --git a/util/ego/share/stack_chg.h b/util/ego/share/stack_chg.h index 226cf9a03..7c44c5857 100644 --- a/util/ego/share/stack_chg.h +++ b/util/ego/share/stack_chg.h @@ -6,7 +6,8 @@ /* S T A C K _ C H A N G E . H */ -extern line_change(); /* ( line_p l; bool *ok_out; int *pop_out,*push_out) +void line_change(line_p l, bool *ok_out, int *pop_out, int *push_out); + /* * Try to determine how the stack-height will be * affected by the EM instruction l. 'ok_out' is set * to false if we fail to do so. pop_out and diff --git a/util/ego/sp/sp.c b/util/ego/sp/sp.c index b04895647..8538d3dfb 100644 --- a/util/ego/sp/sp.c +++ b/util/ego/sp/sp.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include "../share/types.h" @@ -51,10 +52,10 @@ STATIC int globl_sp_allowed; #define IS_ASP(l) (INSTR(l) == op_asp && TYPE(l) == OPSHORT && SHORT(l) > 0) -STATIC sp_machinit(f) - FILE *f; +STATIC void sp_machinit(void *vp) { /* Read target machine dependent information for this phase */ + FILE *f = vp; char s[100]; for (;;) { @@ -193,10 +194,9 @@ STATIC mark_unsave_blocks(p) } -void -sp_optimize(p) - proc_p p; +void sp_optimize(void *vp) { + proc_p p = vp; register bblock_p b; if (IS_ENTERED_WITH_GTO(p)) return; diff --git a/util/ego/sr/sr.c b/util/ego/sr/sr.c index 5f2194ed1..e933cb0de 100644 --- a/util/ego/sr/sr.c +++ b/util/ego/sr/sr.c @@ -8,6 +8,7 @@ #include #include +#include #include "../share/types.h" #include "sr.h" #include "../share/debug.h" @@ -51,10 +52,10 @@ int sli_threshold; int Ssr; /* #optimizations found */ -sr_machinit(f) - FILE *f; +void sr_machinit(void *vp) { /* Read target machine dependent information */ + FILE *f = vp; char s[100]; @@ -218,10 +219,10 @@ STATIC sr_cleanproc(p) } -void -sr_optimize(p) - proc_p p; +void sr_optimize(void *vp) { + proc_p p = vp; + if (IS_ENTERED_WITH_GTO(p)) return; sr_extproc(p); loopblocks(p); diff --git a/util/ego/ud/ud.c b/util/ego/ud/ud.c index afcba53a5..c0fe613fd 100644 --- a/util/ego/ud/ud.c +++ b/util/ego/ud/ud.c @@ -7,6 +7,7 @@ #include #include +#include #include #include "../share/types.h" #include "ud.h" @@ -56,9 +57,9 @@ STATIC cond_p getcondtab(f) } -STATIC ud_machinit(f) - FILE *f; +STATIC void ud_machinit(void *vp) { + FILE *f = vp; char s[100]; for (;;) { @@ -531,10 +532,10 @@ STATIC ud_cleanup(p) } -void -ud_optimize(p) - proc_p p; +void ud_optimize(void *vp) { + proc_p p = vp; + if (IS_ENTERED_WITH_GTO(p)) return; ud_extend(p); locals = (local_p *) 0; diff --git a/util/led/assert.h b/util/led/assert.h deleted file mode 100644 index 3aa7b8787..000000000 --- a/util/led/assert.h +++ /dev/null @@ -1,22 +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$ */ - -#ifndef lint -#ifdef NASSERT - -#define assert(ex) - -#else /* NASSERT */ - -#define assert(ex) \ -{if (!(ex)) fatal("Assertion failed: file %s, line %d", __FILE__, __LINE__);} - -#endif /* NASSERT */ -#else /* lint */ - -#define assert(ex) - -#endif /* lint */ diff --git a/util/led/build.lua b/util/led/build.lua index ed84a79b3..58b4be5a5 100644 --- a/util/led/build.lua +++ b/util/led/build.lua @@ -2,6 +2,8 @@ cprogram { name = "led", srcs = { "./*.c" }, deps = { + "./const.h", "./debug.h", "./defs.h", "./mach.h", + "./memory.h", "./orig.h", "./scan.h", "modules/src/string+lib", "modules/src/object+lib", "h+emheaders", diff --git a/util/led/memory.c b/util/led/memory.c index c5715821e..0c7f02043 100644 --- a/util/led/memory.c +++ b/util/led/memory.c @@ -21,6 +21,7 @@ static char rcsid[] = "$Id$"; * (70000 - 65536). */ +#include #include #include #include @@ -28,7 +29,6 @@ static char rcsid[] = "$Id$"; #include #include #include "const.h" -#include "assert.h" #include "debug.h" #include "memory.h" #include "object.h" diff --git a/util/led/save.c b/util/led/save.c index c06e25c78..20beaa5ca 100644 --- a/util/led/save.c +++ b/util/led/save.c @@ -10,6 +10,7 @@ static char rcsid[] = "$Id$"; * If everything is kept in core, we must save some things for the second pass. */ +#include #include #include #include @@ -18,7 +19,6 @@ static char rcsid[] = "$Id$"; #include "arch.h" #include "out.h" #include "const.h" -#include "assert.h" #include "memory.h" extern bool incore; diff --git a/util/led/scan.c b/util/led/scan.c index 610149be8..01191f39d 100644 --- a/util/led/scan.c +++ b/util/led/scan.c @@ -6,6 +6,7 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include #include @@ -22,7 +23,6 @@ static char rcsid[] = "$Id$"; #include "ranlib.h" #include "object.h" #include "const.h" -#include "assert.h" #include "memory.h" #include "scan.h" #include "debug.h" diff --git a/util/led/write.c b/util/led/write.c index b916949ae..910323e68 100644 --- a/util/led/write.c +++ b/util/led/write.c @@ -6,6 +6,7 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include #include @@ -13,7 +14,6 @@ static char rcsid[] = "$Id$"; #include #include "out.h" #include "const.h" -#include "assert.h" #include "memory.h" extern struct outhead outhead; diff --git a/util/ncgg/assert.h b/util/ncgg/assert.h deleted file mode 100644 index 5af4080d0..000000000 --- a/util/ncgg/assert.h +++ /dev/null @@ -1,11 +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$ */ - -#ifndef NDEBUG -#define assert(x) if (!(x)) badassertion("x",__FILE__,__LINE__) -#else -#define assert(x) /* nothing */ -#endif diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua index b82f3f340..20846f02d 100644 --- a/util/ncgg/build.lua +++ b/util/ncgg/build.lua @@ -32,6 +32,10 @@ cprogram { "+keywords" ), deps = { + "./cost.h", "./expr.h", "./extern.h", "./instruct.h", + "./iocc.h", "./lookup.h", "./param.h", "./property.h", + "./pseudo.h", "./reg.h", "./regvar.h", "./set.h", + "./token.h", "./varinfo.h", "+cggparser", -- for .h file "+cgglexer", -- for .h file "h+emheaders", diff --git a/util/ncgg/coerc.c b/util/ncgg/coerc.c index d6334d5a3..85148cd43 100644 --- a/util/ncgg/coerc.c +++ b/util/ncgg/coerc.c @@ -6,7 +6,7 @@ static char rcsid[]= "$Id$"; #endif -#include "assert.h" +#include #include "param.h" #include "set.h" #include "property.h" diff --git a/util/ncgg/error.c b/util/ncgg/error.c index 5d083d577..6eaf59784 100644 --- a/util/ncgg/error.c +++ b/util/ncgg/error.c @@ -60,15 +60,6 @@ void error(const char* s, ...) va_end(ap); } -#ifndef NDEBUG -badassertion(string,file,line) char *string,*file; { - - fprintf(stderr,"\"%s\", line %d: Assertion failed \"%s\"\n", - file,line,string); - goodbye(); -} -#endif - tabovf(string) char *string; { fatal("%s overflow",string); diff --git a/util/ncgg/expr.c b/util/ncgg/expr.c index 788f0fd5d..d1a345961 100644 --- a/util/ncgg/expr.c +++ b/util/ncgg/expr.c @@ -6,9 +6,10 @@ static char rcsid[]= "$Id$"; #endif +#include #include #include -#include "assert.h" +#include #include "param.h" #include "set.h" #include "reg.h" diff --git a/util/ncgg/hall.c b/util/ncgg/hall.c index f8a5364c7..f670b24b8 100644 --- a/util/ncgg/hall.c +++ b/util/ncgg/hall.c @@ -6,7 +6,7 @@ static char rcsid[]= "$Id$"; #endif -#include "assert.h" +#include #include "param.h" #include "set.h" #include "extern.h" diff --git a/util/ncgg/instruct.c b/util/ncgg/instruct.c index b33f95ad2..a0af649cc 100644 --- a/util/ncgg/instruct.c +++ b/util/ncgg/instruct.c @@ -6,6 +6,7 @@ static char rcsid[]= "$Id$"; #endif +#include #include "param.h" #include "instruct.h" #include "pseudo.h" diff --git a/util/ncgg/iocc.c b/util/ncgg/iocc.c index a6f4506b1..9519b1cd6 100644 --- a/util/ncgg/iocc.c +++ b/util/ncgg/iocc.c @@ -6,9 +6,10 @@ static char rcsid[]= "$Id$"; #endif +#include #include #include -#include "assert.h" +#include #include "param.h" #include "set.h" #include "expr.h" diff --git a/util/ncgg/lookup.c b/util/ncgg/lookup.c index ab31baebc..7c162f926 100644 --- a/util/ncgg/lookup.c +++ b/util/ncgg/lookup.c @@ -6,7 +6,8 @@ static char rcsid[]= "$Id$"; #endif -#include "assert.h" +#include +#include #include "param.h" #include "lookup.h" #include "extern.h" diff --git a/util/ncgg/output.c b/util/ncgg/output.c index 9d2f2b8d4..02e3162f7 100644 --- a/util/ncgg/output.c +++ b/util/ncgg/output.c @@ -20,9 +20,9 @@ char *cd_file= "code"; static char rcsid[]= "$Id$"; #endif +#include #include #include -#include "assert.h" #include "varinfo.h" #include "param.h" #include "reg.h" diff --git a/util/ncgg/strlookup.c b/util/ncgg/strlookup.c index d473341aa..708dd9b41 100644 --- a/util/ncgg/strlookup.c +++ b/util/ncgg/strlookup.c @@ -6,6 +6,7 @@ static char rcsid[]= "$Id$"; #endif +#include #include "param.h" #include "extern.h" diff --git a/util/opt/alloc.c b/util/opt/alloc.c index af154f21e..cc6dc6607 100644 --- a/util/opt/alloc.c +++ b/util/opt/alloc.c @@ -2,12 +2,12 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include #include "param.h" #include "types.h" #include "tes.h" -#include "assert.h" #include "alloc.h" #include "line.h" #include "lookup.h" diff --git a/util/opt/assert.h b/util/opt/assert.h deleted file mode 100644 index 366ef7b2e..000000000 --- a/util/opt/assert.h +++ /dev/null @@ -1,11 +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$ */ - -#ifndef NDEBUG -#define assert(x) if(!(x)) badassertion(__FILE__,__LINE__) -#else -#define assert(x) /* nothing */ -#endif diff --git a/util/opt/backward.c b/util/opt/backward.c index c7b1e4f29..83304ce55 100644 --- a/util/opt/backward.c +++ b/util/opt/backward.c @@ -2,10 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include #include "param.h" #include "types.h" #include "tes.h" -#include "assert.h" #include "line.h" #include "lookup.h" #include "alloc.h" diff --git a/util/opt/build.lua b/util/opt/build.lua index 2a7edf09e..cb86b3fff 100644 --- a/util/opt/build.lua +++ b/util/opt/build.lua @@ -10,18 +10,24 @@ flex { srcs = { "./scan.l" } } +local headers = { + "./alloc.h", "./ext.h", "./line.h", "./lookup.h", "./optim.h", + "./param.h", "./pattern.h", "./pop_push.h", "./proinf.h", + "./tes.h", "./types.h", +} + cprogram { name = "mktab", srcs = { matching(filenamesof("+yacc"), "%.c$"), matching(filenamesof("+flex"), "%.c$"), }, - deps = { - "./*.h", + deps = concat( + headers, "+flex", "+yacc", - "modules/src/em_data+lib", - } + "modules/src/em_data+lib" + ) } normalrule { @@ -57,15 +63,15 @@ local function variant(name, cflags) "+pop_push_c", "./*.c", }, - deps = { - "./*.h", + deps = concat( + headers, "h+emheaders", "modules/src/alloc+lib", "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", - "modules/src/em_data+lib", - }, + "modules/src/em_data+lib" + ), vars = { ["+cflags"] = cflags } diff --git a/util/opt/cleanup.c b/util/opt/cleanup.c index f09feeb7b..95564da0c 100644 --- a/util/opt/cleanup.c +++ b/util/opt/cleanup.c @@ -2,10 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include #include #include "param.h" #include "types.h" -#include "assert.h" #include #include #include diff --git a/util/opt/peephole.c b/util/opt/peephole.c index ccce6a9c0..9ad466ad2 100644 --- a/util/opt/peephole.c +++ b/util/opt/peephole.c @@ -2,10 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include #include "param.h" #include "types.h" #include "tes.h" -#include "assert.h" #include "line.h" #include "lookup.h" #include "proinf.h" diff --git a/util/opt/process.c b/util/opt/process.c index bd1227038..c1ab7d238 100644 --- a/util/opt/process.c +++ b/util/opt/process.c @@ -2,10 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include #include "param.h" #include "types.h" #include "tes.h" -#include "assert.h" #include #include #include "alloc.h" diff --git a/util/opt/putline.c b/util/opt/putline.c index 4bceef01f..50a8a6697 100644 --- a/util/opt/putline.c +++ b/util/opt/putline.c @@ -2,10 +2,10 @@ static char rcsid[] = "$Id$"; #endif +#include #include "param.h" #include "types.h" #include "tes.h" -#include "assert.h" #include #include #include diff --git a/util/opt/reg.c b/util/opt/reg.c index 6066c9f19..c00dcd11e 100644 --- a/util/opt/reg.c +++ b/util/opt/reg.c @@ -2,7 +2,7 @@ static char rcsid[] = "$Id$"; #endif -#include "assert.h" +#include #include "param.h" #include "types.h" #include "line.h" diff --git a/util/opt/tes.c b/util/opt/tes.c index b3d4efda1..028bf845f 100644 --- a/util/opt/tes.c +++ b/util/opt/tes.c @@ -7,12 +7,12 @@ static char rcsid[] = "$Id$"; * Author: Hans van Eck. */ +#include #include #include #include #include #include "param.h" -#include "assert.h" #include "types.h" #include "tes.h" #include "alloc.h" diff --git a/util/opt/util.c b/util/opt/util.c index 9cc650c07..b38796507 100644 --- a/util/opt/util.c +++ b/util/opt/util.c @@ -7,7 +7,6 @@ static char rcsid[] = "$Id$"; #include "param.h" #include "types.h" #include "tes.h" -#include "assert.h" #include "lookup.h" #include "proinf.h" #include "optim.h" @@ -36,14 +35,6 @@ error(s,a) char *s,*a; { exit(-1); } -#ifndef NDEBUG -badassertion(file,line) char *file; unsigned line; { - - fprintf(stderr,"assertion failed file %s, line %u\n",file,line); - error("assertion"); -} -#endif - #ifdef DIAGOPT optim(n) { diff --git a/util/topgen/hash.c b/util/topgen/hash.c index 7661dd375..03b214ecc 100644 --- a/util/topgen/hash.c +++ b/util/topgen/hash.c @@ -11,6 +11,7 @@ #include #include +#include #include "misc.h" struct hlist { /* linear list of pattern numbers */ diff --git a/util/topgen/pattern.c b/util/topgen/pattern.c index bc5b7a64f..db6ad6268 100644 --- a/util/topgen/pattern.c +++ b/util/topgen/pattern.c @@ -12,6 +12,7 @@ #include #include +#include #include #include "misc.h" #include "symtab.h"