Semaphores.def
Storage.def
Strings.def
-TTY.def
Terminal.def
Unix.def
head_m2.e
+(*$Foreign*)
DEFINITION MODULE ASCII;
+(*
+ Module: Mnemonics for ASCII control characters
+ From: ???
+ Version: $Header$
+*)
CONST
nul = 00C; soh = 01C; stx = 02C; etx = 03C;
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: Access to program arguments and environment
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
+
extern char **_argv, **_environ;
extern int _argc;
unsigned int Arguments_Argc;
DEFINITION MODULE Arguments;
-(* Routines and variables to access the programs arguments and
- environment
+(*
+ Module: Access to program arguments and environment
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
*)
VAR Argc: CARDINAL; (* Number of program arguments, including the program
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE ArraySort;
(*
END Sort;
PROCEDURE qsort(a1, a2: ADDRESS; size: CARDINAL);
+ (* Implemented with quick-sort, with some extra's *)
VAR left, right, lefteq, righteq: ADDRESS;
cmp: CompareResult;
mainloop: BOOLEAN;
DEFINITION MODULE CSP;
-(* From
- "A Modula-2 Implementation of CSP",
- M. Collado, R. Morales, J.J. Moreno,
- SIGPlan Notices, Volume 22, Number 6, June 1987.
+(*
+ Module: Communicating Sequential Processes
+ From: "A Modula-2 Implementation of CSP",
+ M. Collado, R. Morales, J.J. Moreno,
+ SIGPlan Notices, Volume 22, Number 6, June 1987.
+ Version: $Header$
See this article for an explanation of the use of this module.
*)
(*$R-*)
IMPLEMENTATION MODULE CSP;
-(* From
- "A Modula-2 Implementation of CSP",
- M. Collado, R. Morales, J.J. Moreno,
- SIGPlan Notices, Volume 22, Number 6, June 1987.
+(*
+ Module: Communicating Sequential Processes
+ From: "A Modula-2 Implementation of CSP",
+ M. Collado, R. Morales, J.J. Moreno,
+ SIGPlan Notices, Volume 22, Number 6, June 1987.
+ Some modifications by Ceriel J.H. Jacobs
+ Version: $Header$
See this article for an explanation of the use of this module.
*)
#include <m2_traps.h>
+;
+; (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$
+;
mes 2,EM_WSIZE,EM_PSIZE
DEFINITION MODULE Conversions;
+(*
+ Module: Numeric-to-string conversions
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
(* Convert number "num" to right-justified octal representation of
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Conversions;
+(*
+ Module: numeric-to-string conversions
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
PROCEDURE ConvertNum(num, len, base: CARDINAL;
neg: BOOLEAN;
(*$Foreign *)
DEFINITION MODULE EM;
-(* An interface to EM instructions and data *)
+(*
+ Module: Interface to some EM instructions and data
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
FROM SYSTEM IMPORT ADDRESS;
(* Generate EM trap number "trapno" *)
PROCEDURE SIG(t: TrapHandler): TrapHandler;
+ (* install traphandler t; return previous handler *)
PROCEDURE FILN(): ADDRESS;
+ (* return current program file-name. This only works if file-name
+ and line-number generation is not disabled during compilation
+ *)
PROCEDURE LINO(): INTEGER;
+ (* return current program line-number. This only works if file-name
+ and line-number generation is not disabled during compilation
+ *)
END EM.
#
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module: Interface to some EM instructions and data
+; Author: Ceriel J.H. Jacobs
+; Version: $Header$
+;
mes 2,EM_WSIZE,EM_PSIZE
#define ARG1 0
(*$Foreign*)
DEFINITION MODULE Epilogue;
-(* MODULA-2 offers a facility for the initialization of modules, but there
+(*
+ Module: install module termination procedures to be called at
+ program termination
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+
+ MODULA-2 offers a facility for the initialization of modules, but there
is no mechanism to have some code executed when the program finishes.
This module is a feeble attempt at solving this problem.
*)
DEFINITION MODULE InOut;
+(*
+ Module: Wirth's Input/Output module
+ From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+ Version: $Header$
+*)
CONST EOL = 12C;
*)
PROCEDURE OpenInputFile(filename: ARRAY OF CHAR);
- (* Like OpenInput, but filename given as parameter
+ (* Like OpenInput, but filename given as parameter.
+ This procedure is not in Wirth's InOut.
*)
PROCEDURE OpenOutputFile(filename: ARRAY OF CHAR);
- (* Like OpenOutput, but filename given as parameter
+ (* Like OpenOutput, but filename given as parameter.
+ This procedure is not in Wirth's InOut.
*)
PROCEDURE CloseInput;
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE InOut ;
+(*
+ Module: Wirth's Input/Output module
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
IMPORT Streams;
IMPORT Conversions;
IMPORT Traps;
- FROM TTY IMPORT isatty;
CONST TAB = 11C;
j : CARDINAL;
BEGIN
Done := TRUE;
- IF isatty(0) THEN
+ IF isatty(Streams.InputStream) THEN
XWriteString(prompt);
END;
XReadString(buf);
InOut.mod
Streams.mod
Terminal.mod
-TTY.mod
-ASCII.mod
MathLib0.mod
Mathlib.mod
Processes.mod
#
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module: Compute non-constant set displays
+; Author: Ceriel J.H. Jacobs
+; Version: $Header$
+;
mes 2,EM_WSIZE,EM_PSIZE
; _LtoUset is called for set displays containing { expr1 .. expr2 }.
SOURCES = ASCII.def EM.def MathLib0.def Processes.def \
RealInOut.def Storage.def Arguments.def Conversion.def \
random.def Semaphores.def Unix.def RealConver.def \
- Strings.def InOut.def Terminal.def TTY.def \
+ Strings.def InOut.def Terminal.def \
Mathlib.def PascalIO.def Traps.def CSP.def \
Epilogue.def Streams.def ArraySort.def
DEFINITION MODULE MathLib0;
(*
+ Module: Some mathematical functions
+ From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+ Version: $Header$
+
Exists for compatibility.
A more elaborate math lib can be found in Mathlib.def
*)
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE MathLib0;
+(*
+ Module: Some mathematical functions
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
IMPORT Mathlib;
DEFINITION MODULE Mathlib;
+(*
+ Module: Mathematical functions
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
(* Some mathematical constants: *)
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Mathlib;
+(*
+ Module: Mathematical functions
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
FROM EM IMPORT FIF, FEF;
FROM Traps IMPORT Message;
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE PascalIO;
(*
DEFINITION MODULE Processes;
+(*
+ Module: Processes
+ From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+ Version: $Header$
+*)
TYPE SIGNAL;
(*$R-*)
IMPLEMENTATION MODULE Processes [1];
-(* This implementation module comes from
- "Programming in Modula-2", by Niklaus Wirth,
- 3rd edition, Springer-Verlag, New York, 1985
+(*
+ Module: Processes
+ From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+ Version: $Header$
*)
FROM SYSTEM IMPORT ADDRESS, TSIZE, NEWPROCESS, TRANSFER;
DEFINITION MODULE RealConversions;
+(*
+ Module: string-to-real and real-to-string conversions
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
PROCEDURE StringToReal(str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN);
(* Convert string "str" to a real number "r" according to the syntax:
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE RealConversions;
+(*
+ Module: string-to-real and real-to-string conversions
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
FROM EM IMPORT FIF;
DEFINITION MODULE RealInOut;
+(*
+ Module: InOut for REAL numbers
+ From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+ Version: $Header$
+*)
VAR Done: BOOLEAN;
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE RealInOut;
+(*
+ Module: InOut for REAL numbers
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
IMPORT InOut;
IMPORT RealConversions;
DEFINITION MODULE Semaphores;
+(*
+ Module: Processes with semaphores
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+
+ On systems using quasi-concurrency, the only opportunities for process-
+ switches are calls to Down and Up.
+*)
TYPE Sema;
(* If the value of "s" is > 0, then just decrement "s".
Else, suspend the current process until the semaphore becomes
positive again.
- May result in a process switch.
*)
PROCEDURE Up(VAR s: Sema);
(* Increment the semaphore "s".
- This call may result in a process switch
*)
PROCEDURE StartProcess(P: PROC; n: CARDINAL);
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Semaphores [1];
+(*
+ Module: Processes with semaphores
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+
+ Quasi-concurrency implementation
+*)
FROM SYSTEM IMPORT ADDRESS, NEWPROCESS, TRANSFER;
FROM Storage IMPORT ALLOCATE;
DEFINITION MODULE Storage;
+(*
+ Module: Dynamic storage allocation
+ From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+ Version: $Header$
+*)
FROM SYSTEM IMPORT ADDRESS;
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Storage;
+(*
+ Module: Dynamic Storage Allocation
+ Author: Ceriel J.H. Jacobs
+ Adapted from a version in C by Hans Tebra
+ Version: $Header$
+*)
(* This storage manager maintains an array of lists of objects with the
same size. Commonly used sizes have their own bucket. The larger ones
are put in a single list.
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: assign string to character array, with possible 0-byte
+ extension
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
_StringAssign(dstsiz, srcsiz, dstaddr, srcaddr)
register char *dstaddr, *srcaddr;
{
srcsiz--;
dstsiz--;
}
- while (dstsiz > 0) {
- *dstaddr++ = 0;
- dstsiz--;
+ if (dstsiz > 0) {
+ *dstaddr = 0;
}
}
DEFINITION MODULE Streams;
(*
+ Module: Stream Input/Output
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+
* This module provides sequential IO through streams.
* A stream is either a text stream or a binary stream, and is either in
* reading, writing or appending mode.
position: LONGINT;
VAR result: StreamResult);
(* sets the actual read/write position to "position".
- "result" is set to illegaloperation if "stream" is not a stream or
- the stream was opened for appending and the position is in front of
- the current position, or it failed for some other
- reason (f.i. when the stream is connected to a terminal).
+ "result" is set to nostream if "stream" is not a stream.
+ It is set to illegaloperation if the stream was opened for appending and
+ the position is in front of the current position, or it failed for some
+ other reason (f.i. when the stream is connected to a terminal).
+ *)
+
+ PROCEDURE isatty(stream: Stream; VAR result: StreamResult): BOOLEAN;
+ (* return TRUE if the stream is connected to a terminal.
+ "result" is set to nostream if "stream" is not a stream, and
+ set to illegaloperation if the operation failed for some other reason.
*)
END Streams.
+#
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Streams;
+(*
+ Module: Stream Input/Output
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+
+ Implementation for Unix
+*)
FROM SYSTEM IMPORT BYTE, ADR;
- IMPORT Unix, TTY, Storage, Epilogue;
+ IMPORT Unix, Storage, Epilogue;
CONST BUFSIZ = 1024; (* tunable *)
TYPE IOB = RECORD
BEGIN
currpos := 0D;
IF (s = NIL) OR (s^.kind = none) THEN
- result := illegaloperation;
+ result := nostream;
RETURN;
END;
IF (s^.mode # reading) THEN
result := succeeded;
END SetPosition;
+ PROCEDURE isatty(stream: Stream): BOOLEAN;
+ VAR buf: ARRAY[1..100] OF CHAR;
+ BEGIN
+ IF (stream = NIL) OR (s^.kind = none) THEN
+ result := nostream;
+ RETURN FALSE;
+ END;
+#ifdef __USG
+ RETURN ioctl(stream^.fildes, INTEGER(ORD('T') * 256 + 1), ADR(buf)) >= 0;
+#else
+#ifdef __BSD4_2
+ RETURN ioctl(stream^.fildes, INTEGER(ORD('t') * 256 + 8 + 6*65536 + 40000000H), ADR(buf)) >= 0;
+#else
+ RETURN ioctl(stream^.fildes, INTEGER(ORD('t') * 256 + 8), ADR(buf)) >= 0;
+#endif
+#endif
+ END isatty;
+
BEGIN
InputStream := ADR(ibuf);
OutputStream := ADR(obuf);
maxcnt := 0;
cnt := 0;
bufferedcnt := BUFSIZ;
- IF TTY.isatty(1) THEN
+ IF isatty(OutputStream) THEN
buffering := linebuffered;
ELSE
buffering := blockbuffered;
maxcnt := 0;
cnt := 0;
bufferedcnt := BUFSIZ;
- IF TTY.isatty(2) THEN
+ IF isatty(ErrorStream) THEN
buffering := linebuffered;
ELSE
buffering := blockbuffered;
DEFINITION MODULE Strings;
+(*
+ Module: String manipulations
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
(* Note: truncation of strings may occur if the user does not provide
large enough variables to contain the result of the operation.
*)
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Strings;
+(*
+ Module: String manipulations
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
(* Assign string source to dest
DEFINITION MODULE Terminal;
+(*
+ Module: Input/Output to/from terminals
+ From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
+ Version: $Header$
+*)
PROCEDURE Read(VAR ch : CHAR);
(* Read a character from the terminal and leave it in ch
#
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Terminal;
-(* This implementation is Unix-dependant
+(*
+ Module: Input/Output to/from terminals
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+
+ Implementation for Unix.
*)
IMPORT Unix;
FROM SYSTEM IMPORT ADR;
DEFINITION MODULE Traps;
+(*
+ Module: Facility for handling traps
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
IMPORT EM;
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE Traps;
+(*
+ Module: Facility for handling traps
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
+
IMPORT EM;
IMPORT Unix;
FROM SYSTEM IMPORT ADDRESS, ADR;
(*$Foreign language module *)
DEFINITION MODULE Unix;
-(* An interface to some Unix system-calls *)
+(*
+ Module: interface to some Unix systemcalls
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
FROM SYSTEM IMPORT WORD, ADDRESS;
(* Type needed for Signal *)
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: double abs function
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
#ifndef NOFLOAT
double
_absd(i)
#
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module: REAL abs function
+; Author: Ceriel J.H. Jacobs
+; Version: $Header$
+;
mes 2,EM_WSIZE,EM_PSIZE
exp $_absf
pro $_absf,0
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: integer abs function
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
+
_absi(i)
{
return i >= 0 ? i : -i;
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: longint abs function
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
long
_absl(i)
long i;
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: default modula-2 trap handler
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
#include <em_abs.h>
#include <m2_traps.h>
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: runtime support for conformant arrays
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
#include <m2_traps.h>
struct descr {
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: program termination routines
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
#define MAXPROCS 16
static int callindex;
#
-/*
- * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
- *
- * This product is part of the Amsterdam Compiler Kit.
- *
- * Permission to use, sell, duplicate or disclose this software must be
- * obtained in writing. Requests for such permissions may be sent to
- *
- * Dr. Andrew S. Tanenbaum
- * Wiskundig Seminarium
- * Vrije Universiteit
- * Postbox 7161
- * 1007 MC Amsterdam
- * The Netherlands
- *
- */
-
-/* Author: C.J.H. Jacobs */
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module: Modula-2 runtime startoff
+; Author: Ceriel J.H. Jacobs
+; Version: $Header$
+;
mes 2,EM_WSIZE,EM_PSIZE
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: get value on stack, byte by byte
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
_load(siz, addr, p)
register char *addr;
register int siz;
DEFINITION MODULE random;
+(*
+ Module: random numbers
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
PROCEDURE Random(): CARDINAL;
(* Return a random CARDINAL
"lwb" must be smaller than "upb", or "lwb" is returned.
*)
+PROCEDURE StartSeed(seed: CARDINAL);
+(* Initialize the generator. You don't have to call this procedure, unless
+ you don't want the system to pick a starting value for itself.
+*)
+
END random.
+(*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*)
+
(*$R-*)
IMPLEMENTATION MODULE random;
+(*
+ Module: random numbers
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*)
FROM Unix IMPORT getpid, time;
TYPE index = [0..54];
RETURN lwb + (Random() MOD (upb - lwb + 1));
END Uniform;
+PROCEDURE StartSeed(seed: CARDINAL);
BEGIN
- X[0] := time(NIL);
- X[0] := CARDINAL(getpid()) * X[0];
+ X[0] := seed;
FOR k := 1 TO 54 DO
X[k] := X[k-1] * 1297;
END;
k := 54;
j := 30;
+END StartSeed;
+
+BEGIN
+ X0 := time(NIL);
+ StartSeed(CARDINAL(getpid()) * X[0]);
END random.
#
+;
+; (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>
mes 2,EM_WSIZE,EM_PSIZE
#
+;
+; (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 LONGINTS
+; Author: Ceriel J.H. Jacobs
+; Version: $Header$
+;
#include <em_abs.h>
mes 2,EM_WSIZE,EM_PSIZE
#
+;
+; (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>
mes 2,EM_WSIZE,EM_PSIZE
#
+;
+; (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>
mes 2,EM_WSIZE,EM_PSIZE
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: Dummy priority routines
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
_stackprio(n)
{
}
+/*
+ (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ See the copyright notice in the ACK home directory, in the file "Copyright".
+*/
+
+/*
+ Module: store values from stack, byte by byte
+ Author: Ceriel J.H. Jacobs
+ Version: $Header$
+*/
_store(siz, addr, p)
register char *addr;
register int siz;
#
+;
+; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
+; See the copyright notice in the ACK home directory, in the file "Copyright".
+;
+;
+; Module: implementation of coroutines
+; Author: Ceriel J.H. Jacobs
+; Version: $Header$
+;
+; This version works for EM implementations that have a contiguous downwards
+; growing stack, on which data below the stack-pointer is not destroyed.
+;
#include <em_mes.h>
#include <m2_traps.h>