Merge from default.

This commit is contained in:
David Given 2016-11-11 20:17:54 +01:00
commit 84ee75ec07
169 changed files with 638 additions and 300 deletions

View file

@ -107,7 +107,7 @@ void phaser_control(void);
void photon_torpedoes(void);
void torpedo_hit(void);
void damage_control(void);
void sheild_control(void);
void shield_control(void);
void library_computer(void);
void galactic_record(void);
void status_report(void);
@ -137,7 +137,7 @@ void sub2(void);
void showfile(char *filename);
int openfile(char * sFilename, char * sMode);
void closefile(void);
int getline(char *s);
int get_line(char *s);
void randomize(void);
int get_rand(int iSpread);
double rnd(void);
@ -203,7 +203,7 @@ void
reads(char* buffer)
{
fflush(stdout);
gets(buffer);
fgets(buffer, sizeof(string), stdin);
}
/* Main Program */
@ -292,7 +292,7 @@ new_game(void)
else if (! strncmp(sTemp, "tor", 3))
photon_torpedoes();
else if (! strncmp(sTemp, "she", 3))
sheild_control();
shield_control();
else if (! strncmp(sTemp, "dam", 3))
damage_control();
else if (! strncmp(sTemp, "com", 3))
@ -307,7 +307,7 @@ new_game(void)
printf(" lrs - Long Range Sensors\n");
printf(" pha - Phasers\n");
printf(" tor - Photon Torpedoes\n");
printf(" she - Sheild Control\n");
printf(" she - Shield Control\n");
printf(" dam - Damage Control\n");
printf(" com - Library Computer\n");
printf(" xxx - Resign Command\n");
@ -1206,14 +1206,14 @@ damage_control(void)
}
void
sheild_control(void)
shield_control(void)
{
int i;
string sTemp;
if (d[7] < 0.0)
{
printf("Sheild Control inoperable\n");
printf("Shield Control inoperable\n");
return;
}
@ -1229,15 +1229,15 @@ sheild_control(void)
if (i < 0 || s == i)
{
printf("<Sheilds Unchanged>\n\n");
printf("<Shields Unchanged>\n\n");
return;
}
if (i >= e + s)
{
printf("Sheild Control Reports:\n");
printf("Shield Control Reports:\n");
printf(" 'This is not the Federation Treasury.'\n");
printf("<Sheilds Unchanged>\n\n");
printf("<Shields Unchanged>\n\n");
return;
}
@ -1776,7 +1776,7 @@ get_device_name(void)
{
static char * device_name[] = {
"", "Warp Engines","Short Range Sensors","Long Range Sensors",
"Phaser Control","Photon Tubes","Damage Control","Sheild Control",
"Phaser Control","Photon Tubes","Damage Control","Shield Control",
"Library-Computer"};
if (r1 < 0 || r1 > 8)
@ -1888,7 +1888,7 @@ showfile(char *filename)
if (openfile(filename, "r") != 0)
return;
while (getline(lBuffer) != 0)
while (get_line(lBuffer) != 0)
{
printf(lBuffer);
@ -1926,7 +1926,7 @@ closefile(void)
}
int
getline(char *s)
get_line(char *s)
{
fflush(stdout);
if (fgets(s, MAXCOL, stream) == NULL)

View file

@ -702,6 +702,7 @@ static int Pgetpid(lua_State *L) /** getpid([options]) */
}
#if 0
static int Phostid(lua_State *L) /** hostid() */
{
char b[32];
@ -709,6 +710,7 @@ static int Phostid(lua_State *L) /** hostid() */
lua_pushstring(L, b);
return 1;
}
#endif
static int Pttyname(lua_State *L) /** ttyname([fd]) */
@ -1060,7 +1062,7 @@ static const luaL_reg R[] =
{"getpasswd", Pgetpasswd},
{"getpid", Pgetpid},
{"glob", Pglob},
{"hostid", Phostid},
//{"hostid", Phostid},
{"kill", Pkill},
{"link", Plink},
{"mkdir", Pmkdir},

View file

@ -31,6 +31,7 @@ int ltype,rtype;
void
conversion(oldtype,newtype)
int oldtype,newtype;
{
@ -71,6 +72,7 @@ int oldtype,newtype;
void
extraconvert(oldtype,newtype,topstack)
int oldtype,newtype,topstack;
{
@ -509,6 +511,7 @@ endarrayload()
void
loadarray(type)
int type;
{

View file

@ -68,6 +68,7 @@ char *str;
void
dcltype(s)
Symbol *s;
{

View file

@ -16,6 +16,7 @@ int errorcnt;
void
warning(str)
char *str;
{

View file

@ -52,6 +52,8 @@ extern int lint_skip_comment;
static struct token LexStack[MAX_LL_DEPTH];
static LexSP = 0;
void skipcomment();
/* In PushLex() the actions are taken in order to initialise or
re-initialise the lexical scanner.
E.g. at the invocation of a sub-parser that uses LLlex(), the
@ -442,6 +444,7 @@ garbage:
}
#ifndef NOPP
void
skipcomment()
{
/* The last character read has been the '*' of '/_*'. The

View file

@ -30,6 +30,7 @@ extern char options[];
extern arith flt_flt2arith();
extern label code_string();
void
arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
register struct expr **e1p, **e2p;
int oper;
@ -523,6 +524,7 @@ opnd2logical(expp, oper)
}
}
void
opnd2test(expp, oper)
register struct expr **expp;
{
@ -548,6 +550,7 @@ opnd2test(expp, oper)
ch3bin(expp, NOTEQUAL, intexpr((arith)0, INT));
}
void
any2opnd(expp, oper)
register struct expr **expp;
{

View file

@ -23,11 +23,14 @@ extern char options[];
extern char *symbol2str();
extern struct type *qualifier_type();
void ch3cast();
/* Most expression-handling routines have a pointer to a
(struct type *) as first parameter. The object under the pointer
gets updated in the process.
*/
void
ch3sel(expp, oper, idf)
struct expr **expp;
struct idf *idf;
@ -169,6 +172,7 @@ ch3incr(expp, oper)
ch3asgn(expp, oper, intexpr((arith)1, INT));
}
void
ch3cast(expp, oper, tp)
register struct expr **expp;
register struct type *tp;

View file

@ -19,6 +19,8 @@
extern char options[];
extern char *symbol2str();
void pntminuspnt();
/* This chapter asks for the repeated application of code to handle
an operation that may be executed at compile time or at run time,
depending on the constancy of the operands.
@ -32,6 +34,7 @@ extern char *symbol2str();
#define commutative_binop(expp, oper, expr) mk_binop(expp, oper, expr, 1)
#define non_commutative_relop(expp, oper, expr) mk_binop(expp, oper, expr, 1)
void
ch3bin(expp, oper, expr)
register struct expr **expp;
struct expr *expr;
@ -292,6 +295,7 @@ ch3bin(expp, oper, expr)
}
}
void
pntminuspnt(expp, oper, expr)
register struct expr **expp, *expr;
{

View file

@ -64,6 +64,8 @@ extern char options[];
extern char *symbol2str();
extern char *source;
void loc_init();
#ifndef LINT
init_code(dst_file)
char *dst_file;
@ -415,6 +417,7 @@ do_return_expr(expr)
return_expr_occurred = 1;
}
void
code_declaration(idf, expr, lvl, sc)
register struct idf *idf; /* idf to be declared */
struct expr *expr; /* initialisation; NULL if absent */
@ -527,6 +530,7 @@ code_declaration(idf, expr, lvl, sc)
}
}
void
loc_init(expr, id)
struct expr *expr;
struct idf *id;
@ -721,6 +725,7 @@ code_break()
it generates a branch instruction to the continue label of the
innermost statement in which continue has a meaning.
*/
void
code_continue()
{
register struct stmt_block *stmt_block = stmt_stack;

View file

@ -34,6 +34,9 @@ char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */
int nestlevel = -1;
void macro_def();
void do_define();
struct idf *
GetIdentifier(skiponerr)
int skiponerr; /* skip the rest of the line on error */
@ -145,6 +148,7 @@ domacro()
int lint_skip_comment;
#endif
void
skip_block(to_endif)
int to_endif;
{
@ -347,6 +351,7 @@ do_include()
}
}
void
do_define()
{
/* do_define() interprets a #define control line.
@ -574,6 +579,7 @@ getparams(buf, parbuf)
/*NOTREACHED*/
}
void
macro_def(id, text, nformals, length, flags)
register struct idf *id;
char *text;

View file

@ -57,7 +57,7 @@ extern char loptions[];
expression, whereas other errors use the information in the token.
*/
static _error();
static void _error();
#if __STDC__
/*VARARGS*/
@ -521,7 +521,7 @@ fatal(va_alist) /* fmt, args */
}
#endif
static
static void
_error(class, fn, ln, fmt, ap)
int class;
char *fn;

View file

@ -37,6 +37,9 @@ arith NewLocal(); /* util.c */
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
extern int err_occurred; /* error.c */
void store_val();
void load_val();
/* EVAL() is the main expression-tree evaluator, which turns
any legal expression tree into EM code. parameters.h:
@ -63,6 +66,7 @@ extern int err_occurred; /* error.c */
labels, in case they are specified (i.e. are non-zero)
*/
void
EVAL(expr, val, code, true_label, false_label)
register struct expr *expr;
int val, code;
@ -836,6 +840,7 @@ ptr_add(size)
- into a local static variable
- absolute addressing
*/
void
store_val(vl, tp)
register struct value *vl;
register struct type *tp;
@ -907,6 +912,7 @@ store_val(vl, tp)
- static variable
- local variable
*/
void
load_val(expr, rlval)
register struct expr *expr; /* expression containing the value */
int rlval; /* generate either LVAL or RVAL */

View file

@ -369,6 +369,7 @@ new_oper(tp, e1, oper, e2)
return expr;
}
void
chk_cst_expr(expp)
struct expr **expp;
{

View file

@ -37,6 +37,8 @@ extern char *symbol2str();
#include <idf_pkg.body>
void global_redecl();
struct idf *
gen_idf()
{
@ -248,6 +250,7 @@ declare_idf(ds, dc, lvl)
}
}
int
actual_declaration(sc, tp)
int sc;
struct type *tp;
@ -269,6 +272,7 @@ actual_declaration(sc, tp)
return 1;
}
void
global_redecl(idf, new_sc, tp)
register struct idf *idf;
struct type *tp;
@ -393,6 +397,7 @@ declare_params(dc)
}
}
void
idf_initialized(idf)
register struct idf *idf;
{
@ -429,6 +434,7 @@ declare_enum(tp, idf, l)
idf->id_def->df_address = l;
}
void
check_formals(idf, dc)
struct idf *idf;
struct declarator *dc;

