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
--- /dev/null
+/*
+ * (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);
+}
--- /dev/null
+/*
+ * (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);
+}
--- /dev/null
+/*
+ * (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);
+}
--- /dev/null
+/*
+ * (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);
+}
--- /dev/null
+/*
+ * (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);
+}
--- /dev/null
+/*
+ * (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