From 31ddd5ca120494e1ccbd8db04491694ec895ea3a Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 19 Feb 1988 15:54:01 +0000 Subject: [PATCH] mainly new comments --- lang/m2/libm2/.distr | 1 - lang/m2/libm2/ASCII.def | 6 ++++++ lang/m2/libm2/Arguments.c | 11 ++++++++++ lang/m2/libm2/Arguments.def | 6 ++++-- lang/m2/libm2/ArraySort.mod | 6 ++++++ lang/m2/libm2/CSP.def | 10 +++++---- lang/m2/libm2/CSP.mod | 11 ++++++---- lang/m2/libm2/ChkCards.e | 9 +++++++++ lang/m2/libm2/Conversion.def | 5 +++++ lang/m2/libm2/Conversion.mod | 10 +++++++++ lang/m2/libm2/EM.def | 13 +++++++++++- lang/m2/libm2/EM.e | 9 +++++++++ lang/m2/libm2/Epilogue.def | 8 +++++++- lang/m2/libm2/InOut.def | 11 ++++++++-- lang/m2/libm2/InOut.mod | 13 ++++++++++-- lang/m2/libm2/LIST | 2 -- lang/m2/libm2/LtoUset.e | 9 +++++++++ lang/m2/libm2/Makefile | 2 +- lang/m2/libm2/MathLib0.def | 4 ++++ lang/m2/libm2/MathLib0.mod | 10 +++++++++ lang/m2/libm2/Mathlib.def | 5 +++++ lang/m2/libm2/Mathlib.mod | 10 +++++++++ lang/m2/libm2/PascalIO.mod | 5 +++++ lang/m2/libm2/Processes.def | 5 +++++ lang/m2/libm2/Processes.mod | 7 ++++--- lang/m2/libm2/RealConver.def | 5 +++++ lang/m2/libm2/RealConver.mod | 10 +++++++++ lang/m2/libm2/RealInOut.def | 5 +++++ lang/m2/libm2/RealInOut.mod | 10 +++++++++ lang/m2/libm2/Semaphores.def | 10 +++++++-- lang/m2/libm2/Semaphores.mod | 12 +++++++++++ lang/m2/libm2/Storage.def | 5 +++++ lang/m2/libm2/Storage.mod | 11 ++++++++++ lang/m2/libm2/StrAss.c | 16 ++++++++++++--- lang/m2/libm2/Streams.def | 18 +++++++++++++---- lang/m2/libm2/Streams.mod | 39 ++++++++++++++++++++++++++++++++---- lang/m2/libm2/Strings.def | 5 +++++ lang/m2/libm2/Strings.mod | 10 +++++++++ lang/m2/libm2/Terminal.def | 5 +++++ lang/m2/libm2/Terminal.mod | 12 ++++++++++- lang/m2/libm2/Traps.def | 5 +++++ lang/m2/libm2/Traps.mod | 11 ++++++++++ lang/m2/libm2/Unix.def | 6 +++++- lang/m2/libm2/absd.c | 10 +++++++++ lang/m2/libm2/absf.e | 9 +++++++++ lang/m2/libm2/absi.c | 11 ++++++++++ lang/m2/libm2/absl.c | 10 +++++++++ lang/m2/libm2/catch.c | 10 +++++++++ lang/m2/libm2/confarray.c | 10 +++++++++ lang/m2/libm2/halt.c | 10 +++++++++ lang/m2/libm2/head_m2.e | 27 +++++++++---------------- lang/m2/libm2/load.c | 10 +++++++++ lang/m2/libm2/random.def | 10 +++++++++ lang/m2/libm2/random.mod | 19 ++++++++++++++++-- lang/m2/libm2/rcki.e | 9 +++++++++ lang/m2/libm2/rckil.e | 9 +++++++++ lang/m2/libm2/rcku.e | 9 +++++++++ lang/m2/libm2/rckul.e | 9 +++++++++ lang/m2/libm2/stackprio.c | 10 +++++++++ lang/m2/libm2/store.c | 10 +++++++++ lang/m2/libm2/transfer.e | 12 +++++++++++ 61 files changed, 529 insertions(+), 58 deletions(-) diff --git a/lang/m2/libm2/.distr b/lang/m2/libm2/.distr index dc9fdf46e..d402b31e6 100644 --- a/lang/m2/libm2/.distr +++ b/lang/m2/libm2/.distr @@ -15,7 +15,6 @@ RealConver.def Semaphores.def Storage.def Strings.def -TTY.def Terminal.def Unix.def head_m2.e diff --git a/lang/m2/libm2/ASCII.def b/lang/m2/libm2/ASCII.def index 54c0cf474..827b4e0d0 100644 --- a/lang/m2/libm2/ASCII.def +++ b/lang/m2/libm2/ASCII.def @@ -1,4 +1,10 @@ +(*$Foreign*) DEFINITION MODULE ASCII; +(* + Module: Mnemonics for ASCII control characters + From: ??? + Version: $Header$ +*) CONST nul = 00C; soh = 01C; stx = 02C; etx = 03C; diff --git a/lang/m2/libm2/Arguments.c b/lang/m2/libm2/Arguments.c index cbd2c6c24..036dae6d6 100644 --- a/lang/m2/libm2/Arguments.c +++ b/lang/m2/libm2/Arguments.c @@ -1,3 +1,14 @@ +/* + (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; diff --git a/lang/m2/libm2/Arguments.def b/lang/m2/libm2/Arguments.def index a84950463..c4d19a3f4 100644 --- a/lang/m2/libm2/Arguments.def +++ b/lang/m2/libm2/Arguments.def @@ -1,6 +1,8 @@ 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 diff --git a/lang/m2/libm2/ArraySort.mod b/lang/m2/libm2/ArraySort.mod index 8ad9c3efe..f48162898 100644 --- a/lang/m2/libm2/ArraySort.mod +++ b/lang/m2/libm2/ArraySort.mod @@ -1,3 +1,8 @@ +(* + (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; (* @@ -21,6 +26,7 @@ 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; diff --git a/lang/m2/libm2/CSP.def b/lang/m2/libm2/CSP.def index 4d0d3193d..5fb7deba0 100644 --- a/lang/m2/libm2/CSP.def +++ b/lang/m2/libm2/CSP.def @@ -1,8 +1,10 @@ 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. *) diff --git a/lang/m2/libm2/CSP.mod b/lang/m2/libm2/CSP.mod index a9c6292c0..74fdd9888 100644 --- a/lang/m2/libm2/CSP.mod +++ b/lang/m2/libm2/CSP.mod @@ -1,9 +1,12 @@ (*$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. *) diff --git a/lang/m2/libm2/ChkCards.e b/lang/m2/libm2/ChkCards.e index b6d7a0580..036981869 100644 --- a/lang/m2/libm2/ChkCards.e +++ b/lang/m2/libm2/ChkCards.e @@ -1,4 +1,13 @@ #include +; +; (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 diff --git a/lang/m2/libm2/Conversion.def b/lang/m2/libm2/Conversion.def index bfaa7e4ad..f732fa284 100644 --- a/lang/m2/libm2/Conversion.def +++ b/lang/m2/libm2/Conversion.def @@ -1,4 +1,9 @@ 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 diff --git a/lang/m2/libm2/Conversion.mod b/lang/m2/libm2/Conversion.mod index cdb90c0d7..b64ebc42c 100644 --- a/lang/m2/libm2/Conversion.mod +++ b/lang/m2/libm2/Conversion.mod @@ -1,5 +1,15 @@ +(* + (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; diff --git a/lang/m2/libm2/EM.def b/lang/m2/libm2/EM.def index 755d6b4a4..82b53de10 100644 --- a/lang/m2/libm2/EM.def +++ b/lang/m2/libm2/EM.def @@ -1,6 +1,10 @@ (*$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; @@ -20,8 +24,15 @@ DEFINITION MODULE EM; (* 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. diff --git a/lang/m2/libm2/EM.e b/lang/m2/libm2/EM.e index 174c82fc8..f5f1b3655 100644 --- a/lang/m2/libm2/EM.e +++ b/lang/m2/libm2/EM.e @@ -1,4 +1,13 @@ # +; +; (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 diff --git a/lang/m2/libm2/Epilogue.def b/lang/m2/libm2/Epilogue.def index ea6d6e9d9..ee87c4640 100644 --- a/lang/m2/libm2/Epilogue.def +++ b/lang/m2/libm2/Epilogue.def @@ -1,6 +1,12 @@ (*$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. *) diff --git a/lang/m2/libm2/InOut.def b/lang/m2/libm2/InOut.def index 1179298be..d8c142c47 100644 --- a/lang/m2/libm2/InOut.def +++ b/lang/m2/libm2/InOut.def @@ -1,4 +1,9 @@ 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; @@ -23,11 +28,13 @@ DEFINITION MODULE InOut; *) 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; diff --git a/lang/m2/libm2/InOut.mod b/lang/m2/libm2/InOut.mod index ab7eebfe2..2fd077171 100644 --- a/lang/m2/libm2/InOut.mod +++ b/lang/m2/libm2/InOut.mod @@ -1,10 +1,19 @@ +(* + (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; @@ -123,7 +132,7 @@ IMPLEMENTATION MODULE InOut ; j : CARDINAL; BEGIN Done := TRUE; - IF isatty(0) THEN + IF isatty(Streams.InputStream) THEN XWriteString(prompt); END; XReadString(buf); diff --git a/lang/m2/libm2/LIST b/lang/m2/libm2/LIST index 3c5b0b20f..91e78c4a7 100644 --- a/lang/m2/libm2/LIST +++ b/lang/m2/libm2/LIST @@ -5,8 +5,6 @@ RealInOut.mod InOut.mod Streams.mod Terminal.mod -TTY.mod -ASCII.mod MathLib0.mod Mathlib.mod Processes.mod diff --git a/lang/m2/libm2/LtoUset.e b/lang/m2/libm2/LtoUset.e index 595747240..2be4da7d6 100644 --- a/lang/m2/libm2/LtoUset.e +++ b/lang/m2/libm2/LtoUset.e @@ -1,4 +1,13 @@ # +; +; (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 }. diff --git a/lang/m2/libm2/Makefile b/lang/m2/libm2/Makefile index b945a1861..313d130f5 100644 --- a/lang/m2/libm2/Makefile +++ b/lang/m2/libm2/Makefile @@ -4,7 +4,7 @@ DEFDIR = $(HOME)/lib/m2 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 diff --git a/lang/m2/libm2/MathLib0.def b/lang/m2/libm2/MathLib0.def index 985a6da44..196c66e82 100644 --- a/lang/m2/libm2/MathLib0.def +++ b/lang/m2/libm2/MathLib0.def @@ -1,5 +1,9 @@ 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 *) diff --git a/lang/m2/libm2/MathLib0.mod b/lang/m2/libm2/MathLib0.mod index 9834ac036..a27d29ffa 100644 --- a/lang/m2/libm2/MathLib0.mod +++ b/lang/m2/libm2/MathLib0.mod @@ -1,5 +1,15 @@ +(* + (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; diff --git a/lang/m2/libm2/Mathlib.def b/lang/m2/libm2/Mathlib.def index 979d1b696..d860673f3 100644 --- a/lang/m2/libm2/Mathlib.def +++ b/lang/m2/libm2/Mathlib.def @@ -1,4 +1,9 @@ DEFINITION MODULE Mathlib; +(* + Module: Mathematical functions + Author: Ceriel J.H. Jacobs + Version: $Header$ +*) (* Some mathematical constants: *) diff --git a/lang/m2/libm2/Mathlib.mod b/lang/m2/libm2/Mathlib.mod index 79858a34f..7b84f89d6 100644 --- a/lang/m2/libm2/Mathlib.mod +++ b/lang/m2/libm2/Mathlib.mod @@ -1,5 +1,15 @@ +(* + (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; diff --git a/lang/m2/libm2/PascalIO.mod b/lang/m2/libm2/PascalIO.mod index ecfdd7ebc..352a77d65 100644 --- a/lang/m2/libm2/PascalIO.mod +++ b/lang/m2/libm2/PascalIO.mod @@ -1,3 +1,8 @@ +(* + (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; (* diff --git a/lang/m2/libm2/Processes.def b/lang/m2/libm2/Processes.def index 8437deba3..0bbac30be 100644 --- a/lang/m2/libm2/Processes.def +++ b/lang/m2/libm2/Processes.def @@ -1,4 +1,9 @@ DEFINITION MODULE Processes; +(* + Module: Processes + From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth + Version: $Header$ +*) TYPE SIGNAL; diff --git a/lang/m2/libm2/Processes.mod b/lang/m2/libm2/Processes.mod index 2bc5d66d8..18b28a6b2 100644 --- a/lang/m2/libm2/Processes.mod +++ b/lang/m2/libm2/Processes.mod @@ -1,8 +1,9 @@ (*$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; diff --git a/lang/m2/libm2/RealConver.def b/lang/m2/libm2/RealConver.def index 680856495..e97083627 100644 --- a/lang/m2/libm2/RealConver.def +++ b/lang/m2/libm2/RealConver.def @@ -1,4 +1,9 @@ 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: diff --git a/lang/m2/libm2/RealConver.mod b/lang/m2/libm2/RealConver.mod index bcd21094d..eac853e7b 100644 --- a/lang/m2/libm2/RealConver.mod +++ b/lang/m2/libm2/RealConver.mod @@ -1,5 +1,15 @@ +(* + (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; diff --git a/lang/m2/libm2/RealInOut.def b/lang/m2/libm2/RealInOut.def index c7eb7eb1a..6a13a4839 100644 --- a/lang/m2/libm2/RealInOut.def +++ b/lang/m2/libm2/RealInOut.def @@ -1,4 +1,9 @@ DEFINITION MODULE RealInOut; +(* + Module: InOut for REAL numbers + From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth + Version: $Header$ +*) VAR Done: BOOLEAN; diff --git a/lang/m2/libm2/RealInOut.mod b/lang/m2/libm2/RealInOut.mod index 64a97d246..342180141 100644 --- a/lang/m2/libm2/RealInOut.mod +++ b/lang/m2/libm2/RealInOut.mod @@ -1,5 +1,15 @@ +(* + (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; diff --git a/lang/m2/libm2/Semaphores.def b/lang/m2/libm2/Semaphores.def index 9883fb971..53a674e73 100644 --- a/lang/m2/libm2/Semaphores.def +++ b/lang/m2/libm2/Semaphores.def @@ -1,4 +1,12 @@ 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; @@ -12,12 +20,10 @@ DEFINITION MODULE Semaphores; (* 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); diff --git a/lang/m2/libm2/Semaphores.mod b/lang/m2/libm2/Semaphores.mod index 96fc2482b..776722560 100644 --- a/lang/m2/libm2/Semaphores.mod +++ b/lang/m2/libm2/Semaphores.mod @@ -1,5 +1,17 @@ +(* + (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; diff --git a/lang/m2/libm2/Storage.def b/lang/m2/libm2/Storage.def index fda4c9c48..234562b4d 100644 --- a/lang/m2/libm2/Storage.def +++ b/lang/m2/libm2/Storage.def @@ -1,4 +1,9 @@ DEFINITION MODULE Storage; +(* + Module: Dynamic storage allocation + From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth + Version: $Header$ +*) FROM SYSTEM IMPORT ADDRESS; diff --git a/lang/m2/libm2/Storage.mod b/lang/m2/libm2/Storage.mod index e3e30faa2..19a7d3b0a 100644 --- a/lang/m2/libm2/Storage.mod +++ b/lang/m2/libm2/Storage.mod @@ -1,5 +1,16 @@ +(* + (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. diff --git a/lang/m2/libm2/StrAss.c b/lang/m2/libm2/StrAss.c index 371042d0a..92f100119 100644 --- a/lang/m2/libm2/StrAss.c +++ b/lang/m2/libm2/StrAss.c @@ -1,3 +1,14 @@ +/* + (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; { @@ -6,8 +17,7 @@ _StringAssign(dstsiz, srcsiz, dstaddr, srcaddr) srcsiz--; dstsiz--; } - while (dstsiz > 0) { - *dstaddr++ = 0; - dstsiz--; + if (dstsiz > 0) { + *dstaddr = 0; } } diff --git a/lang/m2/libm2/Streams.def b/lang/m2/libm2/Streams.def index 4bdc85168..e61336723 100644 --- a/lang/m2/libm2/Streams.def +++ b/lang/m2/libm2/Streams.def @@ -1,5 +1,9 @@ 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. @@ -134,10 +138,16 @@ DEFINITION MODULE Streams; 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. diff --git a/lang/m2/libm2/Streams.mod b/lang/m2/libm2/Streams.mod index 23f472ecd..dd4f918e2 100644 --- a/lang/m2/libm2/Streams.mod +++ b/lang/m2/libm2/Streams.mod @@ -1,8 +1,21 @@ +# +(* + (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 @@ -332,7 +345,7 @@ IMPLEMENTATION MODULE Streams; BEGIN currpos := 0D; IF (s = NIL) OR (s^.kind = none) THEN - result := illegaloperation; + result := nostream; RETURN; END; IF (s^.mode # reading) THEN @@ -360,6 +373,24 @@ IMPLEMENTATION MODULE Streams; 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); @@ -383,7 +414,7 @@ BEGIN maxcnt := 0; cnt := 0; bufferedcnt := BUFSIZ; - IF TTY.isatty(1) THEN + IF isatty(OutputStream) THEN buffering := linebuffered; ELSE buffering := blockbuffered; @@ -398,7 +429,7 @@ BEGIN maxcnt := 0; cnt := 0; bufferedcnt := BUFSIZ; - IF TTY.isatty(2) THEN + IF isatty(ErrorStream) THEN buffering := linebuffered; ELSE buffering := blockbuffered; diff --git a/lang/m2/libm2/Strings.def b/lang/m2/libm2/Strings.def index a5ce67eae..d2f22d558 100644 --- a/lang/m2/libm2/Strings.def +++ b/lang/m2/libm2/Strings.def @@ -1,4 +1,9 @@ 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. *) diff --git a/lang/m2/libm2/Strings.mod b/lang/m2/libm2/Strings.mod index 9d1226132..20e6ccce9 100644 --- a/lang/m2/libm2/Strings.mod +++ b/lang/m2/libm2/Strings.mod @@ -1,5 +1,15 @@ +(* + (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 diff --git a/lang/m2/libm2/Terminal.def b/lang/m2/libm2/Terminal.def index 1a5a71a52..7ea3e63c1 100644 --- a/lang/m2/libm2/Terminal.def +++ b/lang/m2/libm2/Terminal.def @@ -1,4 +1,9 @@ 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 diff --git a/lang/m2/libm2/Terminal.mod b/lang/m2/libm2/Terminal.mod index 2c905a2a1..0ac6c61c3 100644 --- a/lang/m2/libm2/Terminal.mod +++ b/lang/m2/libm2/Terminal.mod @@ -1,7 +1,17 @@ # +(* + (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; diff --git a/lang/m2/libm2/Traps.def b/lang/m2/libm2/Traps.def index 46d34aa1b..fc6d17421 100644 --- a/lang/m2/libm2/Traps.def +++ b/lang/m2/libm2/Traps.def @@ -1,4 +1,9 @@ DEFINITION MODULE Traps; +(* + Module: Facility for handling traps + Author: Ceriel J.H. Jacobs + Version: $Header$ +*) IMPORT EM; diff --git a/lang/m2/libm2/Traps.mod b/lang/m2/libm2/Traps.mod index 2e8f9ff25..e8874b737 100644 --- a/lang/m2/libm2/Traps.mod +++ b/lang/m2/libm2/Traps.mod @@ -1,5 +1,16 @@ +(* + (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; diff --git a/lang/m2/libm2/Unix.def b/lang/m2/libm2/Unix.def index afa212328..57e238e99 100644 --- a/lang/m2/libm2/Unix.def +++ b/lang/m2/libm2/Unix.def @@ -1,6 +1,10 @@ (*$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 *) diff --git a/lang/m2/libm2/absd.c b/lang/m2/libm2/absd.c index f0d5c5334..51ce0b5d4 100644 --- a/lang/m2/libm2/absd.c +++ b/lang/m2/libm2/absd.c @@ -1,3 +1,13 @@ +/* + (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) diff --git a/lang/m2/libm2/absf.e b/lang/m2/libm2/absf.e index f52bcbe59..ff9f4d9ec 100644 --- a/lang/m2/libm2/absf.e +++ b/lang/m2/libm2/absf.e @@ -1,4 +1,13 @@ # +; +; (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 diff --git a/lang/m2/libm2/absi.c b/lang/m2/libm2/absi.c index 16c883849..438179203 100644 --- a/lang/m2/libm2/absi.c +++ b/lang/m2/libm2/absi.c @@ -1,3 +1,14 @@ +/* + (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; diff --git a/lang/m2/libm2/absl.c b/lang/m2/libm2/absl.c index 20feb980d..ae8aa4c34 100644 --- a/lang/m2/libm2/absl.c +++ b/lang/m2/libm2/absl.c @@ -1,3 +1,13 @@ +/* + (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; diff --git a/lang/m2/libm2/catch.c b/lang/m2/libm2/catch.c index 2e6a4ae6d..ca6402c35 100644 --- a/lang/m2/libm2/catch.c +++ b/lang/m2/libm2/catch.c @@ -1,3 +1,13 @@ +/* + (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 #include diff --git a/lang/m2/libm2/confarray.c b/lang/m2/libm2/confarray.c index 2e89d8dbe..204ae69a3 100644 --- a/lang/m2/libm2/confarray.c +++ b/lang/m2/libm2/confarray.c @@ -1,3 +1,13 @@ +/* + (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 struct descr { diff --git a/lang/m2/libm2/halt.c b/lang/m2/libm2/halt.c index d9571a191..f07035093 100644 --- a/lang/m2/libm2/halt.c +++ b/lang/m2/libm2/halt.c @@ -1,3 +1,13 @@ +/* + (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; diff --git a/lang/m2/libm2/head_m2.e b/lang/m2/libm2/head_m2.e index b990ddfbd..c9bfc2a23 100644 --- a/lang/m2/libm2/head_m2.e +++ b/lang/m2/libm2/head_m2.e @@ -1,22 +1,13 @@ # -/* - * (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 diff --git a/lang/m2/libm2/load.c b/lang/m2/libm2/load.c index f88e9a6db..893b33c47 100644 --- a/lang/m2/libm2/load.c +++ b/lang/m2/libm2/load.c @@ -1,3 +1,13 @@ +/* + (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; diff --git a/lang/m2/libm2/random.def b/lang/m2/libm2/random.def index 44d31f77c..d79e0d346 100644 --- a/lang/m2/libm2/random.def +++ b/lang/m2/libm2/random.def @@ -1,4 +1,9 @@ DEFINITION MODULE random; +(* + Module: random numbers + Author: Ceriel J.H. Jacobs + Version: $Header$ +*) PROCEDURE Random(): CARDINAL; (* Return a random CARDINAL @@ -9,4 +14,9 @@ PROCEDURE Uniform (lwb, upb: CARDINAL): 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. diff --git a/lang/m2/libm2/random.mod b/lang/m2/libm2/random.mod index ca6fb3401..ef983c83a 100644 --- a/lang/m2/libm2/random.mod +++ b/lang/m2/libm2/random.mod @@ -1,5 +1,15 @@ +(* + (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]; @@ -21,12 +31,17 @@ BEGIN 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. diff --git a/lang/m2/libm2/rcki.e b/lang/m2/libm2/rcki.e index 57d2b7e9f..72df511f6 100644 --- a/lang/m2/libm2/rcki.e +++ b/lang/m2/libm2/rcki.e @@ -1,4 +1,13 @@ # +; +; (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 mes 2,EM_WSIZE,EM_PSIZE diff --git a/lang/m2/libm2/rckil.e b/lang/m2/libm2/rckil.e index 5b373a7d0..88f461c9a 100644 --- a/lang/m2/libm2/rckil.e +++ b/lang/m2/libm2/rckil.e @@ -1,4 +1,13 @@ # +; +; (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 mes 2,EM_WSIZE,EM_PSIZE diff --git a/lang/m2/libm2/rcku.e b/lang/m2/libm2/rcku.e index ffb1c8c87..687ea51d0 100644 --- a/lang/m2/libm2/rcku.e +++ b/lang/m2/libm2/rcku.e @@ -1,4 +1,13 @@ # +; +; (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 mes 2,EM_WSIZE,EM_PSIZE diff --git a/lang/m2/libm2/rckul.e b/lang/m2/libm2/rckul.e index 6bac67c82..62fb78d18 100644 --- a/lang/m2/libm2/rckul.e +++ b/lang/m2/libm2/rckul.e @@ -1,4 +1,13 @@ # +; +; (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 mes 2,EM_WSIZE,EM_PSIZE diff --git a/lang/m2/libm2/stackprio.c b/lang/m2/libm2/stackprio.c index a1fcd7ca6..c7b195300 100644 --- a/lang/m2/libm2/stackprio.c +++ b/lang/m2/libm2/stackprio.c @@ -1,3 +1,13 @@ +/* + (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) { } diff --git a/lang/m2/libm2/store.c b/lang/m2/libm2/store.c index 6a728785d..b306e879e 100644 --- a/lang/m2/libm2/store.c +++ b/lang/m2/libm2/store.c @@ -1,3 +1,13 @@ +/* + (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; diff --git a/lang/m2/libm2/transfer.e b/lang/m2/libm2/transfer.e index 8d18160f1..65d693f25 100644 --- a/lang/m2/libm2/transfer.e +++ b/lang/m2/libm2/transfer.e @@ -1,4 +1,16 @@ # +; +; (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 #include