View file

@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "parameters.h"
#ifndef NOPP
@ -44,7 +45,7 @@ init_pp()
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
long clock, sys_time();
time_t clock;
static char dbuf[30];
static char tbuf[30];
struct tm *tp;
@ -70,7 +71,7 @@ init_pp()
/* Initialize __LINE__, __FILE__, __DATE__, __TIME__,
and __STDC__ macro definitions.
*/
clock = sys_time();
clock = time(NULL);
tp = localtime(&clock);
/* __DATE__ */

View file

@ -46,6 +46,11 @@ static int pack_level;
struct type **gen_tphead(), **gen_tpmiddle();
struct sdef *gen_align_to_next();
struct e_stack *p_stack;
void pad();
void gen_simple_exp();
void gen_tpcheck();
}
/* initial_value recursively guides the initialisation expression.
@ -122,6 +127,7 @@ initial_value_list(register struct type **tpp; struct expr **expp;)
;
{
void
gen_tpcheck(tpp)
struct type **tpp;
{
@ -147,6 +153,7 @@ gen_tpcheck(tpp)
}
}
void
gen_simple_exp(tpp, expp)
struct type **tpp;
struct expr **expp;
@ -465,6 +472,7 @@ check_and_pad(expp, tpp)
/* pad() fills an element of type tp with zeroes.
If the element is an aggregate, pad() is called recursively.
*/
void
pad(tpx)
struct type *tpx;
{

View file

@ -46,6 +46,8 @@ struct sp_id special_ids[] = {
{0, 0}
};
void dependency();
#ifndef NOCROSS
arith
short_size = SZ_SHORT,
@ -181,6 +183,7 @@ char *s;
}
}
void
dependency(s, source)
char *s, *source;
{

View file

@ -26,6 +26,7 @@
extern char options[];
void
check_for_void(pl)
register struct proto *pl;
{
@ -261,6 +262,7 @@ declare_protos(dc)
}
void
update_proto(tp, otp)
register struct type *tp, *otp;
{
@ -312,6 +314,7 @@ update_proto(tp, otp)
/* struct/union and enum tags can be declared inside prototypes
* remove them from the symbol-table
*/
void
remove_proto_tag(tp)
struct type *tp;
{
@ -380,6 +383,7 @@ remove_proto_idfs(pl)
}
}
void
call_proto(expp)
register struct expr **expp;
{

View file

@ -26,6 +26,10 @@ extern int InputLevel;
struct repl *ReplaceList; /* list of currently active macros */
extern char *strcat(), *strcpy();
void macro2buffer();
void getactuals();
void expand_defined();
int
replace(idf)
register struct idf *idf;
@ -172,6 +176,7 @@ expand_macro(repl, idf)
return 1;
}
void
expand_defined(repl)
register struct repl *repl;
{
@ -211,6 +216,7 @@ newarg(args)
args->a_rawptr = args->a_rawbuf = Malloc(args->a_rawsize = ARGBUF);
}
void
getactuals(repl, idf)
struct repl *repl;
register struct idf *idf;
@ -529,6 +535,7 @@ macro_func(idef)
}
}
void
macro2buffer(repl, idf, args)
register struct repl *repl;
register struct idf *idf;

View file

@ -72,7 +72,7 @@ adds_db_str(s)
while (*s) addc_db_str(*s++);
}
static
static void
stb_type(tp)
register struct type *tp;
{

View file

@ -57,6 +57,7 @@ stack_level() {
#endif /* LINT */
}
void
stack_idf(idf, stl)
struct idf *idf;
register struct stack_level *stl;

View file

@ -159,6 +159,7 @@ code_endswitch()
unstack_stmt();
}
void
code_case(expr)
struct expr *expr;
{
@ -227,6 +228,7 @@ code_case(expr)
}
}
void
code_default()
{
register struct switch_hdr *sh = switch_stack;

View file

@ -163,6 +163,7 @@ LocalFinish()
#endif
}
void
RegisterAccount(offset, size, regtype, sc)
arith offset, size;
{

View file

@ -35,6 +35,8 @@ extern arith char_constant();
#define FLG_ESEEN 0x01 /* possibly a floating point number */
#define FLG_DOTSEEN 0x02 /* certainly a floating point number */
void skipcomment();
int
LLlex()
{
@ -325,6 +327,7 @@ garbage:
/*NOTREACHED*/
}
void
skipcomment()
{
/* The last character read has been the '*' of '/_*'. The

View file

@ -32,6 +32,9 @@ int svnestlevel[30] = {-1};
int nestcount;
extern int do_preprocess;
void macro_def();
void do_define();
char *
GetIdentifier(skiponerr)
int skiponerr; /* skip the rest of the line on error */
@ -148,6 +151,7 @@ domacro()
}
}
void
skip_block(to_endif)
int to_endif;
{
@ -327,6 +331,7 @@ do_include()
}
}
void
do_define()
{
/* do_define() interprets a #define control line.
@ -566,6 +571,7 @@ getparams(buf, parbuf)
/*NOTREACHED*/
}
void
macro_def(id, text, nformals, length, flags)
register struct idf *id;
char *text;

View file

@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "system.h"
#include "alloc.h"
#include "time.h"
@ -42,7 +43,7 @@ init_pp()
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
long clock, sys_time();
time_t clock;
static char dbuf[30];
static char tbuf[30];
struct tm *tp;
@ -68,7 +69,7 @@ init_pp()
/* Initialize __LINE__, __FILE__, __DATE__, __TIME__,
and __STDC__ macro definitions.
*/
clock = sys_time();
clock = time(NULL);
tp = localtime(&clock);
/* __DATE__ */

View file

