Replaced some EM code by C code
This commit is contained in:
parent
81cc04f9a3
commit
d8ff0feed3
|
@ -38,10 +38,10 @@ confarray.c
|
|||
load.c
|
||||
blockmove.c
|
||||
stackprio.c
|
||||
ChkCards.e
|
||||
ucheck.c
|
||||
rcka.c
|
||||
rcku.c
|
||||
rcki.c
|
||||
rckul.c
|
||||
rckil.c
|
||||
EM.e
|
||||
rcka.e
|
||||
rcku.e
|
||||
rcki.e
|
||||
rckul.e
|
||||
rckil.e
|
||||
|
|
25
lang/m2/libm2/rcka.c
Normal file
25
lang/m2/libm2/rcka.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
*
|
||||
* Module: range checks for INTEGER, now for array indexing
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
* Version: $Header$
|
||||
*/
|
||||
|
||||
#include <em_abs.h>
|
||||
|
||||
extern TRP();
|
||||
|
||||
struct array_descr {
|
||||
int lbound;
|
||||
int n_elts_min_one;
|
||||
unsigned size;
|
||||
};
|
||||
|
||||
rcka(descr, indx)
|
||||
struct array_descr *descr;
|
||||
{
|
||||
if (indx < 0 || indx > descr->n_elts_min_one) TRP(EARRAY);
|
||||
}
|
23
lang/m2/libm2/rcki.c
Normal file
23
lang/m2/libm2/rcki.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
*
|
||||
* Module: range checks for INTEGER
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
* Version: $Header$
|
||||
*/
|
||||
|
||||
#include <em_abs.h>
|
||||
|
||||
extern TRP();
|
||||
|
||||
struct range_descr {
|
||||
int low, high;
|
||||
};
|
||||
|
||||
rcki(descr, val)
|
||||
struct range_descr *descr;
|
||||
{
|
||||
if (val < descr->low || val > descr->high) TRP(ERANGE);
|
||||
}
|
24
lang/m2/libm2/rckil.c
Normal file
24
lang/m2/libm2/rckil.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
*
|
||||
* Module: range checks for LONGINT
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
* Version: $Header$
|
||||
*/
|
||||
|
||||
#include <em_abs.h>
|
||||
|
||||
extern TRP();
|
||||
|
||||
struct range_descr {
|
||||
long low, high;
|
||||
};
|
||||
|
||||
rcki(descr, val)
|
||||
struct range_descr *descr;
|
||||
long val;
|
||||
{
|
||||
if (val < descr->low || val > descr->high) TRP(ERANGE);
|
||||
}
|
24
lang/m2/libm2/rcku.c
Normal file
24
lang/m2/libm2/rcku.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
*
|
||||
* Module: range checks for CARDINAL
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
* Version: $Header$
|
||||
*/
|
||||
|
||||
#include <em_abs.h>
|
||||
|
||||
extern TRP();
|
||||
|
||||
struct range_descr {
|
||||
unsigned low, high;
|
||||
};
|
||||
|
||||
rcki(descr, val)
|
||||
struct range_descr *descr;
|
||||
unsigned val;
|
||||
{
|
||||
if (val < descr->low || val > descr->high) TRP(ERANGE);
|
||||
}
|
24
lang/m2/libm2/rckul.c
Normal file
24
lang/m2/libm2/rckul.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
*
|
||||
* Module: range checks for LONGCARD
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
* Version: $Header$
|
||||
*/
|
||||
|
||||
#include <em_abs.h>
|
||||
|
||||
extern TRP();
|
||||
|
||||
struct range_descr {
|
||||
unsigned long low, high;
|
||||
};
|
||||
|
||||
rcki(descr, val)
|
||||
struct range_descr *descr;
|
||||
unsigned long val;
|
||||
{
|
||||
if (val < descr->low || val > descr->high) TRP(ERANGE);
|
||||
}
|
65
lang/m2/libm2/ucheck.c
Normal file
65
lang/m2/libm2/ucheck.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*
|
||||
*
|
||||
* Module: CARDINAL operations with overflow checking
|
||||
* Author: Ceriel J.H. Jacobs
|
||||
* Version: $Header$
|
||||
*/
|
||||
|
||||
#ifndef EM_WSIZE
|
||||
#define EM_WSIZE _EM_WSIZE
|
||||
#endif
|
||||
#ifndef EM_LSIZE
|
||||
#define EM_LSIZE _EM_LSIZE
|
||||
#endif
|
||||
|
||||
#include <m2_traps.h>
|
||||
|
||||
#define MAXCARD ((unsigned)-1)
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
#define MAXLONGCARD ((unsigned long) -1L)
|
||||
#endif
|
||||
|
||||
adduchk(a,b)
|
||||
unsigned a,b;
|
||||
{
|
||||
if (MAXCARD - a > b) TRP(M2_UOVFL);
|
||||
}
|
||||
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
addulchk(a,b)
|
||||
unsigned long a,b;
|
||||
{
|
||||
if (MAXLONGCARD - a > b) TRP(M2_UOVFL);
|
||||
}
|
||||
#endif
|
||||
|
||||
muluchk(a,b)
|
||||
unsigned a,b;
|
||||
{
|
||||
if (a != 0 && MAXCARD/a < b) TRP(M2_UOVFL);
|
||||
}
|
||||
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
mululchk(a,b)
|
||||
unsigned long a,b;
|
||||
{
|
||||
if (a != 0 && MAXLONGCARD/a < b) TRP(M2_UOVFL);
|
||||
}
|
||||
#endif
|
||||
|
||||
subuchk(a,b)
|
||||
unsigned a,b;
|
||||
{
|
||||
if (b < a) TRP(M2_UOVFL);
|
||||
}
|
||||
|
||||
#if EM_WSIZE < EM_LSIZE
|
||||
subulchk(a,b)
|
||||
unsigned long a,b;
|
||||
{
|
||||
if (b < a) TRP(M2_UOVFL);
|
||||
}
|
||||
#endif
|
Loading…
Reference in a new issue