@ -32,6 +32,8 @@ char *prog_name;
extern char **inctable;
extern int inc_max, inc_total;
void dependency();
main(argc, argv)
char *argv[];
{
@ -140,6 +142,7 @@ add_dependency(s)
}
}
void
dependency(s, source)
char *s, *source;
{

View file

@ -102,6 +102,7 @@ do_pragma()
char Xbuf[256];
void
preprocess(fn)
char *fn;
{

View file

@ -26,6 +26,10 @@ extern char *strcat();
extern int InputLevel;
struct repl *ReplaceList; /* list of currently active macros */
void expand_defined();
void getactuals();
void macro2buffer();
int
replace(idf)
register struct idf *idf;
@ -165,6 +169,7 @@ expand_macro(repl, idf)
return 1;
}
void
expand_defined(repl)
register struct repl *repl;
{
@ -208,6 +213,7 @@ newarg(args)
args->a_rawptr = args->a_rawbuf = Malloc((unsigned)(args->a_rawsize = ARGBUF));
}
void
getactuals(repl, idf)
struct repl *repl;
register struct idf *idf;
@ -522,6 +528,7 @@ macro_func(idef)
}
}
void
macro2buffer(repl, idf, args)
register struct repl *repl;
register struct idf *idf;

View file

@ -28,9 +28,9 @@ normalrule {
}
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = {
acklibrary {
name = "lib_"..plat,
srcs = {
"+ctype_files",
"+ctype_tab",
"./ctype/*.c",
@ -43,20 +43,24 @@ for _, plat in ipairs(vars.plats) do
"./setjmp/*.c",
"./setjmp/*.e",
"./signal/*.c",
"./assert/*.c",
"./assert/*.c",
"./stdio/*.c",
"./stdlib/*.c",
"./string/*.c",
"./time/*.c",
},
},
hdrs = {}, -- must be empty
deps = {
"lang/cem/libcc.ansi/headers+headers",
"plat/"..plat.."/include+headers",
"./malloc/malloc.h",
"./math/localmath.h",
"./stdio/loc_incl.h",
"./stdlib/ext_fmt.h",
"./time/loc_time.h",
},
vars = { plat = plat }
}
vars = { plat = plat }
}
ackfile {
name = "crt_"..plat,

View file

@ -1,43 +1,79 @@
/*
<float.h> -- simple version used by "gimplify"
* float.h - implementation limits
*/
/* $Id$ */
last edit: 2007-02-12 D A Gwyn
*/
#if !defined(_FLOAT_H)
#define _FLOAT_H
/* Does not exactly fit any model, and is minimal for "universality". */
#if defined(__vax) || defined(__pdp)
#define FLT_DIG 6
#define FLT_EPSILON 5.96046448e-08F
#define FLT_MANT_DIG 8
#define FLT_MAX 1.70141173e+38F
#define FLT_MAX_10_EXP 38
#define FLT_MAX_EXP 127
#define FLT_MIN 2.93873588e-39F
#define FLT_MIN_10_EXP (-38)
#define FLT_MIN_EXP (-127)
#define FLT_ROUNDS (-1)
#define FLT_EVAL_METHOD (-1)
#define FLT_RADIX 2
#define DECIMAL_DIG 10
#define DBL_DIG 16
#define DBL_EPSILON 1.38777878078144568e-17
#define DBL_MANT_DIG 8
#define DBL_MAX 1.70141183460469229e+38
#define DBL_MAX_10_EXP 38
#define DBL_MAX_EXP 127
#define DBL_MIN 2.93873587705571877e-39
#define DBL_MIN_10_EXP (-38)
#define DBL_MIN_EXP (-127)
/* assumes that "gimplify" specifies "-Dfloat=double" */
#define FLT_MANT_DIG 10
#define FLT_EPSILON (1E-9F)
#define FLT_DIG 10
#define FLT_MIN_EXP (-31)
#define FLT_MIN (1E-37F)
#define FLT_MIN_10_EXP (-37)
#define FLT_MAX_EXP 37
#define FLT_MAX (1E+37F)
#define FLT_MAX_10_EXP 37
#define LDBL_DIG 16
#define LDBL_EPSILON 1.38777878078144568e-17L
#define LDBL_MANT_DIG 8
#define LDBL_MAX 1.70141183460469229e+38L
#define LDBL_MAX_10_EXP 38
#define LDBL_MAX_EXP 127
#define LDBL_MIN 2.93873587705571877e-39L
#define LDBL_MIN_10_EXP (-38)
#define LDBL_MIN_EXP (-127)
#define DBL_MANT_DIG 10
#define DBL_EPSILON (1E-9)
#define DBL_DIG 10
#define DBL_MIN_EXP (-31)
#define DBL_MIN (1E-37)
#define DBL_MIN_10_EXP (-37)
#define DBL_MAX_EXP 37
#define DBL_MAX (1E+37)
#define DBL_MAX_10_EXP 37
#define FLT_ROUNDS 1
#define FLT_RADIX 2
#define LDBL_MANT_DIG 10
#define LDBL_EPSILON (1E-9L)
#define LDBL_DIG 10
#define LDBL_MIN_EXP (-31)
#define LDBL_MIN (1E-37L)
#define LDBL_MIN_10_EXP (-37)
#define LDBL_MAX_EXP 37
#define LDBL_MAX (1E+37L)
#define LDBL_MAX_10_EXP 37
#else /* IEEE format */
#define FLT_DIG 6
#define FLT_EPSILON 1.19209290e-07F
#define FLT_MANT_DIG 24
#define FLT_MAX 3.40282347e+38F
#define FLT_MAX_10_EXP 38
#define FLT_MAX_EXP 128
#define FLT_MIN 1.17549435e-38F
#define FLT_MIN_10_EXP (-37)
#define FLT_MIN_EXP (-125)
#define DBL_DIG 15
#define DBL_EPSILON 2.2204460492503131e-16
#define DBL_MANT_DIG 53
#define DBL_MAX 1.7976931348623157e+308
#define DBL_MAX_10_EXP 308
#define DBL_MAX_EXP 1024
#define DBL_MIN 2.2250738585072014e-308
#define DBL_MIN_10_EXP (-307)
#define DBL_MIN_EXP (-1021)
#define LDBL_DIG 15
#define LDBL_EPSILON 2.2204460492503131e-16L
#define LDBL_MANT_DIG 53
#define LDBL_MAX 1.7976931348623157e+308L
#define LDBL_MAX_10_EXP 308
#define LDBL_MAX_EXP 1024
#define LDBL_MIN 2.2250738585072014e-308L
#define LDBL_MIN_10_EXP (-307)
#define LDBL_MIN_EXP (-1021)
#define FLT_ROUNDS 1
#define FLT_RADIX 2
#endif /* vax, pdp or ieee */
#endif /* _FLOAT_H */

View file

@ -18,18 +18,5 @@
#define POLYNOM12(x, a) (POLYNOM11((x),(a)+1)*(x)+(a)[0])
#define POLYNOM13(x, a) (POLYNOM12((x),(a)+1)*(x)+(a)[0])
/* These are set up for 64-bit doubles. */
#ifndef M_MAX_D
#define M_MAX_D 1.7976931348623157e+308
#define M_MIN_D 2.2250738585072014e-308
#define M_DEXPLEN 11
#endif
#define M_DMAXEXP ((1 << (M_DEXPLEN - 1)) - 1)
#define M_DMINEXP (-M_DMAXEXP)
#define M_LN_MAX_D (M_LN2 * M_DMAXEXP)
#define M_LN_MIN_D (M_LN2 * (M_DMINEXP - 1))
#define HUGE M_MAX_D
#define MAXDOUBLE M_MAX_D
#define M_LN_MAX_D (M_LN2 * DBL_MAX_EXP)
#define M_LN_MIN_D (M_LN2 * (DBL_MIN_EXP - 1))

View file

@ -180,6 +180,7 @@ getch()
return ch;
}
void
CheckForLineDirective()
{
register int ch = getch();

View file

@ -54,6 +54,9 @@ struct case_entry {
arith ce_low, ce_up; /* lower and upper bound of range */
};
void AddCases();
void AddOneCase();
/* STATICALLOCDEF "case_entry" 20 */
/* The constant DENSITY determines when CSA and when CSB instructions
@ -237,6 +240,7 @@ FreeSh(sh)
free_switch_hdr(sh);
}
void
AddCases(sh, node, lbl)
struct switch_hdr *sh;
register t_node *node;
@ -264,6 +268,7 @@ AddCases(sh, node, lbl)
AddOneCase(sh, node, node, lbl);
}
void
AddOneCase(sh, lnode, rnode, lbl)
register struct switch_hdr *sh;
t_node *lnode, *rnode;

View file

@ -53,6 +53,7 @@ df_error(nd, mess, edf)
else node_error(nd, mess);
}
void
MkCoercion(pnd, tp)
t_node **pnd;
register t_type *tp;

View file

@ -37,6 +37,10 @@ extern char options[];
extern t_desig null_desig;
int fp_used;
void RangeCheck();
void CodeParameters();
void CodeCall();
CodeConst(cst, size)
arith cst;
int size;
@ -55,6 +59,7 @@ CodeConst(cst, size)
}
}
void
CodeString(nd)
register t_node *nd;
{
@ -288,6 +293,7 @@ CodeCoercion(t1, t2)
}
}
void
CodeCall(nd)
register t_node *nd;
{
@ -355,6 +361,7 @@ CodeCall(nd)
DoLineno(nd);
}
void
CodeParameters(param, arg)
t_param *param;
register t_node *arg;
@ -672,6 +679,7 @@ needs_rangecheck(tpl, tpr)
return 0;
}
void
RangeCheck(tpl, tpr)
register t_type *tpl, *tpr;
{

View file

@ -45,6 +45,8 @@ arith min_int[] = { 0L, -128L, -32768L, 0L, -2147483647L-1 };
extern char options[];
void CutSize();
overflow(expp)
t_node *expp;
{
@ -160,6 +162,7 @@ divide(pdiv, prem)
#endif
}
void
cstibin(expp)
t_node **expp;
{
@ -351,6 +354,7 @@ cstfbin(expp)
CutSize(exp);
}
void
cstubin(expp)
t_node **expp;
{
@ -457,6 +461,7 @@ cstubin(expp)
CutSize(exp);
}
void
cstset(expp)
t_node **expp;
{
@ -648,6 +653,7 @@ cstcall(expp, call)
}
}
void
CutSize(expr)
register t_node *expr;
{

View file

@ -533,6 +533,7 @@ CodeFieldDesig(df, ds)
}
}
void
CodeVarDesig(df, ds)
register t_def *df;
register t_desig *ds;

View file

@ -247,6 +247,7 @@ EnterParamList(ppr, Idlist, type, VARp, off)
STATIC t_def *DoImport();
void
ImportEffects(idef, scope, flag)
register t_def *idef;
t_scope *scope;
@ -481,6 +482,7 @@ CheckForImports(df)
}
}
void
EnterFromImportList(idlist, FromDef, FromId)
register t_node *idlist;
register t_def *FromDef;

View file

@ -61,6 +61,8 @@ extern char *symbol2str();
node, whereas other errors use the information in the token.
*/
void _error();
#if __STDC__
#ifdef DEBUG
/*VARARGS*/
@ -318,6 +320,7 @@ crash(va_alist)
}
#endif
void
_error(class, node, fmt, ap, warn_class)
int class;
t_node *node;

View file

@ -81,6 +81,7 @@ dot2leaf(class)
return nd;
}
void
FreeNode(nd)
register t_node *nd;
{

View file

@ -71,7 +71,7 @@ adds_db_str(s)
while (*s) addc_db_str(*s++);
}
static
static void
stb_type(tp, assign_num)
register t_type *tp;
{

View file

@ -74,6 +74,8 @@ t_type
*std_type,
*error_type;
void ArraySizes();
t_type *
construct_type(fund, tp)
int fund;
@ -576,6 +578,7 @@ ArrayElSize(tp)
}
}
void
ArraySizes(tp)
register t_type *tp;
{

View file

@ -64,7 +64,7 @@ static int WalkDef();
static int stabdef();
#endif
static int MkCalls();
static int UseWarnings();
static void UseWarnings();
#define NO_EXIT_LABEL ((label) 0)
#define RETURN_LABEL ((label) 1)
@ -72,6 +72,8 @@ static int UseWarnings();
#define REACH_FLAG 1
#define EXIT_FLAG 2
void DoAssign();
int
LblWalkNode(lbl, nd, exit, reach)
label lbl, exit;
@ -995,6 +997,7 @@ node_warning(nd, W_OLDFASHIONED, "compatibility required in FOR statement");
return 1;
}
void
DoAssign(nd)
register t_node *nd;
{
@ -1057,7 +1060,7 @@ RegisterMessage(df)
}
}
static
static void
df_warning(nd, df, warning)
t_node *nd;
t_def *df;
@ -1080,7 +1083,7 @@ df_warning(nd, df, warning)
}
}
static
static void
UseWarnings(df)
register t_def *df;
{

View file

@ -120,7 +120,7 @@ CommentOptions()
}
STATIC
STATIC void
SkipComment()
{
/* Skip ISO-Pascal comments (* ... *) or { ... }.
@ -216,6 +216,7 @@ register int delim;
static char *s_error = "illegal line directive";
void
CheckForLineDirective()
{
register int ch;

View file

@ -47,6 +47,7 @@ MarkDef(nd, flags, on)
}
}
void
AssertStat(expp, line)
register struct node *expp;
unsigned short line;
@ -69,6 +70,7 @@ AssertStat(expp, line)
}
}
void
AssignStat(left, right)
register struct node *left, *right;
{
@ -131,6 +133,7 @@ AssignStat(left, right)
FreeNode(right);
}
void
ProcStat(nd)
register struct node *nd;
{
@ -142,6 +145,7 @@ ProcStat(nd)
}
}
void
ChkForStat(nd)
register struct node *nd;
{
@ -202,6 +206,7 @@ ChkForStat(nd)
return;
}
void
EndForStat(nd)
register struct node *nd;
{
@ -283,6 +288,7 @@ CodeEndFor(nd, stepsize, l1, l2, tmp2)
C_asp(int_size);
}
void
WithStat(nd)
struct node *nd;
{

View file

@ -40,6 +40,7 @@ struct case_entry {
*/
#define compact(nr, low, up) (nr != 0 && (up - low) / nr <= DENSITY)
void
CaseExpr(nd)
struct node *nd;
{
@ -62,6 +63,7 @@ CaseExpr(nd)
}
}
void
CaseEnd(nd, exit_label)
struct node *nd;
label exit_label;

View file

@ -24,6 +24,11 @@
int fp_used;
void Long2Int();
void Int2Long();
void genrck();
void CodeCall();
CodeFil()
{
if ( !options['L'] )
@ -791,6 +796,7 @@ CodePString(nd, tp)
C_loi(tp->tp_size);
}
void
CodeCall(nd)
register struct node *nd;
{
@ -1095,6 +1101,7 @@ CodeStd(nd)
}
}
void
Long2Int()
{
/* convert a long to integer */
@ -1106,6 +1113,7 @@ Long2Int()
C_cii();
}
void
Int2Long()
{
/* convert integer to long */
@ -1160,6 +1168,7 @@ RangeCheck(tpl, tpr)
}
}
void
genrck(tp)
register struct type *tp;
{

View file

@ -66,6 +66,7 @@ cstunary(expp)
expp->nd_right = NULLNODE;
}
void
cstbin(expp)
register struct node *expp;
{
@ -195,6 +196,7 @@ cstbin(expp)
expp->nd_left = expp->nd_right = NULLNODE;
}
void
cstset(expp)
register struct node *expp;
{

View file

@ -116,6 +116,7 @@ define(id, scope, kind)
return MkDef(id, scope, kind);
}
void
DoDirective(directive, nd, tp, scl, function)
struct idf *directive;
struct node *nd;

View file

@ -26,6 +26,7 @@
struct desig InitDesig = {DSG_INIT, 0, 0, NULLDEF, 0};
struct withdesig *WithDesigs;
void CodeValue();
STATIC int
properly(ds, size, al)
@ -71,6 +72,7 @@ CodeCopy(lhs, rhs, sz, psize)
C_sti(sz);
}
void
CodeMove(rhs, left, rtp)
register struct desig *rhs;
register struct node *left;
@ -150,6 +152,7 @@ CodeMove(rhs, left, rtp)
}
}
void
CodeValue(ds, tp)
register struct desig *ds;
register struct type *tp;
@ -366,6 +369,7 @@ CodeFieldDesig(df, ds)
ds->dsg_packed = df->fld_flags & F_PACKED;
}
void
CodeVarDesig(df, ds)
register struct def *df;
register struct desig *ds;

View file

@ -39,6 +39,8 @@ int err_occurred;
extern char *symbol2str();
void _error();
/* There are three general error-message functions:
lexerror() lexical and pre-processor error messages
error() syntactic and pre-processor messagese
@ -304,6 +306,7 @@ crash(va_alist)
}
#endif
void
_error(class, node, fmt, ap)
int class;
struct node *node;

View file

@ -12,6 +12,8 @@
#include "scope.h"
#include "type.h"
void CodeLabel();
DeclLabel(nd)
struct node *nd;
@ -103,6 +105,7 @@ TstLabel(nd, Slevel)
CodeLabel(df, 1);
}
void
DefLabel(nd, Slevel)
register struct node *nd;
{
@ -139,6 +142,7 @@ DefLabel(nd, Slevel)
}
}
void
CodeLabel(df, local)
register struct def *df;
{

View file

@ -42,6 +42,7 @@ MkLeaf(class, token)
return nd;
}
void
FreeNode(nd)
register struct node *nd;
{

View file

@ -15,6 +15,8 @@ static int inpflag = 0; /* input mentioned in heading ? */
static int outpflag = 0; /* output mentioned in heading ? */
static label extfl_label; /* label of array of file pointers */
void make_extfl_args();
set_inp()
{
inpflag = 1;
@ -25,6 +27,7 @@ set_outp()
outpflag = 1;
}
void
make_extfl()
{
if( err_occurred ) return;
@ -54,6 +57,7 @@ make_extfl()
make_extfl_args( GlobalScope->sc_def );
}
void
make_extfl_args(df)
register struct def *df;
{

View file

@ -19,6 +19,12 @@
extern char *sprint();
void CodeRead();
void CodeReadln();
void CodeWrite();
void CodeWriteln();
void
ChkRead(arg)
register struct node *arg;
{
@ -86,6 +92,7 @@ ChkRead(arg)
}
}
void
ChkReadln(arg)
register struct node *arg;
{
@ -142,6 +149,7 @@ ChkReadln(arg)
CodeReadln(file);
}
void
ChkWrite(arg)
register struct node *arg;
{
@ -183,6 +191,7 @@ ChkWrite(arg)
}
}
void
ChkWriteln(arg)
register struct node *arg;
{
@ -318,6 +327,7 @@ ChkStdInOut(name, st_out)
return nd;
}
void
CodeRead(file, arg)
register struct node *file, *arg;
{
@ -376,6 +386,7 @@ CodeRead(file, arg)
}
}
void
CodeReadln(file)
struct node *file;
{
@ -386,6 +397,7 @@ CodeReadln(file)
C_asp(pointer_size);
}
void
CodeWrite(file, arg)
register struct node *file, *arg;
{
@ -472,6 +484,7 @@ CodeWrite(file, arg)
}
}
void
CodeWriteln(file)
register struct node *file;
{

View file

@ -71,7 +71,7 @@ adds_db_str(s)
while (*s) addc_db_str(*s++);
}
static
static void
stb_type(tp, assign_num)
register struct type *tp;
{
@ -247,6 +247,7 @@ stb_addtp(s, tp)
(arith) 0);
}
void
stb_string(df, kind)
register struct def *df;
long kind;

View file

@ -51,6 +51,8 @@ struct type
*void_type,
*error_type;
void ArraySizes();
CheckTypeSizes()
{
/* first, do some checking
@ -442,6 +444,7 @@ ArrayElSize(tp, packed)
return algn;
}
void
ArraySizes(tp)
register struct type *tp;
{
@ -489,6 +492,7 @@ ArraySizes(tp)
C_rom_cst(tp->arr_elsize);
}
void
FreeForward(for_type)
register struct forwtype *for_type;
{

View file

@ -38,6 +38,7 @@ ea_1_16(param)
}
}
void
ea_1(param) {
if (! address_long) {
ea_1_16(param);
@ -134,6 +135,7 @@ regsize(sz)
}
}
void
indexed() {
if (address_long) {
mod_2 = 0;

View file

@ -61,6 +61,7 @@ string holstr(n) word n; {
full lbytes;
#endif
void
prolog(nlocals) full nlocals; {
fputs("push ebp\nmov ebp,esp\n", codefile);
@ -179,6 +180,7 @@ mach_option(s)
}
#endif /* MACH_OPTIONS */
void
mes(type) word type ; {
int argt, a1, a2 ;

View file

@ -54,6 +54,7 @@ con_float() {
}
void
prolog(nlocals) full nlocals; {
fprintf(codefile,"\tpush\tb\n\tlxi\th,0\n\tdad\tsp\n\tmov\tb,h\n\tmov\tc,l\n");
@ -67,6 +68,7 @@ prolog(nlocals) full nlocals; {
}
}
void
mes(type) word type ; {
int argt ;

View file

@ -61,6 +61,7 @@ string holstr(n) word n; {
full lbytes;
#endif
void
prolog(nlocals) full nlocals; {
fputs("\tpush\tbp\n\tmov\tbp,sp\n", codefile);
@ -157,6 +158,7 @@ regreturn()
}
#endif /* REGVARS */
void
mes(type) word type ; {
int argt ;

View file

@ -21,6 +21,8 @@
* then emitted in one go, by emit_instr().
*/
void move_special();
emit_instr()
{
register instr_t *ip;
@ -70,6 +72,7 @@ long words;
T_EMIT2((short)(words), 0, 0, 0);
}
void
ea_1(sz, bits)
{
/* Because displacements come in three sizes (null displacement,
@ -242,6 +245,7 @@ badoperand()
serror("bad operand(s)");
}
void
shift_op(opc, sz)
{
if (mrg_1 < 010 && mrg_2 < 010) {
@ -263,6 +267,7 @@ shift_op(opc, sz)
ea_2(SIZE_W, MEM|ALT);
}
void
bitop(opc)
{
register bits;
@ -291,6 +296,7 @@ bitfield(opc, extension)
ea_2(SIZE_L, (mrg_2 < 010) ? 0 : (CTR | ALT));
}
void
add(opc, sz)
{
if ((mrg_2 & 070) == 010)
@ -326,6 +332,7 @@ add(opc, sz)
badoperand();
}
void
and(opc, sz)
{
if (mrg_1 == 074 && mrg_2 >= 076) { /* ccr or sr */
@ -370,6 +377,7 @@ from_dreg(opc, sz, bits)
return(1);
}
void
cmp(sz)
{
register opc;
@ -416,6 +424,7 @@ link_instr(sz, areg)
ea_2(sz, 0);
}
void
move(sz)
{
register opc;
@ -448,6 +457,7 @@ move(sz)
ea_2(sz, ALT);
}
void
move_special(sz)
{
if (mrg_2 >= 076) {
@ -514,6 +524,7 @@ reverse(regs, max)
return regs;
}
void
movep(sz)
{
checksize(sz, 2|4);
@ -530,6 +541,7 @@ movep(sz)
badoperand();
}
void
branch(opc, exp)
expr_t exp;
{
@ -566,6 +578,7 @@ expr_t exp;
T_EMIT4(exp.val, exp.typ, RELPC|RELO4, relonami);
}
void
cpbcc(opc, exp)
expr_t exp;
{
@ -593,6 +606,7 @@ expr_t exp;
T_EMIT4(exp.val, exp.typ, RELPC|RELO4, relonami);
}
void
ea7071(sz)
{
mrg_2 = 071;
@ -671,6 +685,7 @@ ea7071(sz)
mrg_2 = 070;
}
void
fbranch(opc, exp)
expr_t exp;
{

View file

@ -187,6 +187,7 @@ regsave(s,off,size)
fprintf(codefile, "!Local %ld into %s\n",off,s);
}
void
prolog(n) full n; {
nlocals = n;
@ -207,6 +208,7 @@ mach_option(s)
}
#endif /* MACH_OPTIONS */
void
mes(type) word type ; {
int argt, a1, a2 ;

View file

@ -56,6 +56,7 @@ con_mult(word sz)
#define FL_MSB_AT_LOW_ADDRESS 1
#include <con_float>
void
prolog(full nlocals)
{
int ss = nlocals + 8;
@ -68,6 +69,7 @@ prolog(full nlocals)
framesize = nlocals;
}
void
mes(word type)
{
int argt ;

View file

@ -18,6 +18,9 @@
extern YYSTYPE yylval;
void setupoutput();
void commfinish();
/* ========== Machine independent C routines ========== */
void stop() {
@ -458,6 +461,7 @@ char *s;
#endif
}
void
setupoutput()
{
register sect_t *sp;
@ -493,6 +497,7 @@ setupoutput()
outhead.oh_nchar = off; /* see newsymb() */
}
void
commfinish()
{
#ifndef ASLD

View file

@ -11,6 +11,8 @@
extern YYSTYPE yylval;
void putval();
yylex()
{
register c;
@ -68,6 +70,7 @@ yylex()
return(c);
}
void
putval(c)
{
register valu_t v;

View file

@ -12,6 +12,10 @@
#include "comm1.h"
#include "y.tab.h"
void switchsect();
void newsymb();
void newident();
newequate(ip, typ)
register item_t *ip;
register int typ;
@ -34,6 +38,7 @@ register int typ;
newident(ip, typ);
}
void
newident(ip, typ)
register item_t *ip;
{
@ -74,6 +79,7 @@ register item_t *ip;
);
}
void
newlabel(ip)
register item_t *ip;
{
@ -183,6 +189,7 @@ valu_t val;
}
}
void
switchsect(newtyp)
int newtyp;
{
@ -242,6 +249,7 @@ valu_t bytes;
}
#ifdef RELOCATION
void
newrelo(s, n)
{
int iscomm;
@ -326,6 +334,7 @@ new_string(s)
return r;
}
void
newsymb(name, type, desc, valu)
register char *name;
valu_t valu;

View file

@ -120,6 +120,7 @@ string tostring(n) register word n; {
return(mystrcpy(buf));
}
void
compute(node, presult) register node_p node; register result_t *presult; {
result_t leaf1,leaf2;
register token_p tp;

View file

@ -12,13 +12,13 @@ typedef struct cost {
typedef struct {
string ea_str;
word ea_off;
} addr_t;
} address_t;
typedef struct {
int t_token; /* kind of token, -1 for register */
union {
word aw; /* integer type */
addr_t aa; /* address type */
address_t aa; /* address type */
int ar; /* register type */
} t_att[TOKENSIZE];
} token_t,*token_p;

View file

@ -29,6 +29,8 @@ int maxindex;
int regclass[NREGS];
struct perm *perms;
void permute();
struct perm *
tuples(regls,nregneeded) rl_p *regls; {
int class=0;
@ -64,6 +66,7 @@ tuples(regls,nregneeded) rl_p *regls; {
return(perms);
}
void
permute(index) {
register struct perm *pp;
register rl_p rlp;

View file

@ -83,6 +83,13 @@ extern short em_ptyp[];
extern double atof();
void prolog(full nlocals);
void mes();
void bss();
void savelab();
void dumplab();
void part_flush();
void xdumplab();
void switchseg();
/* Own version of atol that continues computing on overflow.
We don't know that about the ANSI C one.
@ -136,6 +143,7 @@ in_start() {
in_finish() {
}
void
fillemlines() {
register int t,i;
register struct emline *lp;
@ -226,6 +234,7 @@ fillemlines() {
}
}
void
dopseudo() {
register b,t;
register full n;
@ -605,6 +614,7 @@ char *strarg(t) {
return(mystrcpy(argstr));
}
void
bss(n,t,b) full n; {
register long s = 0;
@ -677,6 +687,7 @@ swtxt() {
switchseg(SEGTXT);
}
void
switchseg(s) {
if (s == curseg)
@ -686,6 +697,7 @@ switchseg(s) {
fprintf(codefile,"%s\n",segname[s]);
}
void
savelab() {
register char *p,*q;
@ -700,6 +712,7 @@ savelab() {
;
}
void
dumplab() {
if (labstr[0] == 0)
@ -709,6 +722,7 @@ dumplab() {
labstr[0] = 0;
}
void
xdumplab() {
if (labstr[0] == 0)
@ -717,6 +731,7 @@ xdumplab() {
newdlb(labstr);
}
void
part_flush() {
/*

View file

@ -72,7 +72,7 @@ genstr(stringno) {
fputs(codestrings[stringno],codefile);
}
string ad2str(ad) addr_t ad; {
string ad2str(ad) address_t ad; {
static char buf[100];
if (ad.ea_str==0)
@ -87,7 +87,7 @@ string ad2str(ad) addr_t ad; {
return(mystrcpy(buf));
}
praddr(ad) addr_t ad; {
praddr(ad) address_t ad; {
if (ad.ea_str==0 || *(ad.ea_str) == '\0')
fprintf(codefile,WRD_FMT,ad.ea_off);
@ -108,6 +108,7 @@ gennl() {
putc('\n',codefile);
}
void
prtoken(tp,leadingchar) token_p tp; {
register c;
register char *code;

View file

@ -7,6 +7,7 @@
static label_p label_list = (label_p)0;
extern char *myalloc();
void
add_label(num, height, flth)
{
register label_p lbl = (label_p)0;

View file

@ -42,6 +42,7 @@ linkreg(of,sz,tp,sc) long of; {
return(rvlp);
}
void
tryreg(rvlp,typ) register struct regvar *rvlp; {
int score;
register i;

View file

@ -9,7 +9,7 @@ struct result {
union {
word e_con;
int e_reg;
addr_t e_addr;
address_t e_addr;
} e_v; /* value */
};

View file

@ -32,6 +32,8 @@ static char rcsid[] = "$Id$";
char *stab[MAXSTAB];
int nstab=0;
void chkstr();
string myalloc(size) {
register string p;
@ -72,6 +74,7 @@ compar(p1,p2) char **p1,**p2; {
return(1);
}
void
garbage_collect() {
register i;
struct emline *emlp;
@ -116,6 +119,7 @@ garbage_collect() {
nstab = fillp-stab;
}
void
chkstr(str,used) string str; char used[]; {
register low,middle,high;

View file

@ -23,6 +23,8 @@ static char rcsid[] = "$Id$";
extern int nstab; /* salloc.c */
void bmove();
savestatus(sp) register state_p sp; {
sp->st_sh = stackheight;
@ -57,6 +59,7 @@ restorestatus(sp) register state_p sp; {
popstr(sp->st_ns);
}
void
bmove(from,to,nbytes) register short *from,*to; register nbytes; {
if (nbytes<=0)

View file

@ -49,6 +49,7 @@ 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;
int i;
@ -145,6 +146,7 @@ instance(instno,token) register token_p token; {
}
}
void
cinstance(instno,token,tp,regno) register token_p token,tp; {
register inst_p inp;
int i;

View file

@ -23,6 +23,9 @@ struct variable ANY; /* ANY symbol matching any instruction */
char *REST; /* Opcode of first instruction not matched by current pattern */
void labeldef();
void set_opcode();
#include "gen.c"
@ -170,6 +173,7 @@ write_first(w)
/* Try to recognize the opcode part of an instruction */
void
set_opcode(ip)
register instr_p ip;
{
@ -318,6 +322,7 @@ bool split_operands(ip)
void
labeldef(ip)
register instr_p ip;
{

View file

@ -54,7 +54,7 @@ void prolog(full nlocals)
framesize = nlocals;
}
mes(word type)
void mes(word type)
{
int argt ;

View file

@ -5,6 +5,7 @@
/* $Id$ */
#include <stdint.h>
#include "flt_misc.h"
int
@ -15,16 +16,15 @@ flt_b64_add(e1,e2)
int carry;
/* add higher pair of 32 bits */
overflow = ucmp((long)0xFFFFFFFF - e1->flt_h_32, e2->flt_h_32) < 0;
overflow = (0xFFFFFFFFUL - e1->flt_h_32 < e2->flt_h_32);
e1->flt_h_32 += e2->flt_h_32;
/* add lower pair of 32 bits */
carry = ucmp((long)0xFFFFFFFF - e1->flt_l_32, e2->flt_l_32) < 0;
carry = (0xFFFFFFFFUL - e1->flt_l_32 < e2->flt_l_32);
e1->flt_l_32 += e2->flt_l_32;
if ((carry) && ((++e1->flt_h_32 &~0xFFFFFFFF) || e1->flt_h_32 == 0)) {
e1->flt_h_32 = 0;
if ((carry) && (++e1->flt_h_32 == 0))
return(1); /* had a 64 bit overflow */
}
return(overflow); /* return status from higher add */
}

View file

@ -23,12 +23,10 @@ flt_b64_sft(e,n)
n -= 32;
}
if (n > 0) {
e->flt_l_32 = (e->flt_l_32 >> 1) & 0x7FFFFFFF;
e->flt_l_32 >>= (n - 1);
e->flt_l_32 >>= n;
if (e->flt_h_32 != 0) {
e->flt_l_32 |= (e->flt_h_32 << (32 - n)) & 0xFFFFFFFF;
e->flt_h_32 = (e->flt_h_32 >> 1) & 0x7FFFFFFF;
e->flt_h_32 >>= (n - 1);
e->flt_l_32 |= (e->flt_h_32 << (32 - n));
e->flt_h_32 >>= n;
}
}
n = -n;
@ -38,11 +36,10 @@ flt_b64_sft(e,n)
n -= 32;
}
if (n > 0) {
e->flt_h_32 = (e->flt_h_32 << n) & 0xFFFFFFFF;
e->flt_h_32 <<= n;
if (e->flt_l_32 != 0) {
long l = (e->flt_l_32 >> 1) & 0x7FFFFFFF;
e->flt_h_32 |= (l >> (31 - n));
e->flt_l_32 = (e->flt_l_32 << n) & 0xFFFFFFFF;
e->flt_h_32 |= (e->flt_l_32 >> (32 - n));
e->flt_l_32 <<= n;
}
}
}

View file

@ -15,7 +15,6 @@ clibrary {
"./flt_umin.c",
"./flt_chk.c",
"./split.c",
"./ucmp.c",
},
hdrs = { "./flt_arith.h" },
deps = {
@ -24,4 +23,18 @@ clibrary {
}
}
-- The test program isn't built by default. Here is a target
-- modules/src/flt_arith+pkg to install it as flt_test
cprogram {
name = "test",
srcs = { "./test.c" },
deps = { "+lib" },
}
installable {
name = "pkg",
map = {
["$(INSDIR)/bin/flt_test"] = "+test",
},
}

View file

@ -44,11 +44,10 @@ flt_add(e1,e2,e3)
}
if (e1->flt_sign != e2->flt_sign) {
/* e2 + e1 = e2 - (-e1) */
int tmp = ucmp(e1->m1, e2->m1);
int tmp2 = ucmp(e1->m2, e2->m2);
if (tmp > 0 || (tmp == 0 && tmp2 > 0)) {
if (e1->m1 > e2->m1 ||
(e1->m1 == e2->m1 && e1->m2 > e2->m2)) {
/* abs(e1) > abs(e2) */
if (tmp2 < 0) {
if (e1->m2 < e2->m2) {
e1->m1 -= 1; /* carry in */
}
e1->m1 -= e2->m1;
@ -56,7 +55,7 @@ flt_add(e1,e2,e3)
*e3 = *e1;
}
else {
if (tmp2 > 0)
if (e1->m2 > e2->m2)
e2->m1 -= 1; /* carry in */
e2->m1 -= e1->m1;
e2->m2 -= e1->m2;

View file

@ -25,10 +25,9 @@ flt_arith2flt(n, e, uns)
e->m1 = 0; e->m2 = n;
}
else {
e->m2 = n & 0xffffffffL;
n >>= 1;
n &= ~((arith) 1 << (8*sizeof(arith)-1));
e->m1 = (n >> 31);
/* assuming sizeof(arith) >= 8 */
e->m1 = n >> 32;
e->m2 = n;
}
if (n == 0) {
e->flt_exp = 0;

View file

@ -9,8 +9,8 @@ flt_arith \- high precision floating point arithmetic
.if t .ta 3m 13m 22m
.if n .ta 5m 25m 40m
struct flt_mantissa {
long flt_h_32; /* high order 32 bits of mantissa */
long flt_l_32; /* low order 32 bits of mantissa */
uint32_t flt_h_32; /* high order 32 bits of mantissa */
uint32_t flt_l_32; /* low order 32 bits of mantissa */
};
typedef struct {

View file

@ -7,15 +7,15 @@
#ifndef __FLT_INCLUDED__
#define __FLT_INCLUDED__
#include "ansi.h"
#include <stdint.h>
#ifndef arith
#define arith long
#endif
struct flt_mantissa {
long flt_h_32; /* high order 32 bits of mantissa */
long flt_l_32; /* low order 32 bits of mantissa */
uint32_t flt_h_32; /* high order 32 bits of mantissa */
uint32_t flt_l_32; /* low order 32 bits of mantissa */
};
typedef struct flt_arith {
@ -33,17 +33,17 @@ extern int flt_status;
#define FLT_STRLEN 32 /* max length of result of flt_flt2str() */
_PROTOTYPE(void flt_add, (flt_arith *, flt_arith *, flt_arith *));
_PROTOTYPE(void flt_sub, (flt_arith *, flt_arith *, flt_arith *));
_PROTOTYPE(void flt_mul, (flt_arith *, flt_arith *, flt_arith *));
_PROTOTYPE(void flt_div, (flt_arith *, flt_arith *, flt_arith *));
_PROTOTYPE(void flt_modf, (flt_arith *, flt_arith *, flt_arith *));
_PROTOTYPE(int flt_cmp, (flt_arith *, flt_arith *));
_PROTOTYPE(void flt_str2flt, (char *, flt_arith *));
_PROTOTYPE(void flt_flt2str, (flt_arith *, char *, int));
_PROTOTYPE(void flt_arith2flt, (arith, flt_arith *, int));
_PROTOTYPE(arith flt_flt2arith, (flt_arith *, int));
_PROTOTYPE(void flt_b64_sft, (struct flt_mantissa *, int));
_PROTOTYPE(void flt_umin, (flt_arith *));
void flt_add(flt_arith *, flt_arith *, flt_arith *);
void flt_sub(flt_arith *, flt_arith *, flt_arith *);
void flt_mul(flt_arith *, flt_arith *, flt_arith *);
void flt_div(flt_arith *, flt_arith *, flt_arith *);
void flt_modf(flt_arith *, flt_arith *, flt_arith *);
int flt_cmp(flt_arith *, flt_arith *);
void flt_str2flt(char *, flt_arith *);
void flt_flt2str(flt_arith *, char *, int);
void flt_arith2flt(arith, flt_arith *, int);
arith flt_flt2arith(flt_arith *, int);
void flt_b64_sft(struct flt_mantissa *, int);
void flt_umin(flt_arith *);
#endif /* __FLT_INCLUDED__ */

View file

@ -5,14 +5,15 @@
/* $Id$ */
#include <stdint.h>
#include "flt_misc.h"
void
flt_div(e1,e2,e3)
register flt_arith *e1,*e2,*e3;
{
long result[2];
register long *lp;
uint32_t result[2];
register uint32_t *rp;
unsigned short u[9], v[5];
register int j;
register unsigned short *u_p = u;
@ -44,7 +45,7 @@ flt_div(e1,e2,e3)
while (! v[maxv]) maxv--;
result[0] = 0;
result[1] = 0;
lp = result;
rp = result;
/*
* Use an algorithm of Knuth (The art of programming, Seminumerical
@ -52,35 +53,25 @@ flt_div(e1,e2,e3)
* with base 65536.
*/
for (j = 0; j <= 3; j++, u_p++) {
long q_est, temp;
long v1 = v[1];
uint32_t q_est, temp;
if (j == 2) lp++;
if (j == 2) rp++;
if (u_p[0] == 0 && u_p[1] < v[1]) continue;
temp = ((long)u_p[0] << 16) + u_p[1];
temp = ((uint32_t)u_p[0] << 16) + u_p[1];
if (u_p[0] >= v[1]) {
q_est = 0x0000FFFFL;
q_est = 0x0000FFFFUL;
}
else if (v[1] == 1) {
q_est = temp;
}
else if (temp >= 0) {
q_est = temp / v1;
}
else {
long rem;
q_est = (0x7FFFFFFF/v1)+((temp&0x7FFFFFFF)/v1);
rem = (0x7FFFFFFF%v1)+((temp&0x7FFFFFFF)%v1)+1;
while (rem >= v1) {
q_est++;
rem -= v1;
}
q_est = temp / v[1];
}
temp -= q_est * v1;
temp -= q_est * v[1];
while (!(temp&0xFFFF0000) &&
ucmp((long)v[2]*q_est,(temp<<16)+(long)u_p[2]) > 0) {
v[2]*q_est > (temp<<16)+u_p[2]) {
q_est--;
temp += v1;
temp += v[1];
}
/* Now, according to Knuth, we have an estimate of the
quotient, that is either correct or one too big, but
@ -88,11 +79,11 @@ flt_div(e1,e2,e3)
*/
if (q_est != 0) {
int i;
long k = 0;
uint32_t k = 0;
int borrow = 0;
for (i = maxv; i > 0; i--) {
long tmp = q_est * (long)v[i] + k + borrow;
uint32_t tmp = q_est * v[i] + k + borrow;
unsigned short md = tmp & 0xFFFF;
borrow = (md > u_p[i]);
@ -100,7 +91,7 @@ flt_div(e1,e2,e3)
k = (tmp >> 16) & 0xFFFF;
}
k += borrow;
borrow = (long)u_p[0] < k;
borrow = u_p[0] < k;
u_p[0] -= k;
if (borrow) {
@ -110,15 +101,15 @@ flt_div(e1,e2,e3)
q_est--;
borrow = 0;
for (i = maxv; i > 0; i--) {
long tmp
= v[i]+(long)u_p[i]+borrow;
uint32_t tmp
= v[i]+(uint32_t)u_p[i]+borrow;
u_p[i] = tmp & 0xFFFF;
borrow = (tmp >> 16) & 0xFFFF;
}
u_p[0] += borrow;
}
*lp |= (j & 1) ? q_est : (q_est<<16);
*rp |= (j & 1) ? q_est : (q_est<<16);
}
}
e3->m1 = result[0];

View file

@ -15,14 +15,12 @@
#define EXT_MIN (-16384) /* min exponent */
/* hiding of names: */
#define ucmp _flt_ucmp
#define flt_nrm _flt_nrm
#define flt_chk _flt_chk
#define flt_b64_add _flt_64add
#define flt_split _flt_split
_PROTOTYPE(int ucmp, (long, long));
_PROTOTYPE(void flt_nrm, (flt_arith *));
_PROTOTYPE(void flt_chk, (flt_arith *));
_PROTOTYPE(int flt_b64_add, (struct flt_mantissa *, struct flt_mantissa *));
_PROTOTYPE(void flt_split, (flt_arith *, unsigned short *));
void flt_nrm(flt_arith *);
void flt_chk(flt_arith *);
int flt_b64_add(struct flt_mantissa *, struct flt_mantissa *);
void flt_split(flt_arith *, unsigned short *);

View file

@ -5,6 +5,7 @@
/* $Id$ */
#include <stdint.h>
#include "flt_misc.h"
void
@ -43,9 +44,9 @@ flt_mul(e1,e2,e3)
*/
for(i=4, pres = &result[4];i--;pres--) if (mp[i]) {
unsigned short k = 0;
long mpi = mp[i];
uint32_t mpi = mp[i];
for(j=4;j--;) {
long tmp = (long)pres[j] + k;
long tmp = (uint32_t)pres[j] + k;
if (mc[j]) tmp += mpi * mc[j];
pres[j] = tmp & 0xFFFF;
k = (tmp >> 16) & 0xFFFF;
@ -64,12 +65,12 @@ flt_mul(e1,e2,e3)
/*
* combine the registers to a total
*/
e3->m1 = ((long)result[0] << 16) + result[1];
e3->m2 = ((long)result[2] << 16) + result[3];
e3->m1 = ((uint32_t)result[0] << 16) + result[1];
e3->m2 = ((uint32_t)result[2] << 16) + result[3];
if (result[4] & 0x8000) {
if (++e3->m2 == 0 || (e3->m2 & ~ 0xFFFFFFFF)) {
if (++e3->m2 == 0) {
e3->m2 = 0;
if (++e3->m1 == 0 || (e3->m1 & ~ 0xFFFFFFFF)) {
if (++e3->m1 == 0) {
e3->m1 = 0x80000000;
e3->flt_exp++;
}

View file

@ -5,6 +5,7 @@
/* $Id$ */
#include <stdint.h>
#include "flt_misc.h"
void
@ -24,8 +25,8 @@ flt_nrm(e)
e->m2 = 0L;
e->flt_exp -= 32;
}
if ((e->m1 & 0x80000000) == 0) {
long l = 0x40000000;
if ((e->m1 & 0x80000000UL) == 0) {
uint32_t l = 0x40000000UL;
int cnt = -1;
while (! (l & e->m1)) {

View file

@ -1,3 +1,5 @@
#include <stdio.h>
#include <string.h>
#include "flt_arith.h"
struct tests {
@ -22,6 +24,7 @@ struct tests {
{ 0, 0, 0, 0}
};
int
main()
{
register struct tests *p = tests;
@ -31,7 +34,7 @@ main()
if (! dotest(p)) exit_status = 1;
p++;
}
exit(exit_status);
return exit_status;
}
int

View file

@ -1,21 +0,0 @@
/*
(c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
#include "flt_misc.h"
int
ucmp(l1,l2)
long l1,l2;
{
if (l1 == l2) return 0;
if (l2 >= 0) {
if (l1 > l2 || l1 < 0) return 1;
return -1;
}
if (l1 >= 0 || l1 < l2) return -1;
return 1;
}

View file

@ -4,7 +4,7 @@
sys_open, sys_close, sys_read, sys_write, sys_reset, sys_access,
sys_modtime, sys_remove, sys_rename, sys_filesize, sys_chmode,
sys_lock, sys_unlock,
sys_break, sys_stop, sys_time \- system call interface
sys_break, sys_stop \- system call interface
.SH SYNOPSIS
.nf
.B #include <system.h>
@ -67,8 +67,6 @@ sys_break, sys_stop, sys_time \- system call interface
.B void sys_stop(how)
.B int how;
.PP
.B long sys_time();
.PP
.B long sys_modtime(path)
.B char *path;
.fi

View file

@ -50,7 +50,6 @@ _PROTOTYPE(int sys_unlock, (char *));
#endif
_PROTOTYPE(char *sys_break, (int));
_PROTOTYPE(void sys_stop, (int));
_PROTOTYPE(long sys_time, (void));
_PROTOTYPE(long sys_modtime, (char *));
/* standard file decsriptors */

View file

@ -1,15 +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$ */
#include "system.h"
long time();
long
sys_time()
{
return time((long *) 0);
}

View file

@ -1,3 +1,8 @@
clibrary {
name = "headers",
hdrs = { "./src/*.h" }
}
cprogram {
name = "llgen",
@ -6,6 +11,7 @@ cprogram {
-- do this.
srcs = { "./src/*.c" },
deps = { "+headers" },
vars = {
["+cflags"] = {
"-DLIBDIR=\\\""..posix.getcwd().."/"..cwd().."/lib\\\"",

View file

@ -40,9 +40,9 @@ STATIC prline();
STATIC printset();
STATIC int check();
STATIC moreverbose();
STATIC prrule();
STATIC void prrule(p_gram p);
STATIC cfcheck();
STATIC resolve();
STATIC void resolve(p_gram p);
STATIC propagate();
STATIC spaces();
@ -283,7 +283,7 @@ moreverbose(t) register p_set t; {
}
STATIC
prrule(p) register p_gram p; {
void prrule(p_gram p) {
/*
* Create a verbose printout of grammar rule p
*/
@ -420,7 +420,7 @@ cfcheck(s1,s2,flag) p_set s1,s2; {
}
STATIC
resolve(p) register p_gram p; {
void resolve(p_gram p) {
/*
* resolve conflicts, as specified by the user
*/

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