[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

makeinfo texinfo-format-buffer

1. Using GNU Modula-2

This document contains the user and design issues relevant to the Modula-2 front end to gcc. Throughout this document the GNU Modula-2 front end is often referred to as `gm2-0.53' or `gm2' for short. This corresponds to GCC version 4.1.1 and GNU Modula-2 version 0.53.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1 What is GNU Modula-2

GNU Modula-2 is a front end http://gcc.gnu.org/frontends.html for GCC. GCC is a retargetable C compiler which has been ported to a large number of architectures and operating systems. GNU Modula-2 utilizes the back end of GCC and replaces the C language front end with a Modula-2 front end. Consequently GNU Modula-2 has been built on i[3456]86 GNU/Linux, i[3456]86 BSD, Opteron LP64 GNU/Linux and sparc GNU/Linux systems. It has also been built as a cross compiler for MinGW and StrongARM GNU/Linux.

The GNU Modula-2 compiler is based on the language as defined in 'Programming in Modula-2' 2nd Edition, Springer Verlag, 1982, 1983 by Niklaus Wirth (PIM2), 'Programming in Modula-2', 3rd Corrected Edition, Springer Verlag, 1985 (PIM3) and 'Programming in Modula-2', 4th Edition, Springer Verlag, 1988 (PIM4). It also includes ISO M2 features and GNU Modula-2 extensions. Currently GNU Modula-2 (0.53) implements all PIM dialects of the language, eventually GNU Modula-2 will be fully compliant with ISO Modula-2.

There are currently three sets of libraries. The 'Programming in Modula-2' libraries, the 'University of ULM libraries' and the ISO libraries. The ISO libraries are still being written, however all definition modules for the three library sets are contained within this document.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.2 Why use GNU Modula-2

This section is not designed to generate a language war, but rather map out some of the advantages of using GNU Modula-2 rather than translate Modula-2 sources into another language.

It is expected that the primary purpose of GNU Modula-2 will be to compile legacy code. Currently there are only a few commercial Modula-2 compilers being actively maintained. Code which was written ten or fifteen years ago may still be compiled by older commercial (possibly unmaintained) compilers. While the 32 bit x86 remains these compilers presumably can be run in compatibility mode (some compilers only produced 16 bit code). Time is running out as the computing industry is switching to 64 microprocessors. While x86 emulation or 16 bit backwards compatibility is always possible it has some serious drawbacks. In order for the older source to run natively the source code will either have to be translated into another high level language or alternatively a Modula-2 compiler which can target these new generation of microprocessors will have to be acquired. GNU Modula-2 builds and passes all its regression tests on Debian Pure 64 (LP64 architecture), 64 bit Solaris, 32 bit x86 GNU/Linux (Suse 9.1, Debian, stable and unstable) and 32 bit x86 FreeBSD.

GNU Modula-2 also has the advantage of being closely tied to GCC. Not only does this produce excellent code and excellent architectural and operating system coverage but it also utilises many of the GCC features. For example GNU Modula-2 can invoke the C preprocessor to manage conditional compilation; in-lining of SYSTEM procedures, intrinsic functions, memory copying routines are also exploited; access to assembly language using GCC syntax is also provided. GNU Modula-2 also support sets of any ordinal type (memory permitting).

GNU Modula-2 was based on a Modula-2 front end which performed a substantial amount of static analysis of the source code (see `-Wpedantic', `-Wpedantic-param-names', `-Wstudents' and `-Wpedentic-cast'.

Finally runtime checking has been implemented and can check: bounds of subranges and array indexes, functions execute a RETURN statement, a pointer does not dereference a NIL pointer value and that the expression within a CASE statement is correctly matched.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.3 Release map

This section attempts to give an idea of which releases points are likely in the future. Clearly this is a fairly fluid release map but hopefully it is more helpful than omitting it altogether. Please note that this is not set in stone and if you (the users) wish to see something different please email gaius@gnu.org with your ideas. Also please note that the actual release numbers do not have any correlation to the estimated time of release. For example please do not misunderstand that GM2-1.0 will take twice as long as GM2-0.5 to appear. It is worthing noting that some of the later points in the release life have already been addressed (in part) but are not yet complete.

0.50

compatible with gcc-3.3.6. GNU Modula-2 is stable and passes all regression tests on LP64 Opteron and 32 bit x86 GNU/Linux. The compiler is PIM-234 compatible (use `-Wpim2', `-Wpim3' and `-Wpim4' to force mutually exclusive PIM features).

It is also able to compile the University of Ulm libraries which are now distributed as part of GNU Modula-2. To reference these libraries use the `-Wlibs=ulm' compiler switch.

0.60

many Logitech compatible libraries will be provided, which will be available when invoked by `-Wpim'.

0.80

a full set of ISO libraries will have been implemented. GNU Modula-2 will be sufficiently ISO compliant to compile the libraries but will not yet be able to fully conform to the ISO Modula-2 standard.

1.0

GNU Modula-2 will be fully ISO compliant.

There will be releases inbetween those outlined above and these releases may occur when GNU Modula-2 builds using a different GCC source tree. It is a goal that backward compatibility to gcc-3.3.6 will be provided as far as it is possible. Releases will also occur if a key component of ISO Modula-2 is implemented (for example exception handling, complex types or `FINALLY' is implemented).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.4 Compiler options

This section describes the compiler options specific to GNU Modula-2 for generic flags details see See (gcc)Invoking GCC.

-Wmakeall

generate a temporary makefile and build all dependent modules and link.

-Wbounds

generate code to check the bounds of subranges and array indexes.

-Wreturn

generate code to check that functions always exit with a RETURN and do not fall out at the end.

-Wnil

turns on runtime checking to detect accessing data through a NIL value pointer.

-Wcase

turns on runtime checking to check whether a CASE statement requires an ELSE clause when on was not specified.

-Wcheck-all

turns on all runtime checks. This is the same as invoking GNU Modula-2 using the command options -Wbounds -Wreturn -Wnil -Wcase.

-v

display all calls to subsidiary programs, such as the C preprocessor, the GNU Modula-2 linker and compiler.

-Wstatistics

generates quadruple information: number of quadruples generated, number of quadruples remaining after optimisation.

-Wstudents

checks for bad programming style. This option is aimed at new users of Modula-2 in that it checks for situations which might cause confusion and thus mistakes. It checks whether variables of the same name are declared in different scopes and whether variables look like keywords. Experienced users might find this option too aggressive.

-Wpedantic

forces the compiler to reject nested WITH statements referencing the same record type. Does not allow multiple imports of the same item from a module. It also checks that: procedure variables are written to before being read; variables are not only written to but read from; variables are declared and used. If the compiler encounters a variable being read before written it will terminate with a message. It will check that FOR loop indices are not used outside the end of this loop without being reset.

-Wpedantic-param-names

procedure parameter names are checked in the definition module against their implementation module counterpart. This is not necessary in ISO or PIM versions of Modula-2, but it can be extremely useful, as long as code is intentionally written in this way.

-Wpedantic-cast

warns if the ISO system function is used and if the size of the variable is different from that of the type. This is legal in ISO Modula-2, however it can be dangerous. Some users may prefer to use VAL instead in these situations and use CAST exclusively for changes in type on objects which have the same size.

-Wmakelist

this option is only applicable when linking a program module. The compiler will generate a `modulename.lst' file which contains a list indicating the initialisation order of all modules which are to be linked. The actual link does not occur. The GNU Modula-2 linker scans all IMPORTs, generates a list of dependencies and produces an ordered list for initialisation. It will probably get the order wrong if your project has cyclic dependencies, but the `.lst' file is plain text and can be modified if required. Once the `.lst' file is created it can be used by the compiler to link your project via the `-Wuselist' option. It has no effect if the `-c' option is present.

-Wuselist

providing `gm2' has been told to link the program module this option uses the file `modulename.lst' for the initialisation order of modules.

-Wcpp

preprocess the source with `cpp -lang-asm -traditional-cpp' For further details about these options see See (cpp)Invocation. If `-Wcpp' is supplied then all definition modules and implementation modules which are parsed will be preprocessed by `cpp'.

-Wiso

turn on ISO standard features. Currently this enables the ISO SYSTEM module and alters the default library search path so that the ISO libraries are searched before the PIM libraries. It also effects the behaviour of DIV and MOD operators. See See (gm2)Dialect.

-Wpim

turn on PIM standard features. Currently this enables the PIM SYSTEM module and determines which identifiers are pervasive (declared in the base module). If no other `-Wpim[234]' switch is used then division and modulus operators behave as defined in PIM4. See See (gm2)Dialect.

-Wpim2

turn on PIM-2 standard features. Currently this removes SIZE from being a pervasive identifier (declared in the base module). It places SIZE in the SYSTEM module. It also effects the behaviour of DIV and MOD operators. See See (gm2)Dialect.

-Wpim3

turn on PIM-3 standard features. Currently this only effects the behaviour of DIV and MOD operators. See See (gm2)Dialect.

-Wpim4

turn on PIM-4 standard features. Currently this only effects the behaviour of DIV and MOD operators. See See (gm2)Dialect.

-Wpositive-mod-floor-div

forces the DIV and MOD operators to behave as defined by PIM4. All modulus results are positive and the results from the division are rounded to the floor. See See (gm2)Dialect.

-Wlibs=ulm

modifies the default library search path so that the University of Ulm libraries are searched before the other PIM libraries.

-Wlibs=pim

modifies the default library search path so that the PIM libraries are searched before any others (the default).

-Wlibs=iso

modifies the default library search path so that the ISO libraries are searched before any others (not needed if `-Wiso' was specified).

-Wlibs=logitech

modifies the default library search path so that the Logitech compatible libraries are searched before the base PIM libraries.

-Wlibs=pim-coroutine

modifies the default libraries search path so that the PIM SYSTEM module providing coroutine support is searched before the base PIM libraries. This directory also includes many coroutine related libraries.

-Wextended-opaque

allows opaque types to be implemented as any type. This is a GNU Modula-2 extension and it requires that the implementation module defining the opaque type is available so that it can be resolved when compiling the module which imports the opaque type.

-Wsources

displays the path to the source of each module.

-Wdef=

recognise the specified suffix as a definition module filename. The default implmentation and module filename suffix is `.def'. If this option is used GNU Modula-2 will still fall back to this default if a requested definition module is not found.

-Wmod=

recognise the specified suffix as implementation and module filenames. The default implmentation and module filename suffix is `.mod'. If this option is used GNU Modula-2 will still fall back to this default if it needs to read an implmentation module and the specified suffixed filename does not exist. Both this option and -Wdef= also work with the -Wmakeall option.

-Wverbose-unbounded

inform the user which non VAR unbounded parameters will be passed by reference. This only produces output if the option `-funbounded-by-reference' is also supplied on the command line.

-funbounded-by-reference

enable optimization of unbounded parameters by attempting to pass non VAR unbounded parameters by reference. This optimization avoids the implicit copy inside the callee procedure. GNU Modula-2 will only allow unbounded parameters to be passed by reference if, inside the callee procedure, they are not written to, no address is calculated on the array and it is not passed as a VAR parameter. Note that it is possible to write code to break this optimization, therefore this option should be used carefully. For example it would be possible to take the address of an array, pass the address and the array to a procedure, read from the array in the procedure and write to the location using the address parameter.

Due to the dangerous nature of this option it is not enabled when the -O option is specified.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.5 Example compile and link

This section describes how to compile and link a simple hello world program. It provides a few examples of using the different options mentioned in See (gm2)Compiler options. Assuming that you have a file called `hello.mod' in your current directory which contains:

 
MODULE hello ;

FROM StrIO IMPORT WriteString, WriteLn ;

BEGIN
   WriteString('hello world') ; WriteLn
END hello.

You should be able to compile it by: `gm2 -c -g -I. hello.mod' and link via: `gm2 -g -I. hello.mod'. The result should be an `a.out' file created in your directory.

Alternatively it may be compiled by:

`gm2 -g -I. -Wmakeall hello.mod' (1)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.6 Elementary data types

This section describes the elementary data types supported by GNU Modula-2. It also describes the relationship between these data types and the equivalent C data types.

The following data types are supported: INTEGER, LONGINT, SHORTINT, CARDINAL, LONGCARD, SHORTCARD, BOOLEAN, REAL, LONGREAL, SHORTREAL, and CHAR.

An equivalence table is given below:

 
GNU Modula-2              GNU C
======================================
INTEGER                   int
LONGINT                   long long int
SHORTINT                  short int
CARDINAL                  unsigned int
LONGCARD                  long long unsigned int
SHORTCARD                 short unsigned int
BOOLEAN                   int
REAL                      double
LONGREAL                  long double
SHORTREAL                 float
CHAR                      char

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.7 Permanently accessible base procedures.

This section describes the procedures and functions which are always visible.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.7.1 Standard procedures and functions common to PIM and ISO

The following procedures are implemented and conform with Programming in Modula-2 and ISO Modula-2: NEW, DISPOSE, INC, DEC, INCL, EXCL and HALT. The standard functions are: HIGH, CAP, ABS, ODD, VAL, CHR, MIN, MAX. All these functions and procedures (except HALT, NEW, DISPOSE and, under non constant conditions, LENGTH) generate in-line code for efficiency.

 
(*
   NEW - the procedure NEW is replaced by:
         ALLOCATE(p, TSIZE(p^)) ;
         The user is expected to import the procedure ALLOCATE
         (normally found in the module, Storage.)

         In:  a variable p: of any pointer type.
         Out: variable, p, is set to some allocated memory
              which is large enough to hold all the contents of p^.
*)

PROCEDURE NEW (VAR p:<any pointer type>) ;
 
(*
   DISPOSE - the procedure DISPOSE is replaced by:
             DEALLOCATE(p, TSIZE(p^)) ;
             The user is expected to import the procedure DEALLOCATE
             (normally found in the module, Storage.)

             In:  a variable p: of any pointer type which has been
                  initialized by a call to NEW.
             Out: the area of memory
                  holding p^ is returned to the system.
                  Note that the underlying procedure DEALLOCATE
                  procedure in module Storage will assign p to NIL.
*)

PROCEDURE DISPOSE (VAR p:<any pointer type>) ;
 
(*
   INC - can take one or two parameters. If supplied with one
         parameter it adds 1 to the variable, v.
         If two parameters are supplied then the value, a, is
         added to, v.
*)

PROCEDURE INC (VAR v: <any base type>; [a: <any base type> = 1]) ;
 
(*
   DEC - can take one or two parameters. If supplied with one
         parameter it subtracts 1 from the variable, v.
         If two parameters are supplied then the value, a, is
         subtracted from, v.
*)

PROCEDURE DEC (VAR v: <any base type>; [a: <any base type> = 1]) ;
 
(*
   INCL - includes bit element, e, to a set type, s.
*)

PROCEDURE INCL (VAR s: <any set type>; e: <element of set type s>) ;
 
(*
   EXCL - excludes bit element, e, from a set type, s.
*)

PROCEDURE EXCL (VAR s: <any set type>; e: <element of set type s>) ;
 
(*
   HALT - will call the HALT procedure inside the module M2RTS.
          Users can replace M2RTS.
*)

PROCEDURE HALT ;

The following define the standard set of functions which conform with Programming in Modula-2 and ISO Modula-2.

 
(*
   HIGH - returns the last accessible index of an parameter declared as
          ARRAY OF CHAR. Thus

          PROCEDURE foo (a: ARRAY OF CHAR) ;
          VAR
             c: CARDINAL ;
          BEGIN
             c := HIGH(a)
          END foo ;

          BEGIN
             foo('hello')
          END

          will cause the local variable, c, to contain the value 4
*)

PROCEDURE HIGH (a: ARRAY OF CHAR) : CARDINAL ;
 
(*
   CAP - returns the capital of character, ch, providing
         ch lies within the range 'a'..'z'. Otherwise, ch,
         is returned unaltered.
*)

PROCEDURE CAP (ch: CHAR) : CHAR ;

 
(*
   ABS - returns the positive value of, i.
*)

PROCEDURE ABS (i: <any signed type>) : <any signed type> ;

 
(*
   VAL - converts data, i, of <any simple data type 2> to
         <any simple data type 1> and returns this value.
         No range checking is performed during this conversion.
*)

PROCEDURE VAL (<any simple data type 1>,
               i: <any simple data type 2>) : <any simple data type 1> ;

 
(*
   CHR - converts a value of a <whole number type> into a CHAR.
         CHR(x) is shorthand for VAL(CHAR, x).
*)

PROCEDURE CHR (x: <whole number type>) : CHAR ;

 
(*
   ODD - returns TRUE if the value is not divisible by 2.
*)

PROCEDURE ODD (x: <whole number type>) : BOOLEAN ;

 
(*
   MIN - returns the lowest legal value of an ordinal type.
*)

PROCEDURE MIN (t: <ordinal type>) : <ordinal type> ;

 
(*
   MAX - returns the largest legal value of an ordinal type.
*)

PROCEDURE MAX (t: <ordinal type>) : <ordinal type> ;


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.7.2 ISO specific standard procedures and functions

The standard function LENGTH is specific to ISO Modula-2 and is defined as:

 
(*
   LENGTH - returns the length of string, a.
*)

PROCEDURE LENGTH (a: ARRAY OF CHAR) : CARDINAL ;

This function is evaluated at compile time, providing that string a is a constant. If a cannot be evaluated then a call is made to M2RTS.Length.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.8 GNU Modula-2 supported dialects

This section describes the dialects understood by GNU Modula-2. It also describes the differences between the dialects and any command line switches which determine dialect behaviour.

The GNU Modula-2 compiler is based on the language as defined in 'Programming in Modula-2' 2nd Edition, Springer Verlag, 1982, 1983 by Niklaus Wirth (PIM2), 'Programming in Modula-2', 3rd Corrected Edition, Springer Verlag, 1985 (PIM3) and 'Programming in Modula-2', 4th Edition, Springer Verlag, 1988 (PIM4). It also includes ISO M2 features and GNU Modula-2 extensions. Currently GNU Modula-2 (0.53) implements all PIM dialects of the language, eventually GNU Modula-2 will be fully compliant with ISO Modula-2.

The command line switches `-Wpim2', `-Wpim3', `-Wpim4' and `-Wiso' can be used to force mutually exclusive features. However by default the compiler will not agressively fail if a non mutually exclusive feature is used from another dialect. For example it is possible to specify `-Wpim2' and still utilise `DEFINITION' `MODULES' which have no export list.

Some dialect differences will force a compile time error, for example in PIM2 the user must IMPORT SIZE from the module SYSTEM, whereas in PIM3 and PIM4 SIZE is a pervasive function. Thus compiling PIM4 source code with the `-Wpim2' switch will cause a compile time error. This can be fixed quickly with an additional IMPORT or alternatively by compiling with the `-Wpim4' switch.

However there are some very important differences between the dialects which are mutually exclusive and therefore it is vital that users choose the dialects with care when these language features are used.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.8.1 Integer division, remainder and modulus

The most dangerous set of mutually exclusive features found in the four dialects supported by GNU Modula-2 are the INTEGER division, remainder and modulus arithmetic operators. It is important to note that the same source code can be compiled to give different runtime results depending upon these switches! The reference manual for the various dialects of Modula-2 are quite clear about this behaviour and sadly there are three distinct definitions.

The table below illustrates the problem when a negative operand is used.

 
                  Pim2/3          Pim4                ISO
               -----------    -----------    ----------------------
lval    rval   DIV     MOD    DIV     MOD    DIV    MOD    /    REM
 31      10      3       1      3       1      3      1     3     1
-31      10     -3      -1     -4       9     -4      9    -3    -1
 31     -10     -3       1     -3       1     Exception    -3     1
-31     -10      3      -1      4       9     Exception     3    -1

See also P24 of PIM2, P27 of PIM3, P29 of PIM4 and P201 of the ISO Standard. At present all dialect division, remainder and modulus are implemented as above, apart from the exception calling in the ISO dialect. Instead of exception handling the results are the same as the PIM4 dialect. This is a temporary implementation situation.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.9 GNU Modula-2 language extensions

This section introduces the GNU Modula-2 language extensions. The GNU Modula-2 compiler allows abstract data types to be any type, not just restricted to a pointer type providing the `-Wextended-opaque' option is supplied See (gm2)Compiler options.

Declarations can be made in any order, whether they are types, constants, procedures, nested modules or variables (see See section Passes.)

GNU Modula-2 also allows programmers to interface to C and assembly language.

GNU Modula-2 provides support for the special tokens __LINE__, __FILE__, __FUNCTION__ and __DATE__. Support for these tokens will occur even if the `-Wcpp' option is not supplied. A table of these identifiers and their data type and values is given below:

 
Scope       GNU Modula-2 token      Data type and example value

anywhere    __LINE__                Constant Literal compatible
                                    with CARDINAL, INTEGER and WORD.
                                    Example 1234

anywhere    __FILE__                Constant string compatible
                                    with parameter ARRAY OF CHAR or
                                    an ARRAY whose SIZE is >= string
                                    length. Example
                                    "hello.mod"

procedure   __FUNCTION__            Constant string compatible
                                    with parameter ARRAY OF CHAR or
                                    an ARRAY whose SIZE is >= string
                                    length. Example
                                    "calc"

module      __FUNCTION__            Example
                                    "module hello initialization"

anywhere    __DATE__                Constant string compatible
                                    with parameter ARRAY OF CHAR or
                                    an ARRAY whose SIZE is >= string
                                    length. Example
                                    "Thu Apr 29 10:07:16 BST 2004"

The preprocessor `cpp' can be invoked via the `-Wcpp' command line option. This in turn invokes `cpp' with the following arguments `-traditional -lang-asm'. These options preserve comments and all quotations. `gm2' treats a `#' character in the first column as a preprocessor directive.

For example here is a module which calls FatalError via the macro ERROR.

 
MODULE cpp ;

FROM SYSTEM IMPORT ADR, SIZE ;
FROM libc IMPORT exit, printf, malloc ;

PROCEDURE FatalError (a, file: ARRAY OF CHAR;
                         line: CARDINAL;
                         func: ARRAY OF CHAR) ;
VAR
   r: INTEGER ;
BEGIN
   r := printf("%s:%d:fatal error, %s, in %s\n",
               ADR(file), line, ADR(a), ADR(func)) ;
   exit(1)
END FatalError ;

#define ERROR(X)  FatalError(X, __FILE__, __LINE__, __FUNCTION__)

VAR
   pc: POINTER TO CARDINAL;
BEGIN
   pc := malloc(SIZE(CARDINAL)) ;
   IF pc=NIL
   THEN
      ERROR('out of memory')
   END
END cpp.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.9.1 Optional procedure parameter

GNU Modula-2 allows the last parameter to a procedure or function parameter to be optional. For example in the ISO library `COROUTINES.def' the procedure NEWCOROUTINE is defined as having an optional fifth argument (initProtection) which, if absent, is automatically replaced by NIL.

 
PROCEDURE NEWCOROUTINE (procBody: PROC; workspace: SYSTEM.ADDRESS;
                        size: CARDINAL; VAR cr: COROUTINE;
                        [initProtection: PROTECTION = NIL]);

  (* Creates a new coroutine whose body is given by procBody,
     and returns the identity of the coroutine in cr.
     workspace is a pointer to the work space allocated to
     the coroutine; size specifies the size of this workspace
     in terms of SYSTEM.LOC.

     The optional fifth argument may contain a single parameter
     which specifies the initial protection level of the coroutine.
  *)

The implementation module `COROUTINES.mod' implements this procedure using the following syntax:

 
PROCEDURE NEWCOROUTINE (procBody: PROC; workspace: SYSTEM.ADDRESS;
                        size: CARDINAL; VAR cr: COROUTINE;
                        [initProtection: PROTECTION]);
BEGIN
   
END NEWCOROUTINE ;

Note that it is illegal for this declaration to contain an initialiser value for initProtection. However it is necessary to surround this parameter with the brackets [ and ]. This serves to remind the programmer that the last parameter was declared as optional in the definition module.

Local procedures can be declared to have an optional final parameter in which case the initializer is mandatory in the implementation or program module.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.10 Interfacing GNU Modula-2 to C

The GNU Modula-2 compiler tries to use the C calling convention wherever possible however some parameters have no C equivalent and thus a language specific method is used. For example unbounded arrays are passed as a struct void *address, unsigned int high and the contents of these arrays are copied by callee functions when they are declared as non VAR parameters. The VAR equivalent unbounded array parameters need no copy, but still use the struct representation.

The recommended method of interfacing GNU Modula-2 to C is by telling the definition module that the implementation is in the C language. This is achieved by using the tokens DEFINITION MODULE FOR "C". Here is an example which can be found in the source tree `gcc-version/gcc/gm2/examples/callingC/libprintf.def'

 
DEFINITION MODULE FOR "C" libprintf ;

EXPORT UNQUALIFIED printf ;

PROCEDURE printf (a: ARRAY OF CHAR; ...) ;

END libprintf.

the UNQUALIFIED keyword in the definition module informs GNU Modula-2 not to prefix the module name to exported references in the object file.

The printf declaration states that the first parameter semantically matches ARRAY OF CHAR but since the module is for the C language it will be mapped onto char *. The token ... indicates a variable number of arguments (varargs) and all parameters passed here are mapped onto their C equivalents. Arrays and constant strings are passed as pointers.

The hello world program can be rewritten as:

 
MODULE hello ;

FROM libprintf IMPORT printf ;

BEGIN
   printf("hello world\n")
END hello.

and it can be compiled by:

`gm2 -Wmakeall -g -I. hello.mod -lc'

In reality the `-lc' is redundant as libc is always included in the linking process. It is shown here to emphasize that the C library or object file containing printf must be present.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.11 Semi-automatic translation of C header files

The tool `h2def' can be used to semi-automatically generate DEFINITION MODULE FOR "C" modules. The tool takes as input a C header file and generates as output a corresponding textual definition module. While the tool will not automatically translate complex C header files it will generate definition modules for simple header files.

For example consider the following excerpt from the header file (`vga.h'):

 
/* blit flags */
#define HAVE_BITBLIT 1
#define HAVE_FILLBLIT 2
#define HAVE_IMAGEBLIT 4
#define HAVE_HLINELISTBLIT 8
#define HAVE_BLITWAIT 16

    typedef struct {
	int width;
	int height;
	int bytesperpixel;
	int colors;
	int linewidth;		/* scanline width in bytes */
	int maxlogicalwidth;	/* maximum logical scanline width */
	int startaddressrange;	/* changeable bits set */
	int maxpixels;		/* video memory / bytesperpixel */
	int haveblit;		/* mask of blit functions available */
	int flags;		/* other flags */

	/* Extended fields: */

	int chiptype;		/* Chiptype detected */
	int memory;		/* videomemory in KB */
	int linewidth_unit;	/* Use only a multiple of this as parameter for set_logicalwidth and
				   set_displaystart */
	char *linear_aperture;	/* points to mmap secondary mem aperture of card (NULL if unavailable) */
	int aperture_size;	/* size of aperture in KB if size>=videomemory. 0 if unavail */
	void (*set_aperture_page) (int page);
	/* if aperture_size<videomemory select a memory page */
	void *extensions;	/* points to copy of eeprom for mach32 */
	/* depends from actual driver/chiptype.. etc. */
    } vga_modeinfo;

    extern vga_modeinfo *vga_getmodeinfo(int mode);
    extern int vga_getdefaultmode(void);
    extern int vga_getcurrentmode(void);
    extern int vga_getcurrentchipset(void);
    extern char *vga_getmodename(int mode);

Using the following command line h2def vga.h will generate the module below:

 
DEFINITION MODULE FOR "C" vga ;

CONST
     HAVE_BITBLIT =  1 ;
     HAVE_FILLBLIT =  2 ;
     HAVE_IMAGEBLIT =  4 ;
     HAVE_HLINELISTBLIT =  8 ;
     HAVE_BLITWAIT =  16 ;

TYPE
     vga_modeinfo =   RECORD
                         width: INTEGER ;
                         height: INTEGER ;
                         bytesperpixel: INTEGER ;
                         colors: INTEGER ;
                         linewidth: INTEGER ;
                         maxlogicalwidth: INTEGER ;
                         startaddressrange: INTEGER ;
                         maxpixels: INTEGER ;
                         haveblit: INTEGER ;
                         flags: INTEGER ;
                         chiptype: INTEGER ;
                         memory: INTEGER ;
                         linewidth_unit: INTEGER ;
                         linear_aperture: POINTER TO CHAR ;
                         aperture_size: INTEGER ;
                         set_aperture_page:  PROCEDURE (INTEGER) ;
                         extensions: ADDRESS ;
                      END ;
    
 PROCEDURE vga_getmodeinfo (mode: INTEGER) : ADDRESS ;
 PROCEDURE vga_getdefaultmode () : INTEGER ;
 PROCEDURE vga_getcurrentmode () : INTEGER ;
 PROCEDURE vga_getcurrentchipset () : INTEGER ;
 PROCEDURE vga_getmodename (mode: INTEGER) : ADDRESS ;

END vga.

The main limitation of h2def is in the preprocessing handling. It does not understand the C preprocessor token constructor directives # and ##. Also it will not combine successive string tokens.

Support for the #define mechanism is limited. Initially the macro is parsed to check whether it is a constant expression. If it fails it is reassigned as a macro definition. A macro which contains C statement code cannot be translated into a definition module. These macros and all dependents are poisoned and are not translated. At present it does not understand macros with arguments.

The `-I' option to h2def allows include directories to be specified and the `-C' option states that a macro definition must be computed at compile time. For example consider the following header file called ifdef.h:

 
#if !defined(FOOBAR)
# define FOOBAR
# define MAXIMUM 1000
#else
# define MAXIMUM 2000
#endif

which if processed by h2def -CFOOBAR ifdef.h yields the following code:

 
DEFINITION MODULE FOR "C" ifdef ;

# if (!(defined(FOOBAR)))
CONST
   MAXIMUM = 1000 ;
# else
   MAXIMUM = 2000 ;
# endif
     
END ifdef.

The `-a' option provides a method whereby the C parameter construct sometype *foo is translated in Modula-2 as foo: ARRAY OF sometype.

Normally output for h2def will require some manual intervention. Some header files need more help than others, for example the GNU/Linux svga header file vga.h requires a little help whereas the GNU pthread file pthread.h requires more. Nevertheless the effort required is considerably less than writing the modules by hand.

The `-e' option will emit an error message if a C syntax error is encountered. The `-p' option generate a comment for every occurance of an object which cannot be translated into Modula-2.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.12 Interface to assembly language

The interface for GNU Modula-2 to assembly language is almost identical to GNU C. The only alterations are that the keywords asm and volatile are in capitals, following the Modula-2 convention.

A simple, but highly non optimal, example is given below. Here we want to add the two CARDINALs foo and bar together and return the result.

 
PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
VAR
   myout: CARDINAL ;
BEGIN
   ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
      : "=g" (myout)           (* outputs *)
      : "g" (foo), "g" (bar)   (* inputs  *)
      : "eax") ;               (* we trash *)
   RETURN( myout )
END Example ;

For a full description of this interface we refer the reader to the GNU C manual.

See (gcc)Extended Asm.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.13 Accessing GNU Modula-2 Built-ins

This section describes the built-in constants and functions defined in GNU Modula-2. The following compiler constants can be accessed using the __ATTRIBUTE__ __BUILTIN__ keywords. These are not part of the Modula-2 language and they may differ depending upon the target architecture but they provide a method whereby common libraries can interface to a different underlying architecture.

The built-in constants are: BITS_PER_UNIT, BITS_PER_WORD, BITS_PER_CHAR and UNITS_PER_WORD. They are integrated into GNU Modula-2 by an extension to the ConstFactor rule:

 
ConstFactor := ConstQualidentOrSet | Number | ConstString |
               "(" ConstExpression ")" | "NOT" ConstFactor |
               ConstAttribute =:

ConstAttribute := "__ATTRIBUTE__" "__BUILTIN__" "(" "(" Ident ")" ")" =:

Here is an example taken from the ISO library SYSTEM.def:

 
CONST
   BITSPERLOC    = __ATTRIBUTE__ __BUILTIN__ ((BITS_PER_UNIT)) ;
   LOCSPERWORD   = __ATTRIBUTE__ __BUILTIN__ ((UNITS_PER_WORD)) ;

Built-in functions are transparent to the end user. All built-in functions are declared in DEFINITION MODULEs and are imported as and when required. Built-in functions are declared in definition modules by using the __BUILTIN__ keyword. Here is a section of the ISO library LongMath.def which demonstrates this feature.

 
PROCEDURE __BUILTIN__ sqrt (x: LONGREAL): LONGREAL;
  (* Returns the square root of x *)

This indicates that the function sqrt will be implemented using the gcc built-in maths library. If gcc cannot utilise the built-in function (for example if the programmer requested the address of sqrt) then code is generated to call the alternative function implemented in the IMPLEMENTATION MODULE.

Sometimes a function exported from the DEFINITION MODULE will have a different name from the built-in function within gcc. In such cases the mapping between the GNU Modula-2 function name and the gcc name is expressed using the keywords __ATTRIBUTE__ __BUILTIN__ ((Ident)). For example the function sqrt in LongMath.def maps onto the gcc built-in function sqrtl and this is expressed as:

 
PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((sqrtl)) sqrt
                                    (x: LONGREAL) : LONGREAL;
  (* Returns the positive square root of x *)

The following module Builtins.def enumerates the list of built-in functions which can be accessed in GNU Modula-2. It also serves to define the parameter and return value for each function:

 
DEFINITION MODULE Builtins ;

FROM SYSTEM IMPORT ADDRESS ;

PROCEDURE __BUILTIN__ sinf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ sin (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sinl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ cosf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ cos (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ cosl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ sqrtf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ sqrt (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sqrtl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ fabsf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ fabs (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ fabsl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ alloca (i: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ memcpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ index (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE __BUILTIN__ rindex (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE __BUILTIN__ memcmp (s1, s2: ADDRESS; n: CARDINAL) : INTEGER ;
PROCEDURE __BUILTIN__ memset (s: ADDRESS; c: INTEGER; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ strcat (dest, src: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strncat (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ strcpy (dest, src: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strncpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ strcmp (s1, s2: ADDRESS) : INTEGER ;
PROCEDURE __BUILTIN__ strncmp (s1, s2: ADDRESS; n: CARDINAL) : INTEGER ;
PROCEDURE __BUILTIN__ strlen (s: ADDRESS) : INTEGER ;
PROCEDURE __BUILTIN__ strstr (haystack, needle: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strpbrk (s, accept: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strspn (s, accept: ADDRESS) : CARDINAL ;
PROCEDURE __BUILTIN__ strcspn (s, accept: ADDRESS) : CARDINAL ;
PROCEDURE __BUILTIN__ strchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE __BUILTIN__ strrchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE __BUILTIN__ huge_val (r: REAL) : REAL ;
PROCEDURE __BUILTIN__ huge_valf (s: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ huge_vall (l: LONGREAL) : LONGREAL ;

END Builtins.

Although this module exists and will result in the generation of in-line code if optimization flags are passed to GNU Modula-2, users are advised to utilize the same functions from more generic libraries. The built-in mechanism will be applied to these generic libraries where appropriate. Note for the mathematical routines to be in-lined you need to specify the `-ffast-math -O' options.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.14 The PIM system module

 
DEFINITION MODULE SYSTEM ;

EXPORT QUALIFIED (* the following are built into the compiler: *)
                 ADDRESS, WORD, BYTE, BITSET, ADR, TSIZE, SIZE ;

END SYSTEM.

The different dialects of Modula-2 PIM-[234] and ISO Modula-2 declare the function SIZE in different places. PIM-[34] and ISO Modula-2 declare SIZE as a pervasive function (declared in the base module). PIM-2 defined SIZE in the SYSTEM module (as shown above).

GNU Modula-2 allows users to specify the dialect of Modula-2 by using the -Wiso and -Wpim2 command line switches.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.15 The ISO system module

 
DEFINITION MODULE SYSTEM;

  (* Gives access to system programming facilities that are probably
     non portable. *)

  (* The constants and types define underlying properties of storage *)

EXPORT QUALIFIED BITSPERLOC, LOCSPERWORD,
                 LOC, BYTE, WORD, BITSET, ADDRESS,
                 ADDADR, SUBADR, DIFADR, MAKEADR, ADR, ROTATE,
                 SHIFT, CAST, TSIZE,

                 (* Internal GM2 compiler functions *)
                 ShiftVal, ShiftLeft, ShiftRight,
                 RotateVal, RotateLeft, RotateRight ;

CONST
                  (* <implementation-defined constant> ; *)
  BITSPERLOC    = __ATTRIBUTE__ __BUILTIN__ ((BITS_PER_UNIT)) ;
                  (* <implementation-defined constant> ; *)
  LOCSPERWORD   = __ATTRIBUTE__ __BUILTIN__ ((UNITS_PER_WORD)) ;
                  (* <implementation-defined constant> ; *)
  LOCSPERBYTE = 8 DIV BITSPERLOC ;

(*
   all the objects below are declared internally to gm2
   ====================================================

TYPE
  LOC; (* A system basic type. Values are the uninterpreted
          contents of the smallest addressable unit of storage *)
  ADDRESS = POINTER TO LOC;
  WORD = ARRAY [0 .. LOCSPERWORD-1] OF LOC;

  (* BYTE and LOCSPERBYTE are provided if appropriate for machine *)

TYPE
  BYTE = ARRAY [0 .. LOCSPERBYTE-1] OF LOC;

PROCEDURE ADDADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
  (* Returns address given by (addr + offset), or may raise
     an exception if this address is not valid.
  *)

PROCEDURE SUBADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
  (* Returns address given by (addr - offset), or may raise an
     exception if this address is not valid.
  *)

PROCEDURE DIFADR (addr1, addr2: ADDRESS): INTEGER;
  (* Returns the difference between addresses (addr1 - addr2),
     or may raise an exception if the arguments are invalid
     or address space is non-contiguous.
  *)

PROCEDURE MAKEADR (high: <some type>; ...): ADDRESS;
  (* Returns an address constructed from a list of values whose
     types are implementation-defined, or may raise an
     exception if this address is not valid.

     In GNU Modula-2, MAKEADR can take any number of arguments
     which are mapped onto the type ADDRESS. The first parameter
     maps onto the high address bits and subsequent parameters map
     onto lower address bits. For example:

     a := MAKEADR(BYTE(0FEH), BYTE(0DCH), BYTE(0BAH), BYTE(098H),
                  BYTE(076H), BYTE(054H), BYTE(032H), BYTE(010H)) ;

     then the value of, a, on a 64 bit machine is: 0FEDCBA9876543210H

     The parameters do not have to have the same type, but constants
     _must_ be typed.
  *)

PROCEDURE ADR (VAR v: <anytype>): ADDRESS;
  (* Returns the address of variable v. *)

PROCEDURE ROTATE (val: <a packedset type>;
                  num: INTEGER): <type of first parameter>;
  (* Returns a bit sequence obtained from val by rotating up or down
     (left or right) by the absolute value of num.  The direction is
     down if the sign of num is negative, otherwise the direction is up.
  *)

PROCEDURE SHIFT (val: <a packedset type>;
                 num: INTEGER): <type of first parameter>;
  (* Returns a bit sequence obtained from val by shifting up or down
     (left or right) by the absolute value of num, introducing
     zeros as necessary.  The direction is down if the sign of
     num is negative, otherwise the direction is up.
  *)

PROCEDURE CAST (<targettype>; val: <anytype>): <targettype>;
  (* CAST is a type transfer function.  Given the expression
     denoted by val, it returns a value of the type <targettype>.
     An invalid value for the target value or a
     physical address alignment problem may raise an exception.
  *)

PROCEDURE TSIZE (<type>; ... ): CARDINAL;
  (* Returns the number of LOCS used to store a value of the
     specified <type>.   The extra parameters, if present,
     are used to distinguish variants in a variant record.
  *)
*)


(* The following procedures are invoked by GNU Modula-2 to
   shift non word set types. They are not part of ISO Modula-2
   but are used by GNU Modula-2 to implement the SHIFT procedure
   defined above. *)

(*
   ShiftVal - is a runtime procedure whose job is to implement
              the SHIFT procedure of ISO SYSTEM. GNU Modula-2 will
              in-line a SHIFT of a single WORD sized set and will only
              call this routine for larger sets.
*)

PROCEDURE ShiftVal (VAR s, d: ARRAY OF BITSET;
                    SetSizeInBits: CARDINAL;
                    ShiftCount: INTEGER) ;


(*
   ShiftLeft - performs the shift left for a multi word set.
               This procedure might be called by the back end of
               GNU Modula-2 depending whether amount is known at compile
               time.
*)

PROCEDURE ShiftLeft (VAR s, d: ARRAY OF BITSET;
                     SetSizeInBits: CARDINAL;
                     ShiftCount: INTEGER) ;

(*
   ShiftRight - performs the shift left for a multi word set.
                This procedure might be called by the back end of
                GNU Modula-2 depending whether amount is known at compile
                time.
*)

PROCEDURE ShiftRight (VAR s, d: ARRAY OF BITSET;
                     SetSizeInBits: CARDINAL;
                     ShiftCount: INTEGER) ;


(*
   RotateVal - is a runtime procedure whose job is to implement
               the ROTATE procedure of ISO SYSTEM. GNU Modula-2 will
               in-line a ROTATE of a single WORD (or less)
               sized set and will only call this routine for larger sets.
*)

PROCEDURE RotateVal (VAR s, d: ARRAY OF BITSET;
                     SetSizeInBits: CARDINAL;
                     RotateCount: INTEGER) ;


(*
   RotateLeft - performs the rotate left for a multi word set.
                This procedure might be called by the back end of
                GNU Modula-2 depending whether amount is known at compile
                time.
*)

PROCEDURE RotateLeft (VAR s, d: ARRAY OF BITSET;
                      SetSizeInBits: CARDINAL;
                      RotateCount: INTEGER) ;


(*
   RotateRight - performs the rotate right for a multi word set.
                 This procedure might be called by the back end of
                 GNU Modula-2 depending whether amount is known at compile
                 time.
*)

PROCEDURE RotateRight (VAR s, d: ARRAY OF BITSET;
                       SetSizeInBits: CARDINAL;
                       RotateCount: INTEGER) ;


END SYSTEM.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. Obtaining GNU Modula-2.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1 Warning

This code is currently in development and it is not yet complete. Nevertheless the compiler is sufficiently stable to support itself on Debian GNU/Linux x86 systems. The PIM libraries are complete but the ISO libraries and ISO language features are still in development. Patches and development volunteers highly welcome! See section Contributing to GNU Modula-2.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2 Getting GNU Modula-2

Currently you have several options, you could either download a source tar ball from ftp://floppsie.comp.glam.ac.uk/pub/c and search for files which look like `gm2+gcc-version.tar.gz'. Prebuilt binary packages are also available at http://www.unet.univie.ac.at/~a9406973/modula2/downl.html.

Alternatively the development sources can be downloaded via CVS. Please be aware that as gm2 is in development it might fail to compile with a more recent version of gcc than `gcc-4.1.1'.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3 Easiest method of building the GNU Modula-2 source

The easiest and quickest method to obtain the development CVS source code for GNU Modula-2 and a compatible GCC release and the appropriate testsuite is to download the build harness: ftp://floppsie.comp.glam.ac.uk/pub/c/gm2-harness-0.96.tar.gz. This will download the latest gm2 from the CVS repository, graft it onto the appropriate GCC release, graft the gcc testsuite onto the GCC tree and graft the GNU Modula-2 regression tests onto the tree. After all the source has been placed into the correct position it builds GNU Modula-2, runs the regression tests and finally installs gm2.

The gm2-harness is a normal tarball package and is built using the traditional GNU method.

 
tar zxf gm2-harness-0.96.tar.gz
cd gm2-harness-0.96
./configure --with-gdb --prefix=$HOME/opt
make
make install

The first make downloads, constructs the source tree, builds the code and runs the regression tests. The second make installs GNU Modula-2. Note that GNU Modula-2 is still in development and so it is possible that some of the regression tests may fail.

Once the installation has completed you should set your path so that it includes the install directory. For example if you are using the bash shell could type:

 
export PATH=$HOME/opt/bin:$PATH

Thereafter you will reference the new gm2, gcc and gdb programs and libraries.

The gm2-harness package automates the steps outlined in the next three sections. Note that the option `--with-gdb' will download gdb-6.5 and patch it so that it understands Modula-2. Note that it is not manditory to patch gcc and gdb to build GNU Modula-2. But if the patches are applied (gm2-harness will do this automatically) then debugging executables produced by GNU Modula-2 is easier. The patches provide gdb with knowledge about subranges and sets. So for example:

 
VAR
   s: SET OF CHAR ;
   r: [20..40] ;

will be understood and the debugger can be asked to print the values and types of variables. For example here is a typical gdb session:

 
(gdb) print s
{'A'..'C', 'Z'}
(gdb) ptype s
SET OF CHAR
(gdb) print r
21
(gdb) ptype r
[20..40]

The debugger also has better knowledge of Modula-2 arrays. For example in this code fragment the declaration of s is described.

 
VAR
   s: ARRAY [-10..10] OF CHAR ;

and this information is now seen by gdb

 
(gdb) ptype s
ARRAY [-10..10] OF CHAR

Note that the following compile flags need to be present on the gm2 command line -g -gdwarf-2. Also note that the array handling is not yet complete and although the type is printed correctly, the expression handling still assumes that all arrays have a lower bound of zero and not -10 in the case above. Unbounded arrays are also not yet recognised.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4 Development sources via CVS

To get the latest sources to GNU Modula-2 type the following:

 
cvs -z3 -d:pserver:anoncvs@cvs.sv.gnu.org:/sources/gm2 co gm2

This will checkout a copy of GNU Modula-2 into one subdirectory, `gm2'.

This version of GNU Modula-2 needs to be placed inside the GCC source tree in the position gcc-4.1.1/gcc before GNU Modula-2 can be built. Please check the GNU Modula-2 homepage http://www.nongnu.org/gm2 for details about which GCC releases are supported by GNU Modula-2.

Once you have downloaded the correct GCC release from http://gcc.gnu.org or a mirror site you should unpack the GCC archive. Assuming that both the `gcc-4.1.1' and `gm2' dicectories are at the same level, you can graft `gm2' onto `gcc-4.1.1' by:

 
mv gm2 gcc-4.1.1/gcc

If the directory `gcc-4.1.1/gcc/gm2/patches/gcc/4.1.1' exists then the patch file inside that directory can be applied to the `gcc-4.1.1' tree. This is done via:

 
cd gcc-4.1.1
patch -p1 < gcc/gm2/patches/gcc/4.1.1/gm2/gcc-gm2.patch

Note that this patch is optional as it enables better `dwarf-2' debugging information which in turn allows a patched `gdb' to understand set types and subrange types.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.5 Building GNU Modula-2

To build GNU Modula-2 type:

 
mkdir host-build
cd host-build
../gcc-4.1.1/configure --enable-languages=c,gm2 \
  --enable-checking --disable-multilib
make
cd ..

Installing GNU Modula-2 is achieved by:

 
su
cd host-build
make install
exit

Now you should be able to perform:

 
cd gcc-4.1.1/gcc/gm2/examples/hello
make

which will create an `a.out' for the infamous hello world example.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.6 Stress testing GM2

Currently there are two automated methods to test GNU Modula-2. The first method is `make gm2.paranoid' in which gm2 builds itself and finally the test runs both parent and child generations of the compiler and compares the output. Be warned that this test can take some time to execute. This test is invoked by:

 
cd host-build/gcc ; make gm2.paranoid

The second method used to test GNU Modula-2 is to run the regression test suite. The GNU Modula-2 regression test suite is available for download. To install and run the GNU Modula-2 regression suite you need to have installed the `dejagnu' and `expect' packages. Note that you need to ensure that you have at least the following releases of dejagnu components:

 
$ runtest --version

Expect version is	5.42.1
Tcl version is		8.4
Framework version is	1.4.4

otherwise some of the tests may not run.

You also need to have downloaded the gcc testsuite and grafted it onto the GCC source tree. Finally you need to graft the GNU Modula-2 testsuite onto the gcc testsuite. To ease this process there are pre grafted versions available from ftp://floppsie.comp.glam.ac.uk/pub/c.

Assuming that the root of the GCC source tree is in the current working directory you can use the following commands to install the test suite:

 
cvs -z3 -d:pserver:anoncvs@cvs.sv.gnu.org:/sources/gm2 co testsuite
tar cf - testsuite | ( cd gcc-version/gcc ; tar xf - )

Do not simply move the directory `testsuite' into `gcc-version/gcc' as the GNU Modula-2 regression tests have to be overlaid on top of the gcc testsuite.

Thereafter you can run the GNU Modula-2 testsuite by:

 
cd host-build/gcc
make check-gm2

Depending on the speed of your computer these tests may take a while to complete.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.7 Building GNU Modula-2 under FreeBSD

When building GNU Modula-2 under FreeBSD, there are essentially three issues that need to be addressed.

The first, is the system shell, `/bin/sh'. GNU Modula-2's build script uses some `bash' constructs that are not understood by `sh'. Therefore `bash' must be installed and this can be obtained from the ports package collection (ports:shells/bash).

The second, is the compiler used to bootstrap GNU Modula-2. On FreeBSD4.x the system compiler is from the 2.95.x generation, and should work without problems. On 5-RELEASE and 6-CURRENT, the system compiler is from the 3.4.x generation or greater, and it is known to create a faulty GNU Modula-2 compiler. Therefore you will need to install an earlier gcc on your machine. Known to work are gcc 3.2.3 (ports:lang/gcc32), gcc 3.3.4, 3.3.5 and 3.3.6 (ports:lang/gcc33).

Finally, `gmake' is required.

It is recommended that the same options are used to configure GNU Modula-2 as those suggested in the ports collection. A number of options are not relevant for building GNU Modula-2 and these can be safely omitted. The only two which apply directly to GNU Modula-2's build process are --with-system-zlib and --disable-nls.

The example below assumes that gcc-3.2.3 is installed (from the ports collection) and the compiler is called `gcc32'. The example assumes that the bash shell has been installed (as described above).

 
  mkdir host-build
  cd host-build
  env CONFIG_SHELL=/usr/local/bin/bash CC=gcc32 ../gcc-version/configure
      --with-system-zlib --disable-nls --enable-languages=c,gm2
  gmake

If you choose to install the generated compiler, you are urged to make use of the name rewriting options of configure (--program-prefix and --program-suffix work fine), and to avoid possible conflicts with a port that installs it's own gcc, you may also want to add --host. Here is the author of this section's full configure line:

 
  env CONFIG_SHELL=/usr/local/bin/bash CC=gcc32 ../gcc-version/configure
      --with-system-zlib --disable-nls --enable-languages=c,gm2
      --program-prefix=m2 --host=i386-gm2bld-freebsd5.3

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.8 Licence of GNU Modula-2


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

GNU GENERAL PUBLIC LICENSE

Version 2, June 1991

 
Copyright © 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

    Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

  2. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

    You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

  3. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
    1. You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
    2. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
    3. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

    These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

    Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

    In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

  4. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
    1. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    2. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
    3. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

    The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

    If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

  5. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
  6. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
  7. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
  8. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

    If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

    It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

    This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

  9. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
  10. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

    Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

  11. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

    NO WARRANTY

  12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.

 
one line to give the program's name and a brief idea of what it does.
Copyright (C) year  name of author

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this when it starts in an interactive mode:

 
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:

 
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

The GNU Project and GNU/Linux

The GNU Project was launched in 1984 to develop a complete Unix-like operating system which is free software: the GNU system. (GNU is a recursive acronym for "GNU's Not Unix"; it is pronounced "guh-NEW".) Variants of the GNU operating system, which use the kernel Linux, are now widely used; though these systems are often referred to as "Linux", they are more accurately called GNU/Linux systems.

For more information, see:

 
http://www.gnu.org/
http://www.gnu.org/gnu/linux-and-gnu.html

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1 Contributing to GNU Modula-2

Please do. But also please read the GNU Emacs info under

 
* Standards: (standards).       GNU coding standards.
* Intellectual Property::       Keeping Free Software Free
* Reading Non-Free Code::       Referring to Proprietary Programs
* Contributions::               Accepting Contributions

You might consider joining the GM2 Mailing list available via a web brouser at

http://lists.nongnu.org/mailman/listinfo/gm2 available via email: mail:gm2-subscribe@nongnu.org before you start coding.

Many thanks and enjoy your coding!


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. GNU Modula-2 Internals

This document is a small step in the long journey of documenting the GNU Modula-2 compiler and how it integrates with GCC. The document is still in it's infancy.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 History

The Modula-2 compiler sources have come from the m2f compiler which runs under GNU/Linux. The original m2f compiler was written in Modula-2 and was bootstrapped via a modified version of p2c 1.20. The m2f compiler was a recursive descent which generated quadruples as intermediate code. It also used C style calling convention wherever possible and utilized a C structure for dynamic arrays.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Overview

GNU Modula-2 uses flex and a machine generated recursive descent parser. Most of the source code is written in Modula-2 and bootstrapping is achieved via a modified version of p2c-1.20. The modified p2c-1.20 is contained in the GNU Modula-2 source tree as are a number of other tools necessary for bootstrapping.

The changes to p2c include:

GNU Modula-2 comes with PIM and ISO style libraries. The compiler is built using PIM libraries and the source of the compiler complies with the PIM dialect together with a few C library calling extensions.

The compiler is a four pass compiler. The first pass tokenizes the source code, creates scope and enumeration type symbols. All tokens are placed into a dynamic buffer and subsequent passes reread tokens and build types, quadruples and resolve hidden types. See section Passes.

GNU Modula-2 uses a technique of double book keeping (2). See (gcc)Back end Access to Symbol Table. The front end builds a complete symbol table and a list of quadruples. Each symbol is translated into a gcc equivalent after which each quadruple is translated into a gcc tree.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 How the front end integrates with gcc

The M2Base and M2System modules contain base types and system types respectively they map onto GCC back-end data types.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4 Passes

This section describes the general actions of each pass. The key to building up the symbol table correctly is to ensure that the symbols are only created in the scope where they were declared. This may seem obvious (and easy) but it is complicated by two issues: firstly GNU Modula-2 does not generate .sym files and so all imported definition modules are parsed after the module is parsed; secondly the import/export rules might mean that you can see and use a symbol before it is declared in a completely different scope.

Here is a brief description of the lists of symbols maintained within DefImp and Module symbols. It is these lists and actions at each pass which manipulate these lists which solve the scoping and visability of all symbols.

The DefImp symbol maintains the: ExportQualified, ExportUnQualified, ExportRequest, IncludeList, ImportTree, ExportUndeclared, NeedToBeImplemented, LocalSymbols, EnumerationScopeList, Unresolved, ListOfVars, ListOfProcs and ListOfModules lists.

The Module symbol maintains the: LocalSymbols, ExportTree, IncludeList, ImportTree, ExportUndeclared, EnumerationScopeList, Unresolved, ListOfVars, ListOfProcs and ListOfModules lists.

Initially we discuss the lists which are common to both DefImp and Module symbols, thereafter the lists peculiar to DefImp and Module symbols are discussed.

The ListOfVars, ListOfProcs and ListOfModules lists (common to both symbols) and simply contain a list of variables, procedures and inner modules which are declared with this definition/implementation or program module.

The LocalSymbols list (common to both symbols) contains a complete list of symbols visible in this modules scope. The symbols in this list may have been imported or exported from an inner module.

The EnumerationScope list (common to both symbols) defines all visible enumeration symbols. When this module is parsed the contents of these enumeration types are marked as visible. Internally to GNU Modula-2 these form a pseudo scope (rather like a WITH statement which temporarily makes the fields of the record visible).

The ExportUndeclared list (common to both symbols) contains a list of all symbols marked as exported but are as yet undeclared.

The IncludeList is (common to both symbols) contains a list of all modules imported by the IMPORT modulename ; construct.

The ImportTree (common to both symbols) contains a tree of all imported identifiers.

The ExportQualified and ExportUnQualified trees (only present in the DefImp symbol) contain identifiers which are marked as EXPORT QUALIFIED and EXPORT UNQUALIFIED respectively.

The NeedToBeImplemented list (only present in the DefImp symbol) and contains a list of all unresolved symbols which are exported.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.1 Pass 1

During pass 1 each DefImp and Module symbol is created. These are also placed into a list of outstanding sources to be parsed. The import and export lists are recorded and each object imported is created in the module from whence it is exported and added into the imported list of the current module. Any exported objects are placed into the export list and marked as qualified or unqualified.

Inner module symbols are also created and their import and export lists are also processed. An import list will result in a symbol being fetched (or created if it does not exist) from the outer scope and placed into the scope of the inner module. An export list results in each symbol being fetched or created in the current inner scope and added to the outer scope. If the symbol has not yet been declared then it is added to the current modules ExportUndeclared list.

Procedure symbols are created (the parameters are parsed but no more symbols are created). Enumerated types are created, hidden types in the definition modules are marked as such. All the rest of the Modula-2 syntax is parsed but no symbols are created.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.2 Pass 2

This section discuss varient records and their representation within the front end `gm2/gm2-compiler/SymbolTable.mod'. Records and varient records are declared in pass 2.

Ordinary records are represented by the following symbol table entries:

 
TYPE
   this = RECORD
             foo: CARDINAL ;
             bar: CHAR ;
          END ;


    SymRecord [1]
   +-------------+
   | Name = this |        SymRecordField [2]
   | ListOfSons  |       +-------------------+
   |    +--------|       | Name = foo        |
   |    | [2] [3]|       | Parent = [1]      |
   +-------------+       | Type = [Cardinal] |
   | LocalSymbols|       +-------------------+
   | +-----------+
   | | foo bar   |
   | +-----------+
   +-------------+


    SymRecordField [3]
   +-------------------+
   | Name = bar        |
   | Parent = [1]      |
   | Type = [Cardinal] |
   +-------------------+

Whereas varient records are represented by the following symbol table entries:

 
TYPE
   this = RECORD
             CASE tag: CHAR OF
             'a': foo: CARDINAL ;
                  bar: CHAR |
             'b': an:  REAL |
             ELSE
             END
          END ;


    SymRecord [1]
   +-------------+
   | Name = this |        SymRecordField [2]
   | ListOfSons  |       +-------------------+
   |    +--------|       | Name = tag        |
   |    | [2] [3]|       | Parent = [1]      |
   |    +--------+       | Type = [CHAR]     |
   | LocalSymbols|       +-------------------+
   | +-----------+
   | | tag foo   |
   | | bar an    |
   | +-----------+
   +-------------+

    SymVarient [3]          SymFieldVarient [4]
   +-------------------+   +-------------------+
   | Parent = [1]      |   | Parent = [1]      |
   | ListOfSons        |   | ListOfSons        |  
   |    +--------------|   |    +--------------|
   |    | [4] [5]      |   |    | [6] [7]      |
   +-------------------+   +-------------------+

    SymFieldVarient [5]
   +-------------------+
   | Parent = [1]      |
   | ListOfSons        |  
   |    +--------------|
   |    | [8]          |
   +-------------------+

    SymRecordField [6]      SymRecordField [7]
   +-------------------+   +-------------------+
   | Name = foo        |   | Name = bar        |
   | Parent = [1]      |   | Parent = [1]      |
   | Type = [CARDINAL] |   | Type = [CHAR]     |
   +-------------------+   +-------------------+

    SymRecordField [8]
   +-------------------+
   | Name = an         |
   | Parent = [1]      |
   | Type = [REAL]     |
   +-------------------+

Varient records which have nested CASE statements are represented by the following symbol table entries:

 
TYPE
   this = RECORD
             CASE tag: CHAR OF
             'a': foo: CARDINAL ;
                  CASE bar: BOOLEAN OF
                  TRUE : bt: INTEGER |
                  FALSE: bf: CARDINAL
                  END |
             'b': an:  REAL |
             ELSE
             END
          END ;


    SymRecord [1]
   +-------------+
   | Name = this |        SymRecordField [2]
   | ListOfSons  |       +-------------------+
   |    +--------|       | Name = tag        |
   |    | [2] [3]|       | Parent = [1]      |
   |    +--------+       | Type = [CHAR]     |
   | LocalSymbols|       +-------------------+
   | +-----------+
   | | tag foo   |
   | | bar bt bf |
   | | an        |
   | +-----------+
   +-------------+

      ('1st CASE')            ('a' selector)
    SymVarient [3]          SymFieldVarient [4]
   +-------------------+   +-------------------+
   | Parent = [1]      |   | Parent = [1]      |
   | ListOfSons        |   | ListOfSons        |  
   |    +--------------|   |    +--------------|
   |    | [4] [5]      |   |    | [6] [7] [8]  |
   +-------------------+   +-------------------+

     ('b' selector)
    SymFieldVarient [5]
   +-------------------+
   | Parent = [1]      |
   | ListOfSons        |  
   |    +--------------|
   |    | [9]          |
   +-------------------+

    SymRecordField [6]      SymRecordField [7]
   +-------------------+   +-------------------+
   | Name = foo        |   | Name = bar        |
   | Parent = [1]      |   | Parent = [1]      |
   | Type = [CARDINAL] |   | Type = [BOOLEAN]  |
   +-------------------+   +-------------------+

      ('2nd CASE')
    SymVarient [8]
   +-------------------+
   | Parent = [1]      |
   | ListOfSons        |
   |    +--------------|
   |    | [12] [13]    |
   +-------------------+

    SymRecordField [9]
   +-------------------+
   | Name = an         |
   | Parent = [1]      |
   | Type = [REAL]     |
   +-------------------+

    SymRecordField [10]     SymRecordField [11]
   +-------------------+   +-------------------+
   | Name = bt         |   | Name = bf         |
   | Parent = [1]      |   | Parent = [1]      |
   | Type = [REAL]     |   | Type = [REAL]     |
   +-------------------+   +-------------------+

    (TRUE selector)            (FALSE selector)
    SymFieldVarient [12]    SymFieldVarient [13]
   +-------------------+   +-------------------+
   | Parent = [1]      |   | Parent = [1]      |
   | ListOfSons        |   | ListOfSons        |
   |    +--------------|   |    +--------------|
   |    | [10]         |   |    | [11]         |
   +-------------------+   +-------------------+

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.3 Pass 3

To do


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.4 Pass H

To do


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.5 Declaration ordering

This section gives a few stress testing examples and walks though the mechanics of the passes and how the lists of symbols are created.

The first example contains a nested module in which an enumeration type is created and exported. A procedure declared before the nested module uses the enumeration type.

 
MODULE colour ;

   PROCEDURE make (VAR c: colours) ;
   BEGIN
      c := yellow
   END make ;

   MODULE inner ;
   EXPORT colours ;

   TYPE
      colours = (red, blue, yellow, white) ;
   END inner ;

VAR
   g: colours
BEGIN
   make(g)
END colour.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5 Run time

This section describes how the GNU Modula-2 compiler interfaces with the run time system. The modules which must be common to all library collections are M2RTS and SYSTEM. In the PIM library collection an implementation of M2RTS and SYSTEM exist; likewise in the ISO library and ULM library collection these modules also exist.

The M2RTS module contains many of the base runtime features required by the GNU Modula-2 compiler. For example M2RTS contains the exception handling routines which are called if a pointer whose value is NIL is dereferenced or an array index goes out of bounds. If the `-Wbounds' options is specified then the GNU Modula-2 compiler will call the procedure ArraySubscriptError or SubrangeAssignmentError when an illegal reference or illegal assignment is about to be performed. M2RTS also contains the exception handlers FunctionReturnError, NilPointerError and CaseElseError.

The M2RTS module also contains the HALT and LENGTH procedure. The ISO SYSTEM module contains a number of SHIFT and ROTATE procedures which GNU Modula-2 will call when wishing to shift and rotate multi-word set types.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6 Scope rules

This section describes my understanding of the Modula-2 scope rules with respect to enumerated types. If they are incorrect please correct me by email gaius@gnu.org. They also serve to document the behaviour of GNU Modula-2 in these cirumstances.

In GNU Modula-2 the syntax for a type declaration is defined as:

 
TypeDeclaration := Ident "=" Type =:

Type :=  SimpleType | ArrayType
          | RecordType          
          | SetType             
          | PointerType         
          | ProcedureType
      =:								   
									   
SimpleType := Qualident | Enumeration | SubrangeType =:

If the TypeDeclaration rule is satisfied by SimpleType and Qualident ie:

 
TYPE
   foo = bar ;

then foo is said to be equivalent to bar. Thus variables, parameters and record fields declared with either type will be compatible with each other.

If, however, the TypeDeclaration rule is satisfied by any alternative clause ArrayType, RecordType, SetType, PointerType, ProcedureType, Enumeration or SubrangeType then in these cases a new type is created which is distinct from all other types. It will be incompatible with all other user defined types.

It also has furthur consequences in that if bar was defined as an enumerated type and foo is imported by another module then the enumerated values are also visible in this module.

Consider the following modules:

 
DEFINITION MODULE impc ;

TYPE
   C = (red, blue, green) ;

END impc.
 
DEFINITION MODULE impb ;

IMPORT impc ;

TYPE
   C = impc.C ;

END impb.
 
MODULE impa ;

FROM impb IMPORT C ;

VAR
   a: C ;
BEGIN
   a := red
END impa.

Here we see that the type C defined in module impb is equivalent to the type C in module impc. Module impa imports the type C from module impb and at that point the enumeration values red, blue, green (declared in module impc) are also visible.

The ISO Standand (p.41) in section 6.1.8 Import Lists states:

"Following the module heading, a module may have a sequence of import lists. An import list includes a list of the identifiers that are to be explicitly imported into the module. Explicit import of an enumeration type identifier implicitly imports the enumeration constant identifiers of the enumeration type.

Imported identifiers are introduced into the module, thus extending their scope, but they have a defining occurrence that appears elsewhere.

Every kind of module may include a sequence of import lists, whether it is a program module, a definition module, an implementation module or a local module. In the case of any other kind of module, the imported identifiers may be used in the block of the module."

These statements confirm that the previous example is legal. But it prompts the question, what about implicit imports othersise known as qualified references.

In section 6.10 Implicit Import and Export of the ISO Modula-2 standard it says:

"The set of identifiers that is imported or exported if an identifier is explicitly imported or exported is called the (import and export) closure of that identifier. Normally, the closure includes only the explicitly imported or exported identifier. However, in the case of the explicit import or export of an identifier of an enumeration type, the closure also includes the identifiers of the values of that type.

Implicit export applies to the identifiers that are exported (qualified) from separate modules, by virtue of their being the subject of a definition module, as well as to export from a local module that uses an export list."

Clearly this means that the following is legal:

 
MODULE impd ;

IMPORT impc ;

VAR
   a: impc.C ;
BEGIN
   a := impc.red
END impd.

It also means that the following code is legal:

 
MODULE impe ;

IMPORT impb ;

VAR
   a: impb.C ;
BEGIN
   a := impb.red
END impe.

And also this code is legal:

 
MODULE impf ;

FROM impb IMPORT C ;

VAR
   a: C ;
BEGIN
   a := red
END impf.

And also that this code is legal:

 
DEFINITION MODULE impg ;

IMPORT impc;

TYPE
   C = impc.C ;

END impg.
 
IMPLEMENTATION MODULE impg ;

VAR
   t: C ;
BEGIN
   t := red
END impg.

Furthermore the following code is also legal as the new type, C is declared and exported. Once exported all its enumerated fields are also exported.

 
DEFINITION MODULE imph;

IMPORT impc;
TYPE
   C = impc.C;

END imph.

Here we see that the current scope is populated with the enumeration fields red, blue, green and also it is possible to reference these values via a qualified identifier.

 
IMPLEMENTATION MODULE imph;

IMPORT impc;

VAR
   a: C ;
   b: impc.C ;
BEGIN
   a := impc.red ;
   b := red ;
   a := b ;
   b := a
END imph.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7 Done list

What has been done:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.8 To do list

What needs to be done:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. EBNF of GNU Modula-2

This chapter contains the EBNF of GNU Modula-2. This grammer currently supports PIM and a number of ISO features. It is intended to be altered to become fully complient with ISO in the future. The rules here are automatically extracted from the grammer files in GNU Modula-2 and serve to document the syntax of the extensions described earlier and how they fit in with the base language.

Note that the first six productions are built into the lexical analysis phase.

 
PossiblyExportIdent := is a builtin which automatically exports an identifier
                     =: 
 
Ident := is a builtin and checks for an identifier
       =: 
 
IdentScope := a builtin which provides a context for error messages
            =: 
 
Integer := is a builtin and checks for an integer
         =: 
 
Real := is a builtin and checks for an real constant
      =: 
 
string := is a builtin and checks for an string constant
        =: 
 
FileUnit := ( DefinitionModule  | ImplementationOrProgramModule  ) 
            
          =: 
 
ProgramModule := 'MODULE' Ident [ Priority  ] ';' { Import  } 
                 Block Ident '.' 
               =: 
 
ImplementationModule := 'IMPLEMENTATION' 'MODULE' Ident [ Priority  ] 
                        ';' { Import  } Block Ident '.' 
                      =: 
 
ImplementationOrProgramModule := ImplementationModule  | 
                                 ProgramModule 
                               =: 
 
Number := Integer  | Real 
        =: 
 
Qualident := Ident { '.' Ident  } 
           =: 
 
ConstantDeclaration := PossiblyExportIdent '=' ConstExpression 
                     =: 
 
ConstExpression := SimpleConstExpr [ Relation SimpleConstExpr  ] 
                   
                 =: 
 
Relation := '='  | '#'  | '<>'  | '<'  | '<='  | '>'  | '>='  | 
            'IN' 
          =: 
 
SimpleConstExpr := UnaryOrConstTerm { AddOperator ConstTerm  } 
                 =: 
 
UnaryOrConstTerm := '+' ConstTerm  | '-' ConstTerm  | 
                    ConstTerm 
                  =: 
 
AddOperator := '+'  | '-'  | 'OR' 
             =: 
 
ConstTerm := ConstFactor { MulOperator ConstFactor  } 
           =: 
 
MulOperator := '*'  | '/'  | 'DIV'  | 'MOD'  | 'REM'  | 
               'AND'  | '&' 
             =: 
 
ConstFactor := Number  | ConstString  | ConstSetOrQualidentOrFunction  | 
               '(' ConstExpression ')'  | 
               'NOT' ConstFactor  | ConstAttribute 
             =: 
 
ConstString := string 
             =: 
 
ConstSetOrQualidentOrFunction := SimpleSet  | Qualident [ SimpleSet  | 
                                                          ConstActualParameters  ] 
                               =: 
 
ConstActualParameters := '(' [ ExpList  ] ')' 
                       =: 
 
QualidentOrSet := SimpleSet  | Qualident [ SimpleSet  ] 
                =: 
 
ConstAttribute := '__ATTRIBUTE__' '__BUILTIN__' '(' '(' Ident 
                  ')' ')' 
                =: 
 
Element := ConstExpression [ '..' ConstExpression  ] 
         =: 
 
TypeDeclaration := ( IdentScope '=' Type  ) 
                 =: 
 
Type := ( SimpleType  | ArrayType  | RecordType  | 
          SetType  | PointerType  | ProcedureType  ) 
      =: 
 
SimpleType := Qualident [ SubrangeType  ]  | 
              Enumeration  | SubrangeType 
            =: 
 
Enumeration := '(' ( PossiblyExportIdentList  ) ')' 
             =: 
 
IdentList := Ident { ',' Ident  } 
           =: 
 
IdentScopeList := IdentScope { ',' IdentScope  } 
                =: 
 
PossiblyExportIdentList := PossiblyExportIdent { ',' PossiblyExportIdent 
                                                   } 
                         =: 
 
SubrangeType := '[' ConstExpression '..' ConstExpression ']' 
              =: 
 
ArrayType := 'ARRAY' SimpleType { ',' SimpleType  } 'OF' Type 
           =: 
 
RecordType := 'RECORD' FieldListSequence 'END' 
            =: 
 
FieldListSequence := FieldListStatement { ';' FieldListStatement  } 
                   =: 
 
FieldListStatement := [ FieldList  ] 
                    =: 
 
FieldList := IdentList ':' Type  | 'CASE' TagIdent [ ':' Qualident  | 
                                                     '.' Qualident  ] 
             'OF' Varient { '|' Varient  } [ 'ELSE' FieldListSequence  ] 
             'END' 
           =: 
 
TagIdent := [ Ident  ] 
          =: 
 
Varient := [ CaseLabelList ':' FieldListSequence  ] 
         =: 
 
CaseLabelList := CaseLabels { ',' CaseLabels  } 
               =: 
 
CaseLabels := ConstExpression [ '..' ConstExpression  ] 
            =: 
 
SetType := 'SET' 'OF' SimpleType 
         =: 
 
PointerType := 'POINTER' 'TO' Type 
             =: 
 
ProcedureType := 'PROCEDURE' [ FormalTypeList  ] 
               =: 
 
FormalTypeList := '(' ( ')' FormalReturn  | 
                        ProcedureParameters ')' FormalReturn  ) 
                =: 
 
FormalReturn := [ ':' Qualident  ] 
              =: 
 
ProcedureParameters := ProcedureParameter { ',' ProcedureParameter  } 
                     =: 
 
ProcedureParameter := '...'  | 'VAR' FormalType  | 
                      FormalType 
                    =: 
 
VarIdent := PossiblyExportIdent [ '[' ConstExpression ']'  ] 
          =: 
 
VariableDeclaration := ( VarIdentList ':' Type  ) 
                     =: 
 
VarIdentList := VarIdent { ',' VarIdent  } 
              =: 
 
Designator := Qualident { SubDesignator  } 
            =: 
 
SubDesignator := '.' Ident  | '[' ExpList ']'  | 
                 '^' 
               =: 
 
ExpList := Expression { ',' Expression  } 
         =: 
 
Expression := SimpleExpression [ Relation SimpleExpression  ] 
              
            =: 
 
SimpleExpression := [ '+'  | '-'  ] Term { AddOperator Term  } 
                  =: 
 
Term := Factor { MulOperator Factor  } 
      =: 
 
Factor := Number  | string  | SetOrDesignatorOrFunction  | 
          '(' Expression ')'  | 'NOT' Factor  | 
          ConstAttribute 
        =: 
 
SimpleSet := '{' [ Element { ',' Element  }  ] '}' 
           =: 
 
SetOrDesignatorOrFunction := ( Qualident [ SimpleSet  | 
                                           SimpleDes [ ActualParameters  ]  ]  | 
                               SimpleSet  ) 
                           =: 
 
SimpleDes := { '.' Ident  | '[' ExpList ']'  | 
                '^'  } 
           =: 
 
ActualParameters := '(' [ ExpList  ] ')' 
                  =: 
 
Statement := [ AssignmentOrProcedureCall  | 
               IfStatement  | CaseStatement  | 
               WhileStatement  | RepeatStatement  | 
               LoopStatement  | ForStatement  | 
               WithStatement  | AsmStatement  | 
               'EXIT'  | 'RETURN' [ Expression  ]  ] 
           =: 
 
AssignmentOrProcedureCall := Designator ( ':=' Expression  | 
                                          ActualParameters  | 
                                           ) 
                           =: 
 
StatementSequence := Statement { ';' Statement  } 
                   =: 
 
IfStatement := 'IF' Expression 'THEN' StatementSequence { 'ELSIF' 
                                                           Expression 
                                                           'THEN' 
                                                           StatementSequence  } 
               [ 'ELSE' StatementSequence  ] 'END' 
             =: 
 
CaseStatement := 'CASE' Expression 'OF' Case { '|' Case  } 
                 [ 'ELSE' StatementSequence  ] 'END' 
               =: 
 
Case := [ CaseLabelList ':' StatementSequence  ] 
      =: 
 
WhileStatement := 'WHILE' Expression 'DO' StatementSequence 'END' 
                =: 
 
RepeatStatement := 'REPEAT' StatementSequence 'UNTIL' Expression 
                 =: 
 
ForStatement := 'FOR' Ident ':=' Expression 'TO' Expression [ 
   'BY' ConstExpression  ] 'DO' StatementSequence 'END' 
              =: 
 
LoopStatement := 'LOOP' StatementSequence 'END' 
               =: 
 
WithStatement := 'WITH' Designator 'DO' StatementSequence 'END' 
               =: 
 
ProcedureDeclaration := ProcedureHeading ';' ( ProcedureBlock 
                                               Ident  ) 
                      =: 
 
DefineBuiltinProcedure := '__ATTRIBUTE__' '__BUILTIN__' '(' '(' 
                          Ident ')' ')'  | 
                          '__INLINE__'  | 
                        =: 
 
ProcedureHeading := 'PROCEDURE' DefineBuiltinProcedure ( PossiblyExportIdent 
                                                         [ FormalParameters  ] 
                                                          ) 
                  =: 
 
Builtin := '__BUILTIN__'  | '__INLINE__'  | 
         =: 
 
DefProcedureHeading := 'PROCEDURE' Builtin ( PossiblyExportIdent 
                                             [ DefFormalParameters  ] 
                                              ) 
                     =: 
 
ProcedureBlock := { Declaration  } [ 'BEGIN' StatementSequence  ] 
                  'END' 
                =: 
 
Block := { Declaration  } [ 'BEGIN' StatementSequence  ] 'END' 
       =: 
 
Declaration := 'CONST' { ConstantDeclaration ';'  }  | 
               'TYPE' { TypeDeclaration ';'  }  | 
               'VAR' { VariableDeclaration ';'  }  | 
               ProcedureDeclaration ';'  | 
               ModuleDeclaration ';' 
             =: 
 
DefFormalParameters := '(' [ DefMultiFPSection  ] ')' [ ':' Qualident  ] 
                     =: 
 
DefMultiFPSection := DefExtendedFP  | FPSection [ ';' DefMultiFPSection  ] 
                   =: 
 
FormalParameters := '(' [ MultiFPSection  ] ')' [ ':' Qualident  ] 
                  =: 
 
MultiFPSection := ExtendedFP  | FPSection [ ';' MultiFPSection  ] 
                =: 
 
FPSection := NonVarFPSection  | VarFPSection 
           =: 
 
DefExtendedFP := DefOptArg  | '...' 
               =: 
 
ExtendedFP := OptArg  | '...' 
            =: 
 
VarFPSection := 'VAR' IdentScopeList ':' FormalType 
              =: 
 
NonVarFPSection := IdentScopeList ':' FormalType 
                 =: 
 
OptArg := '[' IdentScope ':' FormalType [ '=' ConstExpression  ] 
          ']' 
        =: 
 
DefOptArg := '[' IdentScope ':' FormalType '=' ConstExpression 
             ']' 
           =: 
 
FormalType := [ 'ARRAY' 'OF'  ] Qualident 
            =: 
 
ModuleDeclaration := 'MODULE' Ident [ Priority  ] ';' { Import 
                                                          } 
                     [ Export  ] Block Ident 
                   =: 
 
Priority := '[' ConstExpression ']' 
          =: 
 
Export := 'EXPORT' ( 'QUALIFIED' IdentList  | 
                     'UNQUALIFIED' IdentList  | 
                     IdentList  ) ';' 
        =: 
 
Import := 'FROM' Ident 'IMPORT' IdentList ';'  | 
          'IMPORT' IdentList ';' 
        =: 
 
DefinitionModule := 'DEFINITION' 'MODULE' ( 'FOR' string  | 
                                             ) Ident ';' { Import 
                                                             } 
                    [ Export  ] { Definition  } 'END' Ident 
                    '.' 
                  =: 
 
Definition := 'CONST' { ConstantDeclaration ';'  }  | 
              'TYPE' { PossiblyExportIdent ( ';'  | '=' Type 
                                              ';'  )  }  | 
              'VAR' { VariableDeclaration ';'  }  | 
              DefProcedureHeading ';' 
            =: 
 
AsmStatement := 'ASM' [ 'VOLATILE'  ] '(' AsmOperands ')' 
              =: 
 
AsmOperands := string [ ':' AsmList [ ':' AsmList [ ':' TrashList  ]  ]  ] 
             =: 
 
AsmList := [ AsmElement  ] { ',' AsmElement  } 
         =: 
 
AsmElement := string '(' Expression ')' 
            =: 
 
TrashList := [ string  ] { ',' string  } 
           =: 

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. PIM and ISO library definitions

This chapter contains M2F, ULM, PIM and ISO libraries. The ISO libraries are currently work in progress, many are incomplete and even more have no implementation module. The M2F libraries are very mature as the compiler uses them extensively. Permission has been kindly granted by the authors of the ULM libraries to include them with GNU Modula-2. These libraries (under the GNU GPL) were written at the University of Ulm and were originally shipped with the ULM sparc Modula-2 compiler.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Base libraries

These are the base libraries for the GNU Modula-2 compiler. These modules originally came from the M2F compiler and have been cleaned up and extended. They provide a basic interface to the underlying operating system via libc. They also include a number of libraries to allow access to compiler built-ins. Perhaps the largest difference to PIM and ISO libraries is the DynamicString module which declares the type String. The heavy use of this opaque data type results in a number of equivalent modules that can either handle ARRAY OF CHAR or String.

These modules have been extensively tested and are used throughout building the GNU Modula-2 compiler.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.1 gm2-libs/ASCII

 
DEFINITION MODULE ASCII ;

(*
   Desciption: Defines all ascii constants (as in man ASCII)
               Note that lf, eof and EOL are added
*)

EXPORT QUALIFIED
     nul, soh, stx, etx, eot, enq, ack, bel,
     bs , ht , nl , vt , np , cr , so , si ,
     dle, dc1, dc2, dc3, dc4, nak, syn, etb,
     can, em , sub, esc, fs , gs , rs , us ,
     sp ,  (* All the above are in order *)
     lf, ff, eof, del, tab, EOL ;

CONST
     nul=000C; soh=001C; stx=002C; etx=003C;
     eot=004C; enq=005C; ack=006C; bel=007C;
     bs =010C; ht =011C; nl =012C; vt =013C;
     np =014C; cr =015C; so =016C; si =017C;
     dle=020C; dc1=021C; dc2=022C; dc3=023C;
     dc4=024C; nak=025C; syn=026C; etb=027C;
     can=030C; em =031C; sub=032C; esc=033C;
     fs =034C; gs =035C; rs =036C; us =037C;
     sp =040C; (* All the above are in order *)
     lf =nl  ; ff =np  ; eof=eot ; tab=ht  ;
     del=177C; EOL=cr  ;

END ASCII.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.2 gm2-libs/Args

 
DEFINITION MODULE Args ;

(*
    Description: provides a simple interface to the command
                 line arguments.
*)

EXPORT QUALIFIED GetArg, Narg ;


(*
   GetArg - returns the nth argument from the command line.
            The success of the operation is returned.
*)

PROCEDURE GetArg (VAR a: ARRAY OF CHAR ; i: CARDINAL) : BOOLEAN ;


(*
   Narg - returns the number of arguments available from
          command line.
*)

PROCEDURE Narg() : CARDINAL ;


END Args.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.3 gm2-libs/Assertion

 
DEFINITION MODULE Assertion ;

(*
   Description: Provides an assert procedure.
*)

EXPORT QUALIFIED Assert ;


(*
   Assert - tests the boolean Condition, if it fails then HALT is called.
*)

PROCEDURE Assert (Condition: BOOLEAN) ;


END Assertion.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.4 gm2-libs/Break

 
DEFINITION MODULE Break ;

END Break.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.5 gm2-libs/Builtins

 
DEFINITION MODULE Builtins ;

(*
    Description: provides a convenient place to list all the GNU Modula-2
                 built-in functions. These functions should be copied into
                 more generic modules.

                 For example the mathematical functions can be applied to
                 gm2-iso/LongMath. But each built-in function is here for
                 reference.
*)

FROM SYSTEM IMPORT ADDRESS ;

PROCEDURE __BUILTIN__ sinf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ sin (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sinl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ cosf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ cos (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ cosl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ sqrtf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ sqrt (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sqrtl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ fabsf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ fabs (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ fabsl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ logf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ log (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ logl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ expf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ exp (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ expl (x: LONGREAL) : LONGREAL ;

PROCEDURE __BUILTIN__ alloca (i: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ memcpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ index (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE __BUILTIN__ rindex (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE __BUILTIN__ memcmp (s1, s2: ADDRESS; n: CARDINAL) : INTEGER ;
PROCEDURE __BUILTIN__ memset (s: ADDRESS; c: INTEGER; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ strcat (dest, src: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strncat (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ strcpy (dest, src: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strncpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE __BUILTIN__ strcmp (s1, s2: ADDRESS) : INTEGER ;
PROCEDURE __BUILTIN__ strncmp (s1, s2: ADDRESS; n: CARDINAL) : INTEGER ;
PROCEDURE __BUILTIN__ strlen (s: ADDRESS) : INTEGER ;
PROCEDURE __BUILTIN__ strstr (haystack, needle: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strpbrk (s, accept: ADDRESS) : ADDRESS ;
PROCEDURE __BUILTIN__ strspn (s, accept: ADDRESS) : CARDINAL ;
PROCEDURE __BUILTIN__ strcspn (s, accept: ADDRESS) : CARDINAL ;
PROCEDURE __BUILTIN__ strchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE __BUILTIN__ strrchr (s: ADDRESS; c: INTEGER) : ADDRESS ;

PROCEDURE __BUILTIN__ huge_val (r: REAL) : REAL ;
PROCEDURE __BUILTIN__ huge_valf (s: SHORTREAL) : SHORTREAL ;
PROCEDURE __BUILTIN__ huge_vall (l: LONGREAL) : LONGREAL ;

END Builtins.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.6 gm2-libs/CmdArgs

 
DEFINITION MODULE CmdArgs ;

(*
   Description: CmdArgs - implements procedures to retrieve arguments from
                a string.
*)

EXPORT QUALIFIED GetArg, Narg ;


(*
   GetArg - returns the nth argument from the command line, CmdLine
            the success of the operation is returned.
*)

PROCEDURE GetArg (CmdLine: ARRAY OF CHAR;
                  n: CARDINAL; VAR Argi: ARRAY OF CHAR) : BOOLEAN ;


(*
   Narg - returns the number of arguments available from
          command line, CmdLine.
*)

PROCEDURE Narg (CmdLine: ARRAY OF CHAR) : CARDINAL ;


END CmdArgs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.7 gm2-libs/Debug

 
DEFINITION MODULE Debug ;

(*
    Description: provides some simple debugging routines.
*)

EXPORT QUALIFIED Halt, DebugString ;


(*
   Halt - writes a message in the format:
          Module:Line:Message

          It then terminates by calling HALT.
*)

PROCEDURE Halt (Message: ARRAY OF CHAR;
                LineNo: CARDINAL;
                Module: ARRAY OF CHAR) ;


(*
   DebugString - writes a string to the debugging device (Scn.Write).
                 It interprets \n as carriage return, linefeed.
*)

PROCEDURE DebugString (a: ARRAY OF CHAR) ;


END Debug.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.8 gm2-libs/DynamicStrings

 
DEFINITION MODULE DynamicStrings ;

(*
    Description: provides a dynamic string type and common methods.
*)

FROM SYSTEM IMPORT ADDRESS ;
EXPORT QUALIFIED String,
                 InitString, KillString, Fin, InitStringCharStar, InitStringChar,
                 Index, RIndex,
                 Mark, Length, ConCat, ConCatChar, Assign, Dup, Add,
                 Equal, EqualCharStar, EqualArray, ToUpper, ToLower,
                 CopyOut, Mult, Slice, RemoveWhitePrefix, char, string ;

TYPE
   String ;


(*
   InitString - creates and returns a String type object.
                Initial contents are, a.
*)

PROCEDURE InitString (a: ARRAY OF CHAR) : String ;


(*
   KillString - frees String, s, and its contents.
                NIL is returned.
*)

PROCEDURE KillString (s: String) : String ;


(*
   Fin - finishes with a string, it calls KillString with, s.
         The purpose of the procedure is to provide a short cut
         to calling KillString and then testing the return result.
*)

PROCEDURE Fin (s: String) ;


(*
   InitStringCharStar - initializes and returns a String to contain the C string.
*)

PROCEDURE InitStringCharStar (a: ADDRESS) : String ;


(*
   InitStringChar - initializes and returns a String to contain the single character, ch.
*)

PROCEDURE InitStringChar (ch: CHAR) : String ;


(*
   Mark - marks String, s, ready for garbage collection.
*)

PROCEDURE Mark (s: String) : String ;


(*
   Length - returns the length of the String, s.
*)

PROCEDURE Length (s: String) : CARDINAL ;


(*
   ConCat - returns String, a, after the contents of, b, have been appended.
*)

PROCEDURE ConCat (a, b: String) : String ;


(*
   ConCatChar - returns String, a, after character, ch, has been appended.
*)

PROCEDURE ConCatChar (a: String; ch: CHAR) : String ;


(*
   Assign - assigns the contents of, b, into, a.
            String, a, is returned.
*)

PROCEDURE Assign (a, b: String) : String ;


(*
   Dup - duplicate a String, s, returning the copy of s.
*)

PROCEDURE Dup (s: String) : String ;


(*
   Add - returns a new String which contains the contents of a and b.
*)

PROCEDURE Add (a, b: String) : String ;


(*
   Equal - returns TRUE if String, a, and, b, are equal.
*)

PROCEDURE Equal (a, b: String) : BOOLEAN ;


(*
   EqualCharStar - returns TRUE if contents of String, s, is the same as the
                   string, a.
*)

PROCEDURE EqualCharStar (s: String; a: ADDRESS) : BOOLEAN ;


(*
   EqualArray - returns TRUE if contents of String, s, is the same as the
                string, a.
*)

PROCEDURE EqualArray (s: String; a: ARRAY OF CHAR) : BOOLEAN ;


(*
   Mult - returns a new string which is n concatenations of String, s.
          If n<=0 then an empty string is returned.
*)

PROCEDURE Mult (s: String; n: CARDINAL) : String ;


(*
   Slice - returns a new string which contains the elements
           low..high-1

           strings start at element 0
           Slice(s, 0, 2)  will return elements 0, 1 but not 2
           Slice(s, 1, 3)  will return elements 1, 2 but not 3
           Slice(s, 2, 0)  will return elements 2..max
           Slice(s, 3, -1) will return elements 3..max-1
           Slice(s, 4, -2) will return elements 4..max-2
*)

PROCEDURE Slice (s: String; low, high: INTEGER) : String ;


(*
   Index - returns the indice of the first occurance of, ch, in
           String, s. -1 is returned if, ch, does not exist.
           The search starts at position, o.
           -1 is returned if, ch, is not found.
*)

PROCEDURE Index (s: String; ch: CHAR; o: CARDINAL) : INTEGER ;


(*
   RIndex - returns the indice of the last occurance of, ch,
            in String, s. The search starts at position, o.
            -1 is returned if, ch, is not found.
*)

PROCEDURE RIndex (s: String; ch: CHAR; o: CARDINAL) : INTEGER ;


(*
   RemoveWhitePrefix - removes any leading white space from String, s.
                       A new string is returned.
*)

PROCEDURE RemoveWhitePrefix (s: String) : String ;


(*
   ToUpper - returns string, s, after it has had its lower case characters
             replaced by upper case characters.
             The string, s, is not duplicated.
*)

PROCEDURE ToUpper (s: String) : String ;


(*
   ToLower - returns string, s, after it has had its upper case characters
             replaced by lower case characters.
             The string, s, is not duplicated.
*)

PROCEDURE ToLower (s: String) : String ;


(*
   CopyOut - copies string, s, to a.
*)

PROCEDURE CopyOut (VAR a: ARRAY OF CHAR; s: String) ;


(*
   char - returns the character, ch, at position, i, in String, s.
          As Slice the index can be negative so:

          char(s, 0) will return the first character
          char(s, 1) will return the second character
          char(s, -1) will return the last character
          char(s, -2) will return the penultimate character

          a nul character is returned if the index is out of range.
*)

PROCEDURE char (s: String; i: INTEGER) : CHAR ;


(*
   string - returns the C style char * of String, s.
*)

PROCEDURE string (s: String) : ADDRESS ;


END DynamicStrings.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.9 gm2-libs/Environment

 
DEFINITION MODULE Environment ;

(*
    Description: provides access to the environment settings of a process.
*)

EXPORT QUALIFIED GetEnvironment ;


(*
   GetEnvironment - gets the environment variable, Env, and places
      	       	    a copy of its value into string, a.
*)

PROCEDURE GetEnvironment (Env: ARRAY OF CHAR; VAR a: ARRAY OF CHAR) : BOOLEAN ;


END Environment.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.10 gm2-libs/FIO

 
DEFINITION MODULE FIO ;

(*
    Description: provides a simple buffered file input/output library.
*)


FROM SYSTEM IMPORT ADDRESS, BYTE ;

EXPORT QUALIFIED (* types *)
                 File,
                 (* procedures *)
                 OpenToRead, OpenToWrite, OpenForRandom, Close,
                 EOF, EOLN, IsNoError, Exists,
                 exists, openToRead, openToWrite, openForRandom,
                 SetPositionFromBeginning, FindPosition,
                 ReadChar, ReadString,
                 WriteChar, WriteString, WriteLine,
                 WriteCardinal, ReadCardinal,
                 UnReadChar,
                 WriteNBytes, ReadNBytes,
                 GetUnixFileDescriptor,
                 (* variables *)
                 StdIn, StdOut, StdErr ;

TYPE
   File = CARDINAL ;

(* the following variables are initialized to their UNIX equivalents *)
VAR
   StdIn, StdOut, StdErr: File ;



(*
   IsNoError - returns a TRUE if no error has occured on file, f.
*)

PROCEDURE IsNoError (f: File) : BOOLEAN ;


(*
   Exists - returns TRUE if a file named, fname exists for reading.
*)

PROCEDURE Exists (fname: ARRAY OF CHAR) : BOOLEAN ;


(*
   OpenToRead - attempts to open a file, fname, for reading and
                it returns this file.
                The success of this operation can be checked by
                calling IsNoError.
*)

PROCEDURE OpenToRead (fname: ARRAY OF CHAR) : File ;


(*
   OpenToWrite - attempts to open a file, fname, for write and
                 it returns this file.
                 The success of this operation can be checked by
                 calling IsNoError.
*)

PROCEDURE OpenToWrite (fname: ARRAY OF CHAR) : File ;


(*
   OpenForRandom - attempts to open a file, fname, for random access
                   read or write and it returns this file.
                   The success of this operation can be checked by
                   calling IsNoError.
                   towrite, determines whether the file should be
                   opened for writing or reading.
*)

PROCEDURE OpenForRandom (fname: ARRAY OF CHAR; towrite: BOOLEAN) : File ;


(*
   Close - close a file which has been previously opened using:
           OpenToRead, OpenToWrite, OpenForRandom.
           It is correct to close a file which has an error status.
*)

PROCEDURE Close (f: File) ;


(* the following functions are functionally equivalent to the above
   except they allow C style names.
*)

PROCEDURE exists        (fname: ADDRESS; flength: CARDINAL) : BOOLEAN ;
PROCEDURE openToRead    (fname: ADDRESS; flength: CARDINAL) : File ;
PROCEDURE openToWrite   (fname: ADDRESS; flength: CARDINAL) : File ;
PROCEDURE openForRandom (fname: ADDRESS; flength: CARDINAL; towrite: BOOLEAN) : File ;


(*
   ReadNBytes - reads nBytes of a file into memory area, a, returning
                the number of bytes actually read.
                This function will consume from the buffer and then
                perform direct libc reads. It is ideal for large reads.
*)

PROCEDURE ReadNBytes (f: File; nBytes: CARDINAL; a: ADDRESS) : CARDINAL ;


(*
   ReadAny - reads HIGH(a) bytes into, a. All input
             is fully buffered, unlike ReadNBytes and thus is more
             suited to small reads.
*)

PROCEDURE ReadAny (f: File; VAR a: ARRAY OF BYTE) ;


(*
   WriteNBytes - writes nBytes of a file into memory area, a, returning
                 the number of bytes actually written.
                 This function will flush the buffer and then
                 write the nBytes using a direct write from libc.
                 It is ideal for large writes.
*)

PROCEDURE WriteNBytes (f: File; nBytes: CARDINAL; a: ADDRESS) : CARDINAL ;


(*
   WriteAny - writes HIGH(a) bytes onto, file, f. All output
              is fully buffered, unlike WriteNBytes and thus is more
              suited to small writes.
*)

PROCEDURE WriteAny (f: File; VAR a: ARRAY OF BYTE) ;


(*
   WriteChar - writes a single character to file, f.
*)

PROCEDURE WriteChar (f: File; ch: CHAR) ;


(*
   EOF - tests to see whether a file, f, has reached end of file.
*)

PROCEDURE EOF (f: File) : BOOLEAN ;


(*
   EOLN - tests to see whether a file, f, is upon a newline.
          It does NOT consume the newline.
*)

PROCEDURE EOLN (f: File) : BOOLEAN ;


(*
   ReadChar - returns a character read from file, f.
              Sensible to check with IsNoError or EOF after calling
              this function.
*)

PROCEDURE ReadChar (f: File) : CHAR ;


(*
   UnReadChar - replaces a character, ch, back into file, f.
                This character must have been read by ReadChar
                and it does not allow successive calls.
*)

PROCEDURE UnReadChar (f: File ; ch: CHAR) ;


(*
   WriteLine - writes out a linefeed to file, f.
*)

PROCEDURE WriteLine (f: File) ;


(*
   WriteString - writes a string to file, f.
*)

PROCEDURE WriteString (f: File; a: ARRAY OF CHAR) ;


(*
   ReadString - reads a string from file, f, into string, a.
                It terminates the string if HIGH is reached or
                if a newline is seen or an error occurs.
*)

PROCEDURE ReadString (f: File; VAR a: ARRAY OF CHAR) ;


(*
   WriteCardinal - writes a CARDINAL to file, f.
                   (Suggest that WriteAny be used instead -
                    here for compatibility)
*)

PROCEDURE WriteCardinal (f: File; c: CARDINAL) ;


(*
   ReadCardinal - reads a CARDINAL from file, f.
                  (Suggest that ReadAny be used instead -
                   here for compatibility)
*)

PROCEDURE ReadCardinal (f: File) : CARDINAL ;


(*
   GetUnixFileDescriptor - returns the UNIX file descriptor of a file.
                           Useful when combining FIO.mod with select
                           (in Selective.def - but note the comments in
                            Selective about using read/write primatives)
*)

PROCEDURE GetUnixFileDescriptor (f: File) : INTEGER ;


(*
   SetPositionFromBeginning - sets the position from the beginning of the file.
*)

PROCEDURE SetPositionFromBeginning (f: File; pos: CARDINAL) ;


(*
   FindPosition - returns the current absolute position in file, f.
*)

PROCEDURE FindPosition (f: File) : CARDINAL ;


END FIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.11 gm2-libs/FormatStrings

 
DEFINITION MODULE FormatStrings ;

(*
    Description: provides a pseudo printf capability for GM2.
*)

FROM SYSTEM IMPORT BYTE ;
FROM DynamicStrings IMPORT String ;
EXPORT QUALIFIED Sprintf0, Sprintf1, Sprintf2, Sprintf3, Sprintf4 ;


(*
   Sprintf0 - returns a String containing, s, after it has had its
              escape sequences translated.
*)

PROCEDURE Sprintf0 (s: String) : String ;


(*
   Sprintf1 - returns a String containing, s, together with encapsulated
              entity, w. It only formats the first %s or %d with n.
*)

PROCEDURE Sprintf1 (s: String; w: ARRAY OF BYTE) : String ;


(*
   Sprintf2 - returns a string, s, which has been formatted.
*)

PROCEDURE Sprintf2 (s: String; w1, w2: ARRAY OF BYTE) : String ;


(*
   Sprintf3 - returns a string, s, which has been formatted.
*)

PROCEDURE Sprintf3 (s: String; w1, w2, w3: ARRAY OF BYTE) : String ;


(*
   Sprintf4 - returns a string, s, which has been formatted.
*)

PROCEDURE Sprintf4 (s: String; w1, w2, w3, w4: ARRAY OF BYTE) : String ;


END FormatStrings.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.12 gm2-libs/FpuIO

 
DEFINITION MODULE FpuIO ;

(*
   Description: Implements a fixed format input/output for REAL, LONGREAL and LONGINT numbers
*)

EXPORT QUALIFIED ReadReal, WriteReal, StrToReal, RealToStr,
                 ReadLongReal, WriteLongReal, StrToLongReal, LongRealToStr,
                 ReadLongInt, WriteLongInt, StrToLongInt, LongIntToStr ;


PROCEDURE ReadReal (VAR x: REAL) ;
PROCEDURE WriteReal (x: REAL; TotalWidth, FractionWidth: CARDINAL) ;
PROCEDURE StrToReal (a: ARRAY OF CHAR ; VAR x: REAL) ;
PROCEDURE RealToStr (x: REAL; TotalWidth, FractionWidth: CARDINAL; VAR a: ARRAY OF CHAR) ;

PROCEDURE ReadLongReal (VAR x: LONGREAL) ;
PROCEDURE WriteLongReal (x: LONGREAL; TotalWidth, FractionWidth: CARDINAL) ;
PROCEDURE StrToLongReal (a: ARRAY OF CHAR ; VAR x: LONGREAL) ;
PROCEDURE LongRealToStr (x: LONGREAL; TotalWidth, FractionWidth: CARDINAL; VAR a: ARRAY OF CHAR) ;

PROCEDURE ReadLongInt (VAR x: LONGINT) ;
PROCEDURE WriteLongInt (x: LONGINT; n: CARDINAL) ;
PROCEDURE StrToLongInt (a: ARRAY OF CHAR ; VAR x: LONGINT) ;
PROCEDURE LongIntToStr (x: LONGINT; n: CARDINAL; VAR a: ARRAY OF CHAR) ;


END FpuIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.13 gm2-libs/IO

 
DEFINITION MODULE IO ;

(*
   Description: provides Read, Write, Errors procedures that map onto UNIX
                file descriptors 0, 1 and 2. This is achieved by using
                FIO if we are in buffered mode and using libc.write
                if not.
*)

EXPORT QUALIFIED Read, Write, Error,
                 IOInRawMode, IOInBufferedMode ;


PROCEDURE Read (VAR ch: CHAR) ;
PROCEDURE Write (ch: CHAR) ;
PROCEDURE Error (ch: CHAR) ;
PROCEDURE IOInRawMode ;
PROCEDURE IOInBufferedMode ;


END IO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.14 gm2-libs/M2RTS

 
DEFINITION MODULE M2RTS ;

(*
   Description: Implements the run time system facilities of Modula-2.
*)

FROM SYSTEM IMPORT BITSET ;
EXPORT QUALIFIED HALT, Halt,
                 SubrangeAssignmentError, ArraySubscriptError,
                 FunctionReturnError, NilPointerError,
                 CaseElseError,
                 InstallTerminationProcedure, Terminate,
                 ExitOnHalt, Length ;


(*
   HALT - terminate the current program.
          The procedure Terminate is called before the program is
          stopped.
*)

PROCEDURE HALT ;


(*
   Halt - provides a more user friendly version of HALT, which takes
          four parameters to aid debugging.
*)

PROCEDURE Halt (file: ARRAY OF CHAR; line: CARDINAL;
                function: ARRAY OF CHAR; description: ARRAY OF CHAR) ;


(*
   SubrangeAssignmentError - part of the runtime checking, called if a
                             subrange variable is just about to be assigned an illegal value.
*)

PROCEDURE SubrangeAssignmentError (file: ARRAY OF CHAR;
                                   line: CARDINAL;
                                   function: ARRAY OF CHAR) ;


(*
   ArraySubscriptError -  part of the runtime checking, called if an
                          array indice is out of range.
*)

PROCEDURE ArraySubscriptError (file: ARRAY OF CHAR;
                               line: CARDINAL;
                               function: ARRAY OF CHAR) ;


(*
   FunctionReturnError -  part of the runtime checking, called if a
                          function exits without a RETURN statement.
*)

PROCEDURE FunctionReturnError (file: ARRAY OF CHAR;
                               line: CARDINAL;
                               function: ARRAY OF CHAR) ;


(*
   NilPointerError -  part of the runtime checking, called if a
                      the code is about to dereference NIL.
*)

PROCEDURE NilPointerError (file: ARRAY OF CHAR;
                           line: CARDINAL;
                           function: ARRAY OF CHAR) ;

(*
   CaseElseError - part of the runtime checking, called if a
                   CASE statement falls into an ELSE statement
                   (which was not declared by the programmer).
*)

PROCEDURE CaseElseError (file: ARRAY OF CHAR;
                         line: CARDINAL;
                         function: ARRAY OF CHAR) ;


(*
   ExitOnHalt - if HALT is executed then call exit with the exit code, e.
*)

PROCEDURE ExitOnHalt (e: INTEGER) ;


(*
   InstallTerminationProcedure - installs a procedure, p, which will
                                 be called when the procedure Terminate
                                 is ionvoked.
*)

PROCEDURE InstallTerminationProcedure (p: PROC) ;


(*
   Terminate - calls each installed termination procedure in turn.
*)

PROCEDURE Terminate ;


(*
   Length - returns the length of a string, a. This is called whenever
            the user calls LENGTH and the parameter cannot be calculated
            at compile time.
*)

PROCEDURE Length (a: ARRAY OF CHAR) : CARDINAL ;


END M2RTS.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.15 gm2-libs/MathLib0

 
DEFINITION MODULE MathLib0 ;

(*
    Description: provides access to math functions.
*)

CONST
   pi   = 3.1415926535897932384626433832795028841972;
   exp1 = 2.7182818284590452353602874713526624977572;


PROCEDURE __BUILTIN__ sqrt (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sqrtl (x: LONGREAL) : LONGREAL ;
PROCEDURE __BUILTIN__ sqrts (x: SHORTREAL) : SHORTREAL ;

PROCEDURE exp (x: REAL) : REAL ;
PROCEDURE exps (x: SHORTREAL) : SHORTREAL ;

PROCEDURE ln (x: REAL) : REAL ;
PROCEDURE lns (x: SHORTREAL) : SHORTREAL ;

PROCEDURE __BUILTIN__ sin (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ sinl (x: LONGREAL) : LONGREAL ;
PROCEDURE __BUILTIN__ sins (x: SHORTREAL) : SHORTREAL ;

PROCEDURE __BUILTIN__ cos (x: REAL) : REAL ;
PROCEDURE __BUILTIN__ cosl (x: LONGREAL) : LONGREAL ;
PROCEDURE __BUILTIN__ coss (x: SHORTREAL) : SHORTREAL ;

PROCEDURE tan (x: REAL) : REAL ;
PROCEDURE tans (x: SHORTREAL) : SHORTREAL ;

PROCEDURE arctan (x: REAL) : REAL ;
PROCEDURE arctans (x: SHORTREAL) : SHORTREAL ;

PROCEDURE entier (x: REAL) : INTEGER ;
PROCEDURE entiers (x: SHORTREAL) : INTEGER ;

END MathLib0.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.16 gm2-libs/MemUtils

 
DEFINITION MODULE MemUtils ;

(*
    Description: provides some basic memory utilities.
*)

FROM SYSTEM IMPORT ADDRESS ;
EXPORT QUALIFIED MemCopy, MemZero ;


(*
   MemCopy - copys a region of memory to the required destination.
*)

PROCEDURE MemCopy (from: ADDRESS; length: CARDINAL; to: ADDRESS) ;


(*
   MemZero - sets a region of memory: a..a+length to zero.
*)

PROCEDURE MemZero (a: ADDRESS; length: CARDINAL) ;


END MemUtils.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.17 gm2-libs/NumberIO

 
DEFINITION MODULE NumberIO ;

(*
   Description: Provides all the input/output of numbers, and also the conversion
                of numbers to strings and visa versa.
*)

EXPORT QUALIFIED ReadCard, WriteCard, ReadHex, WriteHex, ReadInt, WriteInt,
                 CardToStr, StrToCard, StrToHex, HexToStr, StrToInt, IntToStr,
                 ReadOct, WriteOct, OctToStr, StrToOct,
                 ReadBin, WriteBin, BinToStr, StrToBin,
                 StrToBinInt, StrToHexInt, StrToOctInt ;


PROCEDURE ReadCard (VAR x: CARDINAL) ;

PROCEDURE WriteCard (x, n: CARDINAL) ;

PROCEDURE ReadHex (VAR x: CARDINAL) ;

PROCEDURE WriteHex (x, n: CARDINAL) ;

PROCEDURE ReadInt (VAR x: INTEGER) ;

PROCEDURE WriteInt (x: INTEGER ; n: CARDINAL) ;

PROCEDURE CardToStr (x, n: CARDINAL ; VAR a: ARRAY OF CHAR) ;

PROCEDURE StrToCard (a: ARRAY OF CHAR ; VAR x: CARDINAL) ;

PROCEDURE HexToStr (x, n: CARDINAL ; VAR a: ARRAY OF CHAR) ;

PROCEDURE StrToHex (a: ARRAY OF CHAR ; VAR x: CARDINAL) ;

PROCEDURE IntToStr (x: INTEGER ; n: CARDINAL ; VAR a: ARRAY OF CHAR) ;

PROCEDURE StrToInt (a: ARRAY OF CHAR ; VAR x: INTEGER) ;

PROCEDURE ReadOct (VAR x: CARDINAL) ;

PROCEDURE WriteOct (x, n: CARDINAL) ;

PROCEDURE OctToStr (x, n: CARDINAL ; VAR a: ARRAY OF CHAR) ;

PROCEDURE StrToOct (a: ARRAY OF CHAR ; VAR x: CARDINAL) ;

PROCEDURE ReadBin (VAR x: CARDINAL) ;

PROCEDURE WriteBin (x, n: CARDINAL) ;

PROCEDURE BinToStr (x, n: CARDINAL ; VAR a: ARRAY OF CHAR) ;

PROCEDURE StrToBin (a: ARRAY OF CHAR ; VAR x: CARDINAL) ;

PROCEDURE StrToBinInt (a: ARRAY OF CHAR ; VAR x: INTEGER) ;

PROCEDURE StrToHexInt (a: ARRAY OF CHAR ; VAR x: INTEGER) ;

PROCEDURE StrToOctInt (a: ARRAY OF CHAR ; VAR x: INTEGER) ;


END NumberIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.18 gm2-libs/PushBackInput

 
DEFINITION MODULE PushBackInput ;

(*
    Description: provides a method for pushing back and consuming input
                 from a standard file descriptor. Insipred by software
                 tools.
*)

FROM FIO IMPORT File ;
FROM DynamicStrings IMPORT String ;

EXPORT QUALIFIED Open, PutCh, GetCh, Error, WarnError, WarnString, Close, SetDebug, GetExitStatus,
                 PutString, GetColumnPosition, GetCurrentLine ;


(*
   Open - opens a file for reading.
*)

PROCEDURE Open (a: ARRAY OF CHAR) : File ;


(*
   GetCh - gets a character from either the push back stack or
           from file, f.
*)

PROCEDURE GetCh (f: File) : CHAR ;


(*
   PutCh - pushes a character onto the push back stack, it also
           returns the character which has been pushed.
*)

PROCEDURE PutCh (f: File; ch: CHAR) : CHAR ;


(*
   PutString - pushes a string onto the push back stack.
*)

PROCEDURE PutString (f: File; a: ARRAY OF CHAR) ;


(*
   Error - emits an error message with the appropriate file, line combination.
*)

PROCEDURE Error (a: ARRAY OF CHAR) ;


(*
   WarnError - emits an error message with the appropriate file, line combination.
               It does not terminate but when the program finishes an exit status of
               1 will be issued.
*)

PROCEDURE WarnError (a: ARRAY OF CHAR) ;


(*
   WarnString - emits an error message with the appropriate file, line combination.
                It does not terminate but when the program finishes an exit status of
                1 will be issued.
*)

PROCEDURE WarnString (s: String) ;


(*
   Close - closes the opened file.
*)

PROCEDURE Close (f: File) ;


(*
   GetExitStatus - returns the exit status which will be 1 if any warnings were issued.
*)

PROCEDURE GetExitStatus () : CARDINAL ;


(*
   SetDebug - sets the debug flag on or off.
*)

PROCEDURE SetDebug (d: BOOLEAN) ;


(*
   GetColumnPosition - returns the column position of the current character.
*)

PROCEDURE GetColumnPosition () : CARDINAL ;


(*
   GetCurrentLine - returns the current line number.
*)

PROCEDURE GetCurrentLine () : CARDINAL ;


END PushBackInput.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.19 gm2-libs/SArgs

 
DEFINITION MODULE SArgs ;

(*
    Description: provides a String interface to the command line arguments.
*)

FROM DynamicStrings IMPORT String ;
EXPORT QUALIFIED GetArg, Narg ;


(*
   GetArg - returns the nth argument from the command line.
            The success of the operation is returned.
            If TRUE is returned then the string, s, contains a
            new string, otherwise s is set to NIL.
*)

PROCEDURE GetArg (VAR s: String ; i: CARDINAL) : BOOLEAN ;


(*
   Narg - returns the number of arguments available from
          command line.
*)

PROCEDURE Narg() : CARDINAL ;


END SArgs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.20 gm2-libs/SEnvironment

 
DEFINITION MODULE SEnvironment ;

(*
    Description: provides access to the environment settings of a process.
*)

FROM DynamicStrings IMPORT String ;
EXPORT QUALIFIED GetEnvironment ;


(*
   GetEnvironment - gets the environment variable, env, and places
      	       	    a copy of its value into String, s.
                    TRUE is returned if successful.
*)

PROCEDURE GetEnvironment (env: String; VAR s: String) : BOOLEAN ;


END SEnvironment.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.21 gm2-libs/SFIO

 
DEFINITION MODULE SFIO ;

(*
    Description: provides a String interface to the opening routines of FIO
*)

FROM DynamicStrings IMPORT String ;
FROM FIO IMPORT File ;

EXPORT QUALIFIED OpenToRead, OpenToWrite, OpenForRandom, Exists, WriteS, ReadS ;


(*
   Exists - returns TRUE if a file named, fname exists for reading.
*)

PROCEDURE Exists (fname: String) : BOOLEAN ;


(*
   OpenToRead - attempts to open a file, fname, for reading and
                it returns this file.
                The success of this operation can be checked by
                calling IsNoError.
*)

PROCEDURE OpenToRead (fname: String) : File ;


(*
   OpenToWrite - attempts to open a file, fname, for write and
                 it returns this file.
                 The success of this operation can be checked by
                 calling IsNoError.
*)

PROCEDURE OpenToWrite (fname: String) : File ;


(*
   OpenForRandom - attempts to open a file, fname, for random access
                   read or write and it returns this file.
                   The success of this operation can be checked by
                   calling IsNoError.
                   towrite, determines whether the file should be
                   opened for writing or reading.
*)

PROCEDURE OpenForRandom (fname: String; towrite: BOOLEAN) : File ;


(*
   WriteS - writes a string, s, to, file. It returns the String, s.
*)

PROCEDURE WriteS (file: File; s: String) : String ;


(*
   ReadS - reads a string, s, from, file. It returns the String, s.
           It stops reading the string at the end of line or end of file.
           It consumes the newline at the end of line but does not place
           this into the returned string.
*)

PROCEDURE ReadS (file: File) : String ;


END SFIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.22 gm2-libs/SYSTEM

 
DEFINITION MODULE SYSTEM ;

(*
   Description: Implements the SYSTEM dependent module
                in the Modula-2 compiler.
*)

EXPORT QUALIFIED (* the following are built into the compiler: *)
                 ADDRESS, WORD, BYTE, BITSET, ADR, TSIZE, SIZE ;

END SYSTEM.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.23 gm2-libs/Scan

 
DEFINITION MODULE Scan ;

(*
   Description: Provides a primitive symbol fetching from input.
                Symbols are delimited by spaces and tabs.
                Limitation - only allows one source file at
                             a time to deliver symbols.
*)


EXPORT QUALIFIED GetNextSymbol, WriteError,
                 OpenSource, CloseSource,
                 TerminateOnError, DefineComments ;


(* OpenSource - opens a source file for reading.                  *)

PROCEDURE OpenSource (a: ARRAY OF CHAR) : BOOLEAN ;


(* CloseSource - closes the current source file from reading.     *)

PROCEDURE CloseSource ;


(* GetNextSymbol gets the next source symbol and returns it in a. *)

PROCEDURE GetNextSymbol (VAR a: ARRAY OF CHAR) ;


(* WriteError writes a message, a, under the source line, which   *)
(* attempts to pinpoint the Symbol at fault.                      *)

PROCEDURE WriteError (a: ARRAY OF CHAR) ;


(*
   TerminateOnError - exits with status 1 if we call WriteError.
*)

PROCEDURE TerminateOnError ;


(*
   DefineComments - defines the start of comments within the source
                    file.

                    The characters in Start define the comment start
                    and characters in End define the end.
                    The BOOLEAN eoln determine whether the comment
                    is terminated by end of line. If eoln is TRUE
                    then End is ignored.

                    If this procedure is never called then no comments
                    are allowed.
*)

PROCEDURE DefineComments (Start, End: ARRAY OF CHAR; eoln: BOOLEAN) ;


END Scan.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.24 gm2-libs/Selective

 
DEFINITION MODULE Selective ;

(*
    Description: provides Modula-2 with access to the select(2) primitive.
*)

FROM SYSTEM IMPORT ADDRESS ;

EXPORT QUALIFIED SetOfFd, Timeval,
                 InitSet, KillSet, InitTime, KillTime,
                 GetTime, SetTime,
                 FdZero, FdSet, FdClr, FdIsSet, Select,
                 MaxFdsPlusOne, WriteCharRaw, ReadCharRaw,
                 GetTimeOfDay ;

TYPE
   SetOfFd = ADDRESS ;    (* Hidden type in Selective.c *)
   Timeval = ADDRESS ;    (* Hidden type in Selective.c *)


PROCEDURE Select (nooffds: CARDINAL;
                  readfds, writefds, exceptfds: SetOfFd;
                  timeout: Timeval) : INTEGER ;

PROCEDURE InitTime (sec, usec: CARDINAL) : Timeval ;
PROCEDURE KillTime (t: Timeval) : Timeval ;
PROCEDURE GetTime (t: Timeval; VAR sec, usec: CARDINAL) ;
PROCEDURE SetTime (t: Timeval; sec, usec: CARDINAL) ;
PROCEDURE InitSet () : SetOfFd ;
PROCEDURE KillSet (s: SetOfFd) : SetOfFd ;
PROCEDURE FdZero (s: SetOfFd) ;
PROCEDURE FdSet (fd: INTEGER; s: SetOfFd) ;
PROCEDURE FdClr (fd: INTEGER; s: SetOfFd) ;
PROCEDURE FdIsSet (fd: INTEGER; s: SetOfFd) : BOOLEAN ;
PROCEDURE MaxFdsPlusOne (a, b: INTEGER) : INTEGER ;

(* you must use the raw routines with select - not the FIO buffered routines *)
PROCEDURE WriteCharRaw (fd: INTEGER; ch: CHAR) ;
PROCEDURE ReadCharRaw (fd: INTEGER) : CHAR ;

(*
   GetTimeOfDay - fills in a record, Timeval, filled in with the
                  current system time in seconds and microseconds.
                  It returns zero (see man 3p gettimeofday)
*)

PROCEDURE GetTimeOfDay (tv: Timeval) : INTEGER ;


END Selective.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.25 gm2-libs/StdIO

 
DEFINITION MODULE StdIO ;

(*
   Description: Exports a general Read and Write procedure that ALL character
                processes should use.
*)

EXPORT QUALIFIED ProcRead, ProcWrite,
                 Read, Write, PushOutput, PopOutput, GetCurrentOutput ;


TYPE
   ProcWrite = PROCEDURE (CHAR) ;
   ProcRead  = PROCEDURE (VAR CHAR) ;


(*
   Read - is the generic procedure that all higher application layers
          should use to receive a character.
*)

PROCEDURE Read (VAR ch: CHAR) ;


(*
   Write - is the generic procedure that all higher application layers
           should use to emit a character.
*)

PROCEDURE Write (ch: CHAR) ;


(*
   PushOutput - pushes the current Write procedure onto a stack,
                any future references to Write will actually invoke
                procedure, p.
*)

PROCEDURE PushOutput (p: ProcWrite) ;


(*
   PopOutput - restores Write to use the previous output procedure.
*)

PROCEDURE PopOutput ;


(*
   GetCurrentOutput - returns the current output procedure.
*)

PROCEDURE GetCurrentOutput () : ProcWrite ;


END StdIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.26 gm2-libs/Storage

 
DEFINITION MODULE Storage ;

(*
   Description: Implements the dynamic Storage handler for the
                Modula-2 compiler.
*)

FROM SYSTEM IMPORT ADDRESS ;

EXPORT QUALIFIED ALLOCATE, DEALLOCATE, REALLOCATE, Available ;



(*
   ALLOCATE - attempt to allocate memory from the heap.
              NIL is returned in, a, if ALLOCATE fails.
*)

PROCEDURE ALLOCATE (VAR a: ADDRESS ; Size: CARDINAL) ;


(*
   DEALLOCATE - return, Size, bytes to the heap.
                The variable, a, is set to NIL.
*)

PROCEDURE DEALLOCATE (VAR a: ADDRESS ; Size: CARDINAL) ;


(*
   REALLOCATE - attempts to reallocate storage. The address,
                a, should either be NIL in which case ALLOCATE
                is called, or alternatively it should have already
                been initialized by ALLOCATE. The allocated storage
                is resized accordingly.
*)

PROCEDURE REALLOCATE (VAR a: ADDRESS; Size: CARDINAL) ;


(*
   Available - returns TRUE if, Size, bytes can be allocated.
*)

PROCEDURE Available (Size: CARDINAL) : BOOLEAN ;


END Storage.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.27 gm2-libs/StrCase

 
DEFINITION MODULE StrCase ;


EXPORT QUALIFIED StrToUpperCase, StrToLowerCase, Cap, Lower ;


(*
   StrToUpperCase - converts string, a, to uppercase returning the
                    result in, b.
*)

PROCEDURE StrToUpperCase (a: ARRAY OF CHAR ; VAR b: ARRAY OF CHAR) ;


(*
   StrToLowerCase - converts string, a, to lowercase returning the
                    result in, b.
*)

PROCEDURE StrToLowerCase (a: ARRAY OF CHAR ; VAR b: ARRAY OF CHAR) ;


(*
   Cap - converts a lower case character into a capital character.
         If the character is not a lower case character 'a'..'z'
         then the character is simply returned unaltered.
*)

PROCEDURE Cap (ch: CHAR) : CHAR ;


(*
   Lower - converts an upper case character into a lower case character.
           If the character is not an upper case character 'A'..'Z'
           then the character is simply returned unaltered.
*)

PROCEDURE Lower (ch: CHAR) : CHAR ;


END StrCase.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.28 gm2-libs/StrIO

 
DEFINITION MODULE StrIO ;

(*
   Description: Provides simple string input output routines.
*)

EXPORT QUALIFIED ReadString, WriteString,
                 WriteLn ;


(*
   WriteLn - writes a carriage return and a newline
             character.
*)

PROCEDURE WriteLn ;


(*
   ReadString - reads a sequence of characters into a string.
                Line editing accepts Del, Ctrl H, Ctrl W and
                Ctrl U.
*)

PROCEDURE ReadString (VAR a: ARRAY OF CHAR) ;


(*
   WriteString - writes a string to the default output.
*)

PROCEDURE WriteString (a: ARRAY OF CHAR) ;



END StrIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.29 gm2-libs/StrLib

 
DEFINITION MODULE StrLib ;

(*
   Description: Provides string manipulation
*)

EXPORT QUALIFIED StrLen, StrCopy, StrEqual, StrConCat, StrLess,
      	       	 IsSubString, StrRemoveWhitePrefix ;


(*
   StrLess - returns TRUE if string, a, alphabetically occurs before
             string, b.
*)

PROCEDURE StrLess (a, b: ARRAY OF CHAR) : BOOLEAN ;


(*
   StrEqual - performs a = b on two strings.
*)

PROCEDURE StrEqual (a, b: ARRAY OF CHAR) : BOOLEAN ;


(*
   StrLen - returns the length of string, a.
*)

PROCEDURE StrLen (a: ARRAY OF CHAR) : CARDINAL ;


(*
   StrCopy - effectively performs b := a with two strings.
*)

PROCEDURE StrCopy (a: ARRAY OF CHAR ; VAR b: ARRAY OF CHAR) ;


(*
   StrConCat - combines a and b into c.
*)

PROCEDURE StrConCat (a, b: ARRAY OF CHAR; VAR c: ARRAY OF CHAR) ;


(*
   IsSubString - returns true if b is a subcomponent of a.
*)

PROCEDURE IsSubString (a, b: ARRAY OF CHAR) : BOOLEAN ;


(*
   StrRemoveWhitePrefix - copies string, into string, b, excluding any white
                          space infront of a.
*)

PROCEDURE StrRemoveWhitePrefix (a: ARRAY OF CHAR; VAR b: ARRAY OF CHAR) ;


END StrLib.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.30 gm2-libs/StringConvert

 
DEFINITION MODULE StringConvert ;

(*
    Description: provides functions to convert numbers to and from strings.
*)

FROM DynamicStrings IMPORT String ;
EXPORT QUALIFIED IntegerToString, StringToInteger,
                 StringToLongInteger, LongIntegerToString,
                 StringToCardinal, CardinalToString,
                 StringToLongCardinal, LongCardinalToString,
                 StringToShortCardinal, ShortCardinalToString,
                 StringToLongreal, LongrealToString,
                 stoi, itos, ctos, stoc, hstoi, ostoi, bstoi,
                 hstoc, ostoc, bstoc,
                 stor, stolr ;


(*
   IntegerToString - converts INTEGER, i, into a String. The field with
                     can be specified if non zero. Leading characters
                     are defined by padding and this function will
                     prepend a + if sign is set to TRUE.
                     The base allows the caller to generate binary,
                     octal, decimal, hexidecimal numbers.
                     The value of lower is only used when hexidecimal
                     numbers are generated and if TRUE then digits
                     abcdef are used, and if FALSE then ABCDEF are used.
*)

PROCEDURE IntegerToString (i: INTEGER; width: CARDINAL; padding: CHAR; sign: BOOLEAN;
                           base: CARDINAL; lower: BOOLEAN) : String ;


(*
   CardinalToString - converts CARDINAL, c, into a String. The field
                      width can be specified if non zero. Leading
                      characters are defined by padding.
                      The base allows the caller to generate binary,
                      octal, decimal, hexidecimal numbers.
                      The value of lower is only used when hexidecimal
                      numbers are generated and if TRUE then digits
                      abcdef are used, and if FALSE then ABCDEF are used.
*)

PROCEDURE CardinalToString (c: CARDINAL; width: CARDINAL; padding: CHAR;
                            base: CARDINAL; lower: BOOLEAN) : String ;


(*
   StringToInteger - converts a string, s, of, base, into an INTEGER.
                     Leading white space is ignored. It stops converting
                     when either the string is exhausted or if an illegal
                     numeral is found.
                     The parameter found is set TRUE if a number was found.
*)

PROCEDURE StringToInteger (s: String; base: CARDINAL; VAR found: BOOLEAN) : INTEGER ;


(*
   StringToCardinal - converts a string, s, of, base, into a CARDINAL.
                      Leading white space is ignored. It stops converting
                      when either the string is exhausted or if an illegal
                      numeral is found.
                      The parameter found is set TRUE if a number was found.
*)

PROCEDURE StringToCardinal (s: String; base: CARDINAL; VAR found: BOOLEAN) : CARDINAL ;


(*
   LongIntegerToString - converts LONGINT, i, into a String. The field with
                         can be specified if non zero. Leading characters
                         are defined by padding and this function will
                         prepend a + if sign is set to TRUE.
                         The base allows the caller to generate binary,
                         octal, decimal, hexidecimal numbers.
                         The value of lower is only used when hexidecimal
                         numbers are generated and if TRUE then digits
                         abcdef are used, and if FALSE then ABCDEF are used.
*)

PROCEDURE LongIntegerToString (i: LONGINT; width: CARDINAL; padding: CHAR;
                               sign: BOOLEAN; base: CARDINAL; lower: BOOLEAN) : String ;



(*
   StringToLongInteger - converts a string, s, of, base, into an LONGINT.
                         Leading white space is ignored. It stops converting
                         when either the string is exhausted or if an illegal
                         numeral is found.
                         The parameter found is set TRUE if a number was found.
*)

PROCEDURE StringToLongInteger (s: String; base: CARDINAL; VAR found: BOOLEAN) : LONGINT ;


(*
   LongCardinalToString - converts LONGCARD, c, into a String. The field
                          width can be specified if non zero. Leading
                          characters are defined by padding.
                          The base allows the caller to generate binary,
                          octal, decimal, hexidecimal numbers.
                          The value of lower is only used when hexidecimal
                          numbers are generated and if TRUE then digits
                          abcdef are used, and if FALSE then ABCDEF are used.
*)

PROCEDURE LongCardinalToString (c: LONGCARD; width: CARDINAL; padding: CHAR;
                                base: CARDINAL; lower: BOOLEAN) : String ;


(*
   StringToLongCardinal - converts a string, s, of, base, into a LONGCARD.
                          Leading white space is ignored. It stops converting
                          when either the string is exhausted or if an illegal
                          numeral is found.
                          The parameter found is set TRUE if a number was found.
*)

PROCEDURE StringToLongCardinal (s: String; base: CARDINAL; VAR found: BOOLEAN) : LONGCARD ;


(*
   ShortCardinalToString - converts SHORTCARD, c, into a String. The field
                           width can be specified if non zero. Leading
                           characters are defined by padding.
                           The base allows the caller to generate binary,
                           octal, decimal, hexidecimal numbers.
                           The value of lower is only used when hexidecimal
                           numbers are generated and if TRUE then digits
                           abcdef are used, and if FALSE then ABCDEF are used.
*)

PROCEDURE ShortCardinalToString (c: SHORTCARD; width: CARDINAL; padding: CHAR;
                                 base: CARDINAL; lower: BOOLEAN) : String ;


(*
   StringToShortCardinal - converts a string, s, of, base, into a SHORTCARD.
                           Leading white space is ignored. It stops converting
                           when either the string is exhausted or if an illegal
                           numeral is found.
                           The parameter found is set TRUE if a number was found.
*)

PROCEDURE StringToShortCardinal (s: String; base: CARDINAL;
                                 VAR found: BOOLEAN) : SHORTCARD ;


(*
   stoi - decimal string to INTEGER
*)

PROCEDURE stoi (s: String) : INTEGER ;


(*
   itos - integer to decimal string.
*)

PROCEDURE itos (i: INTEGER; width: CARDINAL; padding: CHAR; sign: BOOLEAN) : String ;


(*
   ctos - cardinal to decimal string.
*)

PROCEDURE ctos (c: CARDINAL; width: CARDINAL; padding: CHAR) : String ;


(*
   stoc - decimal string to CARDINAL
*)

PROCEDURE stoc (s: String) : CARDINAL ;


(*
   hstoi - hexidecimal string to INTEGER
*)

PROCEDURE hstoi (s: String) : INTEGER ;


(*
   ostoi - octal string to INTEGER
*)

PROCEDURE ostoi (s: String) : INTEGER ;


(*
   bstoi - binary string to INTEGER
*)

PROCEDURE bstoi (s: String) : INTEGER ;


(*
   hstoc - hexidecimal string to CARDINAL
*)

PROCEDURE hstoc (s: String) : CARDINAL ;


(*
   ostoc - octal string to CARDINAL
*)

PROCEDURE ostoc (s: String) : CARDINAL ;


(*
   bstoc - binary string to CARDINAL
*)

PROCEDURE bstoc (s: String) : CARDINAL ;


(*
   StringToLongreal - returns a LONGREAL and sets found to TRUE
                      if a legal number is seen.
*)

PROCEDURE StringToLongreal (s: String; VAR found: BOOLEAN) : LONGREAL ;


(*
   LongrealToString - converts a LONGREAL number, Real, which has,
                      TotalWidth, and FractionWidth into a string.
*)

PROCEDURE LongrealToString (x: LONGREAL;
                            TotalWidth, FractionWidth: CARDINAL) : String ;


(*
   stor - returns a REAL given a string.
*)

PROCEDURE stor (s: String) : REAL ;


(*
   stolr - returns a LONGREAL given a string.
*)

PROCEDURE stolr (s: String) : LONGREAL ;


END StringConvert.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.31 gm2-libs/SysStorage

 
DEFINITION MODULE SysStorage ;

(*
    Description: provides dynamic allocation for the system components
                 of a realtime system. This allows the application to
                 use the traditional Storage module which can be
                 handled differently.
*)

FROM SYSTEM IMPORT ADDRESS ;
EXPORT QUALIFIED ALLOCATE, DEALLOCATE, REALLOCATE, Available, Init ;


(*
   ALLOCATE - attempt to allocate memory from the heap.
              NIL is returned in, a, if ALLOCATE fails.
*)

PROCEDURE ALLOCATE (VAR a: ADDRESS ; Size: CARDINAL) ;


(*
   DEALLOCATE - return, Size, bytes to the heap.
                The variable, a, is set to NIL.
*)

PROCEDURE DEALLOCATE (VAR a: ADDRESS ; Size: CARDINAL) ;


(*
   REALLOCATE - attempts to reallocate storage. The address,
                a, should either be NIL in which case ALLOCATE
                is called, or alternatively it should have already
                been initialized by ALLOCATE. The allocated storage
                is resized accordingly.
*)

PROCEDURE REALLOCATE (VAR a: ADDRESS; Size: CARDINAL) ;


(*
   Available - returns TRUE if, Size, bytes can be allocated.
*)

PROCEDURE Available (Size: CARDINAL) : BOOLEAN;


(*
   Init - initializes the heap.
*)

PROCEDURE Init ;


END SysStorage.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.32 gm2-libs/TimeString

 
DEFINITION MODULE TimeString ;

(*
    Description: Provides time related string manipulation procedures.
*)


EXPORT QUALIFIED GetTimeString ;


(*
   GetTimeString - places the time in ascii format into array, a.

*)

PROCEDURE GetTimeString (VAR a: ARRAY OF CHAR) ;


END TimeString.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.33 gm2-libs/UnixArgs

 
DEFINITION MODULE UnixArgs ;

(*
   Description: Implements access to the C arguments argc and argv.
*)

FROM SYSTEM IMPORT ADDRESS ;

EXPORT QUALIFIED ArgC, ArgV ;


VAR
   ArgC: CARDINAL ;
   ArgV: ADDRESS ;


END UnixArgs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.34 gm2-libs/cbuiltin

 
DEFINITION MODULE FOR "C" cbuiltin ;

(*
    Description: provides replacement routines in case the builtins are
                 not used by GNU Modula-2. This module is called by
                 implementation modules which implement builtins
                 (see Builtins.mod for an example).
*)

FROM SYSTEM IMPORT ADDRESS ;
EXPORT UNQUALIFIED alloca, memcpy,
                   sinf, sinl, sin,
                   cosf, cosl, cos,
                   sqrtf, sqrtl, sqrt,
                   fabsf, fabsl, fabs,
                   logf, logl, log,
                   expf, expl, exp,
                   index, rindex,
                   memcmp, memset,
                   strcat, strncat, strcpy, strncpy, strcmp, strncmp,
                   strlen, strstr, strpbrk, strspn, strcspn, strchr, strrchr ;

PROCEDURE alloca (i: CARDINAL) : ADDRESS ;
PROCEDURE memcpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE sinf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE sin (x: REAL) : REAL ;
PROCEDURE sinl (x: LONGREAL) : LONGREAL ;
PROCEDURE cosf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE cos (x: REAL) : REAL ;
PROCEDURE cosl (x: LONGREAL) : LONGREAL ;
PROCEDURE sqrtf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE sqrt (x: REAL) : REAL ;
PROCEDURE sqrtl (x: LONGREAL) : LONGREAL ;
PROCEDURE fabsf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE fabs (x: REAL) : REAL ;
PROCEDURE fabsl (x: LONGREAL) : LONGREAL ;
PROCEDURE logf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE log (x: REAL) : REAL ;
PROCEDURE logl (x: LONGREAL) : LONGREAL ;
PROCEDURE expf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE exp (x: REAL) : REAL ;
PROCEDURE expl (x: LONGREAL) : LONGREAL ;
PROCEDURE index (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE rindex (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE memcmp (s1, s2: ADDRESS; n: CARDINAL) : INTEGER ;
PROCEDURE memset (s: ADDRESS; c: INTEGER; n: CARDINAL) : ADDRESS ;
PROCEDURE strcat (dest, src: ADDRESS) : ADDRESS ;
PROCEDURE strncat (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE strcpy (dest, src: ADDRESS) : ADDRESS ;
PROCEDURE strncpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;
PROCEDURE strcmp (s1, s2: ADDRESS) : INTEGER ;
PROCEDURE strncmp (s1, s2: ADDRESS; n: CARDINAL) : INTEGER ;
PROCEDURE strlen (s: ADDRESS) : INTEGER ;
PROCEDURE strstr (haystack, needle: ADDRESS) : ADDRESS ;
PROCEDURE strpbrk (s, accept: ADDRESS) : ADDRESS ;
PROCEDURE strspn (s, accept: ADDRESS) : CARDINAL ;
PROCEDURE strcspn (s, accept: ADDRESS) : CARDINAL ;
PROCEDURE strchr (s: ADDRESS; c: INTEGER) : ADDRESS ;
PROCEDURE strrchr (s: ADDRESS; c: INTEGER) : ADDRESS ;

END cbuiltin.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.35 gm2-libs/libc

 
DEFINITION MODULE FOR "C" libc ;

(*
   Description: Provides an interface to the C library functions.
*)

FROM SYSTEM IMPORT ADDRESS ;

EXPORT UNQUALIFIED time_t, tm, ptrToTM,
                   write, read,
                   system, abort,
                   malloc, free,
                   exit, isatty,
                   getenv, getpid,
                   dup, close, open, lseek,
                   readv, writev,
                   perror, creat,
                   getcwd, chown, strlen, strcpy, strncpy,
                   unlink,
                   memcpy, memset, printf, realloc,
                   rand, srand, time, localtime ;

TYPE
   time_t = LONGINT ;

   ptrToTM = POINTER TO tm ;
   tm = RECORD
           tm_sec: INTEGER ;     (* Seconds.     [0-60] (1 leap second) *)
           tm_min: INTEGER ;     (* Minutes.     [0-59]   *)
           tm_hour: INTEGER ;    (* Hours.       [0-23]   *)
           tm_mday: INTEGER ;    (* Day.         [1-31]   *)
           tm_mon: INTEGER ;     (* Month.       [0-11]   *)
           tm_year: INTEGER ;    (* Year - 1900.          *)
           tm_wday: INTEGER ;    (* Day of week. [0-6]    *)
           tm_yday: INTEGER ;    (* Days in year.[0-365]  *)
           tm_isdst: INTEGER ;   (* DST.         [-1/0/1] *)
           tm_gmtoff: LONGINT ;  (* Seconds east of UTC.  *)
           tm_zone: ADDRESS ;    (* char * zone name      *)
        END ;


(*
     int write(d, buf, nbytes)
     int d;
     char *buf;
     int nbytes;
*)

PROCEDURE write (d: INTEGER; buf: ADDRESS; nbytes: INTEGER) : INTEGER ;


(*
     int read(d, buf, nbytes)
     int d;
     char *buf;
     int nbytes;
*)

PROCEDURE read (d: INTEGER; buf: ADDRESS; nbytes: INTEGER) : INTEGER ;


(*
     int system(string)
     char *string;
*)

PROCEDURE system (a: ADDRESS) : INTEGER ;


(*
     abort - generate a fault

     abort() first closes all open files if possible, then sends
     an IOT signal to the process.  This signal usually results
     in termination with a core dump, which may be used for
     debugging.

     It is possible for abort() to return control if is caught or
     ignored, in which case the value returned is that of the
     kill(2V) system call.
*)

PROCEDURE abort ;


(*
     malloc - memory allocator.

     char *malloc(size)
     unsigned size;

     malloc() returns a pointer to a block of at least size
     bytes, which is appropriately aligned.  If size is zero,
     malloc() returns a non-NULL pointer, but this pointer should
     not be dereferenced.
*)

PROCEDURE malloc (size: CARDINAL) : ADDRESS ;


(*
     free - memory deallocator.

     free(ptr)
     char *ptr;

     free() releases a previously allocated block.  Its argument
     is a pointer to a block previously allocated by malloc,
     calloc, realloc, malloc, or memalign.
*)

PROCEDURE free (ptr: ADDRESS) ;


(*
     void *realloc(void *ptr, size_t size);

     realloc changes the size of the memory block pointed to
     by ptr to size bytes. The contents will be  unchanged  to
     the minimum of the old and new sizes; newly allocated memory
     will be uninitialized. If ptr is NIL, the call is
     equivalent  to malloc(size); if size is equal to zero, the
     call is equivalent to free(ptr). Unless ptr is NIL, it
     must have been returned by an earlier call to malloc(),
     realloc.
*)

PROCEDURE realloc (ptr: ADDRESS; size: CARDINAL) : ADDRESS ;


(*
   isatty - does this descriptor refer to a terminal.
*)

PROCEDURE isatty (fd: INTEGER) : INTEGER ;


(*
   exit - returns control to the invoking process. Result, r, is
          returned.
*)

PROCEDURE exit (r: INTEGER) ;


(*
   getenv - returns the C string for the equivalent C environment
            variable.
*)

PROCEDURE getenv (s: ADDRESS) : ADDRESS ;


(*
   getpid - returns the UNIX process identification number.
*)

PROCEDURE getpid () : INTEGER ;


(*
   dup - duplicates the file descriptor, d.
*)

PROCEDURE dup (d: INTEGER) : INTEGER ;


(*
   close - closes the file descriptor, d.
*)

PROCEDURE close (d: INTEGER) : INTEGER ;


(*
   open - open the file, filename with flag and mode.
*)

PROCEDURE open (filename: ADDRESS; flag, mode: CARDINAL) : INTEGER ;


(*
   creat - creates a new file
*)

PROCEDURE creat (filename : ADDRESS; mode : CARDINAL) : INTEGER;


(*
   lseek - calls unix lseek:

           off_t lseek(int fildes, off_t offset, int whence);
*)

PROCEDURE lseek (fd: INTEGER; offset: INTEGER; whence: INTEGER) : INTEGER ;


(*
   perror - writes errno and string
*)

PROCEDURE perror (string: ADDRESS);


(*
   readv - reads an io vector of bytes.
*)

PROCEDURE readv (fd: INTEGER; v: ADDRESS; n: INTEGER) : INTEGER ;


(*
   writev - writes an io vector of bytes.
*)

PROCEDURE writev (fd: INTEGER; v: ADDRESS; n: INTEGER) : INTEGER ;


(*
   getcwd - copies the absolute pathname of the
            current working directory to the array pointed to by buf,
            which is of length size.

            If the current absolute path name would require a buffer
            longer than size elements, NULL is returned, and errno is
            set to ERANGE; an application should check for this error,
            and allocate a larger buffer if necessary.
*)

PROCEDURE getcwd (buf: ADDRESS; size: INTEGER) : ADDRESS ;


(*
   chown - The  owner  of  the  file  specified  by  path or by fd is
           changed.  Only the super-user may change the  owner  of  a
           file.   The  owner  of  a file may change the group of the
           file to any group of which that owner is  a  member.   The
           super-user may change the group arbitrarily.

           If  the owner or group is specified as -1, then that ID is
           not changed.

           On success, zero is returned.  On error, -1  is  returned,
           and errno is set appropriately.
*)

PROCEDURE chown (filename: ADDRESS; uid, gid: INTEGER) : INTEGER ;


(*
   strlen - returns the length of string, a.
*)

PROCEDURE strlen (a: ADDRESS) : INTEGER ;


(*
   strcpy - copies string, src, into, dest.
            It returns dest.
*)

PROCEDURE strcpy (dest, src: ADDRESS) : ADDRESS ;


(*
   strncpy - copies string, src, into, dest, copying at most, n, bytes.
             It returns dest.
*)

PROCEDURE strncpy (dest, src: ADDRESS; n: CARDINAL) : ADDRESS ;


(*
   unlink - removes file and returns 0 if successful.
*)

PROCEDURE unlink (file: ADDRESS) : INTEGER ;


(*
   memcpy - copy memory area

   SYNOPSIS

   #include <string.h>

   void *memcpy(void *dest, const void *src, size_t n);
   It returns dest.
*)

PROCEDURE memcpy (dest, src: ADDRESS; size: CARDINAL) : ADDRESS ;


(*
   memset - fill memory with a constant byte

   SYNOPSIS

   #include <string.h>

   void *memset(void *s, int c, size_t n);
*)

PROCEDURE memset (s: ADDRESS; c: INTEGER; size: CARDINAL) : ADDRESS ;


(*
   int printf(const char *format, ...);
*)

PROCEDURE printf (format: ARRAY OF CHAR; ...) : INTEGER ;


(*
   srand - initialize the random number seed.
*)

PROCEDURE srand (seed: INTEGER) ;


(*
   rand - return a random integer.
*)

PROCEDURE rand () : INTEGER ;


(*
   time - returns a pointer to the time_t value. If, a,
          is not NIL then the libc value is copied into
          memory at address, a.
*)

PROCEDURE time (a: ADDRESS) : time_t ;


(*
   localtime - returns a pointer to the libc copy of the tm
               structure.
*)

PROCEDURE localtime (VAR t: time_t) : ADDRESS ;


END libc.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.36 gm2-libs/libm

 
DEFINITION MODULE FOR "C" libm ;

(*
    Description: provides access to libm. Users are strongly advised to
                 use MathLib0 or RealMath as call to functions within
                 these modules will generate inline code. This module
                 is used by MathLib0 and RealMath when inline code cannot
                 be generated.
*)

EXPORT UNQUALIFIED sin, sinl, sinf,
                   cos, cosl, cosf,
                   tan, tanl, tanf,
                   sqrt, sqrtl, sqrtf,
                   asin, asinl, asinf,
                   acos, acosl, acosf,
                   atan, atanl, atanf,
                   exp, expl, expf,
                   log, logl, logf,
                   pow, powl, powf ;

PROCEDURE sin (x: REAL) : REAL ;
PROCEDURE sinl (x: LONGREAL) : LONGREAL ;
PROCEDURE sinf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE cos (x: REAL) : REAL ;
PROCEDURE cosl (x: LONGREAL) : LONGREAL ;
PROCEDURE cosf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE tan (x: REAL) : REAL ;
PROCEDURE tanl (x: LONGREAL) : LONGREAL ;
PROCEDURE tanf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE sqrt (x: REAL) : REAL ;
PROCEDURE sqrtl (x: LONGREAL) : LONGREAL ;
PROCEDURE sqrtf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE asin (x: REAL) : REAL ;
PROCEDURE asinl (x: LONGREAL) : LONGREAL ;
PROCEDURE asinf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE acos (x: REAL) : REAL ;
PROCEDURE acosl (x: LONGREAL) : LONGREAL ;
PROCEDURE acosf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE atan (x: REAL) : REAL ;
PROCEDURE atanl (x: LONGREAL) : LONGREAL ;
PROCEDURE atanf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE exp (x: REAL) : REAL ;
PROCEDURE expl (x: LONGREAL) : LONGREAL ;
PROCEDURE expf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE log (x: REAL) : REAL ;
PROCEDURE logl (x: LONGREAL) : LONGREAL ;
PROCEDURE logf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE pow (x, y: REAL) : REAL ;
PROCEDURE powl (x, y: LONGREAL) : LONGREAL ;
PROCEDURE powf (x, y: SHORTREAL) : SHORTREAL ;
PROCEDURE floor (x: REAL) : REAL ;
PROCEDURE floorl (x: LONGREAL) : LONGREAL ;
PROCEDURE floorf (x: SHORTREAL) : SHORTREAL ;
PROCEDURE ceil (x: REAL) : REAL ;
PROCEDURE ceill (x: LONGREAL) : LONGREAL ;
PROCEDURE ceilf (x: SHORTREAL) : SHORTREAL ;

END libm.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.37 gm2-libs/wrapc

 
DEFINITION MODULE wrapc ;

(*
   Description: Provides a Modula-2 interface to the C
                library functionality.
*)

FROM SYSTEM IMPORT ADDRESS ;

EXPORT QUALIFIED strtime, filesize, getrand, getusername, filemtime,
                 getnameuidgid ;


(*
   strtime - returns the C string for the equivalent C asctime
             function.
*)

PROCEDURE strtime () : ADDRESS ;


(*
   filesize - returns the size of a file, f.
*)

PROCEDURE filesize (f: INTEGER) : CARDINAL ;


(*
   filemtime - returns the mtime of a file, f.
*)

PROCEDURE filemtime (f: INTEGER) : INTEGER ;


(*
   getrand - returns a random number between 0..n-1
*)

PROCEDURE getrand (n: INTEGER) : INTEGER ;


(*
   getusername - returns a C string describing the current user.
*)

PROCEDURE getusername () : ADDRESS ;


(*
   getnameuidgid - fills in the, uid, and, gid, which represents
                   user, name.
*)

PROCEDURE getnameuidgid (name: ADDRESS; VAR uid, gid: INTEGER) ;


END wrapc.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2 PIM and Logitech 3.0 Compatible

These modules are provided to enable legacy Modula-2 applications to build with GNU Modula-2. It is advised that these module should not be used for new projects, maybe the ISO libraries or the native compiler PIM libraries (FIO) should be used instead.

Here is an outline of the module layering:

 
InOut  RealInOut  LongIO CardinalIO
    \     |       |      /
           Terminal
-----------------------------------
              |
           Termbase
           /      \
    Keyboard      Display

Above the line are user level PIM [234] and Logitech 3.0 compatible modules. Below the line Logitech 3.0 advised that these modules should be considered part of the runtime system. The libraries do not provide all the features found in the Logitech libraries as a number of these features were MS-DOS related. Essentially the basic input/output, file system, string manipulation and conversion routines are provided. Access to DOSCALL, graphics, time and date are not as these were constrained by the limitations of MS-DOS.

The following libraries are contained within the base GNU Modula-2 libraries but are also Logitech-3.0 compatible: ASCII, Storage and MathLib0.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.1 gm2-libs-pim/Break

 
DEFINITION MODULE Break ;

(*
    Description: provides a Logitech compatible Break handler module
                 which catches ctrl-c.
*)

EXPORT QUALIFIED EnableBreak, DisableBreak, InstallBreak, UnInstallBreak ;


(*
   EnableBreak - enable the current break handler.
*)

PROCEDURE EnableBreak ;


(*
   DisableBreak - disable the current break handler (and all
                  installed handlers).
*)

PROCEDURE DisableBreak ;


(*
   InstallBreak - installs a procedure, p, to be invoked when
                  a ctrl-c is caught. Any number of these
                  procedures may be stacked. Only the top
                  procedure is run when ctrl-c is caught.
*)

PROCEDURE InstallBreak (p: PROC) ;


(*
   UnInstallBreak - pops the break handler stack.
*)

PROCEDURE UnInstallBreak ;


END Break.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.2 gm2-libs-pim/CardinalIO

 
DEFINITION MODULE CardinalIO ;

(*
    Description: provides a PIM and Logitech compatible module.
*)

EXPORT QUALIFIED Done,
                 ReadCardinal, WriteCardinal, ReadHex, WriteHex,
                 ReadLongCardinal, WriteLongCardinal, ReadLongHex,
                 WriteLongHex,
                 ReadShortCardinal, WriteShortCardinal, ReadShortHex,
                 WriteShortHex ;


VAR
   Done: BOOLEAN ;


(*
   ReadCardinal - read an unsigned decimal number from the terminal.
                  The read continues until a space, newline, esc or
                  end of file is reached.
*)

PROCEDURE ReadCardinal (VAR c: CARDINAL) ;


(*
   WriteCardinal - writes the value, c, to the terminal and ensures
                   that at least, n, characters are written. The number
                   will be padded out by preceeding spaces if necessary.
*)

PROCEDURE WriteCardinal (c: CARDINAL; n: CARDINAL) ;


(*
   ReadHex - reads in an unsigned hexadecimal number from the terminal.
             The read continues until a space, newline, esc or
             end of file is reached.
*)

PROCEDURE ReadHex (VAR c: CARDINAL) ;


(*
   WriteHex - writes out a CARDINAL, c, in hexadecimal format padding
              with, n, characters (leading with '0')
*)

PROCEDURE WriteHex (c: CARDINAL; n: CARDINAL) ;


(*
   ReadLongCardinal - read an unsigned decimal number from the terminal.
                      The read continues until a space, newline, esc or
                      end of file is reached.
*)

PROCEDURE ReadLongCardinal (VAR c: LONGCARD) ;


(*
   WriteLongCardinal - writes the value, c, to the terminal and ensures
                       that at least, n, characters are written. The number
                       will be padded out by preceeding spaces if necessary.
*)

PROCEDURE WriteLongCardinal (c: LONGCARD; n: CARDINAL) ;


(*
   ReadLongHex - reads in an unsigned hexadecimal number from the terminal.
                 The read continues until a space, newline, esc or
                 end of file is reached.
*)

PROCEDURE ReadLongHex (VAR c: LONGCARD) ;


(*
   WriteLongHex - writes out a LONGCARD, c, in hexadecimal format padding
                  with, n, characters (leading with '0')
*)

PROCEDURE WriteLongHex (c: LONGCARD; n: CARDINAL) ;


(*
   WriteShortCardinal - writes the value, c, to the terminal and ensures
                       that at least, n, characters are written. The number
                       will be padded out by preceeding spaces if necessary.
*)

PROCEDURE WriteShortCardinal (c: SHORTCARD; n: CARDINAL) ;


(*
   ReadShortCardinal - read an unsigned decimal number from the terminal.
                       The read continues until a space, newline, esc or
                       end of file is reached.
*)

PROCEDURE ReadShortCardinal (VAR c: SHORTCARD) ;


(*
   ReadShortHex - reads in an unsigned hexadecimal number from the terminal.
                 The read continues until a space, newline, esc or
                 end of file is reached.
*)

PROCEDURE ReadShortHex (VAR c: SHORTCARD) ;


(*
   WriteShortHex - writes out a SHORTCARD, c, in hexadecimal format padding
                  with, n, characters (leading with '0')
*)

PROCEDURE WriteShortHex (c: SHORTCARD; n: CARDINAL) ;


END CardinalIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.3 gm2-libs-pim/Conversions

 
DEFINITION MODULE Conversions ;

(*
    Description: provides a Logitech-3.0 compatible library.
*)

EXPORT QUALIFIED ConvertOctal, ConvertHex, ConvertCardinal,
                 ConvertInteger, ConvertLongInt, ConvertShortInt ;

(*
   ConvertOctal - converts a CARDINAL, num, into an octal/hex/decimal
                  string and right justifies the string. It adds
                  spaces rather than '0' to pad out the string
                  to len characters.

                  If the length of str is < num then the number is
                  truncated on the right.
*)

PROCEDURE ConvertOctal    (num, len: CARDINAL; VAR str: ARRAY OF CHAR) ;
PROCEDURE ConvertHex      (num, len: CARDINAL; VAR str: ARRAY OF CHAR) ;
PROCEDURE ConvertCardinal (num, len: CARDINAL; VAR str: ARRAY OF CHAR) ;

(*
   The INTEGER counterparts will add a '-' if, num, is <0
*)

PROCEDURE ConvertInteger  (num: INTEGER; len: CARDINAL; VAR str: ARRAY OF CHAR) ;
PROCEDURE ConvertLongInt  (num: LONGINT; len: CARDINAL; VAR str: ARRAY OF CHAR) ;
PROCEDURE ConvertShortInt (num: SHORTINT; len: CARDINAL; VAR str: ARRAY OF CHAR) ;


END Conversions.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.4 gm2-libs-pim/DebugPMD

 
DEFINITION MODULE DebugPMD ;

END DebugPMD.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.5 gm2-libs-pim/DebugTrace

 
DEFINITION MODULE DebugTrace ;

(*
    Description: provides a compatible module for the
                 Logitech-3.0 PIM Modula-2 compiler.
                 It does nothing other satisfy an import for
                 legacy source code.
*)

END DebugTrace.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.6 gm2-libs-pim/Delay

 
DEFINITION MODULE Delay ;

(*
    Description: provides a Logitech-3.0 compatible module for
                 GNU Modula-2.
*)

EXPORT QUALIFIED Delay ;


(*
   milliSec - delays the program by approximately, milliSec, milliseconds.
*)

PROCEDURE Delay (milliSec: INTEGER) ;


END Delay.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.7 gm2-libs-pim/Display

 
DEFINITION MODULE Display ;

(*
    Description: provides a Logitech 3.0 compatible Display module.
*)

EXPORT QUALIFIED Write ;

(*
   Write - display a character to the stdout.
           ASCII.EOL moves to the beginning of the next line.
           ASCII.del erases the character to the left of the cursor.
*)

PROCEDURE Write (ch: CHAR) ;


END Display.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.8 gm2-libs-pim/ErrorCode

 
DEFINITION MODULE ErrorCode ;

(*
    Description: provides a Logitech-3.0 compatible module which
                 handles exiting from an application with an exit
                 value.
*)

EXPORT QUALIFIED SetErrorCode, GetErrorCode, ExitToOS ;


(*
   SetErrorCode - sets the exit value which will be used if
                  the application terminates normally.
*)

PROCEDURE SetErrorCode (value: INTEGER) ;


(*
   GetErrorCode - returns the current value to be used upon
                  application termination.
*)

PROCEDURE GetErrorCode (VAR value: INTEGER) ;


(*
   ExitToOS - terminate the application and exit returning
              the last value set by SetErrorCode to the OS.
*)

PROCEDURE ExitToOS ;


END ErrorCode.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.9 gm2-libs-pim/FileSystem

 
DEFINITION MODULE FileSystem ;

(*
    Description: provides GNU Modula-2 with a PIM [234] FileSystem
                 compatible module. Use this module sparingly,
                 FIO or the ISO file modules have a much cleaner
                 interface.
*)

FROM SYSTEM IMPORT WORD, BYTE, ADDRESS ;
IMPORT FIO ;
FROM DynamicStrings IMPORT String ;

EXPORT QUALIFIED File, Response, Flag, FlagSet,

                 Create, Close, Lookup, Rename, Delete,
                 SetRead, SetWrite, SetModify, SetOpen,
                 Doio, SetPos, GetPos, Length,

                 ReadWord, ReadChar, ReadByte, ReadNBytes,
                 WriteWord, WriteChar, WriteByte, WriteNBytes ;

TYPE
   File = RECORD
             res     : Response ;
             flags   : FlagSet ;
             eof     : BOOLEAN ;
             lastRead: WORD ;
             fio     : FIO.File ;
             highpos,
             lowpos  : CARDINAL ;
             name    : String ;
          END ;

   Flag = (
           read,        (* read access mode *)
           write,       (* write access mode *)
           truncate,    (* truncate file when closed *)
           again        (* reread the last character *)
          );

   FlagSet = SET OF Flag;

   Response = (done, notdone, notsupported, callerror,
               unknownfile, paramerror, toomanyfiles,
               userdeverror) ;

   Command = (create, close, lookup, rename, delete,
              setread, setwrite, setmodify, setopen,
              doio, setpos, getpos, length) ;

(*
   Create - creates a temporary file. To make the file perminant
            the file must be renamed.
*)

PROCEDURE Create (VAR f: File) ;


(*
   Close - closes an open file.
*)

PROCEDURE Close (f: File) ;


(*
   Lookup - looks for a file, filename. If the file is found
            then, f, is opened. If it is not found and, newFile,
            is TRUE then a new file is created and attached to, f.
            If, newFile, is FALSE and no file was found then f.res
            is set to notdone.
*)

PROCEDURE Lookup (VAR f: File; filename: ARRAY OF CHAR; newFile: BOOLEAN) ;


(*
   Rename - rename a file.
            f.res is set appropriately.
*)

PROCEDURE Rename (VAR f: File; newname: ARRAY OF CHAR) ;


(*
   Delete - deletes a file, name, and sets the f.res field.
            f.res is set appropriately.
*)

PROCEDURE Delete (name: ARRAY OF CHAR; VAR f: File) ;


(*
   ReadWord - reads a WORD, w, from file, f.
              f.res is set appropriately.
*)

PROCEDURE ReadWord (VAR f: File; VAR w: WORD) ;


(*
   WriteWord - writes one word to a file, f.
               f.res is set appropriately.
*)

PROCEDURE WriteWord (VAR f: File; w: WORD) ;


(*
   ReadChar - reads one character from a file, f.
*)

PROCEDURE ReadChar (VAR f: File; VAR ch: CHAR) ;


(*
   WriteChar - writes a character, ch, to a file, f.
               f.res is set appropriately.
*)

PROCEDURE WriteChar (VAR f: File; ch: CHAR) ;


(*
   ReadByte - reads a BYTE, b, from file, f.
              f.res is set appropriately.
*)

PROCEDURE ReadByte (VAR f: File; VAR b: BYTE) ;


(*
   WriteByte - writes one BYTE, b, to a file, f.
               f.res is set appropriately.
*)

PROCEDURE WriteByte (VAR f: File; b: BYTE) ;


(*
   ReadNBytes - reads a sequence of bytes from a file, f.
*)

PROCEDURE ReadNBytes (VAR f: File; a: ADDRESS; amount: CARDINAL;
                      VAR actuallyRead: CARDINAL) ;


(*
   WriteNBytes - writes a sequence of bytes to file, f.
*)

PROCEDURE WriteNBytes (VAR f: File; a: ADDRESS; amount: CARDINAL;
                       VAR actuallyWritten: CARDINAL) ;


(*
   Again - returns the last character read to the internal buffer
           so that it can be read again.
*)

PROCEDURE Again (VAR f: File) ;


(*
   SetRead - puts the file, f, into the read state.
             The file position is unchanged.
*)

PROCEDURE SetRead (VAR f: File) ;


(*
   SetWrite - puts the file, f, into the write state.
              The file position is unchanged.
*)

PROCEDURE SetWrite (VAR f: File) ;


(*
   SetModify - puts the file, f, into the modify state.
               The file position is unchanged but the file can be
               read and written.
*)

PROCEDURE SetModify (VAR f: File) ;


(*
   SetOpen - places a file, f, into the open state. The file may
             have been in the read/write/modify state before and
             in which case the previous buffer contents are flushed
             and the file state is reset to open. The position is
             unaltered.
*)

PROCEDURE SetOpen (VAR f: File) ;


(*
   Reset - places a file, f, into the open state and reset the
           position to the start of the file.
*)

PROCEDURE Reset (VAR f: File) ;


(*
   SetPos - lseek to a position within a file.
*)

PROCEDURE SetPos (VAR f: File; high, low: CARDINAL) ;


(*
   GetPos - return the position within a file.
*)

PROCEDURE GetPos (VAR f: File; VAR high, low: CARDINAL) ;


(*
   Length - returns the length of file, in, high, and, low.
*)

PROCEDURE Length (VAR f: File; VAR high, low: CARDINAL) ;


(*
   Doio - effectively flushes a file in write mode, rereads the
          current buffer from disk if in read mode and writes
          and rereads the buffer if in modify mode.
*)

PROCEDURE Doio (VAR f: File) ;


(*
   FileNameChar - checks to see whether the character, ch, is
                  legal in a filename. nul is returned if the
                  character was illegal.
*)

PROCEDURE FileNameChar (ch: CHAR) ;


END FileSystem.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.10 gm2-libs-pim/FloatingUtilities

 
DEFINITION MODULE FloatingUtilities ;

(*
    Description: provides a Logitech-3.0 compatible library
*)

EXPORT QUALIFIED Frac, Round, Float, Trunc,
                 Fracl, Roundl, Floatl, Truncl ;


(*
   Frac - returns the fractional component of, r.
*)

PROCEDURE Frac (r: REAL) : REAL ;


(*
   Int - returns the integer part of r. It rounds the value towards zero.
*)

PROCEDURE Int (r: REAL) : INTEGER ;


(*
   Round - returns the number rounded to the nearest integer.
*)

PROCEDURE Round (r: REAL) : REAL ;


(*
   Float - returns a REAL value corresponding to, i.
*)

PROCEDURE Float (i: INTEGER) : REAL ;


(*
   Trunc - round to the nearest integer not larger in absolute
           value.
*)

PROCEDURE Trunc (r: REAL) : INTEGER ;


(*
   Fracl - returns the fractional component of, r.
*)

PROCEDURE Fracl (r: LONGREAL) : LONGREAL ;


(*
   Intl - returns the integer part of r. It rounds the value towards zero.
*)

PROCEDURE Intl (r: LONGREAL) : LONGINT ;


(*
   Roundl - returns the number rounded to the nearest integer.
*)

PROCEDURE Roundl (r: LONGREAL) : LONGREAL ;


(*
   Floatl - returns a REAL value corresponding to, i.
*)

PROCEDURE Floatl (i: INTEGER) : LONGREAL ;


(*
   Truncl - round to the nearest integer not larger in absolute
            value.
*)

PROCEDURE Truncl (r: LONGREAL) : LONGINT ;


END FloatingUtilities.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.11 gm2-libs-pim/InOut

 
DEFINITION MODULE InOut ;

(*
    Description: provides a compatible PIM [234] InOut module.
*)

IMPORT ASCII ;
FROM DynamicStrings IMPORT String ;
EXPORT QUALIFIED EOL, Done, termCH, OpenInput, CloseInput, CloseOutput,
                 Read, ReadString, ReadInt, ReadCard,
                 Write, WriteLn, WriteString, WriteInt, WriteCard,
                 WriteOct, WriteHex,
                 ReadS, WriteS ;

CONST
   EOL = ASCII.EOL ;

VAR
   Done  : BOOLEAN ;
   termCH: CHAR ;


(*
   OpenInput - reads a string from stdin as the filename for reading.
               If the filename ends with `.' then it appends the defext
               extension. The global variable Done is set if all
               was successful.
*)

PROCEDURE OpenInput (defext: ARRAY OF CHAR) ;


(*
   CloseInput - closes an opened input file and returns input back to
                StdIn.
*)

PROCEDURE CloseInput ;


(*
   OpenOutput - reads a string from stdin as the filename for writing.
                If the filename ends with `.' then it appends the defext
                extension. The global variable Done is set if all
                was successful.
*)

PROCEDURE OpenOutput (defext: ARRAY OF CHAR) ;


(*
   CloseOutput - closes an opened output file and returns output back to
                 StdOut.
*)

PROCEDURE CloseOutput ;


(*
   Read - reads a single character from the current input file.
          Done is set to FALSE if end of file is reached or an
          error occurs.
*)

PROCEDURE Read (VAR ch: CHAR) ;


(*
   ReadString - reads a sequence of characters. Leading white space
                is ignored and the string is terminated with a character
                <= ' '
*)

PROCEDURE ReadString (VAR s: ARRAY OF CHAR) ;


(*
   WriteString - writes a string to the output file.
*)

PROCEDURE WriteString (s: ARRAY OF CHAR) ;


(*
   Write - writes out a single character, ch, to the current output file.
*)

PROCEDURE Write (ch: CHAR) ;


(*
   WriteLn - writes a newline to the output file.
*)

PROCEDURE WriteLn ;


(*
   ReadInt - reads a string and converts it into an INTEGER, x.
             Done is set if an INTEGER is read.
*)

PROCEDURE ReadInt (VAR x: INTEGER) ;


(*
   ReadInt - reads a string and converts it into an INTEGER, x.
             Done is set if an INTEGER is read.
*)

PROCEDURE ReadCard (VAR x: CARDINAL) ;


(*
   WriteCard - writes the CARDINAL, x, to the output file. It ensures
               that the number occupies, n, characters. Leading spaces
               are added if required.
*)

PROCEDURE WriteCard (x, n: CARDINAL) ;


(*
   WriteInt - writes the INTEGER, x, to the output file. It ensures
              that the number occupies, n, characters. Leading spaces
              are added if required.
*)

PROCEDURE WriteInt (x: INTEGER; n: CARDINAL) ;


(*
   WriteOct - writes the CARDINAL, x, to the output file in octal.
              It ensures that the number occupies, n, characters.
              Leading spaces are added if required.
*)

PROCEDURE WriteOct (x, n: CARDINAL) ;


(*
   WriteHex - writes the CARDINAL, x, to the output file in hexadecimal.
              It ensures that the number occupies, n, characters.
              Leading spaces are added if required.
*)

PROCEDURE WriteHex (x, n: CARDINAL) ;


(*
   ReadS - returns a string which has is a sequence of characters.
           The string is terminated with a character <= ' '
*)

PROCEDURE ReadS () : String ;


(*
   WriteS - writes a String to the output device.
            It returns the string, s.
*)

PROCEDURE WriteS (s: String) : String ;


END InOut.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.12 gm2-libs-pim/Keyboard

 
DEFINITION MODULE Keyboard ;

(*
    Description: provides compatibility with Logitech 3.0 Keyboard module.
*)

EXPORT QUALIFIED Read, KeyPressed ;


(*
   Read - reads a character from StdIn. If necessary it will wait
          for a key to become present on StdIn.
*)

PROCEDURE Read (VAR ch: CHAR) ;


(*
   KeyPressed - returns TRUE if a character can be read from StdIn
                without blocking the caller.
*)

PROCEDURE KeyPressed () : BOOLEAN ;


END Keyboard.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.13 gm2-libs-pim/LongIO

 
DEFINITION MODULE LongIO ;

(*
    Description: provides a Logitech-3.0 compatible library for GNU Modula-2.
*)

EXPORT QUALIFIED Done, ReadLongInt, WriteLongInt ;

VAR
   Done: BOOLEAN ;

PROCEDURE ReadLongInt (VAR i: LONGINT) ;
PROCEDURE WriteLongInt (i: LONGINT; n: CARDINAL) ;


END LongIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.14 gm2-libs-pim/Random

 
DEFINITION MODULE Random ;

(*
    Description: provides a Logitech-3.0 compatible library
*)

FROM SYSTEM IMPORT BYTE ;
EXPORT QUALIFIED Randomize, RandomInit, RandomCard, RandomInt, RandomReal ;



(*
   Randomize - initialize the random number generator with a seed
               based on the microseconds.
*)

PROCEDURE Randomize ;


(*
   RandomInit - initialize the random number generator with value, seed.
*)

PROCEDURE RandomInit (seed: CARDINAL) ;


(*
   RandomBytes - fills in an array with random values.
*)

PROCEDURE RandomBytes (a: ARRAY OF BYTE) ;


(*
   RandomInt - return an INTEGER in the range 0..bound-1
*)

PROCEDURE RandomInt (bound: INTEGER) : INTEGER ;


(*
   RandomCard - return a CARDINAL in the range 0..bound-1
*)

PROCEDURE RandomCard (bound: CARDINAL) : CARDINAL ;


(*
   RandomReal - return a REAL number in the range 0.0..1.0
*)

PROCEDURE RandomReal () : REAL ;


(*
   RandomLongReal - return a LONGREAL number in the range 0.0..1.0
*)

PROCEDURE RandomLongReal () : LONGREAL ;


END Random.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.15 gm2-libs-pim/RealConversions

 
DEFINITION MODULE RealConversions ;

(*
    Description: provides a Logitech-3.0 compatible module.
*)

EXPORT QUALIFIED RealToString, StringToReal,
                 LongRealToString, StringToLongReal ;


(*
   RealToString - converts a real, r, into a right justified string, str.
                  The number of digits to the right of the decimal point
                  is given in, digits. The value, width, represents the
                  maximum number of characters to be used in the string,
                  str.

                  If digits is negative then exponent notation is used
                  whereas if digits is positive then fixed point notation
                  is used.

                  If, r, is less than 0.0 then a '-' preceeds the value,
                  str. However, if, r, is >= 0.0 a '+' is not added.

                  If the conversion of, r, to a string requires more
                  than, width, characters then the string, str, is set
                  to a nul string and, ok is assigned FALSE.

                  For fixed point notation the minimum width required is
                  ABS(width)+8

                  For exponent notation the minimum width required is
                  ABS(width)+2+ the number of digits to the left of the
                  decimal point.
*)

PROCEDURE RealToString (r: REAL; digits: INTEGER; width : CARDINAL;
                        VAR str: ARRAY OF CHAR; VAR ok: BOOLEAN) ;


(*
   LongRealToString - converts a real, r, into a right justified string, str.
                      The number of digits to the right of the decimal point
                      is given in, digits. The value, width, represents the
                      maximum number of characters to be used in the string,
                      str.

                      If digits is negative then exponent notation is used
                      whereas if digits is positive then fixed point notation
                      is used.

                      If, r, is less than 0.0 then a '-' preceeds the value,
                      str. However, if, r, is >= 0.0 a '+' is not added.

                      If the conversion of, r, to a string requires more
                      than, width, characters then the string, str, is set
                      to a nul string and, ok is assigned FALSE.

                      For fixed point notation the minimum width required is
                      ABS(width)+8

                      For exponent notation the minimum width required is
                      ABS(width)+2+ the number of digits to the left of the
                      decimal point.
*)

PROCEDURE LongRealToString (r: LONGREAL; digits: INTEGER; width : CARDINAL;
                            VAR str: ARRAY OF CHAR; VAR ok: BOOLEAN) ;


(*
   StringToReal - converts, str, into a REAL, r. The parameter, ok, is
                  set to TRUE if the conversion was successful.
*)

PROCEDURE StringToReal (str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN) ;


(*
   StringToLongReal - converts, str, into a LONGREAL, r. The parameter, ok, is
                      set to TRUE if the conversion was successful.
*)

PROCEDURE StringToLongReal (str: ARRAY OF CHAR; VAR r: LONGREAL; VAR ok: BOOLEAN) ;


END RealConversions.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.16 gm2-libs-pim/RealInOut

 
DEFINITION MODULE RealInOut ;

(*
    Description: provides a compatible RealInOut PIM 234 module.
*)

EXPORT QUALIFIED ReadReal, WriteReal, WriteRealOct, Done ;

VAR
   Done: BOOLEAN ;


(*
   ReadReal - reads a real number, legal syntaxes include:
              100, 100.0, 100e0, 100E0, 100E-1, E2, +1E+2, 1e+2
*)

PROCEDURE ReadReal (VAR x: REAL) ;


(*
   WriteReal - writes a real to the terminal. The real number
               is right justified and, n, is the minimum field
               width.
*)

PROCEDURE WriteReal (x: REAL; n: CARDINAL) ;


(*
   WriteRealOct - writes the real to terminal in octal words.
*)

PROCEDURE WriteRealOct (x: REAL) ;


(*
   ReadLongReal - reads a LONGREAL number, legal syntaxes include:
                  100, 100.0, 100e0, 100E0, 100E-1, E2, +1E+2, 1e+2
*)

PROCEDURE ReadLongReal (VAR x: LONGREAL) ;


(*
   WriteLongReal - writes a LONGREAL to the terminal. The real number
                   is right justified and, n, is the minimum field
                   width.
*)

PROCEDURE WriteLongReal (x: LONGREAL; n: CARDINAL) ;


(*
   WriteLongRealOct - writes the LONGREAL to terminal in octal words.
*)

PROCEDURE WriteLongRealOct (x: LONGREAL) ;


(*
   ReadShortReal - reads a SHORTREAL number, legal syntaxes include:
                  100, 100.0, 100e0, 100E0, 100E-1, E2, +1E+2, 1e+2
*)

PROCEDURE ReadShortReal (VAR x: SHORTREAL) ;


(*
   WriteShortReal - writes a SHORTREAL to the terminal. The real number
                   is right justified and, n, is the minimum field
                   width.
*)

PROCEDURE WriteShortReal (x: SHORTREAL; n: CARDINAL) ;


(*
   WriteShortRealOct - writes the SHORTREAL to terminal in octal words.
*)

PROCEDURE WriteShortRealOct (x: SHORTREAL) ;


END RealInOut.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.17 gm2-libs-pim/Strings

 
DEFINITION MODULE Strings ;

(*
    Description: provides a Logitech-3.0 compatible library
*)

EXPORT QUALIFIED Assign, Insert, Delete, Pos, Copy, ConCat, Length,
                 CompareStr ;

(*
   Assign - source := dest.
*)

PROCEDURE Assign (VAR source: ARRAY OF CHAR; dest: ARRAY OF CHAR) ;


(*
   Insert - insert the string, substr, into str at position, index.
            substr, is added to the end of, str, if, index >= length(str)
*)

PROCEDURE Insert (substr: ARRAY OF CHAR; VAR str: ARRAY OF CHAR;
                  index: CARDINAL) ;


(*
   Delete - delete len characters from, str, starting at, index.
*)

PROCEDURE Delete (VAR str: ARRAY OF CHAR; index: CARDINAL; length: CARDINAL) ;


(*
   Pos - return the first position of, substr, in, str.
*)

PROCEDURE Pos (substr, str: ARRAY OF CHAR) : CARDINAL ;


(*
   Copy - copy at most, length, characters in, substr, to, str,
          starting at position, index.
*)

PROCEDURE Copy (str: ARRAY OF CHAR;
                index, length: CARDINAL; VAR result: ARRAY OF CHAR) ;

(*
   ConCat - concatenates two strings, s1, and, s2
            and places the result into, dest.
*)

PROCEDURE ConCat (s1, s2: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR) ;


(*
   Length - return the length of string, s.
*)

PROCEDURE Length (s: ARRAY OF CHAR) : CARDINAL ;


(*
   CompareStr - compare two strings, left, and, right.
*)

PROCEDURE CompareStr (left, right: ARRAY OF CHAR) : INTEGER ;


END Strings.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.18 gm2-libs-pim/Termbase

 
DEFINITION MODULE Termbase ;

(*
    Description: provides GNU Modula-2 with a PIM 234 compatible Termbase
                 module. Definition module complies with Logitech 3.0.
                 Initially the read routines from Keyboard and the
                 write routine from Display is assigned to the Read,
                 KeyPressed and Write procedures.
*)

EXPORT QUALIFIED ReadProcedure, StatusProcedure, WriteProcedure,
                 AssignRead, AssignWrite, UnAssignRead, UnAssignWrite,
                 Read, KeyPressed, Write ;

TYPE
   ReadProcedure = PROCEDURE (VAR CHAR) ;
   WriteProcedure = PROCEDURE (CHAR) ;
   StatusProcedure = PROCEDURE () : BOOLEAN ;


(*
   AssignRead - assigns a read procedure and status procedure for terminal
                input. Done is set to TRUE if successful. Subsequent
                Read and KeyPressed calls are mapped onto the user supplied
                procedures. The previous read and status procedures are
                uncovered and reused after UnAssignRead is called.
*)

PROCEDURE AssignRead (rp: ReadProcedure; sp: StatusProcedure;
                      VAR Done: BOOLEAN) ;


(*
   UnAssignRead - undo the last call to AssignRead and set Done to TRUE
                  on success.
*)

PROCEDURE UnAssignRead (VAR Done: BOOLEAN) ;


(*
   Read - reads a single character using the currently active read
          procedure.
*)

PROCEDURE Read (VAR ch: CHAR) ;


(*
   KeyPressed - returns TRUE if a character is available to be read.
*)

PROCEDURE KeyPressed () : BOOLEAN ;


(*
   AssignWrite - assigns a write procedure for terminal output.
                 Done is set to TRUE if successful. Subsequent
                 Write calls are mapped onto the user supplied
                 procedure. The previous write procedure is
                 uncovered and reused after UnAssignWrite is called.
*)

PROCEDURE AssignWrite (wp: WriteProcedure; VAR Done: BOOLEAN) ;


(*
   UnAssignWrite - undo the last call to AssignWrite and set Done to TRUE
                   on success.
*)

PROCEDURE UnAssignWrite (VAR Done: BOOLEAN) ;


(*
   Write - writes a single character using the currently active write
           procedure.
*)

PROCEDURE Write (VAR ch: CHAR) ;


END Termbase.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.19 gm2-libs-pim/Terminal

 
DEFINITION MODULE Terminal ;

(*
    Description: provides a Logitech 3.0 compatible and PIM [234] compatible
                 Terminal module. It provides simple terminal input output
                 routines which all utilize the TermBase module.
*)

EXPORT QUALIFIED Read, KeyPressed, ReadAgain, ReadString, Write,
                 WriteString, WriteLn ;


(*
   Read - reads a single character.
*)

PROCEDURE Read (VAR ch: CHAR) ;


(*
   KeyPressed - returns TRUE if a character can be read without blocking
                the caller.
*)

PROCEDURE KeyPressed () : BOOLEAN ;


(*
   ReadString - reads a sequence of characters.
                Tabs are expanded into 8 spaces and <cr> or <lf> terminates
                the string.
*)

PROCEDURE ReadString (VAR s: ARRAY OF CHAR) ;


(*
   ReadAgain - makes the last character readable again.
*)

PROCEDURE ReadAgain ;


(*
   Write - writes a single character to the Termbase module.
*)

PROCEDURE Write (ch: CHAR) ;


(*
   WriteString - writes out a string which is terminated by a <nul>
                 character or the end of string HIGH(s).
*)

PROCEDURE WriteString (s: ARRAY OF CHAR) ;


(*
   WriteLn - writes a lf character.
*)

PROCEDURE WriteLn ;


END Terminal.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2.20 gm2-libs-pim/TimeDate

 
DEFINITION MODULE TimeDate ;

(*
    Description: provides a Logitech-3.0 compatible library module.
                 Advised to use cleaner designed modules based on 'man 3 strtime'
                 and friends for new projects as the day value here is ugly
                 [maybe it mapped onto MSDOS].
*)

EXPORT QUALIFIED Time, GetTime, SetTime, CompareTime, TimeToZero,
                 TimeToString ;

TYPE
(*
   day holds:  bits 0..4 = day of month (1..31)
                    5..8 = month of year (1..12)
                    9..  = year - 1900
   minute holds:    hours * 60 + minutes
   millisec holds:  seconds * 1000 + millisec
                    which is reset to 0 every minute
*)

   Time = RECORD
             day, minute, millisec: CARDINAL ;
          END ;


(*
   GetTime - returns the current date and time.
*)

PROCEDURE GetTime (VAR curTime: Time) ;


(*
   SetTime - does nothing, but provides compatibility with
             the Logitech-3.0 library.
*)

PROCEDURE SetTime (curTime: Time) ;


(*
   CompareTime - compare two dates and time which returns:

                 -1  if t1 < t2
                  0  if t1 = t2
                  1  if t1 > t2
*)

PROCEDURE CompareTime (t1, t2: Time) : INTEGER ;


(*
   TimeToZero - initializes, t, to zero.
*)

PROCEDURE TimeToZero (VAR t: Time) ;


(*
   TimeToString - convert time, t, to a string.
                  The string, s, should be at least 19 characters
                  long and the returned string will be

                  yyyy-mm-dd hh:mm:ss
*)

PROCEDURE TimeToString (t: Time; VAR s: ARRAY OF CHAR) ;


END TimeDate.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 PIM coroutine support

This directory contains a PIM SYSTEM containing the PROCESS primitives built on top of GNU Pthreads.

The justification for this approach is that it provides a SYSTEM compatible with Programming in Modula-2 [234] and the Logitech 3.0 compiler. It also allows higher level executives to be ported onto GM2 with little effort. The disadvantage with this approach is that IOTRANSFER is not preemptive. IOTRANSFER will only context switch when a call to LISTEN is made or a call to SYSTEM.TurnInterrupts is made.

In practice this limitation can be tolerated as long as processes perform IO at some point (or wait for a timer interrupt) or call SYSTEM.TurnInterrupts. But nevertheless a LOOP END will starve all other processes. However the great advantage is that GNU Modula-2 can offer users the ability to use IOTRANSFER, TRANSFER, NEWPROCESS in user space, on a multi-user operating system and across a range of platforms.

The GNU Modula-2 SYSTEM works by utilizing the user context switching mechanism provided by GNU Pthreads. NEWPROCESS creates a new context, TRANSFER switches contexts. IOTRANSFER is more complex. There is a support module SysVec which provides pseudo interrupt vectors. These can be created from input/output file descriptors or timer events timeval. This vector is then passed to IOTRANSFER which keeps track of which file descriptors and timevals are active. When a call to TurnInterrupts or LISTEN is made the sub system calls pth_select and tests for any ready file descriptor or timeout. A ready file descriptor or timeout will ultimately cause the backwards TRANSFER inside IOTRANSFER to take effect.

See the `gm2/examples/executive' directory for an executive and timerhandler module which provide higher level process creation, synchronisation and interrupt handling routines. These libraries have been tested with the examples shown in `gm2/examples/executive' and `gm2/gm2-libs-coroutines'.

Users of these libraries and the libraries in `gm2/examples/executive' must link their application against the GNU Pthread library (typically by using -lpth).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.1 gm2-libs-coroutines/Debug

 
DEFINITION MODULE Debug ;

(*
    Description: provides some simple debugging routines.
*)

EXPORT QUALIFIED Halt, DebugString, PushOutput ;

TYPE
   WriteP = PROCEDURE (CHAR) ;


(*
   Halt - writes a message in the format:
          Module:Line:Message

          It then terminates by calling HALT.
*)

PROCEDURE Halt (File    : ARRAY OF CHAR;
                LineNo  : CARDINAL;
                Function,
                Message : ARRAY OF CHAR) ;


(*
   DebugString - writes a string to the debugging device (Scn.Write).
                 It interprets \n as carriage return, linefeed.
*)

PROCEDURE DebugString (a: ARRAY OF CHAR) ;


(*
   PushOutput - pushes the output procedure, p, which is used Debug.
*)

PROCEDURE PushOutput (p: WriteP) ;


(*
   PopOutput - pops the current output procedure from the stack.
*)

PROCEDURE PopOutput ;


END Debug.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.2 gm2-libs-coroutines/Executive

 
DEFINITION MODULE Executive ;

(*
    Description: provides a simple multitasking executive.
*)

EXPORT QUALIFIED SEMAPHORE, DESCRIPTOR,
                 InitProcess, KillProcess, Resume, Suspend, InitSemaphore,
                 Wait, Signal, WaitForIO, Ps, GetCurrentProcess,
                 RotateRunQueue, ProcessName, DebugProcess ;

TYPE
   SEMAPHORE ;         (* defines dijkstra's semaphores *)
   DESCRIPTOR ;        (* handle onto a process         *)


(*
   InitProcess - initializes a process which is held in the suspended
                 state. When the process is resumed it will start executing
                 procedure, p. The process has a maximum stack size of,
                 StackSize, bytes and its textual name is, Name.
                 The StackSize should be at least 5000 bytes.
*)

PROCEDURE InitProcess (p: PROC; StackSize: CARDINAL;
                       Name: ARRAY OF CHAR) : DESCRIPTOR ;


(*
   KillProcess - kills the current process. Notice that if InitProcess
                 is called again, it might reuse the DESCRIPTOR of the
                 killed process. It is the responsibility of the caller
                 to ensure all other processes understand this process
                 is different.
*)

PROCEDURE KillProcess ;


(*
   Resume - resumes a suspended process. If all is successful then the process, p,
            is returned. If it fails then NIL is returned.
*)

PROCEDURE Resume (d: DESCRIPTOR) : DESCRIPTOR ;


(*
   Suspend - suspend the calling process.
             The process can only continue running if another process
             Resumes it.
*)

PROCEDURE Suspend ;


(*
   InitSemaphore - creates a semaphore whose initial value is, v, and
                   whose name is, Name.
*)

PROCEDURE InitSemaphore (v: CARDINAL; Name: ARRAY OF CHAR) : SEMAPHORE ;


(*
   Wait - performs dijkstra's P operation on a semaphore.
          A process which calls this procedure will
          wait until the value of the semaphore is > 0
          and then it will decrement this value.
*)

PROCEDURE Wait (s: SEMAPHORE) ;


(*
   Signal - performs dijkstra's V operation on a semaphore.
            A process which calls the procedure will increment
            the semaphores value.
*)

PROCEDURE Signal (s: SEMAPHORE) ;


(*
   WaitForIO - waits for an interrupt to occur on vector, VectorNo.
*)

PROCEDURE WaitForIO (VectorNo: CARDINAL) ;


(*
   Ps - displays a process list together with process status.
*)

PROCEDURE Ps ;


(*
   GetCurrentProcess - returns the descriptor of the current running
                       process.
*)

PROCEDURE GetCurrentProcess () : DESCRIPTOR ;


(*
   RotateRunQueue - rotates the process run queue.
                    It does not call the scheduler.
*)

PROCEDURE RotateRunQueue ;


(*
   ProcessName - displays the name of process, d, through
                 DebugString.
*)

PROCEDURE ProcessName (d: DESCRIPTOR) ;


(*
   DebugProcess - gdb debug handle to enable users to debug deadlocked
                  semaphore processes.
*)

PROCEDURE DebugProcess (d: DESCRIPTOR) ;


END Executive.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.3 gm2-libs-coroutines/KeyBoardLEDs

 
DEFINITION MODULE KeyBoardLEDs ;

(*
    Description: provides a simple module to manipulate the keyboard
                 LEDs in Linux.
*)

EXPORT QUALIFIED SwitchLeds,
                 SwitchScroll, SwitchNum, SwitchCaps ;


(*
   SwitchLeds - switch the keyboard LEDs to the state defined
                by the BOOLEAN variables. TRUE = ON.
*)

PROCEDURE SwitchLeds (NumLock, CapsLock, ScrollLock: BOOLEAN) ;


(*
   SwitchScroll - switchs the scroll LED on or off.
*)

PROCEDURE SwitchScroll (Scroll: BOOLEAN) ;


(*
   SwitchNum - switches the Num LED on or off.
*)

PROCEDURE SwitchNum (Num: BOOLEAN) ;


(*
   SwitchCaps - switches the Caps LED on or off.
*)

PROCEDURE SwitchCaps (Caps: BOOLEAN) ;


END KeyBoardLEDs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.4 gm2-libs-coroutines/SYSTEM

 
DEFINITION MODULE SYSTEM ;

(*
   Description: Implements the SYSTEM dependent module
                in the Modula-2 compiler. This module is designed
                to be used on a native operating system rather than
                an embedded system as it implements the coroutine
                primitives TRANSFER, IOTRANSFER and
                NEWPROCESS through the GNU Pthread library.
*)


EXPORT QUALIFIED (* the following are built into the compiler: *)
                 ADDRESS, WORD, BYTE, BITSET, ADR, TSIZE, SIZE,

                 (* and the rest are implemented in SYSTEM.mod *)
                 PROCESS, TRANSFER, NEWPROCESS, IOTRANSFER,
                 LISTEN,

                 ListenLoop, TurnInterrupts, PRIORITY ;


TYPE
   PROCESS  = RECORD
                 context: ADDRESS ;
                 ints   : PRIORITY ;
              END ;

   PRIORITY = [0..7] ;


(*
   TRANSFER - save the current volatile environment into, p1.
              Restore the volatile environment from, p2.
*)

PROCEDURE TRANSFER (VAR p1: PROCESS; p2: PROCESS) ;


(*
   NEWPROCESS - p is a parameterless procedure, a, is the origin of
                the workspace used for the process stack and containing
                the volatile environment of the process. n, is the amount
                in bytes of this workspace. new, is the new process.
*)

PROCEDURE NEWPROCESS (p: PROC; a: ADDRESS; n: CARDINAL; VAR new: PROCESS) ;


(*
   IOTRANSFER - saves the current volatile environment into, First,
                and restores volatile environment, Second.
                When an interrupt, InterruptNo, is encountered then
                the reverse takes place. (The then current volatile
                environment is shelved onto Second and First is resumed).

                NOTE: that upon interrupt the Second might not be the
                      same process as that before the original call to
                      IOTRANSFER.
*)

PROCEDURE IOTRANSFER (VAR First, Second: PROCESS; InterruptNo: CARDINAL) ;


(*
   LISTEN - briefly listen for any interrupts.
*)

PROCEDURE LISTEN ;


(*
   ListenLoop - should be called instead of users writing:

                LOOP
                   LISTEN
                END

                It performs the same function but yields
                control back to the underlying operating system
                via a call to pth_select.
                It also checks for deadlock.
                This function returns when an interrupt occurs ie
                a file descriptor becomes ready or a time event expires.
                See the module SysVec.
*)

PROCEDURE ListenLoop ;


(*
   TurnInterrupts - switches processor interrupts to the priority, to.
                    It returns the old value.

                    This function is available in this implementation
                    to allow microkernel Modula-2 code to be
                    compiled and run both under a Pthread implementation
                    and a stand alone system.
*)

PROCEDURE TurnInterrupts (to: PRIORITY) : PRIORITY ;


END SYSTEM.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.5 gm2-libs-coroutines/SysVec

 
DEFINITION MODULE SysVec ;

(*
    Description: provides SYSTEM with the pseudo interrupt vector
                 manipulation routines. This module interface was
                 designed to allow SYSTEM to have the same interface
                 as PIM [234] and Logitech 3.0. It would have been
                 easier to include this functionality into SYSTEM
                 at the expense of stricter compatibility.
*)

FROM SYSTEM IMPORT ADDRESS ;
EXPORT QUALIFIED InitInputVector, InitOutputVector, InitTimeVector,
                 AttachVector,
                 ReArmTimeVector, GetTimeVector,
                 Listen, IncludeVector, ExcludeVector, DespatchVector ;

TYPE
   DespatchVector = PROCEDURE (CARDINAL, CARDINAL, ADDRESS) ;


(*
   InitInputVector - returns an interrupt vector which is associated
                     with the file descriptor, fd.
*)

PROCEDURE InitInputVector (fd: INTEGER; pri: CARDINAL) : CARDINAL ;


(*
   InitOutputVector - returns an interrupt vector which is associated
                      with the file descriptor, fd.
*)

PROCEDURE InitOutputVector (fd: INTEGER; pri: CARDINAL) : CARDINAL ;


(*
   InitTimeVector - returns an interrupt vector associated with
                    the relative time.
*)

PROCEDURE InitTimeVector (micro, secs: CARDINAL; pri: CARDINAL) : CARDINAL ;


(*
   ReArmTimeVector - reprimes the vector, vec, to deliver an interrupt
                     at the new relative time.
*)

PROCEDURE ReArmTimeVector (vec: CARDINAL; micro, secs: CARDINAL) ;


(*
   GetTimeVector - assigns, micro, and, secs, with the remaining
                   time before this interrupt will expire.
                   This value is only updated when a Listen
                   occurs.
*)

PROCEDURE GetTimeVector (vec: CARDINAL; VAR micro, secs: CARDINAL) ;


(*
   AttachVector - adds the pointer, p, to be associated with the interrupt
                  vector. It returns the previous value attached to this
                  vector.
*)

PROCEDURE AttachVector (vec: CARDINAL; p: ADDRESS) : ADDRESS ;


(*
   IncludeVector - includes, vec, into the despatcher list of
                   possible interrupt causes.
*)

PROCEDURE IncludeVector (vec: CARDINAL) ;


(*
   ExcludeVector - excludes, vec, from the despatcher list of
                   possible interrupt causes.
*)

PROCEDURE ExcludeVector (vec: CARDINAL) ;


(*
   Listen - will either block indefinitely (until an interrupt)
            or alteratively will test to see whether any interrupts
            are pending.
            If a pending interrupt was found then, call, is called
            and then this procedure returns.
            It only listens for interrupts > pri.
*)

PROCEDURE Listen (untilInterrupt: BOOLEAN;
                  call: DespatchVector;
                  pri: CARDINAL) ;


END SysVec.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.6 gm2-libs-coroutines/TimerHandler

 
DEFINITION MODULE TimerHandler ;

(*
    Description: provides a simple timer handler for the
                 Executive.
                 It also provides the Executive with a basic
                 round robin scheduler.
*)

EXPORT QUALIFIED TicksPerSecond, GetTicks,
                 EVENT,
                 Sleep, ArmEvent, WaitOn, Cancel, ReArmEvent ;


CONST
   TicksPerSecond =   25 ;  (* Number of ticks per second.         *)

TYPE
   EVENT ;


(*
   GetTicks - returns the number of ticks since boottime.
*)

PROCEDURE GetTicks () : CARDINAL ;


(*
   Sleep - suspends the current process for a time, t.
           The time is measured in ticks.
*)

PROCEDURE Sleep (t: CARDINAL) ;


(*
   ArmEvent - initializes an event, e, to occur at time, t.
              The time, t, is measured in ticks.
              The event is NOT placed onto the event queue.
*)

PROCEDURE ArmEvent (t: CARDINAL) : EVENT ;


(*
   WaitOn - places event, e, onto the event queue and then the calling
            process suspends. It is resumed up by either the event
            expiring or the event, e, being cancelled.
            TRUE is returned if the event was cancelled
            FALSE is returned if the event expires.
*)

PROCEDURE WaitOn (e: EVENT) : BOOLEAN ;


(*
   Cancel - cancels the event, e, on the event queue and makes
            the appropriate process runnable again.
            TRUE is returned if the event was cancelled and
            FALSE is returned is the event was not found or
                  no process was waiting on this event.
*)

PROCEDURE Cancel (e: EVENT) : BOOLEAN ;


(*
   ReArmEvent - removes an event, e, from the event queue. A new time
                is given to this event and it is then re-inserted onto the
                event queue in the correct place.
                TRUE is returned if this occurred
                FALSE is returned if the event was not found.
*)

PROCEDURE ReArmEvent (e: EVENT; t: CARDINAL) : BOOLEAN ;


END TimerHandler.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.7 gm2-libs-coroutines/pth

 
DEFINITION MODULE FOR "C" pth ;

FROM SYSTEM IMPORT ADDRESS, BITSET ;

CONST
     PTH_VERSION_STR =  "1.4.1 (27-Jan-2002)" ;
     PTH_VERSION_HEX =  1065473 ;
     PTH_VERSION =  PTH_VERSION_HEX ;

TYPE
     fd_set =  ADDRESS ;
     __time_t =   INTEGER ;
     __useconds_t =   CARDINAL ;
     __suseconds_t =   INTEGER ;
     size_t =   CARDINAL ;
    timeval = RECORD
                 tv_sec : __time_t ;
                 tv_usec: __suseconds_t ;
              END ;

    sockaddr = RECORD
               END ;
     sigset_t =  ADDRESS ;
     pth_uctx_t =  POINTER TO   pth_uctx_st ;
    pth_uctx_st = RECORD
                  END ;
     pid_t =   INTEGER ;
     ssize_t =   CARDINAL ;
     socklen_t =   CARDINAL ;
     off_t =   INTEGER ;
     sig_atomic_t =   INTEGER ;
     nfds_t =   LONGCARD ;

CONST
     PTH_KEY_MAX =  256 ;
     PTH_ATFORK_MAX =  128 ;
     PTH_DESTRUCTOR_ITERATIONS =  4 ;
     PTH_SYSCALL_HARD =  0 ;
     PTH_SYSCALL_SOFT =  0 ;

TYPE
     pth_time_t =  ADDRESS ;
     pth_t =  ADDRESS ;
     pth_state_t =   pth_state_en ;
     pth_state_en =  ( PTH_STATE_SCHEDULER, PTH_STATE_NEW, PTH_STATE_READY, PTH_STATE_WAITING, PTH_STATE_DEAD) ;

CONST
     PTH_PRIO_MAX =   5 ;
     PTH_PRIO_STD =  0 ;
     PTH_PRIO_MIN =  -( 5) ;

TYPE
     pth_attr_t =  ADDRESS ;

CONST
     PTH_ATTR_PRIO = 0 ;
     PTH_ATTR_NAME = 1 ;
     PTH_ATTR_JOINABLE = 2 ;
     PTH_ATTR_CANCEL_STATE = 3 ;
     PTH_ATTR_STACK_SIZE = 4 ;
     PTH_ATTR_STACK_ADDR = 5 ;
     PTH_ATTR_TIME_SPAWN = 6 ;
     PTH_ATTR_TIME_LAST = 7 ;
     PTH_ATTR_TIME_RAN = 8 ;
     PTH_ATTR_START_FUNC = 9 ;
     PTH_ATTR_START_ARG = 10 ;
     PTH_ATTR_STATE = 11 ;
     PTH_ATTR_EVENTS = 12 ;
     PTH_ATTR_BOUND = 13 ;
     PTH_ATTR_DEFAULT =  0 ;



    (* event subject classes *)
    PTH_EVENT_FD    =  BITSET {1} ;
    PTH_EVENT_SELECT=  BITSET {2} ;
    PTH_EVENT_SIGS  =  BITSET {3} ;
    PTH_EVENT_TIME  =  BITSET {4} ;
    PTH_EVENT_MSG   =  BITSET {5} ;
    PTH_EVENT_MUTEX =  BITSET {6} ;
    PTH_EVENT_COND  =  BITSET {7} ;
    PTH_EVENT_TID   =  BITSET {8} ;
    PTH_EVENT_FUNC  =  BITSET {9} ;

    (* event occurange restrictions *)
    PTH_UNTIL_OCCURRED     =  BITSET {11} ;
    PTH_UNTIL_FD_READABLE  =  BITSET {12} ;
    PTH_UNTIL_FD_WRITEABLE =  BITSET {13} ;
    PTH_UNTIL_FD_EXCEPTION =  BITSET {14} ;
    PTH_UNTIL_TID_NEW      =  BITSET {15} ;
    PTH_UNTIL_TID_READY    =  BITSET {16} ;
    PTH_UNTIL_TID_WAITING  =  BITSET {17} ;
    PTH_UNTIL_TID_DEAD     =  BITSET {18} ;

    (* event structure handling modes *)
    PTH_MODE_REUSE  =  BITSET {20} ;
    PTH_MODE_CHAIN  =  BITSET {21} ;
    PTH_MODE_STATIC =  BITSET {22} ;

TYPE
     pth_event_t =  ADDRESS ;

CONST
     PTH_FREE_THIS = 0 ;
     PTH_FREE_ALL = 1 ;

TYPE
     pth_key_t =   INTEGER ;

CONST
     PTH_KEY_INIT =  -( 1) ;

TYPE
     pth_once_t =   INTEGER ;

CONST
     PTH_ONCE_INIT =  FALSE ;

TYPE
     pth_ringnode_t =   pth_ringnode_st ;
    pth_ringnode_st = RECORD
                         rn_next: POINTER TO  pth_ringnode_t ;
                         rn_prev: POINTER TO  pth_ringnode_t ;
                      END ;
     pth_ring_t =   pth_ring_st ;
    pth_ring_st = RECORD
                     r_hook: POINTER TO  pth_ringnode_t ;
                     r_nodes: CARDINAL ;
                  END ;
     pth_msgport_t =  ADDRESS ;
     pth_message_t =   pth_message_st ;
    pth_message_st = RECORD
                        m_node: pth_ringnode_t ;
                        m_replyport: pth_msgport_t ;
                        m_size: CARDINAL ;
                        m_data: ADDRESS ;
                     END ;
     pth_mutex_t =   pth_mutex_st ;
    pth_mutex_st = RECORD
                      mx_node: pth_ringnode_t ;
                      mx_state: INTEGER ;
                      mx_owner: pth_t ;
                      mx_count: CARDINAL ;
                   END ;
     pth_rwlock_t =   pth_rwlock_st ;
    pth_rwlock_st = RECORD
                       rw_state: INTEGER ;
                       rw_mode: CARDINAL ;
                       rw_readers: CARDINAL ;
                       rw_mutex_rd: pth_mutex_t ;
                       rw_mutex_rw: pth_mutex_t ;
                    END ;
     pth_cond_t =   pth_cond_st ;
    pth_cond_st = RECORD
                     cn_state: CARDINAL ;
                     cn_waiters: CARDINAL ;
                  END ;
     pth_barrier_t =   pth_barrier_st ;
    pth_barrier_st = RECORD
                        br_state: CARDINAL ;
                        br_threshold: INTEGER ;
                        br_count: INTEGER ;
                        br_cycle: INTEGER ;
                        br_cond: pth_cond_t ;
                        br_mutex: pth_mutex_t ;
                     END ;

CONST
     POLLIN =  1 ;
     POLLPRI =  2 ;
     POLLOUT =  4 ;
     POLLERR =  8 ;
     POLLHUP =  16 ;
     POLLNVAL =  32 ;
     POLLRDNORM =  POLLIN ;
     POLLRDBAND =  POLLIN ;
     POLLWRNORM =  POLLOUT ;
     POLLWRBAND =  POLLOUT ;
     INFTIM =  -( 1) ;

CONST
     PTH_FAKE_RWV =  0 ;

TYPE
    iovec = RECORD
               iov_base: ADDRESS ;
               iov_len: size_t ;
            END ;

CONST
     UIO_MAXIOV =  1024 ;
     PTH_EXT_SFIO =  0 ;

TYPE
     Sfdisc_t =  ADDRESS ;

 PROCEDURE pth_init () : INTEGER ;
 PROCEDURE pth_kill () : INTEGER ;
 PROCEDURE pth_ctrl (p1: CARDINAL; ...) : INTEGER ;
 PROCEDURE pth_version () : INTEGER ;
 PROCEDURE pth_attr_of (p1: pth_t) : pth_attr_t ;
 PROCEDURE pth_attr_new () : pth_attr_t ;
 PROCEDURE pth_attr_init (p1: pth_attr_t) : INTEGER ;
 PROCEDURE pth_attr_set (p1: pth_attr_t; p2: INTEGER; ...) : INTEGER ;
 PROCEDURE pth_attr_get (p1: pth_attr_t; p2: INTEGER; ...) : INTEGER ;
 PROCEDURE pth_attr_destroy (p1: pth_attr_t) : INTEGER ;
 PROCEDURE pth_spawn (p2: pth_attr_t; p1: t1; p3: ADDRESS) : pth_t;

TYPE
     t1 =    PROCEDURE (ADDRESS) : ADDRESS ;

PROCEDURE pth_once (p2: ADDRESS; p1: t2; p3: ADDRESS) : INTEGER;

TYPE
     t2 =    PROCEDURE (ADDRESS) ;

 PROCEDURE pth_self () : pth_t ;
 PROCEDURE pth_suspend (p1: pth_t) : INTEGER ;
 PROCEDURE pth_resume (p1: pth_t) : INTEGER ;
 PROCEDURE pth_yield (p1: pth_t) : INTEGER ;
 PROCEDURE pth_nap (p1: pth_time_t) : INTEGER ;
 PROCEDURE pth_wait (p1: pth_event_t) : INTEGER ;
 PROCEDURE pth_cancel (p1: pth_t) : INTEGER ;
 PROCEDURE pth_abort (p1: pth_t) : INTEGER ;
 PROCEDURE pth_raise (p1: pth_t; p2: INTEGER) : INTEGER ;
 PROCEDURE pth_join (p1: pth_t; p2: ADDRESS) : INTEGER ;
 PROCEDURE pth_exit (p1: ADDRESS) ;
 PROCEDURE pth_fdmode (p1: INTEGER; p2: INTEGER) : INTEGER ;
 PROCEDURE pth_time (p1: INTEGER; p2: INTEGER) : pth_time_t ;
 PROCEDURE pth_timeout (p1: INTEGER; p2: INTEGER) : pth_time_t ;
 PROCEDURE pth_cancel_state (p1: INTEGER; p2: ADDRESS) ;
 PROCEDURE pth_cancel_point  ;
 PROCEDURE pth_event (p1: CARDINAL; ...) : pth_event_t ;
 PROCEDURE pth_event_typeof (p1: pth_event_t) : CARDINAL ;
 PROCEDURE pth_event_extract (ev: pth_event_t; ...) : INTEGER ;
 PROCEDURE pth_event_concat (p1: pth_event_t; ...) : pth_event_t ;
 PROCEDURE pth_event_isolate (p1: pth_event_t) : pth_event_t ;
 PROCEDURE pth_event_walk (p1: pth_event_t; p2: CARDINAL) : pth_event_t ;
 PROCEDURE pth_event_occurred (p1: pth_event_t) : INTEGER ;
 PROCEDURE pth_event_free (p1: pth_event_t; p2: INTEGER) : INTEGER ;
 PROCEDURE pth_key_create (p2: ADDRESS; p1: t3) : INTEGER;

TYPE
     t3 =    PROCEDURE (ADDRESS) ;

 PROCEDURE pth_key_delete (p1: pth_key_t) : INTEGER ;
 PROCEDURE pth_key_setdata (p1: pth_key_t; p2: ADDRESS) : INTEGER ;
 PROCEDURE pth_key_getdata (p1: pth_key_t) : ADDRESS ;
 PROCEDURE pth_msgport_create (p1: ADDRESS) : pth_msgport_t ;
 PROCEDURE pth_msgport_destroy (p1: pth_msgport_t) ;
 PROCEDURE pth_msgport_find (p1: ADDRESS) : pth_msgport_t ;
 PROCEDURE pth_msgport_pending (p1: pth_msgport_t) : INTEGER ;
 PROCEDURE pth_msgport_put (p1: pth_msgport_t; p2: ADDRESS) : INTEGER ;
 PROCEDURE pth_msgport_get (p1: pth_msgport_t) : ADDRESS ;
 PROCEDURE pth_msgport_reply (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_cleanup_push (p1: t4; p2: ADDRESS) : INTEGER;

TYPE
     t4 =    PROCEDURE (ADDRESS) ;

 PROCEDURE pth_cleanup_pop (p1: INTEGER) : INTEGER ;

TYPE
     t5 =    PROCEDURE (ADDRESS);

 PROCEDURE pth_atfork_pop () : INTEGER ;
 PROCEDURE pth_fork () : pid_t ;
 PROCEDURE pth_mutex_init (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_mutex_acquire (p1: ADDRESS; p2: INTEGER; p3: pth_event_t) : INTEGER ;
 PROCEDURE pth_mutex_release (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_rwlock_init (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_rwlock_acquire (p1: ADDRESS; p2: INTEGER; p3: INTEGER; p4: pth_event_t) : INTEGER ;
 PROCEDURE pth_rwlock_release (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_cond_init (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_cond_await (p1: ADDRESS; p2: ADDRESS; p3: pth_event_t) : INTEGER ;
 PROCEDURE pth_cond_notify (p1: ADDRESS; p2: INTEGER) : INTEGER ;
 PROCEDURE pth_barrier_init (p1: ADDRESS; p2: INTEGER) : INTEGER ;
 PROCEDURE pth_barrier_reach (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_uctx_create (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_uctx_make (p2: pth_uctx_t; p3: ADDRESS; p4: size_t; p5: ADDRESS; p1: t8; p6: ADDRESS; p7: pth_uctx_t) : INTEGER;

TYPE
     t8 =    PROCEDURE (ADDRESS) ;

 PROCEDURE pth_uctx_save (p1: pth_uctx_t) : INTEGER ;
 PROCEDURE pth_uctx_restore (p1: pth_uctx_t) : INTEGER ;
 PROCEDURE pth_uctx_switch (p1: pth_uctx_t; p2: pth_uctx_t) : INTEGER ;
 PROCEDURE pth_uctx_destroy (p1: pth_uctx_t) : INTEGER ;
 PROCEDURE pth_sfiodisc () : ADDRESS ;
 PROCEDURE pth_sigwait_ev (p1: ADDRESS; p2: ADDRESS; p3: pth_event_t) : INTEGER ;
 PROCEDURE pth_connect_ev (p1: INTEGER; p2: ADDRESS; p3: socklen_t; p4: pth_event_t) : INTEGER ;
 PROCEDURE pth_accept_ev (p1: INTEGER; p2: ADDRESS; p3: ADDRESS; p4: pth_event_t) : INTEGER ;
 PROCEDURE pth_select_ev (p1: INTEGER; p2: ADDRESS; p3: ADDRESS; p4: ADDRESS; p5: ADDRESS; p6: pth_event_t) : INTEGER ;
 PROCEDURE pth_poll_ev (p1: ADDRESS; p2: nfds_t; p3: INTEGER; p4: pth_event_t) : INTEGER ;
 PROCEDURE pth_read_ev (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: pth_event_t) : ssize_t ;
 PROCEDURE pth_write_ev (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: pth_event_t) : ssize_t ;
 PROCEDURE pth_readv_ev (p1: INTEGER; p2: ADDRESS; p3: INTEGER; p4: pth_event_t) : ssize_t ;
 PROCEDURE pth_writev_ev (p1: INTEGER; p2: ADDRESS; p3: INTEGER; p4: pth_event_t) : ssize_t ;
 PROCEDURE pth_recv_ev (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER; p5: pth_event_t) : ssize_t ;
 PROCEDURE pth_send_ev (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER; p5: pth_event_t) : ssize_t ;
 PROCEDURE pth_recvfrom_ev (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER; p5: ADDRESS; p6: ADDRESS; p7: pth_event_t) : ssize_t ;
 PROCEDURE pth_sendto_ev (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER; p5: ADDRESS; p6: socklen_t; p7: pth_event_t) : ssize_t ;
 PROCEDURE pth_usleep (p1: CARDINAL) : INTEGER ;
 PROCEDURE pth_sleep (p1: CARDINAL) : CARDINAL ;
 PROCEDURE pth_waitpid (p1: pid_t; p2: ADDRESS; p3: INTEGER) : pid_t ;
 PROCEDURE pth_system (p1: ADDRESS) : INTEGER ;
 PROCEDURE pth_sigmask (p1: INTEGER; p2: ADDRESS; p3: ADDRESS) : INTEGER ;
 PROCEDURE pth_sigwait (p1: ADDRESS; p2: ADDRESS) : INTEGER ;
 PROCEDURE pth_connect (p1: INTEGER; p2: ADDRESS; p3: socklen_t) : INTEGER ;
 PROCEDURE pth_accept (p1: INTEGER; p2: ADDRESS; p3: ADDRESS) : INTEGER ;
 PROCEDURE pth_select (p1: INTEGER; p2: ADDRESS; p3: ADDRESS; p4: ADDRESS; p5: ADDRESS) : INTEGER ;
 PROCEDURE pth_poll (p1: ADDRESS; p2: nfds_t; p3: INTEGER) : INTEGER ;
 PROCEDURE pth_read (p1: INTEGER; p2: ADDRESS; p3: size_t) : ssize_t ;
 PROCEDURE pth_write (p1: INTEGER; p2: ADDRESS; p3: size_t) : ssize_t ;
 PROCEDURE pth_readv (p1: INTEGER; p2: ADDRESS; p3: INTEGER) : ssize_t ;
 PROCEDURE pth_writev (p1: INTEGER; p2: ADDRESS; p3: INTEGER) : ssize_t ;
 PROCEDURE pth_recv (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER) : ssize_t ;
 PROCEDURE pth_send (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER) : ssize_t ;
 PROCEDURE pth_recvfrom (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER; p5: ADDRESS; p6: ADDRESS) : ssize_t ;
 PROCEDURE pth_sendto (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: INTEGER; p5: ADDRESS; p6: socklen_t) : ssize_t ;
 PROCEDURE pth_pread (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: off_t) : ssize_t ;
 PROCEDURE pth_pwrite (p1: INTEGER; p2: ADDRESS; p3: size_t; p4: off_t) : ssize_t ;

END pth.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 M2 ISO Libraries

This directory contains the ISO definition modules and some corresponding implementation modules. All definition files except M2RTS.def were defined by the International Standard Information technology - programming languages BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language. The Copyright to the definition files (except M2RTS.def) belong to ISO/IEC (International Organization for Standardization and International Electrotechnical Commission). However the implementation modules and M2RTS.def are Copyright of the FSF and are held under the LGPL.

The definition modules are allowed to be distributed together with the compiler.

Currently this is work in progress and the code is incomplete and probably highly buggy.

The following implementation modules are complete:

ChanConsts CharClass ConvTypes


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.1 gm2-iso/COROUTINES

 
DEFINITION MODULE COROUTINES;

(* Facilities for coroutines and the handling of interrupts *)

IMPORT SYSTEM;

CONST
   UnassignedPriority = PTH_PRIO_MIN - 1 ;

TYPE
  COROUTINE; (* Values of this type are created dynamically by NEWCOROUTINE
                and identify the coroutine in subsequent operations *)
  INTERRUPTSOURCE;
  PROTECTION = [UnassignedPriority..PTH_PRIO_MAX]


PROCEDURE NEWCOROUTINE (procBody: PROC;
                        workspace: SYSTEM.ADDRESS;
                        size: CARDINAL;
                        VAR cr: COROUTINE;
                        [initProtection: PROTECTION = UnassignedPriority]);
  (* Creates a new coroutine whose body is given by procBody, and
     returns the identity of the coroutine in cr. workspace is a
     pointer to the work space allocated to the coroutine; size
     specifies the size of this workspace in terms of SYSTEM.LOC.

     The optarg, initProtection, may contain a single parameter which
     specifies the initial protection level of the coroutine.
  *)

PROCEDURE TRANSFER (VAR from: COROUTINE; to: COROUTINE);
  (* Returns the identity of the calling coroutine in from, and
     transfers control to the coroutine specified by to.
  *)

PROCEDURE IOTRANSFER (VAR from: COROUTINE; to: COROUTINE);
  (* Returns the identity of the calling coroutine in from and
     transfers control to the coroutine specified by to.  On
     occurrence of an interrupt, associated with the caller, control
     is transferred back to the caller, and the identity of the
     interrupted coroutine is returned in from.  The calling coroutine
     must be associated with a source of interrupts.
  *)

PROCEDURE ATTACH (source: INTERRUPTSOURCE);
  (* Associates the specified source of interrupts with the calling
     coroutine. *)

PROCEDURE DETACH (source: INTERRUPTSOURCE);
  (* Dissociates the specified source of interrupts from the calling
     coroutine. *)

PROCEDURE IsATTACHED (source: INTERRUPTSOURCE): BOOLEAN;
  (* Returns TRUE if and only if the specified source of interrupts is
     currently associated with a coroutine; otherwise returns FALSE.
  *)

PROCEDURE HANDLER (source: INTERRUPTSOURCE): COROUTINE;
  (* Returns the coroutine, if any, that is associated with the source
     of interrupts. The result is undefined if IsATTACHED(source) =
     FALSE.
  *)

PROCEDURE CURRENT (): COROUTINE;
  (* Returns the identity of the calling coroutine. *)

PROCEDURE LISTEN (p: PROTECTION);
  (* Momentarily changes the protection of the calling coroutine to
     p. *)

PROCEDURE PROT (): PROTECTION;
  (* Returns the protection of the calling coroutine. *)

END COROUTINES.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.2 gm2-iso/ChanConsts

 
DEFINITION MODULE ChanConsts;

  (* Common types and values for channel open requests and results *)

TYPE
  ChanFlags =        (* Request flags possibly given when a channel is opened *)
  ( readFlag,        (* input operations are requested/available *)
    writeFlag,       (* output operations are requested/available *)
    oldFlag,         (* a file may/must/did exist before the channel is opened *)
    textFlag,        (* text operations are requested/available *)
    rawFlag,         (* raw operations are requested/available *)
    interactiveFlag, (* interactive use is requested/applies *)
    echoFlag         (* echoing by interactive device on removal of characters from input
                        stream requested/applies *)
  );

  FlagSet = SET OF ChanFlags;

  (* Singleton values of FlagSet, to allow for example, read + write *)

CONST
  read = FlagSet{readFlag};   (* input operations are requested/available *)
  write = FlagSet{writeFlag}; (* output operations are requested/available *)
  old = FlagSet{oldFlag};     (* a file may/must/did exist before the channel is opened *)
  text = FlagSet{textFlag};   (* text operations are requested/available *)
  raw = FlagSet{rawFlag};     (* raw operations are requested/available *)
  interactive = FlagSet{interactiveFlag}; (* interactive use is requested/applies *)
  echo = FlagSet{echoFlag};   (* echoing by interactive device on removal of characters from
                                 input stream requested/applies *)

TYPE
  OpenResults =        (* Possible results of open requests *)
    (opened,           (* the open succeeded as requested *)
     wrongNameFormat,  (* given name is in the wrong format for the implementation *)
     wrongFlags,       (* given flags include a value that does not apply to the device *)
     tooManyOpen,      (* this device cannot support any more open channels *)
     outOfChans,       (* no more channels can be allocated *)
     wrongPermissions, (* file or directory permissions do not allow request *)
     noRoomOnDevice,   (* storage limits on the device prevent the open *)
     noSuchFile,       (* a needed file does not exist *)
     fileExists,       (* a file of the given name already exists when a new one is required *)
     wrongFileType,    (* the file is of the wrong type to support the required operations *)
      noTextOperations, (* text operations have been requested, but are not supported *)
     noRawOperations,  (* raw operations have been requested, but are not supported *)
     noMixedOperations,(* text and raw operations have been requested, but they
                          are not supported in combination *)
     alreadyOpen,      (* the source/destination is already open for operations not supported
                          in combination with the requested operations *)
     otherProblem      (* open failed for some other reason *)
    );

END ChanConsts.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.3 gm2-iso/CharClass

 
DEFINITION MODULE CharClass;

  (* Classification of values of the type CHAR *)

PROCEDURE IsNumeric (ch: CHAR): BOOLEAN;
  (* Returns TRUE if and only if ch is classified as a numeric character *)

PROCEDURE IsLetter (ch: CHAR): BOOLEAN;
  (* Returns TRUE if and only if ch is classified as a letter *)

PROCEDURE IsUpper (ch: CHAR): BOOLEAN;
  (* Returns TRUE if and only if ch is classified as an upper case letter *)

PROCEDURE IsLower (ch: CHAR): BOOLEAN;
  (* Returns TRUE if and only if ch is classified as a lower case letter *)

PROCEDURE IsControl (ch: CHAR): BOOLEAN;
  (* Returns TRUE if and only if ch represents a control function *)

PROCEDURE IsWhiteSpace (ch: CHAR): BOOLEAN;
  (* Returns TRUE if and only if ch represents a space character or a format effector *)

END CharClass.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.4 gm2-iso/ComplexMath

 
DEFINITION MODULE ComplexMath;

  (* Mathematical functions for the type COMPLEX *)

CONST
  i =    CMPLX (0.0, 1.0);
  one =  CMPLX (1.0, 0.0);
  zero = CMPLX (0.0, 0.0);

PROCEDURE abs (z: COMPLEX): REAL;
  (* Returns the length of z *)

PROCEDURE arg (z: COMPLEX): REAL;
  (* Returns the angle that z subtends to the positive real axis *)

PROCEDURE conj (z: COMPLEX): COMPLEX;
  (* Returns the complex conjugate of z *)

PROCEDURE power (base: COMPLEX; exponent: REAL): COMPLEX;
  (* Returns the value of the number base raised to the power exponent *)

PROCEDURE sqrt (z: COMPLEX): COMPLEX;
  (* Returns the principal square root of z *)

PROCEDURE exp (z: COMPLEX): COMPLEX;
  (* Returns the complex exponential of z *)

PROCEDURE ln (z: COMPLEX): COMPLEX;
  (* Returns the principal value of the natural logarithm of z *)

PROCEDURE sin (z: COMPLEX): COMPLEX;
  (* Returns the sine of z *)

PROCEDURE cos (z: COMPLEX): COMPLEX;
  (* Returns the cosine of z *)

PROCEDURE tan (z: COMPLEX): COMPLEX;
  (* Returns the tangent of z *)

PROCEDURE arcsin (z: COMPLEX): COMPLEX;
  (* Returns the arcsine of z *)

PROCEDURE arccos (z: COMPLEX): COMPLEX;
  (* Returns the arccosine of z *)

PROCEDURE arctan (z: COMPLEX): COMPLEX;
  (* Returns the arctangent of z *)

PROCEDURE polarToComplex (abs, arg: REAL): COMPLEX;
  (* Returns the complex number with the specified polar coordinates *)

PROCEDURE scalarMult (scalar: REAL; z: COMPLEX): COMPLEX;
  (* Returns the scalar product of scalar with z *)

PROCEDURE IsCMathException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception in a routine from this module; otherwise
     returns FALSE.
  *)

END ComplexMath.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.5 gm2-iso/ConvTypes

 
DEFINITION MODULE ConvTypes;

  (* Common types used in the string conversion modules *)

TYPE
  ConvResults =     (* Values of this type are used to express the format of a string *)
  (
    strAllRight,    (* the string format is correct for the corresponding conversion *)
    strOutOfRange,  (* the string is well-formed but the value cannot be represented *)
    strWrongFormat, (* the string is in the wrong format for the conversion *)
    strEmpty        (* the given string is empty *)
  );

  ScanClass =  (* Values of this type are used to classify input to finite state scanners *)
  (
    padding,   (* a leading or padding character at this point in the scan - ignore it *)
    valid,     (* a valid character at this point in the scan - accept it *)
    invalid,   (* an invalid character at this point in the scan - reject it *)
    terminator (* a terminating character at this point in the scan (not part of token) *)
  );

  ScanState =  (* The type of lexical scanning control procedures *)
    PROCEDURE (CHAR, VAR ScanClass, VAR ScanState);

END ConvTypes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.6 gm2-iso/EXCEPTIONS

 
DEFINITION MODULE EXCEPTIONS;

(* Provides facilities for raising user exceptions
   and for making enquiries concerning the current execution state.
*)

TYPE
  ExceptionSource;                (* values of this type are used within library modules to
                                     identify the source of raised exceptions
 *)
  ExceptionNumber = CARDINAL;

PROCEDURE AllocateSource(VAR newSource: ExceptionSource);
  (* Allocates a unique value of type ExceptionSource *)

PROCEDURE RAISE (source: ExceptionSource; number: ExceptionNumber; message: ARRAY OF CHAR);
  (* Associates the given values of source, number and message with the current context
     and raises an exception.
  *)

PROCEDURE CurrentNumber (source: ExceptionSource): ExceptionNumber;
  (* If the current coroutine is in the exceptional execution state because of the raising
     of an exception from source, returns the corresponding number, and otherwise
     raises an exception.
  *)

PROCEDURE GetMessage (VAR text: ARRAY OF CHAR);
  (* If the current coroutine is in the exceptional execution state, returns the possibly
     truncated string associated with the current context.
     Otherwise, in normal execution state, returns the empty string.
  *)

PROCEDURE IsCurrentSource (source: ExceptionSource): BOOLEAN;
  (* If the current coroutine is in the exceptional execution state because of the raising
     of an exception from source, returns TRUE, and otherwise returns FALSE.
  *)

PROCEDURE IsExceptionalExecution (): BOOLEAN;
  (* If the current coroutine is in the exceptional execution state because of the raising
     of an exception, returns TRUE, and otherwise returns FALSE.
  *)

END EXCEPTIONS.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.7 gm2-iso/GeneralUser

 
DEFINITION MODULE GeneralUserExceptions;

(* Provides facilities for general user-defined exceptions *)

TYPE
  GeneralExceptions = (problem, disaster);

PROCEDURE RaiseGeneralException (exception: GeneralExceptions; text: ARRAY OF CHAR);
  (* Raises exception using text as the associated message *)

PROCEDURE IsGeneralException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception from GeneralExceptions;
     otherwise returns FALSE.
  *)

PROCEDURE GeneralException(): GeneralExceptions;
  (* If the current coroutine is in the exceptional execution state because of the
     raising of an exception from GeneralExceptions, returns the corresponding
     enumeration value, and otherwise raises an exception.
  *)

END GeneralUserExceptions.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.8 gm2-iso/IOChan

 
DEFINITION MODULE IOChan;

  (* Types and procedures forming the interface to channels for
device-independent data
     transfer modules
  *)

IMPORT IOConsts, ChanConsts, SYSTEM;

TYPE
  ChanId; (* Values of this type are used to identify channels *)

  (* There is one pre-defined value identifying an invalid channel on which
     no data transfer operations are available.  It may be used to
     initialize variables of type ChanId.
  *)

PROCEDURE InvalidChan (): ChanId;
  (* Returns the value identifying the invalid channel. *)

  (* For each of the following operations, if the device supports the
     operation on the channel, the behaviour of the procedure conforms
     with the description below.  The full behaviour is defined for
     each device module.  If the device does not support the operation
     on the channel, the behaviour of the procedure is to raise the exception
     notAvailable.
  *)

  (* Text operations - these perform any required translation between the
     internal and external representation of text.
  *)

PROCEDURE Look (cid: ChanId; VAR ch: CHAR; VAR res: IOConsts.ReadResults);
  (* If there is a character as the next item in the input stream cid,
     assigns its value to ch without removing it from the stream;
     otherwise the value of ch is not defined.  res
     (and the stored read result) are set to the value allRight,
      endOfLine, or endOfInput.
  *)

PROCEDURE Skip (cid: ChanId);
  (* If the input stream cid has ended, the exception skipAtEnd
     is raised; otherwise the next character or line mark in cid is removed,
     and the stored read result is set to the value allRight.
  *)

PROCEDURE SkipLook (cid: ChanId; VAR ch: CHAR; VAR res: IOConsts.ReadResults);
  (* If the input stream cid has ended, the exception skipAtEnd is raised;
     otherwise the next character or line mark in cid is removed.
     If there is a character as the next item in cid stream, assigns
     its value to ch without removing it from the stream.
     Otherwise, the value of ch is not defined.  res (and the stored
     read result) are set to the value allRight, endOfLine, or endOfInput.
  *)

PROCEDURE WriteLn (cid: ChanId);
  (* Writes a line mark over the channel cid. *)

PROCEDURE TextRead (cid: ChanId; to: SYSTEM.ADDRESS; maxChars: CARDINAL;
                    VAR charsRead: CARDINAL);
  (* Reads at most maxChars characters from the current line in cid,
     and assigns corresponding values to successive components of
     an ARRAY OF CHAR variable for which the address of the first
     component is to. The number of characters read is assigned to charsRead.
     The stored read result is set to allRight, endOfLine, or endOfInput.
  *)

PROCEDURE TextWrite (cid: ChanId; from: SYSTEM.ADDRESS;
                     charsToWrite: CARDINAL);
  (* Writes a number of characters given by the value of charsToWrite,
     from successive components of an ARRAY OF CHAR variable for which
     the address of the first component is from, to the channel cid.
  *)

  (* Direct raw operations  - these do not effect translation between
     the internal and external representation of data
  *)

PROCEDURE RawRead (cid: ChanId; to: SYSTEM.ADDRESS; maxLocs: CARDINAL;
                   VAR locsRead: CARDINAL);
  (* Reads at most maxLocs items from cid, and assigns corresponding
     values to successive components of an ARRAY OF LOC variable for
     which the address of the first component is to. The number of
     characters read is assigned to charsRead. The stored read result
     is set to the value allRight, or endOfInput.
  *)

PROCEDURE RawWrite (cid: ChanId; from: SYSTEM.ADDRESS; locsToWrite: CARDINAL);
  (* Writes a number of items given by the value of charsToWrite,
     from successive components of an ARRAY OF LOC variable for
     which the address of the first component is from, to the channel cid.
  *)

  (* Common operations *)

PROCEDURE GetName (cid: ChanId; VAR s: ARRAY OF CHAR);
  (* Copies to s a name associated with the channel cid, possibly truncated
     (depending on the capacity of s).
  *)

PROCEDURE Reset (cid: ChanId);
  (* Resets the channel cid to a state defined by the device module. *)

PROCEDURE Flush (cid: ChanId);
  (* Flushes any data buffered by the device module out to the channel cid. *)

  (* Access to read results *)

PROCEDURE SetReadResult (cid: ChanId; res: IOConsts.ReadResults);
  (* Sets the read result value for the channel cid to the value res. *)

PROCEDURE ReadResult (cid: ChanId): IOConsts.ReadResults;
  (* Returns the stored read result value for the channel cid.
     (This is initially the value notKnown).
  *)

  (* Users can discover which flags actually apply to a channel *)

PROCEDURE CurrentFlags (cid: ChanId): ChanConsts.FlagSet;
  (* Returns the set of flags that currently apply to the channel cid. *)

  (* The following exceptions are defined for this module and its clients *)

TYPE
  ChanExceptions =
    (wrongDevice,      (* device specific operation on wrong device *)
     notAvailable,     (* operation attempted that is not available on that
                          channel *)
     skipAtEnd,        (* attempt to skip data from a stream that has ended *)
     softDeviceError,  (* device specific recoverable error *)
     hardDeviceError,  (* device specific non-recoverable error *)
     textParseError,   (* input data does not correspond to a character or
                          line mark - optional detection *)
     notAChannel       (* given value does not identify a channel -
                          optional detection *)
    );

PROCEDURE IsChanException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional
     execution state because of the raising of an exception from
     ChanExceptions; otherwise returns FALSE.
  *)

PROCEDURE ChanException (): ChanExceptions;
  (* If the current coroutine is in the exceptional execution state
     because of the raising of an exception from ChanExceptions,
     returns the corresponding enumeration value, and otherwise
     raises an exception.
  *)

  (* When a device procedure detects a device error, it raises the
     exception softDeviceError or hardDeviceError.  If these
     exceptions are handled, the following facilities may be
     used to discover an implementation-defined error number for
     the channel.
  *)

TYPE
  DeviceErrNum = INTEGER;

PROCEDURE DeviceError (cid: ChanId): DeviceErrNum;
  (* If a device error exception has been raised for the channel cid,
     returns the error number stored by the device module.
  *)

END IOChan.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.9 gm2-iso/IOConsts

 
DEFINITION MODULE IOConsts;

  (* Types and constants for input/output modules *)

TYPE
  ReadResults =  (* This type is used to classify the result of an input operation *)
  (
    notKnown,    (* no read result is set *)
    allRight,    (* data is as expected or as required *)
    outOfRange,  (* data cannot be represented *)
    wrongFormat, (* data not in expected format *)
    endOfLine,   (* end of line seen before expected data *)
    endOfInput   (* end of input seen before expected data *)
  );

END IOConsts.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.10 gm2-iso/IOLink

 
DEFINITION MODULE IOLink;

  (* Types and procedures for the standard implementation of channels *)

IMPORT IOChan, IOConsts, ChanConsts, SYSTEM;

TYPE
  DeviceId;
    (* Values of this type are used to identify new device modules, and are normally
       obtained by them during their initialization.
    *)

PROCEDURE AllocateDeviceId (VAR did: DeviceId);
  (* Allocates a unique value of type DeviceId, and assigns this value to did. *)

PROCEDURE MakeChan (did: DeviceId; VAR cid: IOChan.ChanId);
  (* Attempts to make a new channel for the device module identified by did. If no more
     channels can be made, the identity of the invalid channel is assigned to cid.
     Otherwise, the identity of a new channel is assigned to cid.
  *)

PROCEDURE UnMakeChan (did: DeviceId; VAR cid: IOChan.ChanId);
  (* If the device module identified by did is not the module that made the channel
     identified by cid, the exception wrongDevice is raised; otherwise the channel is
     deallocated, and the value identifying the invalid channel is assigned to cid.
  *)

TYPE
  DeviceTablePtr = POINTER TO DeviceTable;
    (* Values of this type are used to refer to device tables *)

TYPE
  LookProc =      PROCEDURE (DeviceTablePtr, VAR CHAR, VAR IOConsts.ReadResults);
  SkipProc =      PROCEDURE (DeviceTablePtr);
  SkipLookProc =  PROCEDURE (DeviceTablePtr, VAR CHAR, VAR IOConsts.ReadResults);
  WriteLnProc =   PROCEDURE (DeviceTablePtr);
  TextReadProc =  PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL, VAR CARDINAL);
  TextWriteProc = PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL);
  RawReadProc =   PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL, VAR CARDINAL);
  RawWriteProc =  PROCEDURE (DeviceTablePtr, SYSTEM.ADDRESS, CARDINAL);
  GetNameProc =   PROCEDURE (DeviceTablePtr, VAR ARRAY OF CHAR);
  ResetProc =     PROCEDURE (DeviceTablePtr);
  FlushProc =     PROCEDURE (DeviceTablePtr);
  FreeProc =      PROCEDURE (DeviceTablePtr);
      (* Carry out the operations involved in closing the corresponding channel, including
         flushing buffers, but do not unmake the channel.
      *)

TYPE
  DeviceData = SYSTEM.ADDRESS;

  DeviceTable =
    RECORD                         (* Initialized by MakeChan to: *)
      cd: DeviceData;              (* the value NIL *)
      did: DeviceId;               (* the value given in the call of MakeChan *)
      cid: IOChan.ChanId;          (* the identity of the channel *)
      result: IOConsts.ReadResults;(* the value notKnown *)
      errNum: IOChan.DeviceErrNum; (* undefined *)
      flags: ChanConsts.FlagSet;   (* ChanConsts.FlagSet{} *)
      doLook: LookProc;            (* raise exception notAvailable *)
      doSkip: SkipProc;            (* raise exception notAvailable *)
      doSkipLook: SkipLookProc;    (* raise exception notAvailable *)
      doLnWrite: WriteLnProc;      (* raise exception notAvailable *)
      doTextRead: TextReadProc;    (* raise exception notAvailable *)
      doTextWrite: TextWriteProc;  (* raise exception notAvailable *)
      doRawRead: RawReadProc;      (* raise exception notAvailable *)
      doRawWrite: RawWriteProc;    (* raise exception notAvailable *)
      doGetName: GetNameProc;      (* return the empty string *)
      doReset: ResetProc;          (* do nothing *)
      doFlush: FlushProc;          (* do nothing *)
      doFree: FreeProc;            (* do nothing *)
    END;


  (* The pointer to the device table for a channel is obtained using the
     following procedure: *)

PROCEDURE DeviceTablePtrValue (cid: IOChan.ChanId; did: DeviceId;
                               x: DevExceptionRange; s:  ARRAY OF CHAR): DeviceTablePtr;
  (* If the device module identified by did is not the module that made the channel
     identified by cid, the exception wrongDevice is raised; otherwise the given exception
     is raised, and the string value in s is included in the exception message.
  *)


PROCEDURE IsDevice (cid: IOChan.ChanId; did: DeviceId) : BOOLEAN;
  (* Tests if the device module identified by did is the module that made the channel
     identified by cid.
  *)


TYPE
  DevExceptionRange = [IOChan.notAvailable ..  IOChan.textParseError];

PROCEDURE RAISEdevException (cid: IOChan.ChanId; did: DeviceId;
                             x: DevExceptionRange; s: ARRAY OF CHAR);

  (* If the device module identified by did is not the module that made the channel
     identified by cid, the exception wrongDevice is raised; otherwise the given exception
     is raised, and the string value in s is included in the exception message.
  *)

PROCEDURE IsIOException () : BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising af an exception from ChanExceptions;
     otherwise FALSE.
  *)

PROCEDURE IOException () : IOChan.ChanExceptions;
  (* If the current coroutine is in the exceptional execution state because of the
     raising af an exception from ChanExceptions, returns the corresponding
     enumeration value, and otherwise raises an exception.
  *)

END IOLink.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.11 gm2-iso/IOResult

 
DEFINITION MODULE IOResult;

  (* Read results for specified channels *)

IMPORT IOConsts, IOChan;

TYPE
  ReadResults = IOConsts.ReadResults;

  (*
    ReadResults =  (* This type is used to classify the result of an input operation *)
    (
      notKnown,    (* no read result is set *)
      allRight,    (* data is as expected or as required *)
      outOfRange,  (* data cannot be represented *)
      wrongFormat, (* data not in expected format *)
      endOfLine,   (* end of line seen before expected data *)
      endOfInput   (* end of input seen before expected data *)
    );
  *)

PROCEDURE ReadResult (cid: IOChan.ChanId): ReadResults;
  (* Returns the result for the last read operation on the channel cid. *)

END IOResult.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.12 gm2-iso/LongComplex

 
DEFINITION MODULE LongComplexMath;

  (* Mathematical functions for the type LONGCOMPLEX *)

CONST
  i =    CMPLX (0.0, 1.0);
  one =  CMPLX (1.0, 0.0);
  zero = CMPLX (0.0, 0.0);

PROCEDURE abs (z: LONGCOMPLEX): LONGREAL;
  (* Returns the length of z *)

PROCEDURE arg (z: LONGCOMPLEX): LONGREAL;
  (* Returns the angle that z subtends to the positive real axis *)

PROCEDURE conj (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the complex conjugate of z *)

PROCEDURE power (base: LONGCOMPLEX; exponent: LONGREAL): LONGCOMPLEX;
  (* Returns the value of the number base raised to the power exponent *)

PROCEDURE sqrt (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the principal square root of z *)

PROCEDURE exp (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the complex exponential of z *)

PROCEDURE ln (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the principal value of the natural logarithm of z *)

PROCEDURE sin (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the sine of z *)

PROCEDURE cos (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the cosine of z *)

PROCEDURE tan (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the tangent of z *)

PROCEDURE arcsin (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the arcsine of z *)

PROCEDURE arccos (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the arccosine of z *)

PROCEDURE arctan (z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the arctangent of z *)

PROCEDURE polarToComplex (abs, arg: LONGREAL): LONGCOMPLEX;
  (* Returns the complex number with the specified polar coordinates *)

PROCEDURE scalarMult (scalar: LONGREAL; z: LONGCOMPLEX): LONGCOMPLEX;
  (* Returns the scalar product of scalar with z *)

PROCEDURE IsCMathException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception in a routine from this module; otherwise
     returns FALSE.
  *)

END LongComplexMath.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.13 gm2-iso/LongConv

 
DEFINITION MODULE LongConv;

  (* Low-level LONGREAL/string conversions *)

IMPORT
  ConvTypes;

TYPE
  ConvResults = ConvTypes.ConvResults; (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)

PROCEDURE ScanReal (inputCh: CHAR; VAR chClass: ConvTypes.ScanClass;
                    VAR nextState: ConvTypes.ScanState);
  (* Represents the start state of a finite state scanner for real numbers - assigns
     class of inputCh to chClass and a procedure representing the next state to
     nextState.
  *)

PROCEDURE FormatReal (str: ARRAY OF CHAR): ConvResults;
  (* Returns the format of the string value for conversion to LONGREAL. *)

PROCEDURE ValueReal (str: ARRAY OF CHAR): LONGREAL;
  (* Returns the value corresponding to the real number string value str if str is
     well-formed; otherwise raises the LongConv exception.
  *)

PROCEDURE LengthFloatReal (real: LONGREAL; sigFigs: CARDINAL): CARDINAL;
  (* Returns the number of characters in the floating-point string representation of
     real with sigFigs significant figures.
  *)

PROCEDURE LengthEngReal (real: LONGREAL; sigFigs: CARDINAL): CARDINAL;
  (* Returns the number of characters in the floating-point engineering string
     representation of real with sigFigs significant figures.
  *)

PROCEDURE LengthFixedReal (real: LONGREAL; place: INTEGER): CARDINAL;
  (* Returns the number of characters in the fixed-point string representation of real
     rounded to the given place relative to the decimal point.
  *)

PROCEDURE IsRConvException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state because
     of the raising of an exception in a routine from this module; otherwise returns
     FALSE.
  *)

END LongConv.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.14 gm2-iso/LongIO

 
DEFINITION MODULE LongIO;

  (* Input and output of long real numbers in decimal text form over specified channels.
     The read result is of the type IOConsts.ReadResults.
  *)

IMPORT IOChan;

  (* The text form of a signed fixed-point real number is
       ["+" | "-"], decimal digit, {decimal digit}, [".", {decimal digit}]

     The text form of a signed floating-point real number is
       signed fixed-point real number,
       "E", ["+" | "-"], decimal digit, {decimal digit}
  *)

PROCEDURE ReadReal (cid: IOChan.ChanId; VAR real: LONGREAL);
  (* Skips leading spaces, and removes any remaining characters from cid that form part of a
     signed fixed or floating point number.  The value of this number is assigned to real.
     The read result is set to the value allRight, outOfRange, wrongFormat, endOfLine, or
     endOfInput.
  *)

PROCEDURE WriteFloat (cid: IOChan.ChanId; real: LONGREAL; sigFigs: CARDINAL; width: CARDINAL);
  (* Writes the value of real to cid in floating-point text form, with sigFigs significant
     figures, in a field of the given minimum width.
  *)

PROCEDURE WriteEng (cid: IOChan.ChanId; real: LONGREAL; sigFigs: CARDINAL; width: CARDINAL);
  (* As for WriteFloat, except that the number is scaled with one to three digits in the
     whole number part, and with an exponent that is a multiple of three.
  *)

PROCEDURE WriteFixed (cid: IOChan.ChanId; real: LONGREAL; place: INTEGER; width: CARDINAL);
  (* Writes the value of real to cid in fixed-point text form, rounded to the given place
     relative to the decimal point, in a field of the given minimum width.
  *)

PROCEDURE WriteReal (cid: IOChan.ChanId; real: LONGREAL; width: CARDINAL);
  (* Writes the value of real to cid, as WriteFixed if the sign and magnitude can be shown
     in the given width, or otherwise as WriteFloat.  The number of places or significant
     digits depends on the given width.
  *)

END LongIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.15 gm2-iso/LongMath

 
DEFINITION MODULE LongMath;

  (* Mathematical functions for the type LONGREAL *)

CONST
  pi   = 3.1415926535897932384626433832795028841972;
  exp1 = 2.7182818284590452353602874713526624977572;

PROCEDURE __BUILTIN__ sqrt (x: LONGREAL): LONGREAL;
  (* Returns the positive square root of x *)

PROCEDURE exp (x: LONGREAL): LONGREAL;
  (* Returns the exponential of x *)

PROCEDURE ln (x: LONGREAL): LONGREAL;
  (* Returns the natural logarithm of x *)

  (* The angle in all trigonometric functions is measured in radians *)

PROCEDURE __BUILTIN__ sin (x: LONGREAL): LONGREAL;
  (* Returns the sine of x *)

PROCEDURE __BUILTIN__ cos (x: LONGREAL): LONGREAL;
  (* Returns the cosine of x *)

PROCEDURE tan (x: LONGREAL): LONGREAL;
  (* Returns the tangent of x *)

PROCEDURE arcsin (x: LONGREAL): LONGREAL;
  (* Returns the arcsine of x *)

PROCEDURE arccos (x: LONGREAL): LONGREAL;
  (* Returns the arccosine of x *)

PROCEDURE arctan (x: LONGREAL): LONGREAL;
  (* Returns the arctangent of x *)

PROCEDURE power (base, exponent: LONGREAL): LONGREAL;
  (* Returns the value of the number base raised to the power exponent *)

PROCEDURE round (x: LONGREAL): INTEGER;
  (* Returns the value of x rounded to the nearest integer *)

PROCEDURE IsRMathException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception in a routine from this module; otherwise
     returns FALSE.
  *)

END LongMath.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.16 gm2-iso/LongStr

 
DEFINITION MODULE LongStr;

  (* LONGREAL/string conversions *)

IMPORT
  ConvTypes;

TYPE
  ConvResults = ConvTypes.ConvResults; (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)

(* the string form of a signed fixed-point real number is
     ["+" | "-"], decimal digit, {decimal digit}, [".", {decimal digit}]
*)

(* the string form of a signed floating-point real number is
     signed fixed-point real number, "E", ["+" | "-"], decimal digit, {decimal digit}
*)

PROCEDURE StrToReal (str: ARRAY OF CHAR; VAR real: LONGREAL; VAR res: ConvResults);
  (* Ignores any leading spaces in str. If the subsequent characters in str are in the
     format of a signed real number, assigns a corresponding value to real.
     Assigns a value indicating the format of str to res.
  *)

PROCEDURE RealToFloat (real: LONGREAL; sigFigs: CARDINAL; VAR str: ARRAY OF CHAR);
  (* Converts the value of real to floating-point string form, with sigFigs significant
     figures, and copies the possibly truncated result to str.
  *)

PROCEDURE RealToEng (real: LONGREAL; sigFigs: CARDINAL; VAR str: ARRAY OF CHAR);
  (* Converts the value of real to floating-point string form, with sigFigs significant
     figures, and copies the possibly truncated result to str. The number is scaled with
     one to three digits in the whole number part and with an exponent that is a
     multiple of three.
  *)

PROCEDURE RealToFixed (real: LONGREAL; place: INTEGER; VAR str: ARRAY OF CHAR);
  (* Converts the value of real to fixed-point string form, rounded to the given place
     relative to the decimal point, and copies the possibly truncated result to str.
  *)

PROCEDURE RealToStr (real: LONGREAL; VAR str: ARRAY OF CHAR);
  (* Converts the value of real as RealToFixed if the sign and magnitude can be shown
     within the capacity of str, or otherwise as RealToFloat, and copies the possibly
     truncated result to str. The number of places or significant digits depend on the
     capacity of str.
  *)

END LongStr.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.17 gm2-iso/LowLong

 
DEFINITION MODULE LowLong;

  (* Access to underlying properties of the type LONGREAL *)

CONST
  radix =      <implementation-defined whole number value>;
  places =     <implementation-defined whole number value>;
  expoMin =    <implementation-defined whole number value>;
  expoMax =    <implementation-defined whole number value>;
  large =      <implementation-defined real number value>;
  small =      <implementation-defined real number value>;
  IEEE =       <implementation-defined BOOLEAN value>;
  ISO =        <implementation-defined BOOLEAN value>;
  rounds =     <implementation-defined BOOLEAN value>;
  gUnderflow = <implementation-defined BOOLEAN value>;
  exception =  <implementation-defined BOOLEAN value>;
  extend =     <implementation-defined BOOLEAN value>;
  nModes =     <implementation-defined whole number value>;

TYPE
  Modes = PACKEDSET OF [0 .. nModes-1];

PROCEDURE exponent (x: LONGREAL): INTEGER;
  (* Returns the exponent value of x *)

PROCEDURE fraction (x: LONGREAL): LONGREAL;
  (* Returns the significand (or significant part) of x *)

PROCEDURE sign (x: LONGREAL): LONGREAL;
  (* Returns the signum of x *)

PROCEDURE succ (x: LONGREAL): LONGREAL;
  (* Returns the next value of the type LONGREAL greater than x *)

PROCEDURE ulp (x: LONGREAL): LONGREAL;
  (* Returns the value of a unit in the last place of x *)

PROCEDURE pred (x: LONGREAL): LONGREAL;
  (* Returns the previous value of the type LONGREAL less than x *)

PROCEDURE intpart (x: LONGREAL): LONGREAL;
  (* Returns the integer part of x *)

PROCEDURE fractpart (x: LONGREAL): LONGREAL;
  (* Returns the fractional part of x *)

PROCEDURE scale (x: LONGREAL; n: INTEGER): LONGREAL;
  (* Returns the value of x * radix ** n *)

PROCEDURE trunc (x: LONGREAL; n: INTEGER): LONGREAL;
  (* Returns the value of the first n places of x *)

PROCEDURE round (x: LONGREAL; n: INTEGER): LONGREAL;
  (* Returns the value of x rounded to the first n places *)

PROCEDURE synthesize (expart: INTEGER; frapart: LONGREAL): LONGREAL;
  (* Returns a value of the type LONGREAL constructed from the given expart and frapart *)

PROCEDURE setMode (m: Modes);
  (* Sets status flags appropriate to the underlying implementation of the type LONGREAL *)

PROCEDURE currentMode (): Modes;
  (* Returns the current status flags in the form set by setMode *)

PROCEDURE IsLowException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception in a routine from this module; otherwise
     returns FALSE.
  *)

END LowLong.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.18 gm2-iso/LowReal

 
DEFINITION MODULE LowReal;

  (* Access to underlying properties of the type REAL *)

CONST
  radix =      <implementation-defined whole number value>;
  places =     <implementation-defined whole number value>;
  expoMin =    <implementation-defined whole number value>;
  expoMax =    <implementation-defined whole number value>;
  large =      <implementation-defined real number value>;
  small =      <implementation-defined real number value>;
  IEEE =       <implementation-defined BOOLEAN value>;
  ISO =        <implementation-defined BOOLEAN value>;
  rounds =     <implementation-defined BOOLEAN value>;
  gUnderflow = <implementation-defined BOOLEAN value>;
  exception =  <implementation-defined BOOLEAN value>;
  extend =     <implementation-defined BOOLEAN value>;
  nModes =     <implementation-defined whole number value>;

TYPE
  Modes = SET OF [0 .. nModes-1];

PROCEDURE exponent (x: REAL): INTEGER;
  (* Returns the exponent value of x *)

PROCEDURE fraction (x: REAL): REAL;
  (* Returns the significand (or significant part) of x *)

PROCEDURE sign (x: REAL): REAL;
  (* Returns the signum of x *)

PROCEDURE succ (x: REAL): REAL;
  (* Returns the next value of the type REAL greater than x *)

PROCEDURE ulp (x: REAL): REAL;
  (* Returns the value of a unit in the last place of x *)

PROCEDURE pred (x: REAL): REAL;
  (* Returns the previous value of the type REAL less than x *)

PROCEDURE intpart (x: REAL): REAL;
  (* Returns the integer part of x *)

PROCEDURE fractpart (x: REAL): REAL;
  (* Returns the fractional part of x *)

PROCEDURE scale (x: REAL; n: INTEGER): REAL;
  (* Returns the value of x * radix ** n *)

PROCEDURE trunc (x: REAL; n: INTEGER): REAL;
  (* Returns the value of the first n places of x *)

PROCEDURE round (x: REAL; n: INTEGER): REAL;
  (* Returns the value of x rounded to the first n places *)

PROCEDURE synthesize (expart: INTEGER; frapart: REAL): REAL;
  (* Returns a value of the type REAL constructed from the given expart and frapart *)

PROCEDURE setMode (m: Modes);
  (* Sets status flags appropriate to the underlying implementation of the type REAL *)

PROCEDURE currentMode (): Modes;
  (* Returns the current status flags in the form set by setMode *)

PROCEDURE IsLowException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception in a routine from this module; otherwise
     returns FALSE.
  *)

END LowReal.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.19 gm2-iso/M2EXCEPTION

 
DEFINITION MODULE M2EXCEPTION;

(* Provides facilities for identifying language exceptions *)

TYPE
  M2Exceptions =
    (indexException,     rangeException,         caseSelectException,  invalidLocation,
     functionException,  wholeValueException,    wholeDivException,    realValueException,
     realDivException,   complexValueException,  complexDivException,  protException,
     sysException,       coException,            exException
    );

PROCEDURE M2Exception (): M2Exceptions;
  (* If the current coroutine is in the exceptional execution state because of the raising
     of a language exception, returns the corresponding enumeration value, and otherwise
     raises an exception.
  *)

PROCEDURE IsM2Exception (): BOOLEAN;
  (* If the current coroutine is in the exceptional execution state because of the raising
     of a language exception, returns TRUE, and otherwise returns FALSE.
  *)

END M2EXCEPTION.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.20 gm2-iso/M2RTS

 
DEFINITION MODULE M2RTS ;

(*
   Description: Implements the run time system facilities of Modula-2.
*)

FROM SYSTEM IMPORT BITSET ;
EXPORT QUALIFIED HALT, Halt,
                 SubrangeAssignmentError, ArraySubscriptError,
                 FunctionReturnError, NilPointerError,
                 CaseElseError,
                 InstallTerminationProcedure, Terminate,
                 ExitOnHalt, Length ;


(*
   HALT - terminate the current program.
          The procedure Terminate is called before the program is
          stopped.
*)

PROCEDURE HALT ;


(*
   Halt - provides a more user friendly version of HALT, which takes
          four parameters to aid debugging.
*)

PROCEDURE Halt (file: ARRAY OF CHAR; line: CARDINAL;
                function: ARRAY OF CHAR; description: ARRAY OF CHAR) ;


(*
   SubrangeAssignmentError - part of the runtime checking, called if a
                             subrange variable is just about to be assigned an illegal value.
*)

PROCEDURE SubrangeAssignmentError (file: ARRAY OF CHAR;
                                   line: CARDINAL;
                                   function: ARRAY OF CHAR) ;


(*
   ArraySubscriptError -  part of the runtime checking, called if an
                          array indice is out of range.
*)

PROCEDURE ArraySubscriptError (file: ARRAY OF CHAR;
                               line: CARDINAL;
                               function: ARRAY OF CHAR) ;


(*
   FunctionReturnError -  part of the runtime checking, called if a
                          function exits without a RETURN statement.
*)

PROCEDURE FunctionReturnError (file: ARRAY OF CHAR;
                               line: CARDINAL;
                               function: ARRAY OF CHAR) ;


(*
   NilPointerError -  part of the runtime checking, called if a
                      the code is about to dereference NIL.
*)

PROCEDURE NilPointerError (file: ARRAY OF CHAR;
                           line: CARDINAL;
                           function: ARRAY OF CHAR) ;


(*
   CaseElseError - part of the runtime checking, called if a
                   CASE statement falls into an ELSE statement
                   (which was not declared by the programmer).
*)

PROCEDURE CaseElseError (file: ARRAY OF CHAR;
                         line: CARDINAL;
                         function: ARRAY OF CHAR) ;


(*
   ExitOnHalt - if HALT is executed then call exit with the exit code, e.
*)

PROCEDURE ExitOnHalt (e: INTEGER) ;


(*
   InstallTerminationProcedure - installs a procedure, p, which will
                                 be called when the procedure Terminate
                                 is ionvoked.
*)

PROCEDURE InstallTerminationProcedure (p: PROC) ;


(*
   Terminate - calls each installed termination procedure in turn.
*)

PROCEDURE Terminate ;


(*
   Length - returns the length of a string, a. This is called whenever
            the user calls LENGTH and the parameter cannot be calculated
            at compile time.
*)

PROCEDURE Length (a: ARRAY OF CHAR) : CARDINAL ;


END M2RTS.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.21 gm2-iso/Processes

 
DEFINITION MODULE Processes;

  (* This module allows concurrent algorithms to be expressed using processes. A process is
     a unit of a program that has the potential to run in parallel with other processes.
  *)

IMPORT SYSTEM;

TYPE
  ProcessId;                      (* Used to identify processes *)
  Parameter     = SYSTEM.ADDRESS; (* Used to pass data between processes *)
  Body          = PROC;           (* Used as the type of a process body *)
  Urgency       = INTEGER;        (* Used by the internal scheduler *)
  Sources       = CARDINAL;       (* Used to identify event sources *)
  ProcessesExceptions =           (* Exceptions raised by this module *)
    (passiveProgram, processError);

(* The following procedures create processes and switch control between them. *)

PROCEDURE Create (procBody: Body; extraSpace: CARDINAL; procUrg: Urgency;
                  procParams: Parameter; VAR procId: ProcessId);
  (* Creates a new process with procBody as its body, and with urgency and parameters
     given by procUrg and procParams.  At least as much workspace (in units of
     SYSTEM.LOC) as is specified by extraSpace is allocated to the process.
     An identity for the new process is returned in procId.
     The process is created in the passive state; it will not run until activated.
  *)

PROCEDURE Start (procBody: Body; extraSpace: CARDINAL; procUrg: Urgency;
                 procParams: Parameter; VAR procId: ProcessId);
  (* Creates a new process, with parameters as for Create.
     The process is created in the ready state; it is eligible to run immediately.
  *)

PROCEDURE StopMe ();
  (* Terminates the calling process.
     The process must not be associated with a source of events.
  *)

PROCEDURE SuspendMe ();
  (* Causes the calling process to enter the passive state.  The procedure only returns
     when the calling process is again activated by another process.
  *)

PROCEDURE Activate (procId: ProcessId);
  (* Causes the process identified by procId to enter the ready state, and thus to become
     eligible to run again.
  *)

PROCEDURE SuspendMeAndActivate (procId: ProcessId);
  (* Executes an atomic sequence of SuspendMe() and Activate(procId). *)

PROCEDURE Switch (procId: ProcessId; VAR info: Parameter);
  (* Causes the calling process to enter the passive state; the process identified by procId
     becomes the currently executing process.
     info is used to pass parameter information from the calling to the activated process.
     On return, info will contain information from the process that chooses to switch back to
     this one (or will be NIL if Activate or SuspendMeAndActivate are used instead of
     Switch).
  *)

PROCEDURE Wait ();
  (* Causes the calling process to enter the waiting state.  The procedure will return when
     the calling process is activated by another process, or when one of its associated
     eventSources has generated an event.
  *)

(* The following procedures allow the association of processes with sources of external
   events.
*)

PROCEDURE Attach (eventSource: Sources);
  (* Associates the specified eventSource with the calling process. *)

PROCEDURE Detach (eventSource: Sources);
  (* Dissociates the specified eventSource from the program. *)

PROCEDURE IsAttached (eventSource: Sources): BOOLEAN;
  (* Returns TRUE if and only if the specified eventSource is currently associated with
     one of the processes of the program.
  *)

PROCEDURE Handler (eventSource: Sources): ProcessId;
  (* Returns the identity of the process, if any, that is associated with the specified
     eventSource.
  *)

(* The following procedures allow processes to obtain their identity, parameters, and
   urgency.
*)

PROCEDURE Me (): ProcessId;
  (* Returns the identity of the calling process (as assigned when the process was first
     created).
  *)

PROCEDURE MyParam (): Parameter;
  (* Returns the value specified as procParams when the calling process was created. *)

PROCEDURE UrgencyOf (procId: ProcessId): Urgency;
  (* Returns the urgency established when the process identified by procId was first
     created.
  *)

(* The following procedure provides facilities for exception handlers. *)

PROCEDURE ProcessesException (): ProcessesExceptions;
  (* If the current coroutine is in the exceptional execution state because of the raising
     of a language exception, returns the corresponding enumeration value, and
     otherwise raises an exception.
  *)

PROCEDURE IsProcessesException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception in a routine from this module; otherwise
     returns FALSE.
  *)

END Processes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.22 gm2-iso/ProgramArgs

 
DEFINITION MODULE ProgramArgs;

  (* Access to program arguments *)

IMPORT IOChan;

TYPE
  ChanId = IOChan.ChanId;

PROCEDURE ArgChan (): ChanId;
  (* Returns a value that identifies a channel for reading program arguments *)

PROCEDURE IsArgPresent (): BOOLEAN;
  (* Tests if there is a current argument to read from. If not, read <=
     IOChan.CurrentFlags() will be FALSE, and attempting to read from the argument channel
     will raise the exception notAvailable.
  *)

PROCEDURE NextArg ();
  (* If there is another argument, causes subsequent input from the argument device to come
     from the start of the next argument.  Otherwise there is no argument to read from, and
     a call of IsArgPresent will return FALSE.
  *)

END ProgramArgs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.23 gm2-iso/RawIO

 
DEFINITION MODULE RawIO;

  (* Reading and writing data over specified channels using raw operations, that is, with no
     conversion or interpretation. The read result is of the type IOConsts.ReadResults.
  *)

IMPORT IOChan, SYSTEM;

PROCEDURE Read (cid: IOChan.ChanId; VAR to: ARRAY OF SYSTEM.LOC);
  (* Reads storage units from cid, and assigns them to successive components of to. The read
     result is set to the value allRight, wrongFormat, or endOfInput.
  *)

PROCEDURE Write (cid: IOChan.ChanId; from: ARRAY OF SYSTEM.LOC);
  (* Writes storage units to cid from successive components of from. *)

END RawIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.24 gm2-iso/RealConv

 
DEFINITION MODULE RealConv;

  (* Low-level REAL/string conversions *)

IMPORT
  ConvTypes;

TYPE
  ConvResults = ConvTypes.ConvResults; (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)

PROCEDURE ScanReal (inputCh: CHAR; VAR chClass: ConvTypes.ScanClass;
                    VAR nextState: ConvTypes.ScanState);
  (* Represents the start state of a finite state scanner for real numbers - assigns
     class of inputCh to chClass and a procedure representing the next state to
     nextState.
   *)

PROCEDURE FormatReal (str: ARRAY OF CHAR): ConvResults;
  (* Returns the format of the string value for conversion to REAL. *)

PROCEDURE ValueReal (str: ARRAY OF CHAR): REAL;
  (* Returns the value corresponding to the real number string value str if str is
     well-formed; otherwise raises the RealConv exception.
  *)

PROCEDURE LengthFloatReal (real: REAL; sigFigs: CARDINAL): CARDINAL;
  (* Returns the number of characters in the floating-point string representation of
     real with sigFigs significant figures.
  *)

PROCEDURE LengthEngReal (real: REAL; sigFigs: CARDINAL): CARDINAL;
  (* Returns the number of characters in the floating-point engineering string
     representation of real with sigFigs significant figures.
  *)

PROCEDURE LengthFixedReal (real: REAL; place: INTEGER): CARDINAL;
  (* Returns the number of characters in the fixed-point string representation of real
     rounded to the given place relative to the decimal point.
  *)

PROCEDURE IsRConvException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state because
     of the raising of an exception in a routine from this module; otherwise returns
     FALSE.
  *)

END RealConv.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.25 gm2-iso/RealIO

 
DEFINITION MODULE RealIO;

  (* Input and output of real numbers in decimal text form over specified channels.
     The read result is of the type IOConsts.ReadResults.
  *)

IMPORT IOChan;

  (* The text form of a signed fixed-point real number is
       ["+" | "-"], decimal digit, {decimal digit},
       [".", {decimal digit}]

     The text form of a signed floating-point real number is
       signed fixed-point real number,
       "E", ["+" | "-"], decimal digit, {decimal digit}
  *)

PROCEDURE ReadReal (cid: IOChan.ChanId; VAR real: REAL);
  (* Skips leading spaces, and removes any remaining characters from cid that form part of a
     signed fixed or floating point number.  The value of this number is assigned to real.
     The read result is set to the value allRight, outOfRange, wrongFormat, endOfLine, or
     endOfInput.
  *)

PROCEDURE WriteFloat (cid: IOChan.ChanId; real: REAL; sigFigs: CARDINAL; width:
CARDINAL);
  (* Writes the value of real to cid in floating-point text form, with sigFigs significant
     figures, in a field of the given minimum width.
  *)

PROCEDURE WriteEng (cid: IOChan.ChanId; real: REAL; sigFigs: CARDINAL; width: CARDINAL);
  (* As for WriteFloat, except that the number is scaled with one to three digits in the
     whole number part, and with an exponent that is a multiple of three.
  *)

PROCEDURE WriteFixed (cid: IOChan.ChanId; real: REAL; place: INTEGER; width: CARDINAL);
  (* Writes the value of real to cid in fixed-point text form, rounded to the given place
     relative to the decimal point, in a field of the given minimum width.
  *)

PROCEDURE WriteReal (cid: IOChan.ChanId; real: REAL; width: CARDINAL);
  (* Writes the value of real to cid, as WriteFixed if the sign and magnitude can be shown
     in the given width, or otherwise as WriteFloat.  The number of places or significant
     digits depends on the given width.
  *)

END RealIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.26 gm2-iso/RealMath

 
DEFINITION MODULE RealMath;

  (* Mathematical functions for the type REAL *)

CONST
  pi   = 3.1415926535897932384626433832795028841972;
  exp1 = 2.7182818284590452353602874713526624977572;

PROCEDURE __BUILTIN__ sqrt (x: REAL): REAL;
  (* Returns the positive square root of x *)

PROCEDURE exp (x: REAL): REAL;
  (* Returns the exponential of x *)

PROCEDURE ln (x: REAL): REAL;
  (* Returns the natural logarithm of x *)

  (* The angle in all trigonometric functions is measured in radians *)

PROCEDURE __BUILTIN__ sin (x: REAL): REAL;
  (* Returns the sine of x *)

PROCEDURE __BUILTIN__ cos (x: REAL): REAL;
  (* Returns the cosine of x *)

PROCEDURE tan (x: REAL): REAL;
  (* Returns the tangent of x *)

PROCEDURE arcsin (x: REAL): REAL;
  (* Returns the arcsine of x *)

PROCEDURE arccos (x: REAL): REAL;
  (* Returns the arccosine of x *)

PROCEDURE arctan (x: REAL): REAL;
  (* Returns the arctangent of x *)

PROCEDURE power (base, exponent: REAL): REAL;
  (* Returns the value of the number base raised to the power exponent *)

PROCEDURE round (x: REAL): INTEGER;
  (* Returns the value of x rounded to the nearest integer *)

PROCEDURE IsRMathException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception in a routine from this module; otherwise
     returns FALSE.
  *)

END RealMath.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.27 gm2-iso/RealStr

 
DEFINITION MODULE RealStr;

  (* REAL/string conversions *)

IMPORT
  ConvTypes;

TYPE
  ConvResults = ConvTypes.ConvResults; (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)

(* the string form of a signed fixed-point real number is
     ["+" | "-"], decimal digit, {decimal digit}, [".", {decimal digit}]
*)

(* the string form of a signed floating-point real number is
     signed fixed-point real number, "E", ["+" | "-"], decimal digit, {decimal digit}
*)

PROCEDURE StrToReal (str: ARRAY OF CHAR; VAR real: REAL; VAR res: ConvResults);
  (* Ignores any leading spaces in str. If the subsequent characters in str are in the
     format of a signed real number, assigns a corresponding value to real.
     Assigns a value indicating the format of str to res.
  *)

PROCEDURE RealToFloat (real: REAL; sigFigs: CARDINAL; VAR str: ARRAY OF CHAR);
  (* Converts the value of real to floating-point string form, with sigFigs significant
     figures, and copies the possibly truncated result to str.
  *)

PROCEDURE RealToEng (real: REAL; sigFigs: CARDINAL; VAR str: ARRAY OF CHAR);
  (* Converts the value of real to floating-point string form, with sigFigs significant
     figures, and copies the possibly truncated result to str. The number is scaled with
     one to three digits in the whole number part and with an exponent that is a
     multiple of three.
  *)

PROCEDURE RealToFixed (real: REAL; place: INTEGER; VAR str: ARRAY OF CHAR);
  (* Converts the value of real to fixed-point string form, rounded to the given place
     relative to the decimal point, and copies the possibly truncated result to str.
  *)

PROCEDURE RealToStr (real: REAL; VAR str: ARRAY OF CHAR);
  (* Converts the value of real as RealToFixed if the sign and magnitude can be shown
     within the capacity of str, or otherwise as RealToFloat, and copies the possibly
     truncated result to str. The number of places or significant digits are
     implementation-defined.
  *)

END RealStr.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.28 gm2-iso/RndFile

 
DEFINITION MODULE RndFile;

  (* Random access files *)

IMPORT IOChan, ChanConsts, SYSTEM;

TYPE
  ChanId = IOChan.ChanId;
  FlagSet = ChanConsts.FlagSet;
  OpenResults = ChanConsts.OpenResults;

  (* Accepted singleton values of FlagSet *)

CONST
  read = FlagSet{ChanConsts.readFlag};   (* input operations are requested/available *)
  write = FlagSet{ChanConsts.writeFlag}; (* output operations are requested/available *)
  old = FlagSet{ChanConsts.oldFlag};     (* a file may/must/did exist before the channel is
                                            opened *)
  text = FlagSet{ChanConsts.textFlag};   (* text operations are requested/available *)
  raw = FlagSet{ChanConsts.rawFlag};     (* raw operations are requested/available *)

PROCEDURE OpenOld (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                   VAR res: OpenResults);
  (* Attempts to obtain and open a channel connected to a stored random access file of the
     given name.
     The old flag is implied; without the write flag, read is implied; without the text
     flag, raw is implied.
     If successful, assigns to cid the identity of the opened channel, assigns the value
     opened to res, and sets the read/write position to the start of the file.
     If a channel cannot be opened as required, the value of res indicates the reason, and
     cid identifies the invalid channel.
  *)

PROCEDURE OpenClean (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                     VAR res: OpenResults);
  (* Attempts to obtain and open a channel connected to a stored random access file of the
     given name.
     The write flag is implied; without the text flag, raw is implied.
     If successful, assigns to cid the identity of the opened channel, assigns the value
     opened to res, and truncates the file to zero length.
     If a channel cannot be opened as required, the value of res indicates the reason, and
     cid identifies the invalid channel.
  *)

PROCEDURE IsRndFile (cid: ChanId): BOOLEAN;
  (* Tests if the channel identified by cid is open to a random access file. *)

PROCEDURE IsRndFileException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state because
     of the raising of a RndFile exception; otherwise returns FALSE.
  *)

CONST
  FilePosSize = <implementation-defined whole number greater than zero>;

TYPE
  FilePos = ARRAY [1 .. FilePosSize] OF SYSTEM.LOC;

PROCEDURE StartPos (cid: ChanId): FilePos;
  (* If the channel identified by cid is not open to a random access file, the exception
     wrongDevice is raised; otherwise returns the position of the start of the file.
  *)

PROCEDURE CurrentPos (cid: ChanId): FilePos;
  (* If the channel identified by cid is not open to a random access file, the exception
     wrongDevice is raised; otherwise returns the position of the current read/write
     position.
  *)

PROCEDURE EndPos (cid: ChanId): FilePos;
  (* If the channel identified by cid is not open to a random access file, the exception
     wrongDevice is raised; otherwise returns the first position after which there have been
     no writes.
  *)

PROCEDURE NewPos (cid: ChanId; chunks: INTEGER; chunkSize: CARDINAL; from: FilePos): FilePos;
  (* If the channel identified by cid is not open to a random access file, the exception
     wrongDevice is raised; otherwise returns the position (chunks * chunkSize) relative to
     the position given by from, or raises the exception posRange if the required position
     cannot be represented as a value of type FilePos.
  *)

PROCEDURE SetPos (cid: ChanId; pos: FilePos);
  (* If the channel identified by cid is not open to a random access file, the exception
     wrongDevice is raised; otherwise sets the read/write position to the value given by
     pos.
  *)

PROCEDURE Close (VAR cid: ChanId);
  (* If the channel identified by cid is not open to a random access file, the exception
     wrongDevice is raised; otherwise closes the channel, and assigns the value identifying
     the invalid channel to cid.
  *)

END RndFile.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.29 gm2-iso/SIOResult

 
DEFINITION MODULE SIOResult;

  (* Read results for the default input channel *)

IMPORT IOConsts;

TYPE
  ReadResults = IOConsts.ReadResults;

  (*
    ReadResults =   (* This type is used to classify the result of an input operation *)
    (
      notKnown,     (* no read result is set *)
      allRight,     (* data is as expected or as required *)
      outOfRange,   (* data cannot be represented *)
      wrongFormat,  (* data not in expected format *)
      endOfLine,    (* end of line seen before expected data *)
      endOfInput    (* end of input seen before expected data *)
    );
  *)

PROCEDURE ReadResult (): ReadResults;
  (* Returns the result for the last read operation on the default input channel. *)

END SIOResult.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.30 gm2-iso/SLongIO

 
DEFINITION MODULE SLongIO;

  (* Input and output of long real numbers in decimal text form using default channels.  The
     read result is of the type IOConsts.ReadResults.
  *)

  (* The text form of a signed fixed-point real number is
       ["+" | "-"], decimal digit, {decimal digit},
       [".", {decimal digit}]

     The text form of a signed floating-point real number is
       signed fixed-point real number,
       "E", ["+" | "-"], decimal digit, {decimal digit}
  *)

PROCEDURE ReadReal (VAR real: LONGREAL);
  (* Skips leading spaces, and removes any remaining characters from the default input
     channel that form part of a signed fixed or floating point number. The value of this
     number is assigned to real.  The read result is set to the value allRight, outOfRange,
     wrongFormat, endOfLine, or endOfInput.
  *)

PROCEDURE WriteFloat (real: LONGREAL; sigFigs: CARDINAL; width: CARDINAL);
  (* Writes the value of real to the default output channel in floating-point text form,
     with sigFigs significant figures, in a field of the given minimum width.
  *)

PROCEDURE WriteEng (real: LONGREAL; sigFigs: CARDINAL; width: CARDINAL);
  (* As for WriteFloat, except that the number is scaled with one to three digits in the
     whole number part, and with an exponent that is a multiple of three.
  *)

PROCEDURE WriteFixed (real: LONGREAL; place: INTEGER; width: CARDINAL);
  (* Writes the value of real to the default output channel in fixed-point text form,
     rounded to the given place relative to the decimal point, in a field of the given
     minimum width.
  *)

PROCEDURE WriteReal (real: LONGREAL; width: CARDINAL);
  (* Writes the value of real to the default output channel, as WriteFixed if the sign and
     magnitude can be shown in the given width, or otherwise as WriteFloat. The number of
     places or significant digits depends on the given width.
  *)

END SLongIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.31 gm2-iso/SRawIO

 
DEFINITION MODULE SRawIO;

  (* Reading and writing data over default channels using raw operations, that is, with no
     conversion or interpretation. The read result is of the type IOConsts.ReadResults.
  *)

IMPORT SYSTEM;

PROCEDURE Read (VAR to: ARRAY OF SYSTEM.LOC);
  (* Reads storage units from the default input channel, and assigns them to successive
     components of to.  The read result is set to the value allRight, wrongFormat, or
     endOfInput.
  *)

PROCEDURE Write (from: ARRAY OF SYSTEM.LOC);
  (* Writes storage units to the default output channel from successive components of from.
  *)

END SRawIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.32 gm2-iso/SRealIO

 
DEFINITION MODULE SRealIO;

  (* Input and output of real numbers in decimal text form over default
     channels.  The read result is of the type IOConsts.ReadResults.
  *)

  (* The text form of a signed fixed-point real number is
       ["+" | "-"], decimal digit, {decimal digit},
       [".", {decimal digit}]

     The text form of a signed floating-point real number is
       signed fixed-point real number,
       "E", ["+" | "-"], decimal digit, {decimal digit}
  *)

PROCEDURE ReadReal (VAR real: REAL);
  (* Skips leading spaces, and removes any remaining characters from the default input
     channel that form part of a signed fixed or floating point number. The value of this
     number is assigned to real.  The read result is set to the value allRight, outOfRange,
     wrongFormat, endOfLine, or endOfInput.
  *)

PROCEDURE WriteFloat (real: REAL; sigFigs: CARDINAL; width: CARDINAL);
  (* Writes the value of real to the default output channel in floating-point text form,
     with sigFigs significant figures, in a field of the given minimum width.
  *)

PROCEDURE WriteEng (real: REAL; sigFigs: CARDINAL; width: CARDINAL);
  (* As for WriteFloat, except that the number is scaled with one to three digits in the
     whole number part, and with an exponent that is a multiple of three.
  *)

PROCEDURE WriteFixed (real: REAL; place: INTEGER; width: CARDINAL);
  (* Writes the value of real to the default output channel in fixed-point text form,
     rounded to the given place relative to the decimal point, in a field of the given
     minimum width.
  *)

PROCEDURE WriteReal (real: REAL; width: CARDINAL);
  (* Writes the value of real to the default output channel, as WriteFixed if the sign and
     magnitude can be shown in the given width, or otherwise as WriteFloat. The number of
     places or significant digits depends on the given width.
  *)

END SRealIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.33 gm2-iso/STextIO

 
DEFINITION MODULE STextIO;

  (* Input and output of character and string types over default channels. The read result
     is of the type IOConsts.ReadResults.
  *)

  (* The following procedures do not read past line marks *)

PROCEDURE ReadChar (VAR ch: CHAR);
  (* If possible, removes a character from the default input stream, and assigns the
     corresponding value to ch.  The read result is set to allRight, endOfLine or
     endOfInput.
  *)

PROCEDURE ReadRestLine (VAR s: ARRAY OF CHAR);
  (* Removes any remaining characters from the default input stream before the next line
     mark, copying to s as many as can be accommodated as a string value.  The read result
     is set to the value allRight, outOfRange, endOfLine, or endOfInput.
  *)

PROCEDURE ReadString (VAR s: ARRAY OF CHAR);
  (* Removes only those characters from the default input stream before the next line mark
     that can be accommodated in s as a string value, and copies them to s. The read result
     is set to the value allRight, endOfLine, or endOfInput.
  *)

PROCEDURE ReadToken (VAR s: ARRAY OF CHAR);
  (* Skips leading spaces, and then removes characters from the default input stream before
     the next space or line mark, copying to s as many as can be accommodated as a string
     value.  The read result is set to the value allRight, outOfRange, endOfLine, or
     endOfInput.
  *)

  (* The following procedure reads past the next line mark *)

PROCEDURE SkipLine;
  (* Removes successive items from the default input stream up to and including the next
     line mark or until the end of input is reached. The read result is set to the value
     allRight, or endOfInput.
  *)


  (* Output procedures *)

PROCEDURE WriteChar (ch: CHAR);
  (* Writes the value of ch to the default output stream. *)

PROCEDURE WriteLn;
  (* Writes a line mark to the default output stream. *)

PROCEDURE WriteString (s: ARRAY OF CHAR);
  (* Writes the string value of s to the default output stream. *)

END STextIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.34 gm2-iso/SWholeIO

 
DEFINITION MODULE SWholeIO;

  (* Input and output of whole numbers in decimal text form over default
     channels.  The read result is of the type IOConsts.ReadResults.
  *)

  (* The text form of a signed whole number is
       ["+" | "-"], decimal digit, {decimal digit}

     The text form of an unsigned whole number is
       decimal digit, {decimal digit}
  *)

PROCEDURE ReadInt (VAR int: INTEGER);
  (* Skips leading spaces, and removes any remaining characters from the default input
     channel that form part of a signed whole number.  The value of this number is assigned
     to int.  The read result is set to the value allRight, outOfRange, wrongFormat,
     endOfLine, or endOfInput.
  *)

PROCEDURE WriteInt (int: INTEGER; width: CARDINAL);
  (* Writes the value of int to the default output channel in text form, in a field of the
     given minimum width.
  *)

PROCEDURE ReadCard (VAR card: CARDINAL);
  (* Skips leading spaces, and removes any remaining characters from the default input
     channel that form part of an unsigned whole number.  The value of this number is
     assigned to card.  The read result is set to the value allRight, outOfRange,
     wrongFormat, endOfLine, or endOfInput.
  *)

PROCEDURE WriteCard (card: CARDINAL; width: CARDINAL);
  (* Writes the value of card to the default output channel in text form, in a field of the
     given minimum width.
  *)

END SWholeIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.35 gm2-iso/SYSTEM

 
DEFINITION MODULE SYSTEM;

  (* Gives access to system programming facilities that are probably
     non portable. *)

  (* The constants and types define underlying properties of storage *)

EXPORT QUALIFIED BITSPERLOC, LOCSPERWORD,
                 LOC, BYTE, WORD, BITSET, ADDRESS,
                 ADDADR, SUBADR, DIFADR, MAKEADR, ADR, ROTATE,
                 SHIFT, CAST, TSIZE,

                 (* Internal GM2 compiler functions *)
                 ShiftVal, ShiftLeft, ShiftRight,
                 RotateVal, RotateLeft, RotateRight ;

CONST
                  (* <implementation-defined constant> ; *)
  BITSPERLOC    = __ATTRIBUTE__ __BUILTIN__ ((BITS_PER_UNIT)) ;
                  (* <implementation-defined constant> ; *)
  LOCSPERWORD   = __ATTRIBUTE__ __BUILTIN__ ((UNITS_PER_WORD)) ;
                  (* <implementation-defined constant> ; *)
  LOCSPERBYTE = 8 DIV BITSPERLOC ;

(*
   all the objects below are declared internally to gm2
   ====================================================

TYPE
  LOC; (* A system basic type. Values are the uninterpreted
          contents of the smallest addressable unit of storage *)
  ADDRESS = POINTER TO LOC;
  WORD = ARRAY [0 .. LOCSPERWORD-1] OF LOC;

  (* BYTE and LOCSPERBYTE are provided if appropriate for machine *)

TYPE
  BYTE = ARRAY [0 .. LOCSPERBYTE-1] OF LOC;

PROCEDURE ADDADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
  (* Returns address given by (addr + offset), or may raise
     an exception if this address is not valid.
  *)

PROCEDURE SUBADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
  (* Returns address given by (addr - offset), or may raise an
     exception if this address is not valid.
  *)

PROCEDURE DIFADR (addr1, addr2: ADDRESS): INTEGER;
  (* Returns the difference between addresses (addr1 - addr2),
     or may raise an exception if the arguments are invalid
     or address space is non-contiguous.
  *)

PROCEDURE MAKEADR (high: <some type>; ...): ADDRESS;
  (* Returns an address constructed from a list of values whose
     types are implementation-defined, or may raise an
     exception if this address is not valid.

     In GNU Modula-2, MAKEADR can take any number of arguments
     which are mapped onto the type ADDRESS. The first parameter
     maps onto the high address bits and subsequent parameters map
     onto lower address bits. For example:

     a := MAKEADR(BYTE(0FEH), BYTE(0DCH), BYTE(0BAH), BYTE(098H),
                  BYTE(076H), BYTE(054H), BYTE(032H), BYTE(010H)) ;

     then the value of, a, on a 64 bit machine is: 0FEDCBA9876543210H

     The parameters do not have to have the same type, but constants
     _must_ be typed.
  *)

PROCEDURE ADR (VAR v: <anytype>): ADDRESS;
  (* Returns the address of variable v. *)

PROCEDURE ROTATE (val: <a packedset type>;
                  num: INTEGER): <type of first parameter>;
  (* Returns a bit sequence obtained from val by rotating up or down
     (left or right) by the absolute value of num.  The direction is
     down if the sign of num is negative, otherwise the direction is up.
  *)

PROCEDURE SHIFT (val: <a packedset type>;
                 num: INTEGER): <type of first parameter>;
  (* Returns a bit sequence obtained from val by shifting up or down
     (left or right) by the absolute value of num, introducing
     zeros as necessary.  The direction is down if the sign of
     num is negative, otherwise the direction is up.
  *)

PROCEDURE CAST (<targettype>; val: <anytype>): <targettype>;
  (* CAST is a type transfer function.  Given the expression
     denoted by val, it returns a value of the type <targettype>.
     An invalid value for the target value or a
     physical address alignment problem may raise an exception.
  *)

PROCEDURE TSIZE (<type>; ... ): CARDINAL;
  (* Returns the number of LOCS used to store a value of the
     specified <type>.   The extra parameters, if present,
     are used to distinguish variants in a variant record.
  *)
*)


(* The following procedures are invoked by GNU Modula-2 to
   shift non word set types. They are not part of ISO Modula-2
   but are used by GNU Modula-2 to implement the SHIFT procedure
   defined above. *)

(*
   ShiftVal - is a runtime procedure whose job is to implement
              the SHIFT procedure of ISO SYSTEM. GNU Modula-2 will
              inline a SHIFT of a single WORD sized set and will only
              call this routine for larger sets.
*)

PROCEDURE ShiftVal (VAR s, d: ARRAY OF BITSET;
                    SetSizeInBits: CARDINAL;
                    ShiftCount: INTEGER) ;


(*
   ShiftLeft - performs the shift left for a multi word set.
               This procedure might be called by the back end of
               GNU Modula-2 depending whether amount is known at compile
               time.
*)

PROCEDURE ShiftLeft (VAR s, d: ARRAY OF BITSET;
                     SetSizeInBits: CARDINAL;
                     ShiftCount: INTEGER) ;

(*
   ShiftRight - performs the shift left for a multi word set.
                This procedure might be called by the back end of
                GNU Modula-2 depending whether amount is known at compile
                time.
*)

PROCEDURE ShiftRight (VAR s, d: ARRAY OF BITSET;
                     SetSizeInBits: CARDINAL;
                     ShiftCount: INTEGER) ;


(*
   RotateVal - is a runtime procedure whose job is to implement
               the ROTATE procedure of ISO SYSTEM. GNU Modula-2 will
               inline a ROTATE of a single WORD (or less)
               sized set and will only call this routine for larger sets.
*)

PROCEDURE RotateVal (VAR s, d: ARRAY OF BITSET;
                     SetSizeInBits: CARDINAL;
                     RotateCount: INTEGER) ;


(*
   RotateLeft - performs the rotate left for a multi word set.
                This procedure might be called by the back end of
                GNU Modula-2 depending whether amount is known at compile
                time.
*)

PROCEDURE RotateLeft (VAR s, d: ARRAY OF BITSET;
                      SetSizeInBits: CARDINAL;
                      RotateCount: INTEGER) ;


(*
   RotateRight - performs the rotate right for a multi word set.
                 This procedure might be called by the back end of
                 GNU Modula-2 depending whether amount is known at compile
                 time.
*)

PROCEDURE RotateRight (VAR s, d: ARRAY OF BITSET;
                       SetSizeInBits: CARDINAL;
                       RotateCount: INTEGER) ;


END SYSTEM.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.36 gm2-iso/Semaphores

 
DEFINITION MODULE Semaphores;

  (* Provides mutual exclusion facilities for use by processes. *)

TYPE
  SEMAPHORE;

PROCEDURE Create (VAR s: SEMAPHORE; initialCount: CARDINAL );
  (* Creates and returns s as the identity of a new semaphore that has its associated count
     initialized to initialCount, and has no processes yet waiting on it.
  *)

PROCEDURE Destroy (VAR s: SEMAPHORE);
  (* Recovers the resources used to implement the semaphore s, provided that no process is
     waiting for s to become free.
  *)

PROCEDURE Claim (s: SEMAPHORE);
  (* If the count associated with the semaphore s is non-zero, decrements this count and
     allows the calling process to continue; otherwise suspends the calling process until
     s is released.
  *)

PROCEDURE Release (s: SEMAPHORE);
  (* If there are any processes waiting on the semaphore s, allows one of them
     to enter the ready state; otherwise increments the count associated with s.
  *)

PROCEDURE CondClaim (s: SEMAPHORE): BOOLEAN;
  (* Returns TRUE if the call Claim(s) would cause the calling process to be suspended;
     in this case the count associated with s is not changed. Otherwise returns TRUE and
     the associated count is decremented.
  *)

END Semaphores.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.37 gm2-iso/SeqFile

 
DEFINITION MODULE SeqFile;

  (* Rewindable sequential files *)

IMPORT IOChan, ChanConsts;

TYPE
  ChanId = IOChan.ChanId;
  FlagSet = ChanConsts.FlagSet;
  OpenResults = ChanConsts.OpenResults;

  (* Accepted singleton values of FlagSet *)

CONST
  read = FlagSet{ChanConsts.readFlag};   (* input operations are requested/available *)
  write = FlagSet{ChanConsts.writeFlag}; (* output operations are requested/available *)
  old = FlagSet{ChanConsts.oldFlag};     (* a file may/must/did exist before the channel is
                                            opened *)
  text = FlagSet{ChanConsts.textFlag};   (* text operations are requested/available *)
  raw = FlagSet{ChanConsts.rawFlag};     (* raw operations are requested/available *)

PROCEDURE OpenWrite (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                     VAR res: OpenResults);
  (* Attempts to obtain and open a channel connected to a stored rewindable file of the
     given name.
     The write flag is implied; without the raw flag, text is implied.
     If successful, assigns to cid the identity of the opened channel, assigns the value
     opened to res, and selects output mode, with the write position at the start of the
     file (i.e. the file is of zero length).
     If a channel cannot be opened as required, the value of res indicates the reason, and
     cid identifies the invalid channel.
  *)

PROCEDURE OpenAppend (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                      VAR res: OpenResults);
  (* Attempts to obtain and open a channel connected to a stored rewindable file of the
     given name.
     The write and old flags are implied; without the raw flag, text is implied.
     If successful, assigns to cid the identity of the opened channel, assigns the value
     opened to res, and selects output mode, with the write position corresponding to the
     length of the file.
     If a channel cannot be opened as required, the value of res indicates the reason, and
     cid identifies the invalid channel.
  *)

PROCEDURE OpenRead (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet;
                    VAR res: OpenResults);
  (* Attempts to obtain and open a channel connected to a stored rewindable file of the
     given name.
     The read and old flags are implied; without the raw flag, text is implied.
     If successful, assigns to cid the identity of the opened channel, assigns the value
     opened to res, and selects input mode, with the read position corresponding to the
     start of the file.
     If a channel cannot be opened as required, the value of res indicates the reason, and
     cid identifies the invalid channel.
  *)

PROCEDURE IsSeqFile (cid: ChanId): BOOLEAN;
  (* Tests if the channel identified by cid is open to a rewindable sequential file. *)

PROCEDURE Reread (cid: ChanId);
  (* If the channel identified by cid is not open to a rewindable sequential file, the
     exception wrongDevice is raised; otherwise attempts to set the read position to the
     start of the file, and to select input mode.
     If the operation cannot be performed (perhaps because of insufficient permissions)
     neither input mode nor output mode is selected.
  *)

PROCEDURE Rewrite (cid: ChanId);
  (* If the channel identified by cid is not open to a rewindable sequential file, the
     exception wrongDevice is raised; otherwise, attempts to truncate the file to zero
     length, and to select output mode.
     If the operation cannot be performed (perhaps because of insufficient permissions)
     neither input mode nor output mode is selected.
  *)

PROCEDURE Close (VAR cid: ChanId);
  (* If the channel identified by cid is not open to a rewindable sequential file, the
     exception wrongDevice is raised; otherwise closes the channel, and assigns the value
     identifying the invalid channel to cid.
  *)

END SeqFile.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.38 gm2-iso/StdChans

 
DEFINITION MODULE StdChans;

  (* Access to standard and default channels *)

IMPORT IOChan;

TYPE
  ChanId = IOChan.ChanId;
    (* Values of this type are used to identify channels *)

  (* The following functions return the standard channel values.
     These channels cannot be closed.
  *)

PROCEDURE StdInChan (): ChanId;
  (* Returns the identity of the implementation-defined standard source for
program
     input.
  *)

PROCEDURE StdOutChan (): ChanId;
  (* Returns the identity of the implementation-defined standard source for program
     output.
  *)

PROCEDURE StdErrChan (): ChanId;
  (* Returns the identity of the implementation-defined standard destination for program
     error messages.
  *)

PROCEDURE NullChan (): ChanId;
  (* Returns the identity of a channel open to the null device. *)

  (* The following functions return the default channel values *)

PROCEDURE InChan (): ChanId;
  (* Returns the identity of the current default input channel. *)

PROCEDURE OutChan (): ChanId;
  (* Returns the identity of the current default output channel. *)

PROCEDURE ErrChan (): ChanId;
  (* Returns the identity of the current default error message channel. *)

  (* The following procedures allow for redirection of the default channels *)

PROCEDURE SetInChan (cid: ChanId);
  (* Sets the current default input channel to that identified by cid. *)

PROCEDURE SetOutChan (cid: ChanId);
  (* Sets the current default output channel to that identified by cid. *)

PROCEDURE SetErrChan (cid: ChanId);
  (* Sets the current default error channel to that identified by cid. *)

END StdChans.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.39 gm2-iso/Storage

 
DEFINITION MODULE Storage;

  (* Facilities for dynamically allocating and deallocating storage *)

IMPORT SYSTEM;

PROCEDURE ALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
  (* Allocates storage for a variable of size amount and assigns the address of this
     variable to addr. If there is insufficient unallocated storage to do this, the
     value NIL is assigned to addr.
  *)

PROCEDURE DEALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
  (* Deallocates amount locations allocated by ALLOCATE for the storage of the variable
     addressed by addr and assigns the value NIL to addr.
  *)

TYPE
  StorageExceptions = (
    nilDeallocation,             (* first argument to DEALLOCATE is NIL *)
    pointerToUnallocatedStorage, (* storage to deallocate not allocated by ALLOCATE *)
    wrongStorageToUnallocate     (* amount to deallocate is not amount allocated *)
  );

PROCEDURE IsStorageException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state
     because of the raising of an exception from StorageExceptions;
     otherwise returns FALSE.
  *)

PROCEDURE StorageException (): StorageExceptions;
  (* If the current coroutine is in the exceptional execution state because of the
     raising of an exception from StorageExceptions, returns the corresponding
     enumeration value, and otherwise raises an exception.
  *)

END Storage.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.40 gm2-iso/StreamFile

 
DEFINITION MODULE StreamFile;

  (* Independent sequential data streams *)

IMPORT IOChan, ChanConsts;

TYPE
  ChanId = IOChan.ChanId;
  FlagSet = ChanConsts.FlagSet;
  OpenResults = ChanConsts.OpenResults;

  (* Accepted singleton values of FlagSet *)

CONST
  read = FlagSet{ChanConsts.readFlag};   (* input operations are requested/available *)
  write = FlagSet{ChanConsts.writeFlag}; (* output operations are requested/available *)
  old = FlagSet{ChanConsts.oldFlag};     (* a file may/must/did exist before the channel is
                                            opened *)
  text = FlagSet{ChanConsts.textFlag};   (* text operations are requested/available *)
  raw = FlagSet{ChanConsts.rawFlag};     (* raw operations are requested/available *)


PROCEDURE Open (VAR cid: ChanId; name: ARRAY OF CHAR; flags: FlagSet; VAR res: OpenResults);
  (* Attempts to obtain and open a channel connected to a sequential stream of the given
     name.
     The read flag implies old; without the raw flag, text is implied.
     If successful, assigns to cid the identity of the opened channel, and assigns the value
     opened to res.
     If a channel cannot be opened as required, the value of res indicates the reason, and
     cid identifies the invalid channel.
  *)

PROCEDURE IsStreamFile (cid: ChanId): BOOLEAN;
  (* Tests if the channel identified by cid is open to a sequential stream. *)

PROCEDURE Close (VAR cid: ChanId);
  (* If the channel identified by cid is not open to a sequential stream, the exception
     wrongDevice is raised; otherwise closes the channel, and assigns the value identifying
     the invalid channel to cid.
  *)

END StreamFile.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.41 gm2-iso/Strings

 
DEFINITION MODULE Strings;

  (* Facilities for manipulating strings *)

TYPE
  String1 = ARRAY [0..0] OF CHAR;
    (* String1 is provided for constructing a value of a single-character string type from a
       single character value in order to pass CHAR values to ARRAY OF CHAR parameters.
    *)

PROCEDURE Length (stringVal: ARRAY OF CHAR): CARDINAL;
  (* Returns the length of stringVal (the same value as would be returned by the
     pervasive function LENGTH).
  *)


(* The following seven procedures construct a string value, and attempt to assign it to a
   variable parameter.  They all have the property that if the length of the constructed string
   value exceeds the capacity of the variable parameter, a truncated value is assigned, while
   if the length of the constructed string value is less than the capacity of the variable
   parameter, a string terminator is appended before assignment is performed.
*)

PROCEDURE Assign (source: ARRAY OF CHAR; VAR destination: ARRAY OF CHAR);
  (* Copies source to destination *)

PROCEDURE Extract (source: ARRAY OF CHAR; startIndex, numberToExtract: CARDINAL;
                   VAR destination: ARRAY OF CHAR);
  (* Copies at most numberToExtract characters from source to destination, starting at position
     startIndex in source.
  *)

PROCEDURE Delete (VAR stringVar: ARRAY OF CHAR; startIndex, numberToDelete:
CARDINAL);
  (* Deletes at most numberToDelete characters from stringVar, starting at position
     startIndex.
  *)

PROCEDURE Insert (source: ARRAY OF CHAR; startIndex: CARDINAL;
                  VAR destination: ARRAY OF CHAR);
  (* Inserts source into destination at position startIndex *)

PROCEDURE Replace (source: ARRAY OF CHAR; startIndex: CARDINAL;
                   VAR destination: ARRAY OF CHAR);
  (* Copies source into destination, starting at position startIndex. Copying stops when
     all of source has been copied, or when the last character of the string value in
     destination has been replaced.
  *)

PROCEDURE Append (source: ARRAY OF CHAR; VAR destination: ARRAY OF CHAR);
  (* Appends source to destination. *)

PROCEDURE Concat (source1, source2: ARRAY OF CHAR; VAR destination: ARRAY OF CHAR);
  (* Concatenates source2 onto source1 and copies the result into destination. *)

(* The following predicates provide for pre-testing of the operation-completion
   conditions for the procedures above.
*)

PROCEDURE CanAssignAll (sourceLength: CARDINAL; VAR destination: ARRAY OF CHAR): BOOLEAN;
  (* Returns TRUE if a number of characters, indicated by sourceLength, will fit into
     destination; otherwise returns FALSE.
  *)

PROCEDURE CanExtractAll (sourceLength, startIndex, numberToExtract: CARDINAL;
                         VAR destination: ARRAY OF CHAR): BOOLEAN;
  (* Returns TRUE if there are numberToExtract characters starting at startIndex and
     within the sourceLength of some string, and if the capacity of destination is
     sufficient to hold numberToExtract characters; otherwise returns FALSE.
  *)

PROCEDURE CanDeleteAll (stringLength, startIndex, numberToDelete: CARDINAL): BOOLEAN;
  (* Returns TRUE if there are numberToDelete characters starting at startIndex and
     within the stringLength of some string; otherwise returns FALSE.
  *)

PROCEDURE CanInsertAll (sourceLength, startIndex: CARDINAL;
                        VAR destination: ARRAY OF CHAR): BOOLEAN;
  (* Returns TRUE if there is room for the insertion of sourceLength characters from
     some string into destination starting at startIndex; otherwise returns FALSE.
  *)

PROCEDURE CanReplaceAll (sourceLength, startIndex: CARDINAL;
                         VAR destination: ARRAY OF CHAR): BOOLEAN;
  (* Returns TRUE if there is room for the replacement of sourceLength characters in
     destination starting at startIndex; otherwise returns FALSE.
  *)

PROCEDURE CanAppendAll (sourceLength: CARDINAL; VAR destination: ARRAY OF CHAR): BOOLEAN;
  (* Returns TRUE if there is sufficient room in destination to append a string of
     length sourceLength to the string in destination; otherwise returns FALSE.
  *)

PROCEDURE CanConcatAll (source1Length, source2Length: CARDINAL;
                        VAR destination: ARRAY OF CHAR): BOOLEAN;
  (* Returns TRUE if there is sufficient room in destination for a two strings of
     lengths source1Length and source2Length; otherwise returns FALSE.
  *)

(* The following type and procedures provide for the comparison of string values, and for the
   location of substrings within strings.
*)

TYPE
  CompareResults = (less, equal, greater);

PROCEDURE Compare (stringVal1, stringVal2: ARRAY OF CHAR): CompareResults;
  (* Returns less, equal, or greater, according as stringVal1 is lexically less than,
     equal to, or greater than stringVal2.
  *)

PROCEDURE Equal (stringVal1, stringVal2: ARRAY OF CHAR): BOOLEAN;
  (* Returns Strings.Compare(stringVal1, stringVal2) = Strings.equal *)

PROCEDURE FindNext (pattern, stringToSearch: ARRAY OF CHAR; startIndex: CARDINAL;
                    VAR patternFound: BOOLEAN; VAR posOfPattern: CARDINAL);
  (* Looks forward for next occurrence of pattern in stringToSearch, starting the search at
     position startIndex. If startIndex < LENGTH(stringToSearch) and pattern is found,
     patternFound is returned as TRUE, and posOfPattern contains the start position in
     stringToSearch of pattern. Otherwise patternFound is returned as FALSE, and posOfPattern
     is unchanged.
  *)

PROCEDURE FindPrev (pattern, stringToSearch: ARRAY OF CHAR; startIndex: CARDINAL;
                    VAR patternFound: BOOLEAN; VAR posOfPattern: CARDINAL);
  (* Looks backward for the previous occurrence of pattern in stringToSearch and returns the
     position of the first character of the pattern if found. The search for the pattern
     begins at startIndex. If pattern is found, patternFound is returned as TRUE, and
     posOfPattern contains the start position in stringToSearch of pattern in the range
     [0..startIndex]. Otherwise patternFound is returned as FALSE, and posOfPattern is unchanged.
  *)

PROCEDURE FindDiff (stringVal1, stringVal2: ARRAY OF CHAR;
                    VAR differenceFound: BOOLEAN; VAR posOfDifference: CARDINAL);
  (* Compares the string values in stringVal1 and stringVal2 for differences. If they
     are equal, differenceFound is returned as FALSE, and TRUE otherwise. If
     differenceFound is TRUE, posOfDifference is set to the position of the first
     difference; otherwise posOfDifference is unchanged.
  *)

PROCEDURE Capitalize (VAR stringVar: ARRAY OF CHAR);
  (* Applies the function CAP to each character of the string value in stringVar. *)

END Strings.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.42 gm2-iso/SysClock

 
DEFINITION MODULE SysClock;

(* Facilities for accessing a system clock that records the date and time of day *)

CONST
  maxSecondParts = <implementation-defined integral value>;

TYPE
  Month    = [1 .. 12];
  Day      = [1 .. 31];
  Hour     = [0 .. 23];
  Min      = [0 .. 59];
  Sec      = [0 .. 59];
  Fraction = [0 .. maxSecondParts];
  UTCDiff  = [-780 .. 720];
  DateTime =
    RECORD
      year:      CARDINAL;
      month:     Month;
      day:       Day;
      hour:      Hour;
      minute:    Min;
      second:    Sec;
      fractions: Fraction;      (* parts of a second *)
      zone:      UTCDiff;       (* Time zone differential factor which is the number
                                   of minutes to add to local time to obtain UTC. *)
      summerTimeFlag: BOOLEAN;  (* Interpretation of flag depends on local usage. *)
    END;

PROCEDURE CanGetClock(): BOOLEAN;
(* Tests if the clock can be read *)

PROCEDURE CanSetClock(): BOOLEAN;
(* Tests if the clock can be set *)

PROCEDURE IsValidDateTime(userData: DateTime): BOOLEAN;
(* Tests if the value of userData is a valid *)

PROCEDURE GetClock(VAR userData: DateTime);
(* Assigns local date and time of the day to userData *)

PROCEDURE SetClock(userData: DateTime): BOOLEAN;
(* Sets the system time clock to the given local date and time *)

END SysClock.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.43 gm2-iso/TERMINATION

 
DEFINITION MODULE TERMINATION;

(* Provides facilities for enquiries concerning the occurrence of termination events. *)

PROCEDURE IsTerminating (): BOOLEAN ;
  (* Returns true if any coroutine has started  program termination and false otherwise. *)

PROCEDURE HasHalted (): BOOLEAN ;
  (* Returns true if a call to HALT has been made and false otherwise. *)

END TERMINATION.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.44 gm2-iso/TermFile

 
DEFINITION MODULE TermFile;

  (* Access to the terminal device *)

  (* Channels opened by this module are connected to a single terminal device; typed
     characters are distributed between channels according to the sequence of read requests.
  *)

IMPORT IOChan, ChanConsts;

TYPE
  ChanId = IOChan.ChanId;
  FlagSet = ChanConsts.FlagSet;
  OpenResults = ChanConsts.OpenResults;

  (* Accepted singleton values of FlagSet *)

CONST
  read = FlagSet{ChanConsts.readFlag};   (* input operations are requested/available *)
  write = FlagSet{ChanConsts.writeFlag}; (* output operations are requested/available *)
  text = FlagSet{ChanConsts.textFlag};   (* text operations are requested/available *)
  raw = FlagSet{ChanConsts.rawFlag};     (* raw operations are requested/available *)
  echo = FlagSet{ChanConsts.echoFlag};   (* echoing by interactive device on reading of
                                            characters from input stream requested/applies
                                         *)

PROCEDURE Open (VAR cid: ChanId; flags: FlagSet; VAR res: OpenResults);
  (* Attempts to obtain and open a channel connected to the terminal.
     Without the raw flag, text is implied.
     Without the echo flag, line mode is requested, otherwise single character mode is
     requested.
     If successful, assigns to cid the identity of the opened channel, and assigns the value
     opened to res.
     If a channel cannot be opened as required, the value of res indicates the reason, and
     cid identifies the invalid channel.
  *)

PROCEDURE IsTermFile (cid: ChanId): BOOLEAN;
  (* Tests if the channel identified by cid is open to the terminal. *)

PROCEDURE Close (VAR cid: ChanId);
  (* If the channel identified by cid is not open to the terminal, the exception wrongDevice
     is raised; otherwise closes the channel and assigns the value identifying the invalid
     channel to cid.
  *)

END TermFile.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.45 gm2-iso/TextIO

 
DEFINITION MODULE TextIO;

  (* Input and output of character and string types over specified channels.
     The read result is of the type IOConsts.ReadResults.
  *)

IMPORT IOChan;

  (* The following procedures do not read past line marks *)

PROCEDURE ReadChar (cid: IOChan.ChanId; VAR ch: CHAR);
  (* If possible, removes a character from the input stream cid and assigns the
     corresponding value to ch.  The read result is set to the value allRight, endOfLine, or
     endOfInput.
  *)

PROCEDURE ReadRestLine (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR);
  (* Removes any remaining characters from the input stream cid before the next line mark,
     copying to s as many as can be accommodated as a string value. The read result is set
     to the value allRight, outOfRange, endOfLine, or endOfInput.
  *)

PROCEDURE ReadString (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR);
  (* Removes only those characters from the input stream cid before the next line mark that
     can be accommodated in s as a string value, and copies them to s.  The read result is
     set to the value allRight, endOfLine, or endOfInput.
  *)

PROCEDURE ReadToken (cid: IOChan.ChanId; VAR s: ARRAY OF CHAR);
  (* Skips leading spaces, and then removes characters from the input stream cid before the
     next space or line mark, copying to s as many as can be accommodated as a string value.
     The read result is set to the value allRight, outOfRange, endOfLine, or endOfInput.
  *)

  (* The following procedure reads past the next line mark *)

PROCEDURE SkipLine (cid: IOChan.ChanId);
  (* Removes successive items from the input stream cid up to and including the next line
     mark, or until the end of input is reached.  The read result is set to the value
     allRight, or endOfInput.
  *)

  (* Output procedures *)

PROCEDURE WriteChar (cid: IOChan.ChanId; ch: CHAR);
  (* Writes the value of ch to the output stream cid. *)

PROCEDURE WriteLn (cid: IOChan.ChanId);
  (* Writes a line mark to the output stream cid. *)

PROCEDURE WriteString (cid: IOChan.ChanId; s: ARRAY OF CHAR);
  (* Writes the string value in s to the output stream cid. *)

END TextIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.46 gm2-iso/WholeConv

 
DEFINITION MODULE WholeConv;

  (* Low-level whole-number/string conversions *)

IMPORT
  ConvTypes;

TYPE
  ConvResults = ConvTypes.ConvResults; (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)

PROCEDURE ScanInt (inputCh: CHAR; VAR chClass: ConvTypes.ScanClass;
                   VAR nextState: ConvTypes.ScanState);
  (* Represents the start state of a finite state scanner for signed whole numbers -
     assigns class of inputCh to chClass and a procedure representing the next state to
     nextState.
  *)

PROCEDURE FormatInt (str: ARRAY OF CHAR): ConvResults;
  (* Returns the format of the string value for conversion to INTEGER. *)

PROCEDURE ValueInt (str: ARRAY OF CHAR): INTEGER;
  (* Returns the value corresponding to the signed whole number string value str if str
     is well-formed; otherwise raises the WholeConv exception.
  *)

PROCEDURE LengthInt (int: INTEGER): CARDINAL;
  (* Returns the number of characters in the string representation of int. *)

PROCEDURE ScanCard (inputCh: CHAR; VAR chClass: ConvTypes.ScanClass;
                    VAR nextState: ConvTypes.ScanState);
  (* Represents the start state of a finite state scanner for unsigned whole numbers -
     assigns class of inputCh to chClass and a procedure representing the next state to
     nextState.
  *)

PROCEDURE FormatCard (str: ARRAY OF CHAR): ConvResults;
  (* Returns the format of the string value for conversion to CARDINAL. *)

PROCEDURE ValueCard (str: ARRAY OF CHAR): CARDINAL;
  (* Returns the value corresponding to the unsigned whole number string value str if
     str is well-formed; otherwise raises the WholeConv exception.
   *)

PROCEDURE LengthCard (card: CARDINAL): CARDINAL;
  (* Returns the number of characters in the string representation of card. *)

PROCEDURE IsWholeConvException (): BOOLEAN;
  (* Returns TRUE if the current coroutine is in the exceptional execution state because
     of the raising of an exception in a routine from this module; otherwise returns
     FALSE.
  *)

END WholeConv.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.47 gm2-iso/WholeIO

 
DEFINITION MODULE WholeIO;

  (* Input and output of whole numbers in decimal text form over specified channels.
     The read result is of the type IOConsts.ReadResults.
  *)

IMPORT IOChan;

  (* The text form of a signed whole number is
       ["+" | "-"], decimal digit, {decimal digit}

     The text form of an unsigned whole number is
       decimal digit, {decimal digit}
  *)

PROCEDURE ReadInt (cid: IOChan.ChanId; VAR int: INTEGER);
  (* Skips leading spaces, and removes any remaining characters from cid that form part of a
     signed whole number.  The value of this number is assigned to int.  The read result is
     set to the value allRight, outOfRange, wrongFormat, endOfLine, or endOfInput.
  *)

PROCEDURE WriteInt (cid: IOChan.ChanId; int: INTEGER; width: CARDINAL);
  (* Writes the value of int to cid in text form, in a field of the given minimum width. *)

PROCEDURE ReadCard (cid: IOChan.ChanId; VAR card: CARDINAL);
  (* Skips leading spaces, and removes any remaining characters from cid that form part of
     an unsigned whole number.  The value of this number is assigned to card. The read
     result is set to the value allRight, outOfRange, wrongFormat, endOfLine, or endOfInput.
  *)

PROCEDURE WriteCard (cid: IOChan.ChanId; card: CARDINAL; width: CARDINAL);
  (* Writes the value of card to cid in text form, in a field of the given minimum width. *)

END WholeIO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4.48 gm2-iso/WholeStr

 
DEFINITION MODULE WholeStr;

  (* Whole-number/string conversions *)

IMPORT
  ConvTypes;

TYPE
  ConvResults = ConvTypes.ConvResults; (* strAllRight, strOutOfRange, strWrongFormat, strEmpty *)

(* the string form of a signed whole number is
     ["+" | "-"], decimal digit, {decimal digit}
*)

PROCEDURE StrToInt (str: ARRAY OF CHAR; VAR int: INTEGER; VAR res: ConvResults);
  (* Ignores any leading spaces in str. If the subsequent characters in str are in the
     format of a signed whole number, assigns a corresponding value to int. Assigns a
     value indicating the format of str to res.
  *)

PROCEDURE IntToStr (int: INTEGER; VAR str: ARRAY OF CHAR);
  (* Converts the value of int to string form and copies the possibly truncated result to str. *)

(* the string form of an unsigned whole number is
     decimal digit, {decimal digit}
*)

PROCEDURE StrToCard (str: ARRAY OF CHAR; VAR card: CARDINAL; VAR res: ConvResults);
  (* Ignores any leading spaces in str. If the subsequent characters in str are in the
     format of an unsigned whole number, assigns a corresponding value to card.
     Assigns a value indicating the format of str to res.
  *)

PROCEDURE CardToStr (card: CARDINAL; VAR str: ARRAY OF CHAR);
  (* Converts the value of card to string form and copies the possibly truncated result to str. *)

END WholeStr.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5 ULM System Libraries


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.1 ulm-lib-gm2/sys/Errno

 
DEFINITION MODULE Errno;

   (* following constants have been extracted from
         /usr/include/sys/errno.h
      on SunOS 5.5.1 at 1997/02/26
   *)

   CONST
      EPERM           =   1;  EL3RST          =  40;  ELIBSCN         =  85;
      ENOENT          =   2;  ELNRNG          =  41;  ELIBMAX         =  86;
      ESRCH           =   3;  EUNATCH         =  42;  ELIBEXEC        =  87;
      EINTR           =   4;  ENOCSI          =  43;  EILSEQ          =  88;
      EIO             =   5;  EL2HLT          =  44;  ENOSYS          =  89;
      ENXIO           =   6;  EDEADLK         =  45;  ELOOP           =  90;
      E2BIG           =   7;  ENOLCK          =  46;  ERESTART        =  91;
      ENOEXEC         =   8;  ECANCELED       =  47;  ESTRPIPE        =  92;
      EBADF           =   9;  ENOTSUP         =  48;  ENOTEMPTY       =  93;
      ECHILD          =  10;  EDQUOT          =  49;  EUSERS          =  94;
      EAGAIN          =  11;  EBADE           =  50;  ENOTSOCK        =  95;
      ENOMEM          =  12;  EBADR           =  51;  EDESTADDRREQ    =  96;
      EACCES          =  13;  EXFULL          =  52;  EMSGSIZE        =  97;
      EFAULT          =  14;  ENOANO          =  53;  EPROTOTYPE      =  98;
      ENOTBLK         =  15;  EBADRQC         =  54;  ENOPROTOOPT     =  99;
      EBUSY           =  16;  EBADSLT         =  55;  EPROTONOSUPPORT = 120;
      EEXIST          =  17;  EDEADLOCK       =  56;  ESOCKTNOSUPPORT = 121;
      EXDEV           =  18;  EBFONT          =  57;  EOPNOTSUPP      = 122;
      ENODEV          =  19;  ENOSTR          =  60;  EPFNOSUPPORT    = 123;
      ENOTDIR         =  20;  ENODATA         =  61;  EAFNOSUPPORT    = 124;
      EISDIR          =  21;  ETIME           =  62;  EADDRINUSE      = 125;
      EINVAL          =  22;  ENOSR           =  63;  EADDRNOTAVAIL   = 126;
      ENFILE          =  23;  ENONET          =  64;  ENETDOWN        = 127;
      EMFILE          =  24;  ENOPKG          =  65;  ENETUNREACH     = 128;
      ENOTTY          =  25;  EREMOTE         =  66;  ENETRESET       = 129;
      ETXTBSY         =  26;  ENOLINK         =  67;  ECONNABORTED    = 130;
      EFBIG           =  27;  EADV            =  68;  ECONNRESET      = 131;
      ENOSPC          =  28;  ESRMNT          =  69;  ENOBUFS         = 132;
      ESPIPE          =  29;  ECOMM           =  70;  EISCONN         = 133;
      EROFS           =  30;  EPROTO          =  71;  ENOTCONN        = 134;
      EMLINK          =  31;  EMULTIHOP       =  74;  ESHUTDOWN       = 143;
      EPIPE           =  32;  EBADMSG         =  77;  ETOOMANYREFS    = 144;
      EDOM            =  33;  ENAMETOOLONG    =  78;  ETIMEDOUT       = 145;
      ERANGE          =  34;  EOVERFLOW       =  79;  ECONNREFUSED    = 146;
      ENOMSG          =  35;  ENOTUNIQ        =  80;  EHOSTDOWN       = 147;
      EIDRM           =  36;  EBADFD          =  81;  EHOSTUNREACH    = 148;
      ECHRNG          =  37;  EREMCHG         =  82;  EALREADY        = 149;
      EL2NSYNC        =  38;  ELIBACC         =  83;  EINPROGRESS     = 150;
      EL3HLT          =  39;  ELIBBAD         =  84;  ESTALE          = 151;

      EWOULDBLOCK     = EAGAIN;

   CONST
      maxerror = 151;
      maxmsglen = 41;
      maxnamelen = 15;

   TYPE
      ErrorNumber = [0..maxerror];
      ErrorMessage = ARRAY [0..maxmsglen] OF CHAR;
      ErrorName = ARRAY [0..maxnamelen] OF CHAR;

   VAR
      message: ARRAY ErrorNumber OF ErrorMessage;
      name: ARRAY ErrorNumber OF ErrorName;

   VAR
      errno: CARDINAL;

END Errno.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.2 ulm-lib-gm2/sys/SYSTEM

 
DEFINITION MODULE FOR "C" SYSTEM ;

(*
    Description: provides a SYSTEM module for GNU Modula-2 so that the
                 ULM libraries can be built.
*)

EXPORT QUALIFIED (* the following are built into the compiler: *)
                 ADDRESS, WORD, BYTE, BITSET, ADR, TSIZE, SIZE,
                 (* the rest are implemented in SYSTEM.c *)
                 UNIXCALL, UNIXSIGNAL, UNIXFORK ;


(*
   UNIXCALL - returns TRUE if the syscall was successful, results from
              the system call are returned in r0 and r1.
*)

PROCEDURE UNIXCALL (syscall: CARDINAL; VAR r0, r1: INTEGER; ...) : BOOLEAN;


(*
   UNIXFORK - returns TRUE if successful and pid is set to the son pid
              if the parent is returning. If the child is returning pid=0.
              UNIXFORK returns FALSE if an error occurs and errno is held in pid.
*)

PROCEDURE UNIXFORK (VAR pid: CARDINAL) : BOOLEAN ;


(*
   UNIXSIGNAL -
*)

PROCEDURE UNIXSIGNAL (signo: CARDINAL; p: PROC;
                      VAR old: PROC; VAR result: CARDINAL) : BOOLEAN;


END SYSTEM.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.3 ulm-lib-gm2/sys/Sys

 
DEFINITION MODULE Sys;

(*
   The constants included here are those which are needed to get
   the ulm modules working. This is a much reduced list from the
   original ULM library. Please email <gm2 at glam.ac.uk> if you
   require more system calls than those presented below:
*)

CONST
    access = 0 ;
    brk = 1 ;
    close = 2 ;
    creat = 3 ;
    dup = 4 ;
    execve = 5 ;
    exit = 6 ;
    fcntl = 7 ;
    fstat = 8 ;
    getdents = 9 ;
    getgid = 10 ;
    getpid = 11 ;
    gettimeofday = 12 ;
    getuid = 13 ;
    ioctl = 14 ;
    kill = 15 ;
    link = 16 ;
    lseek = 17 ;
    open = 18 ;
    pause = 19 ;
    pipe = 20 ;
    read = 21 ;
    setitimer = 22 ;
    setgid = 23 ;
    setuid = 24 ;
    stat = 25 ;
    times = 26 ;
    unlink = 27 ;
    wait = 28 ;
    write = 29 ;

END Sys.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.4 ulm-lib-gm2/sys/SysAccess

 
DEFINITION MODULE SysAccess;

   PROCEDURE Access(filename: ARRAY OF CHAR; mode: CARDINAL) : BOOLEAN;

END SysAccess.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.5 ulm-lib-gm2/sys/SysAlarm

 
DEFINITION MODULE SysAlarm;

   VAR
      previous: CARDINAL; (* previous amount *)

   PROCEDURE Alarm(sec: CARDINAL) : BOOLEAN;

END SysAlarm.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.6 ulm-lib-gm2/sys/SysBreak

 
DEFINITION MODULE SysBreak;

   FROM SYSTEM IMPORT ADDRESS;

   PROCEDURE Break(addr: ADDRESS) : BOOLEAN;

   PROCEDURE Sbreak(incr: CARDINAL) : ADDRESS;

END SysBreak.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.7 ulm-lib-gm2/sys/SysClose

 
DEFINITION MODULE SysClose;

   PROCEDURE Close(fd: CARDINAL) : BOOLEAN;

END SysClose.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.8 ulm-lib-gm2/sys/SysCreat

 
DEFINITION MODULE SysCreat;

   PROCEDURE Creat(VAR fd: CARDINAL; filename: ARRAY OF CHAR;
                   mode: CARDINAL) : BOOLEAN;

END SysCreat.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.9 ulm-lib-gm2/sys/SysDup

 
DEFINITION MODULE SysDup;

   PROCEDURE Dup(fd: CARDINAL; VAR newfd: CARDINAL) : BOOLEAN;

   PROCEDURE Dup2(fd, newfd: CARDINAL) : BOOLEAN;

END SysDup.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.10 ulm-lib-gm2/sys/SysExec

 
DEFINITION MODULE SysExec;

   FROM SYSTEM IMPORT ADDRESS;

   PROCEDURE Exec(name: ARRAY OF CHAR; argv: ADDRESS);

   PROCEDURE Exece(name: ARRAY OF CHAR; argv, envp: ADDRESS);

END SysExec.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.11 ulm-lib-gm2/sys/SysExit

 
DEFINITION MODULE SysExit;

   PROCEDURE Exit(exitCode: CARDINAL);

   PROCEDURE EnterCleanup(p: PROC);

END SysExit.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.12 ulm-lib-gm2/sys/SysFcntl

 
DEFINITION MODULE SysFcntl;

   FROM SYSTEM IMPORT WORD;

   TYPE
      FcntlRequest = (dupfd, getfd, setfd, getfl, setfl,getown,
			setown,getlk,setlk,setlkw);

   PROCEDURE Fcntl(fd: CARDINAL; cmd: FcntlRequest; VAR arg: WORD) : BOOLEAN;

END SysFcntl.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.13 ulm-lib-gm2/sys/SysFork

 
DEFINITION MODULE SysFork;

   (* IF pid = 0 THEN son ELSE father END *)

   PROCEDURE Fork(VAR pid: CARDINAL) : BOOLEAN;

END SysFork.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.14 ulm-lib-gm2/sys/SysGetpid

 
DEFINITION MODULE SysGetpid;			(* mh 11/1987 *)

   FROM SystemTypes IMPORT ProcessId;

   PROCEDURE Getpid(): ProcessId;

END SysGetpid.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.15 ulm-lib-gm2/sys/SysGetuid

 
DEFINITION MODULE SysGetuid;

   PROCEDURE Getuid() : CARDINAL;

   PROCEDURE Geteuid() : CARDINAL;

   PROCEDURE Getgid() : CARDINAL;

   PROCEDURE Getegid() : CARDINAL;

END SysGetuid.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.16 ulm-lib-gm2/sys/SysIoctl

 
DEFINITION MODULE SysIoctl;

   (* SUN version *)

   FROM SYSTEM IMPORT BYTE, BITSET;

   CONST
      shift = 0;
      Tandem = { shift + 15 };
      Cbreak = { shift + 14 };
      Lcase  = { shift + 13 };
      Echo   = { shift + 12 };
      Crmod  = { shift + 11 };
      Raw    = { shift + 10 };
      Oddp   = { shift + 9 };
      Evenp  = { shift + 8 };
      Anyp   = Oddp + Evenp;
      Nldelay = { shift + 6 , shift + 7 };
      Tbdelay = { shift + 4 , shift + 5 };
      Xtabs  = { shift + 4 , shift + 5 };
      Crdelay = { shift + 2 , 3 };
      Vtdelay = { shift + 1 };
      Bsdelay = { shift + 0 };
      Alldelay = Bsdelay + Vtdelay + Crdelay +
                 Xtabs + Tbdelay + Nldelay;

      IocVoid = { 2 };
      IocOut = { 1 };
      IocIn = { 0 };
      IocInOut = IocIn + IocOut;

      getd = BITSET(0) + IocOut;
      setd = BITSET(1) + IocIn;
      hpcl = BITSET(2) + IocVoid;
      modg = BITSET(3) + IocOut;
      mods = BITSET(4) + IocIn;
      getp = BITSET(8) + IocOut;
      setp = BITSET(9) + IocIn;
      setn = BITSET(10) + IocIn;
      excl = BITSET(13) + IocVoid;
      nxcl = BITSET(14) + IocVoid;
      flush = BITSET(16) + IocIn;
      setc = BITSET(17) + IocIn;
      getc = BITSET(18) + IocOut;
      (* BSD or SUN specific ioctl-calls *)
      lbis = BITSET(127) + IocIn;
      lbic = BITSET(126) + IocIn;
      lset = BITSET(125) + IocIn;
      lget = BITSET(124) + IocOut;
      sbrk = BITSET(123) + IocVoid;
      cbrk = BITSET(122) + IocVoid;
      cdtr = BITSET(120) + IocVoid;
      gprgp = BITSET(119) + IocOut;
      sprgp = BITSET(118) + IocIn;
      sltc = BITSET(117) + IocIn;
      gltc = BITSET(116) + IocOut;
      outq = BITSET(115) + IocOut;
      sti = BITSET(114) + IocIn;
      notty = BITSET(113) + IocVoid;
      pkt = BITSET(112) + IocIn;
      stop = BITSET(111) + IocVoid;
      start = BITSET(110) + IocVoid;
      mset = BITSET(109) + IocIn;
      mbis = BITSET(108) + IocIn;
      mbic = BITSET(107) + IocIn;
      mget = BITSET(106) + IocOut;
      remote = BITSET(105) + IocIn;
      gwinsz = BITSET(104) + IocOut;
      swinsz = BITSET(103) + IocIn;
      ucntl = BITSET(102) + IocIn;

      SizeOfSgttyb = 6;	(* size of corresponding C-structures *)
      SizeOfTchars = 6;
      SizeOfWinsize = 8;

      (* values of Sgttyb ispeed and ospeed *)
      b0    =  0;
      b50   =  1;
      b75   =  2;
      b110  =  3;
      b134  =  4;
      b150  =  5;
      b200  =  6;
      b300  =  7;
      b600  =  8;
      b1200 =  9;
      b1800 = 10;
      b2400 = 11;
      b4800 = 12;
      b9600 = 13;
      exta  = 14;
      extb  = 15;

   TYPE

      Sgttyb =
         RECORD
            ispeed: CHAR;
            ospeed: CHAR;
            erase: CHAR;
            kill: CHAR;
            flags: BITSET;
         END;

      Tchars =
         RECORD
            intrc: CHAR;
            quitc: CHAR;
            startc: CHAR;
            stopc: CHAR;
            eofc: CHAR;
            brkc: CHAR;
         END;

      Winsize =
	 RECORD
	    rows, cols: CARDINAL;
	    xpixels, ypixels: CARDINAL; (* not used *)
	 END;

   PROCEDURE Ioctl(fd: CARDINAL; request: BITSET;
                   VAR argp: ARRAY OF BYTE;
		   argpsize: CARDINAL) : BOOLEAN;
      (* argpsize: size of corresponding C-structure *)

   PROCEDURE Stty(fd: CARDINAL; argp: Sgttyb) : BOOLEAN;

   PROCEDURE Gtty(fd: CARDINAL; VAR argp: Sgttyb) : BOOLEAN;

   PROCEDURE Isatty(fd: CARDINAL) : BOOLEAN;

   PROCEDURE GetWinsize(fd: CARDINAL; VAR winbuf: Winsize) : BOOLEAN;

   PROCEDURE Baudrate(speed: CHAR) : CARDINAL;

END SysIoctl.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.17 ulm-lib-gm2/sys/SysKill

 
DEFINITION MODULE SysKill; (* AFB 9/88 *)

   FROM SystemTypes IMPORT Sig, ProcessId;

   PROCEDURE Kill(pid: ProcessId; sig: Sig) : BOOLEAN;

END SysKill.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.18 ulm-lib-gm2/sys/SysLink

 
DEFINITION MODULE SysLink;

   PROCEDURE Link(name1, name2: ARRAY OF CHAR) : BOOLEAN;

END SysLink.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.19 ulm-lib-gm2/sys/SysLocations

 
DEFINITION MODULE SysLocations;

   FROM SYSTEM IMPORT ADDRESS;

   VAR
      ProgramEnd, Etext, Edata, Break, Environment: ADDRESS;

END SysLocations.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.20 ulm-lib-gm2/sys/SysLseek

 
DEFINITION MODULE SysLseek;

   FROM SystemTypes IMPORT OFF;

   PROCEDURE Lseek(fd: CARDINAL; offset: OFF;
                   whence: CARDINAL) : BOOLEAN;

   PROCEDURE Tell(fd: CARDINAL; VAR offset: OFF) : BOOLEAN;

END SysLseek.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.21 ulm-lib-gm2/sys/SysOpen

 
DEFINITION MODULE SysOpen;

   FROM SYSTEM IMPORT WORD;

   (* oflag: see SystemTypes *)

   PROCEDURE Open(VAR fd: CARDINAL; filename: ARRAY OF CHAR;
                  oflag: WORD) : BOOLEAN;

   PROCEDURE OpenCreat(VAR fd: CARDINAL; filename: ARRAY OF CHAR;
		       oflag: WORD; mode: CARDINAL) : BOOLEAN;

END SysOpen.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.22 ulm-lib-gm2/sys/SysPanic

 
DEFINITION MODULE SysPanic;

   (* print text on stderr and abort with HALT *)

   PROCEDURE Panic(text: ARRAY OF CHAR);

END SysPanic.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.23 ulm-lib-gm2/sys/SysPause

 
DEFINITION MODULE SysPause;

   PROCEDURE Pause;

END SysPause.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.24 ulm-lib-gm2/sys/SysPipe

 
DEFINITION MODULE SysPipe;

   PROCEDURE Pipe(VAR ReadFileDesc, WriteFileDesc: CARDINAL) : BOOLEAN;

END SysPipe.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.25 ulm-lib-gm2/sys/SysRead

 
DEFINITION MODULE SysRead;

   FROM SYSTEM IMPORT ADDRESS;

   PROCEDURE Read(fd: CARDINAL; ptr: ADDRESS;
                  VAR bytecount: CARDINAL) : BOOLEAN;

END SysRead.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.26 ulm-lib-gm2/sys/SysSetuid

 
DEFINITION MODULE SysSetuid;

   PROCEDURE Setuid(uid: CARDINAL) : BOOLEAN;

   PROCEDURE Setgid(gid: CARDINAL) : BOOLEAN;

END SysSetuid.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.27 ulm-lib-gm2/sys/SysSignal

 
DEFINITION MODULE SysSignal;

   FROM SystemTypes IMPORT Sig;

   VAR
      default, ignore: PROC;
      old: PROC; (* will be set after each successfull Signal-call *)

   PROCEDURE Signal(sig: Sig; p: PROC) : BOOLEAN;

END SysSignal.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.28 ulm-lib-gm2/sys/SysStat

 
DEFINITION MODULE SysStat;

   FROM SystemTypes IMPORT TIME, OFF;
   FROM SYSTEM IMPORT BITSET ;

   TYPE
      StatBuf =
         RECORD
            dev: CARDINAL;
            ino: CARDINAL;
            mode: BITSET;
            nlink: CARDINAL;
            uid: CARDINAL;
            gid: CARDINAL;
            rdev: CARDINAL;
            size: OFF;
            atime: TIME;
	    spare1 : CARDINAL;
            mtime: TIME;
	    spare2 : CARDINAL;
            ctime: TIME;
	    spare3 : CARDINAL;
	    blksize : CARDINAL;
	    blocks : CARDINAL;
	    spare4 : ARRAY[0..1] OF CARDINAL;
         END;
   CONST
      (* bit masks for mode; bits 0..15 used *)
      FileType = { 0..3 };
      (* IF Ifxxx = mode * FileType *)
      IfDir = { 1 };      (* directory *)
      IfChr = { 2 };      (* character special *)
      IfBlk = { 1..2 };   (* block special *)
      IfReg = { 0 };      (* regular *)
      IfLnk = { 0,2 };	  (* symbolic link *)
      IfSock = { 0..1 };  (* socket *)
      IfFifo = { 3 };     (* fifo *)
      (* IF Isxxx <= mode THEN *)
      IsUid =  { 4 };     (* set user id on execution *)
      IsGid =  { 5 };     (* set group id on execution *)
      IsVtx =  { 6 };     (* save swapped text even after use *)
      (* permissions on file: IF ... <= mode *)
      OwnerRead = { 7 };  (* read permission, owner *)
      OwnerWrite = { 8 }; (* write permission, owner *)
      OwnerExec = { 9 };  (* execute/search permission, owner *)
      GroupRead = { 10 };
      GroupWrite = { 11 };
      GroupExec = { 12 };
      WorldRead = { 13 };
      WorldWrite = { 14 };
      WorldExec = { 15 };

   PROCEDURE Stat(file: ARRAY OF CHAR; VAR buf: StatBuf) : BOOLEAN;

   PROCEDURE Fstat(fd: CARDINAL; VAR buf: StatBuf) : BOOLEAN;

END SysStat.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.29 ulm-lib-gm2/sys/SysTermIO

 
DEFINITION MODULE SysTermIO;

   IMPORT termios ;

   TYPE
      ControlChar = termios.ControlChar ;
      Flag = termios.Flag ;

      ControlCharRange = [MIN(ControlChar)..MAX(ControlChar)];

      Modes = SET OF Flag ;

      TermIO = RECORD
                  modes   : Modes ;
                  baud    : CARDINAL ;
                  cc      : ARRAY ControlCharRange OF CHAR ;
                  rows,
                  columns,
                  line    : CARDINAL ;
               END;

   PROCEDURE SetTermIO(fd: CARDINAL; termio: TermIO) : BOOLEAN;

   PROCEDURE GetTermIO(fd: CARDINAL; VAR termio: TermIO) : BOOLEAN;

   PROCEDURE Baudrate(termio: TermIO) : CARDINAL;

   PROCEDURE Isatty(fd: CARDINAL) : BOOLEAN;

END SysTermIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.30 ulm-lib-gm2/sys/SysTime

 
DEFINITION MODULE SysTime; (* AFB 4/84 *)

   FROM SystemTypes IMPORT TIME;

   PROCEDURE Time(VAR t: TIME) : BOOLEAN;

END SysTime.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.31 ulm-lib-gm2/sys/SysUnlink

 
DEFINITION MODULE SysUnlink;

   PROCEDURE Unlink(name: ARRAY OF CHAR) : BOOLEAN;

END SysUnlink.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.32 ulm-lib-gm2/sys/SysWait

 
DEFINITION MODULE SysWait;

   PROCEDURE Wait(VAR pid, status: CARDINAL) : BOOLEAN;

END SysWait.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.33 ulm-lib-gm2/sys/SysWrite

 
DEFINITION MODULE SysWrite;

   FROM SYSTEM IMPORT ADDRESS;

   PROCEDURE Write(fd: CARDINAL; ptr: ADDRESS;
                   VAR bytecount: CARDINAL) : BOOLEAN;

END SysWrite.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.34 ulm-lib-gm2/sys/SystemTypes

 
DEFINITION MODULE SystemTypes; (* and constants *)

   (* see...
	/usr/include/fcntl.h
	/usr/include/signal.h
	/usr/include/sys/dir.h
	/usr/include/sys/param.h
	/usr/include/sys/types.h
   *)

   CONST
      DirSize = 255;
      MaxOpenFiles = 128;
      (* file control options; arguments of fcntl(2) and open(2) *)
      rdonly = {};
      wronly = { 31 };
      rdwr = { 30 };
      ndelay = { 29 };
      append = { 28 };
      async = { 25 };
      creat = { 22 };
      trunc = { 21 };
      excl = { 20 };
      nbio = { 19 };
      sync = { 18 };
   TYPE
      Sig = (SIG0,                                                     (*  0 *)
	     SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGIOT, SIGEMT, (*  7 *)
	     SIGFPE, SIGKILL, SIGBUS, SIGSEGV, SIGSYS, SIGPIPE,        (* 13 *)
	     SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGCHLD, SIGPWR,      (* 19 *)
	     SIGWINCH, SIGURG, SIGPOLL, SIGSTOP, SIGTSTP, SIGCONT,     (* 25 *)
	     SIGTTIN, SIGTTOU, SIGVTALRM, SIGPROF, SIGXCPU, SIGXFSZ,   (* 31 *)
	     SIGWAITING, SIGLWP, SIGFREEZE, SIGTHAW,                   (* 35 *)
	     SIGRT36, SIGRT37, SIGRT38, SIGRT39, SIGRT40, SIGRT41,     (* 41 *)
	     SIGRT42, SIGRT43);                                        (* 43 *)
   CONST
      (* aliases *)
      SIGABRT = SIGIOT;
      SIGCLD = SIGCHLD;
      SIGIO = SIGPOLL;
      SIGRTMIN = SIGRT36;
      SIGRTMAX = SIGRT43;

   TYPE
      SigSet = SET OF Sig;

      ProcessId = INTEGER;	(* ProcessId may be -1 for kill *)
      TIME = LONGINT;
      OFF = LONGINT;		(* offset/size of files *)

END SystemTypes.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.35 ulm-lib-gm2/sys/UnixString

 
DEFINITION MODULE UnixString;

   CONST
      BufSiz = 512;
   TYPE
      Buffer = ARRAY[0..BufSiz-1] OF CHAR;

   PROCEDURE Copy(VAR buf: Buffer; str: ARRAY OF CHAR);
      (* copy str to Buf and guarantee 0C-termination;
         str is silently truncated on copying if necessary
      *)

END UnixString.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.36 ulm-lib-gm2/sys/termios

 
DEFINITION MODULE termios ;

(*
    Description: provides a procedural interface to termios.
*)

FROM SYSTEM IMPORT ADDRESS ;

TYPE
   TERMIOS = ADDRESS ;

   ControlChar = (vintr, vquit, verase, vkill, veof, vtime, vmin,
                  vswtc, vstart, vstop, vsusp, veol, vreprint, vdiscard,
                  vwerase, vlnext, veol2) ;

   Flag = (
           (* input flag bits *)
           ignbrk, ibrkint, ignpar, iparmrk, inpck, istrip, inlcr,
           igncr, icrnl, iuclc, ixon, ixany, ixoff, imaxbel,
           (* output flag bits *)
           opost, olcuc, onlcr, ocrnl, onocr, onlret, ofill, ofdel,
           onl0, onl1, ocr0, ocr1, ocr2, ocr3,
           otab0, otab1, otab2, otab3, obs0, obs1, off0, off1, ovt0, ovt1,
           (* baud rate *)
           b0, b50, b75, b110, b135, b150, b200, b300, b600, b1200,
           b1800, b2400, b4800, b9600, b19200, b38400,
           b57600, b115200, b240400, b460800, b500000, b576000,
           b921600, b1000000, b1152000, b1500000, b2000000, b2500000,
           b3000000, b3500000, b4000000, maxbaud, crtscts,
           (* character size *)
           cs5, cs6, cs7, cs8, cstopb, cread, parenb, parodd, hupcl, clocal,
           (* local flags *)
           lisig, licanon, lxcase, lecho, lechoe, lechok, lechonl, lnoflsh,
           ltopstop, lechoctl, lechoprt, lechoke, lflusho, lpendin, liexten) ;


(*
   InitTermios - new data structure.
*)

PROCEDURE InitTermios () : TERMIOS ;


(*
   KillTermios - delete data structure.
*)

PROCEDURE KillTermios (t: TERMIOS) : TERMIOS ;


(*
   cfgetospeed - return output baud rate.
*)

PROCEDURE cfgetospeed (t: TERMIOS) : INTEGER ;


(*
   cfgetispeed - return input baud rate.
*)

PROCEDURE cfgetispeed (t: TERMIOS) : INTEGER ;


(*
   cfsetospeed - set output baud rate.
*)

PROCEDURE cfsetospeed (t: TERMIOS; b: CARDINAL) : INTEGER ;


(*
   cfsetispeed - set input baud rate.
*)

PROCEDURE cfsetispeed (t: TERMIOS; b: CARDINAL) : INTEGER ;


(*
   cfsetspeed - set input and output baud rate.
*)

PROCEDURE cfsetspeed (t: TERMIOS; b: CARDINAL) : INTEGER ;


(*
   tcgetattr - get state of, fd, into, t.
*)

PROCEDURE tcgetattr (fd: INTEGER; t: TERMIOS) : INTEGER ;


(*
   The following three functions return the different option values.
*)

PROCEDURE tcsnow () : INTEGER ;   (* alter fd now *)
PROCEDURE tcsdrain () : INTEGER ; (* alter when all output has been sent *)
PROCEDURE tcsflush () : INTEGER ; (* like drain, except discard any pending input *)


(*
   tcsetattr - set state of, fd, to, t, using option.
*)

PROCEDURE tcsetattr (fd: INTEGER; option: INTEGER; t: TERMIOS) : INTEGER ;


(*
   tcsendbreak - send zero bits for duration.
*)

PROCEDURE tcsendbreak (fd: INTEGER; duration: INTEGER) : INTEGER ;


(*
   tcdrain - waits for pending output to be written on, fd.
*)

PROCEDURE tcdrain (fd: INTEGER) : INTEGER ;


(*
   tcflushi - flush input.
*)

PROCEDURE tcflushi (fd: INTEGER) : INTEGER ;


(*
   tcflusho - flush output.
*)

PROCEDURE tcflusho (fd: INTEGER) : INTEGER ;


(*
   tcflushio - flush input and output.
*)

PROCEDURE tcflushio (fd: INTEGER) : INTEGER ;


(*
   tcflowoni - restart input on, fd.
*)

PROCEDURE tcflowoni (fd: INTEGER) : INTEGER ;


(*
   tcflowoffi - stop input on, fd.
*)

PROCEDURE tcflowoffi (fd: INTEGER) : INTEGER ;


(*
   tcflowono - restart output on, fd.
*)

PROCEDURE tcflowono (fd: INTEGER) : INTEGER ;


(*
   tcflowoffo - stop output on, fd.
*)

PROCEDURE tcflowoffo (fd: INTEGER) : INTEGER ;


(*
   GetFlag - sets a flag value from, t, in, b, and returns TRUE
             if, t, supports, f.
*)

PROCEDURE GetFlag (t: TERMIOS; f: Flag; VAR b: BOOLEAN) : BOOLEAN ;


(*
   SetFlag - sets a flag value in, t, to, b, and returns TRUE if
             this flag value is supported.
*)

PROCEDURE SetFlag (t: TERMIOS; f: Flag; b: BOOLEAN) : BOOLEAN ;


(*
   GetChar - sets a CHAR, ch, value from, t, and returns TRUE if
             this value is supported.
*)

PROCEDURE GetChar (t: TERMIOS; c: ControlChar; VAR ch: CHAR) : BOOLEAN ;


(*
   SetChar - sets a CHAR value in, t, and returns TRUE if, c,
             is supported.
*)

PROCEDURE SetChar (t: TERMIOS; c: ControlChar; ch: CHAR) : BOOLEAN ;


END termios.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6 ULM Standard Libraries


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.1 ulm-lib-gm2/std/ASCII

 
DEFINITION MODULE ASCII;

   CONST

      (* control characters *)

      nul = 0C;   ack = 6C;   ff  = 14C;  dc2 = 22C;  can = 30C;  rs  = 36C;
      soh = 1C;   bel = 7C;   cr  = 15C;  dc3 = 23C;  em  = 31C;  us  = 37C;
      stx = 2C;   bs  = 10C;  so  = 16C;  dc4 = 24C;  sub = 32C;  sp  = 40C;
      etx = 3C;   ht  = 11C;  si  = 17C;  nak = 25C;  esc = 33C;
      eot = 4C;   lf  = 12C;  dle = 20C;  syn = 26C;  fs  = 34C;
      enq = 5C;   vt  = 13C;  dc1 = 21C;  etb = 27C;  gs  = 35C;

      (* other usual names *)

      null = nul;
      bell = bel;
      nl   = lf; (* new line *)
      tab  = ht;
      np   = ff; (* new page *)

      del  = 177C;

END ASCII.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.2 ulm-lib-gm2/std/Archive

 
DEFINITION MODULE Archive; (* AFB 3/84 *)

   FROM SYSTEM IMPORT BITSET ;
   FROM SystemTypes IMPORT TIME, OFF;

   (* routines for reading an archive file *)

   CONST NameLength = 14;

   TYPE AFILE; (* hidden *)
      FileName = ARRAY[0..NameLength-1] OF CHAR;
      AStat =
         RECORD
            name: FileName;
            uid, gid: CARDINAL;
            date: TIME;
            size: OFF;
            mode: BITSET;
	    offset: OFF; (* absolute offset in archive file *)
         END;

   PROCEDURE ArchiveOpen(VAR a: AFILE; archive: ARRAY OF CHAR;
			 filename: ARRAY OF CHAR) : BOOLEAN;

   PROCEDURE ArchiveReopen(a: AFILE; filename: ARRAY OF CHAR) : BOOLEAN;
   (* in case of an error "a" will be closed *)

   PROCEDURE ArchiveClose(a: AFILE);

   PROCEDURE ArchiveRead(a: AFILE; VAR ch: CHAR) : BOOLEAN;

   PROCEDURE ArchiveStat(a: AFILE; VAR buf: AStat);

END Archive.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.3 ulm-lib-gm2/std/Arguments

 
DEFINITION MODULE Arguments;	(* mh 5/85 *)
				(* rev mh 6/88 *)
(*
 *	This module reads options and other arguments from the command
 *	line. An argument "-" or "--" stops option reading. "-", how-
 *	ever, will be delivered as argument then, whereas "--" will not.
 *)

(*
 *	Example:
 *
 *	xflag := FALSE;
 *	string := defaultstring;
 *	number := 1;
 *	InitArgs("[-x] [-s string] [-nnn] [file]...");
 *	WHILE GetFlag(flag) DO
 *	   CASE flag OF
 *	      "x":  xflag := TRUE;
 *	   |  "s":  FetchString(string);
 *	   |  "0".."9":
 *	            UngetOpt;
 *	            FetchCard(number);
 *	      ELSE  Usage
 *	   END;
 *	END; (*WHILE GetFlag*)
 *	WHILE GetArg(filename) DO
 *	   IF StrCmp(filename,"-") = 0 THEN
 *	      (* process stdin *)
 *	   ELSE
 *	      (* process filename *)
 *	   END;
 *	END; (*WHILE GetArg*)
 *)

   PROCEDURE InitArgs(is: ARRAY OF CHAR);
	(* specifies infoString and (re)starts the reading cyclus *)

   PROCEDURE Usage;
	(* prints 'Usage: command infoString' on stderr and aborts
	 * program execution. FetchString, FetchCard and FetchInt call
	 * this procedure automatically in case of errors.
	 *)

   PROCEDURE GetFlag(VAR flag: CHAR): BOOLEAN;
	(* tries to read one flag, i.e. a character within a string containing
	 * a leading '-',from the argument list and returns TRUE if successful.
	 *)

   PROCEDURE GetOpt( VAR flag: CHAR; VAR plus: BOOLEAN): BOOLEAN;
	(* reads one character within a string starting in '+' or '-'.
	 *)

   PROCEDURE FetchString(VAR string: ARRAY OF CHAR);
	(* The procedures FetchXXX try to read data of type XXX from
	 * the argument list.
	 *)

   PROCEDURE FetchCard(  VAR number: CARDINAL);
	(* syntax of cardinal arguments:  [+]{digit}  *)

   PROCEDURE FetchInt(   VAR number: INTEGER);
	(* syntax of integer arguments:  [+|-]{digit}  *)

   PROCEDURE FetchOct(   VAR number: CARDINAL);
	(* syntax of octal arguments:  [+]{octdigit}  *)

   PROCEDURE FetchHex(   VAR number: CARDINAL);
	(* syntax of hexadecimal arguments:  [+]{hexdigit}  *)

   PROCEDURE GetArg(VAR arg: ARRAY OF CHAR): BOOLEAN;
	(* reads one argument or returns FALSE if all are read. *)

   PROCEDURE UngetArg;
	(* pushes the argument that has been read just before
	 * back to the argument list.
	 *)

   PROCEDURE UngetOpt;
	(* pushes the flag or option that has been read just before
	 * back to the argument list.
	 *)

   PROCEDURE AllArgs;
	(* calls 'Usage' if any arguments are not yet read. *)

END Arguments.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.4 ulm-lib-gm2/std/Calendar

 
DEFINITION MODULE Calendar;

   FROM SystemTypes IMPORT TIME;

(*
 *	Date calculations with
 *	(a)	Julius Caesar's calendar since Jan 01, 0001
 *	(b)	the Gregorian calendar	 since Oct 15, 1582
 *	(c)	Xelos system time.
 *
 *	Martin Hasch, University of Ulm, Jan 1988
 *)

   TYPE
      Time         = TIME;    			(* consecutive seconds *)
      Date         = LONGCARD;			(* consecutive days *)

      Year         = CARDINAL;
      Month        = [1..12];
      Day          = [1..31];
      Hour         = [0..23];
      Minute       = [0..59];
      Second       = [0..59];
      Weekday      = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
      Week         = [1..53];
      Yearday      = [1..366];

      Daytime      = RECORD
			hour:    Hour;
			minute:  Minute;
			second:  Second;
		     END;
      Calendarday  = RECORD
			year:    Year;
			month:   Month;
			day:     Day;
		     END;
      CalendarInfo = RECORD
			weekday: Weekday;
			week:	 Week;
			yearday: Yearday;
		     END;

   PROCEDURE CurrentTime(): Time;
   (*
    *	returns actual system time = seconds since Jan 1, 1970, 00:00:00 GMT
    *)

   PROCEDURE ConvertTime(time: Time; VAR date: Date; VAR daytime: Daytime);
   PROCEDURE ConvertDate(date: Date; VAR calendarday: Calendarday);
   PROCEDURE ConvertCald(calendarday: Calendarday; VAR info: CalendarInfo);

   PROCEDURE CTime   (date: Date; daytime: Daytime):       Time;
   PROCEDURE CDate   (year: Year; month: Month; day: Day): Date;
   PROCEDURE CUltimo (year: Year; month: Month):	   Date;
   PROCEDURE CWeekday(date: Date):			   Weekday;

   PROCEDURE DateOK(year, month, day: CARDINAL): BOOLEAN;

   PROCEDURE TimeToString(time: Time; VAR string: ARRAY OF CHAR);
   (*
    *	converts time to a string, e.g. "Sun Sep 16 01:03:52 1973 GMT"
    *)

   PROCEDURE SetFirstOfWeek(weekday: Weekday);
   (*
    *	important for week of year calculation in ConvertCald; default is Mon.
    *)

   PROCEDURE GetTimezone (VAR tzName: ARRAY OF CHAR);
   PROCEDURE SetTimezone (    tzName: ARRAY OF CHAR);
   PROCEDURE GetLocaltime(VAR delay: Time);
   PROCEDURE SetLocaltime(    delay: Time);
   (*
    *	important for CTime, ConvertTime and TimeToString.
    *)

END Calendar.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.5 ulm-lib-gm2/std/CallShell

 
DEFINITION MODULE CallShell;

   PROCEDURE Shell(cmd: ARRAY OF CHAR; VAR status: CARDINAL) : BOOLEAN;

END CallShell.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.6 ulm-lib-gm2/std/Clock

 
DEFINITION MODULE Clock;

   FROM SystemTypes IMPORT TIME;

   CONST UnitsPerSecond = 100;

   PROCEDURE RealTime(reset: BOOLEAN): TIME;
   PROCEDURE CPUTime (reset: BOOLEAN): TIME;
   (*
    *	These functions return the time in units elapsed since the start
    *	of the current process or since the last call with argument TRUE.
    *)

END Clock.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.7 ulm-lib-gm2/std/Conversions

 
DEFINITION MODULE Conversions;                  (* LG *)

  PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
    (* conversion of an octal number to a string *)

  PROCEDURE ConvertHex(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
    (* conversion of a hexadecimal number to a string *)

  PROCEDURE ConvertCardinal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
    (* conversion of a cardinal decimal number to a string *)

  PROCEDURE ConvertInteger(num: INTEGER; len: CARDINAL;
                           VAR str: ARRAY OF CHAR);
    (* conversion of an integer decimal number to a string *)

END Conversions.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.8 ulm-lib-gm2/std/Directories

 
DEFINITION MODULE Directories;

   FROM SystemTypes IMPORT DirSize, OFF;

   TYPE
      DIR;

      FileName = ARRAY [0..DirSize-1] OF CHAR;
      Direct =
         RECORD
            ino: CARDINAL;
            name: FileName;
         END;

   PROCEDURE OpenDir(VAR dirp: DIR; filename: ARRAY OF CHAR) : BOOLEAN;

   PROCEDURE ReadDir(dirp: DIR; VAR direct: Direct) : BOOLEAN;

   PROCEDURE TellDir(dirp: DIR; VAR offset: OFF) : BOOLEAN;

   PROCEDURE SeekDir(dirp: DIR; pos: OFF) : BOOLEAN;

   PROCEDURE RewindDir(dirp: DIR) : BOOLEAN;

   PROCEDURE CloseDir(VAR dirp: DIR);

END Directories.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.9 ulm-lib-gm2/std/Environment

 
DEFINITION MODULE Environment;

   PROCEDURE GetEnv(name: ARRAY OF CHAR; (* parameter name to be looked for *)
		    VAR text: ARRAY OF CHAR; (* parameter contents *)
		    VAR ok: BOOLEAN);

   PROCEDURE EnvPar(index: CARDINAL; (* ranging [0.. #parameters-1] *)
		    VAR text: ARRAY OF CHAR; (* "name=contents" *)
		    VAR ok: BOOLEAN);

END Environment.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.10 ulm-lib-gm2/std/EtcGroup

 
DEFINITION MODULE EtcGroup;
(*
 *	scanning and searching the etc/group file
 *
 *	Martin Hasch, University of Ulm, Dec-06-1988
 *)

   TYPE
      MemberList = POINTER TO Member;
      Member =
	 RECORD
	    logname:  ARRAY [0..7] OF CHAR;
	    nextmem:  MemberList;
	 END;

      Grent =
	 RECORD
	    grname:   ARRAY [0..7] OF CHAR;
	    password: ARRAY [0..15] OF CHAR;
	    gid:      CARDINAL;
	    members:  MemberList;		(* NIL-terminated *)
	 END;

   PROCEDURE OpenGr(filename: ARRAY OF CHAR): BOOLEAN;
   (* returns TRUE on success *)

   PROCEDURE GetGrent(VAR grent: Grent): BOOLEAN;

   PROCEDURE GetGrgid(gid: CARDINAL; VAR grent: Grent): BOOLEAN;

   PROCEDURE GetGrnam(grn: ARRAY OF CHAR; VAR grent: Grent): BOOLEAN;

   PROCEDURE ReopenGr(): BOOLEAN;
   (* returns TRUE if group file is open and seekable *)

   PROCEDURE CloseGr(): BOOLEAN;
   (* returns TRUE if group file was open *)


   PROCEDURE FetchGrgid(gid: CARDINAL; VAR grent: Grent): BOOLEAN;
   (* implies OpenGr("/etc/group"), and CloseGr() *)

   PROCEDURE FetchGrnam(grn: ARRAY OF CHAR; VAR grent: Grent): BOOLEAN;
   (* implies OpenGr("/etc/group"), and CloseGr() *)

END EtcGroup.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.11 ulm-lib-gm2/std/Files

 
DEFINITION MODULE Files;

   FROM SystemTypes IMPORT OFF;

   (* high level module for file handling *)

   IMPORT StdIO;

   TYPE
      FILE = StdIO.FILE;

   VAR Done: BOOLEAN;

   PROCEDURE OpenRead(VAR f: FILE; filename: ARRAY OF CHAR);

   PROCEDURE OpenWrite(VAR f: FILE; filename: ARRAY OF CHAR);

   PROCEDURE Close(f: FILE);

   PROCEDURE SetPos(f: FILE; pos: OFF);

   PROCEDURE GetPos(f: FILE; VAR pos: OFF);

   PROCEDURE Reset(f: FILE);

   PROCEDURE Delete(filename: ARRAY OF CHAR);

   PROCEDURE Rename(oldname, newname: ARRAY OF CHAR);

END Files.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.12 ulm-lib-gm2/std/FtdIO

 
DEFINITION MODULE FtdIO;

   FROM SYSTEM IMPORT WORD;
   FROM StdIO IMPORT FILE;

   VAR Done: BOOLEAN;
       termCH: CHAR;

   PROCEDURE FreadInt(f: FILE; VAR arg: INTEGER);

   PROCEDURE FwriteInt(f: FILE; arg: INTEGER; w: CARDINAL);

   PROCEDURE FreadCard(f: FILE; VAR arg: CARDINAL);

   PROCEDURE FwriteCard(f: FILE; arg: CARDINAL; w: CARDINAL);

   PROCEDURE FreadString(f: FILE; VAR str: ARRAY OF CHAR);

   PROCEDURE FwriteString(f: FILE; str: ARRAY OF CHAR);

   PROCEDURE FwriteLn(f: FILE);

   PROCEDURE Fread(f: FILE; VAR arr: ARRAY OF WORD);

   PROCEDURE Fwrite(f: FILE; arr: ARRAY OF WORD);

   PROCEDURE FreadWord(f: FILE; VAR w: WORD);

   PROCEDURE FwriteWord(f: FILE; w: WORD);

   PROCEDURE FreadChar(f: FILE; VAR ch: CHAR);

   PROCEDURE FwriteChar(f: FILE; ch: CHAR);

END FtdIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.13 ulm-lib-gm2/std/Functions

 
DEFINITION MODULE Functions; (* AFB 12/88 *)

(*
   (C) Andreas Borchert, Universitaet Ulm, 1988

   The expression grammar is Modula-2 oriented with following exceptions:

   (1)	The ?: operator has been added (semantic close to C).
	?: has lowest priority and right-to-left associativity
   (2)	Integer constants are real constants, too.
   (3)  Operator-keywords are not supported, so use
	   &  instead of AND,
	   |  instead of OR, and
	   ~  instead of NOT.
   (4)	TRUE is represented as 1.0 and FALSE as 0.0
	Anything but 0.0 is taken to be TRUE (in conditions).

   The grammar (in EBNF):

      CondExpression = Expression [ "?" CondExpression ":" CondExpression ] .
      Expression = SimpleExpression [ RelOp SimpleExpression ] .
      SimpleExpression = ["+"|"-"] Term { AddOp Term } .
      Term = Factor { MulOp Factor } .
      Factor = Constant | IDENT | FunctionCall | "~" Factor |
	       "(" CondExpression ")" .
      FunctionCall = IDENT "(" CondExpression [ "," CondExpression ] ")" .
      RelOp = "=" | "#" | "<" | ">" | "<=" | ">=" .
      AddOp = "+" | "-" | "|" .
      MulOp = "*" | "/" | "&" .

   The start symbol is CondExpression.
   Identifiers are sequences of letters and digits. The first character
   must be a letter.
   Syntax of constants:

      Digit { Digit } [ "." { Digit } ] [ ("E"|"e") Digit { Digit } ]

   On errors `ParseFunction' returns FALSE after `errpos' has been set
   to the error position.
   Errors can result from

      (1) Syntax errors.
      (2) Bad constants, e.g. exponent is too large
      (3) Bad number of arguments to a function

   Each identifier not declared as a constant or a function is
   considered to be a parameter. The value of a parameter is
   predefined to 0.0. `FirstParam' and `NextParam' give the parameter names
   in alphabetical order. Parameter values can be changed using
   `SetFuncParam'. `EvalFunction' evaluates the function with the
   parameters set previously.

   Example:

      WriteString("func: "); ReadString(functxt);
      IF ParseFunction(func, functxt) THEN
	 FirstParam;
	 WHILE NextParam(func, parname) DO
	    WriteString(parname); WriteString(" = ");
	    ReadReal(val);
	    SetFuncParam(func, parname, val);
	 END;
	 WriteReal(EvalFunction(func), 1); WriteLn;
      ELSE
	 (* error at errpos *)
      END;

   Warning:

   EvalFunction does not check for division by zero or any other
   operations which can result in a floating point exception.

   Hint:

   Import `StdFuncs' for having a standard set of functions and
   constants.

*)

   TYPE
      Function;
      Real = REAL;
      StdFunc1 = PROCEDURE (Real) : Real;
      StdFunc2 = PROCEDURE (Real, Real) : Real;

   VAR
      errpos: CARDINAL; (* error position in expr of ParseFunction *)

   PROCEDURE InstallStdFunc1(funcname: ARRAY OF CHAR; stdfunc: StdFunc1);

   PROCEDURE InstallStdFunc2(funcname: ARRAY OF CHAR; stdfunc: StdFunc2);

   PROCEDURE InstallStdConst(constname: ARRAY OF CHAR; val: Real);

   PROCEDURE ParseFunction(expr: ARRAY OF CHAR; VAR func: Function) : BOOLEAN;

   PROCEDURE FirstParam(func: Function);

   PROCEDURE NextParam(func: Function; VAR symname: ARRAY OF CHAR) : BOOLEAN;

   PROCEDURE SetFuncParam(func: Function; parname: ARRAY OF CHAR;
			  value: Real);

   PROCEDURE EvalFunction(func: Function) : Real;

   PROCEDURE DisposeFunction(VAR func: Function);
      (* release storage associated with `func' *)

END Functions.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.14 ulm-lib-gm2/std/GetPass

 
DEFINITION MODULE GetPass;

   PROCEDURE GetPass(prompt: ARRAY OF CHAR;
                     VAR passwd: ARRAY OF CHAR);

END GetPass.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.15 ulm-lib-gm2/std/InOut

 
DEFINITION MODULE InOut; (* stripped version: AFB 4/84 *)

   CONST
      EOL = 12C;
   VAR
      Done: BOOLEAN; (* on eof true *)
      termCH: CHAR; (* set in ReadString and numeric input procs *)

   PROCEDURE Read(VAR ch: CHAR);

   PROCEDURE ReadString(VAR str: ARRAY OF CHAR);

   PROCEDURE ReadCard(VAR arg: CARDINAL);

   PROCEDURE ReadInt(VAR arg: INTEGER);

   PROCEDURE Write(ch: CHAR);

   PROCEDURE WriteLn;

   PROCEDURE WriteString(s: ARRAY OF CHAR);

   (* n: minimum field width *)

   PROCEDURE WriteInt(x: INTEGER; n: CARDINAL);

   PROCEDURE WriteCard(x: CARDINAL; n: CARDINAL);

   PROCEDURE WriteOct(x: CARDINAL; n: CARDINAL);

   PROCEDURE WriteHex(x: CARDINAL; n: CARDINAL);

END InOut.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.16 ulm-lib-gm2/std/MathLib

 
DEFINITION MODULE MathLib;

   PROCEDURE arctan(x: REAL) : REAL;

   PROCEDURE exp(x: REAL) : REAL;

   PROCEDURE ln(x: REAL) : REAL;

   PROCEDURE sin(x: REAL) : REAL;

   PROCEDURE cos(x: REAL) : REAL;

   PROCEDURE sqrt(x: REAL) : REAL;

END MathLib.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.17 ulm-lib-gm2/std/Passwd

 
DEFINITION MODULE Passwd;
(*
 *	scanning and searching the passord file
 *
 *	Martin Hasch, University of Ulm, Nov-29-1988
 *)

   TYPE
      Pwent =
	 RECORD
	    logname:  ARRAY [0..7] OF CHAR;
	    password: ARRAY [0..15] OF CHAR;
	    uid:      CARDINAL;
	    gid:      CARDINAL;
	    fullname: ARRAY [0..31] OF CHAR;
	    dir:      ARRAY [0..31] OF CHAR;
	    shell:    ARRAY [0..31] OF CHAR;
	 END;

   PROCEDURE OpenPw(filename: ARRAY OF CHAR): BOOLEAN;
   (* returns TRUE on success *)

   PROCEDURE GetPwent(VAR pwent: Pwent): BOOLEAN;

   PROCEDURE GetPwuid(uid: CARDINAL; VAR pwent: Pwent): BOOLEAN;

   PROCEDURE GetPwnam(logn: ARRAY OF CHAR; VAR pwent: Pwent): BOOLEAN;

   PROCEDURE ReopenPw(): BOOLEAN;
   (* returns TRUE if passwd file is open and seekable *)

   PROCEDURE ClosePw(): BOOLEAN;
   (* returns TRUE if passwd file was open *)


   PROCEDURE FetchPwuid(uid: CARDINAL; VAR pwent: Pwent): BOOLEAN;
   (* implies OpenPw("/etc/passwd"), and ClosePw() *)

   PROCEDURE FetchPwnam(logn: ARRAY OF CHAR; VAR pwent: Pwent): BOOLEAN;
   (* implies OpenPw("/etc/passwd"), and ClosePw() *)

END Passwd.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.18 ulm-lib-gm2/std/PipeIO

 
DEFINITION MODULE PipeIO;

   FROM StdIO IMPORT FILE, MODE;

   PROCEDURE Popen(VAR f: FILE; cmd: ARRAY OF CHAR; mode: MODE;
                   buffered: BOOLEAN) : BOOLEAN;

   PROCEDURE Pclose(f: FILE) : BOOLEAN;

END PipeIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.19 ulm-lib-gm2/std/Plot

 
DEFINITION MODULE Plot;

   FROM StdIO IMPORT FILE;

   (* device independent plotter interface; see plot(3) and plot(5) *)

   PROCEDURE OpenPlot(f: FILE);

   PROCEDURE ClosePlot;

   PROCEDURE Move(xto, yto: INTEGER);

   PROCEDURE Cont(xto, yto: INTEGER);

   PROCEDURE Point(xpoint, ypoint: INTEGER);

   PROCEDURE Line(xfrom, yfrom, xto, yto: INTEGER);

   PROCEDURE String(str: ARRAY OF CHAR);

   PROCEDURE Arc(xcenter, ycenter, xstart, ystart, xend, yend: INTEGER);

   PROCEDURE Circle(xcenter, ycenter, radius: INTEGER);

   PROCEDURE Erase;

   PROCEDURE LineMod(style: ARRAY OF CHAR);

   PROCEDURE Space(xupleft, yupleft, xlowright, ylowright: INTEGER);

   PROCEDURE Reverse(xupleft, yupleft, xlowright, ylowright: INTEGER);

   PROCEDURE Polygon(xcenter, ycenter, xstart, ystart, edges: INTEGER);

   PROCEDURE CharMod(plotchar: CHAR);

END Plot.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.20 ulm-lib-gm2/std/RTErrors

 
DEFINITION MODULE RTErrors;

   FROM SYSTEM IMPORT ADDRESS;

   TYPE
      Kind = (noError, halt, case, stack, crend, prio, fret, range);
      RangeCheck = (none, unsigned, signed, sign, dyn);

      Error = POINTER TO ErrorRec;
      ErrorRec =
	 RECORD
	    kind: Kind;
	    module: ADDRESS; (* points to name of module *)
	    line: CARDINAL; (* line number in source *)
	    pc: ADDRESS; (* program counter *)
	    CASE (* kind *) : Kind OF
	    | range: CASE rtype: RangeCheck OF
		     | unsigned, dyn:
			   value, min, max: CARDINAL;
		     | signed:
			   ivalue, imin, imax: INTEGER;
		     END;
	    END;
	 END;

      Handler = PROCEDURE (Error);

   PROCEDURE Notify(error: Error);
      (* called by runtime system *)

   PROCEDURE SetHandler(newHandler: Handler);
      (* define alternative handler of runtime errors *)

END RTErrors.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.21 ulm-lib-gm2/std/RandomGenerator

 
DEFINITION MODULE RandomGenerator;

   (*    Anyone who considers arithmetical
	methods of producing random digits
	 is, of course, in a state of sin.
		 - John von Neumann (1951)
   *)

   PROCEDURE IntVal() : INTEGER;
      (* get random 32-bit value *)

   PROCEDURE RealVal() : REAL;
      (* get a uniformly distributed real value in [0..1) *)

   PROCEDURE Random(low, high: INTEGER) : INTEGER;
      (* get a uniformly distributed integer in [low..high] *)

   PROCEDURE Flip() : BOOLEAN;
      (* return TRUE or FALSE *)

   PROCEDURE Init(seed: INTEGER);

END RandomGenerator.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.22 ulm-lib-gm2/std/ReadIntCard

 
DEFINITION MODULE ReadIntCard;

   FROM SYSTEM IMPORT WORD;

   TYPE
      Type = (int, card);
      ReadProc = PROCEDURE(VAR CHAR);

   VAR Done: BOOLEAN;

   (* convention: ReadChar returns 0C on eof or error *)

   PROCEDURE Read(VAR w: WORD; t: Type; ReadChar: ReadProc);

END ReadIntCard.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.23 ulm-lib-gm2/std/RealConv

 
DEFINITION MODULE RealConv; (* AFB 6/84 * rev. wsc 2/85 *)

   TYPE
      ReadProc = PROCEDURE(VAR CHAR);
   VAR
      Done: BOOLEAN;
      termCH: CHAR;

   PROCEDURE ReadReal(Read: ReadProc; VAR x: REAL);
   (* convention: Read returns 0C on eof or error *)

   PROCEDURE WriteFloat(VAR field: ARRAY OF CHAR; x: REAL; cbase: CARDINAL;
                        dp: CARDINAL);
   PROCEDURE WriteFix(VAR field: ARRAY OF CHAR; x: REAL; cbase: CARDINAL;
                      VAR dp: CARDINAL);

END RealConv.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.24 ulm-lib-gm2/std/RealInOut

 
DEFINITION MODULE RealInOut; (* AFB 6/84 * rev. wsc 2/85 *)

   FROM StdIO IMPORT FILE;

   VAR
      Done: BOOLEAN;

   (*
    *	Read REAL number x according to syntax:
    *
    *	["+" | "-"] digit { digit } ["." digit { digit } ]
    *	["E" ["+" | "-"] digit [digit] ]
    *
    *	Done := "a number was read".
    *
    *	at most 16 digits are significant, leading zeroes not
    *	counting. Maximum exponent is 76. Input terminates
    *	with a blank or any control character.
    *)

   PROCEDURE ReadReal(VAR x: REAL);

   PROCEDURE FreadReal(f: FILE; VAR x: REAL);

   (*
    *	Write x using n characters. If fewer than n characters
    *	are needed, leading blanks are inserted.
    *)

   PROCEDURE WriteReal(x: REAL; n: CARDINAL);

   PROCEDURE FwriteReal(f: FILE; x: REAL; n: CARDINAL);

   (*
    *	Write x in fixed point notation using pd digits in front
    *	of decimal point and dp digits behind decial point. If
    *	fewer than pd digits are needed, leading blanks are
    *	inserted.
    *)

   PROCEDURE WriteFloat(x: REAL; pd: CARDINAL; dp: CARDINAL);

   PROCEDURE FwriteFloat(f: FILE; x: REAL; pd: CARDINAL; dp: CARDINAL);

   (*
    *	Write x in octal/hexadecimal form with exponent and mantissa
    *)

   PROCEDURE WriteRealOct(x: REAL);

   PROCEDURE FwriteRealOct(f: FILE; x: REAL);

   PROCEDURE WriteRealHex(x: REAL);

   PROCEDURE FwriteRealHex(f: FILE; x: REAL);

END RealInOut.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.25 ulm-lib-gm2/std/ScanPwfile

 
DEFINITION MODULE ScanPwfile;
(*
 *	utility functions for modules Passwd and EtcGroup
 *
 *	Martin Hasch, University of Ulm, Dec-06-1988
 *)

   FROM StdIO IMPORT FILE;
   FROM ASCII IMPORT nl;

   CONST
      fieldsep = ":";
      linesep = nl;

   PROCEDURE ReRead(pwfile: FILE): BOOLEAN;

   PROCEDURE GetText(pwfile: FILE; VAR text: ARRAY OF CHAR; sepchar: CHAR): BOOLEAN;

   PROCEDURE GetNumber(pwfile: FILE; VAR number: CARDINAL; sepchar: CHAR): BOOLEAN;

END ScanPwfile.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.26 ulm-lib-gm2/std/StdFuncs

 
DEFINITION MODULE StdFuncs;

END StdFuncs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.27 ulm-lib-gm2/std/StdIO

 
DEFINITION MODULE StdIO; (* AFB 1/84 *)

   FROM SYSTEM IMPORT ADDRESS;
   FROM SystemTypes IMPORT OFF;

   TYPE
      FILE; (* hidden *)
      MODE = (read, write, append);

   VAR
      stdin, stdout, stderr: FILE;

   (* all functions return FALSE in error case *)

   PROCEDURE Fopen(VAR f: FILE; name: ARRAY OF CHAR; mode: MODE;
		   buffered: BOOLEAN) : BOOLEAN;

   PROCEDURE Fclose(f: FILE) : BOOLEAN;

   PROCEDURE Fread(ptr: ADDRESS; size: CARDINAL; VAR nitems: CARDINAL;
		   f: FILE) : BOOLEAN;

   PROCEDURE Fwrite(ptr: ADDRESS; size: CARDINAL; VAR nitems: CARDINAL;
		    f: FILE) : BOOLEAN;

   PROCEDURE Fseek(f: FILE; offset: OFF; whence: CARDINAL) : BOOLEAN;

   PROCEDURE Ftell(f: FILE; VAR pos: OFF) : BOOLEAN;

   PROCEDURE Feof(f: FILE) : BOOLEAN;

   PROCEDURE Ferror(f: FILE) : BOOLEAN;

   PROCEDURE Fgetc(VAR ch: CHAR; f: FILE) : BOOLEAN;

   PROCEDURE Fputc(ch: CHAR; f: FILE) : BOOLEAN;

   PROCEDURE Fungetc(ch: CHAR; f: FILE) : BOOLEAN;

   PROCEDURE CloseAll() : BOOLEAN;

   PROCEDURE Fflush(f: FILE) : BOOLEAN;

   PROCEDURE Fdopen(VAR f: FILE; filedesc: CARDINAL; mode: MODE;
                    buffered: BOOLEAN) : BOOLEAN;

   PROCEDURE FileNo(f: FILE) : CARDINAL;

END StdIO.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.28 ulm-lib-gm2/std/Storage

 
DEFINITION MODULE Storage;              (* A. Borchert *)

   FROM SYSTEM IMPORT ADDRESS;

   PROCEDURE ALLOCATE(VAR ptr:ADDRESS; size: CARDINAL);

   PROCEDURE DEALLOCATE(VAR ptr:ADDRESS; size: CARDINAL);

   PROCEDURE Setmode(m: CARDINAL);

END Storage.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.29 ulm-lib-gm2/std/StrSpec

 
DEFINITION MODULE StrSpec;		(* gsk 1/85 *)

   PROCEDURE StrPartCpy ( VAR target           : ARRAY OF CHAR;
			      source           : ARRAY OF CHAR;
			      position, number : CARDINAL );

   PROCEDURE StrDel ( VAR target           : ARRAY OF CHAR ;
			  position, number : CARDINAL );

   PROCEDURE StrIns ( VAR target      : ARRAY OF CHAR;
			  insertion   : ARRAY OF CHAR;
			  position    : CARDINAL );

   PROCEDURE StrPos ( source, search : ARRAY OF CHAR ) : CARDINAL;

END StrSpec.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.30 ulm-lib-gm2/std/StrToNum

 
DEFINITION MODULE StrToNum; (* mh 5/85; rev afb 4/86: StrToOct/StrToHex *)

   PROCEDURE StrToCard(str: ARRAY OF CHAR; VAR card: CARDINAL): BOOLEAN;
	(* converts str to the CARDINAL card. Leading spaces, tabs and new-
	 * lines are ignored. Returns FALSE if str is not of the syntax:
	 *   [+] {digit} , or if the resulting number exceeds CARDINAL range.
	 *)

   PROCEDURE StrToInt(str: ARRAY OF CHAR; VAR integ: INTEGER): BOOLEAN;
	(* converts str to the INTEGER integ in analogue manner.
	 * Required syntax of str here:  [+|-] {digit} .
	 *)

   PROCEDURE StrToOct(str: ARRAY OF CHAR; VAR card: CARDINAL) : BOOLEAN;

   PROCEDURE StrToHex(str: ARRAY OF CHAR; VAR card: CARDINAL) : BOOLEAN;

END StrToNum.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.31 ulm-lib-gm2/std/StrToReal

 
DEFINITION MODULE StrToReal;

   PROCEDURE StrToReal(str: ARRAY OF CHAR; VAR real: REAL) : BOOLEAN;
      (* converts str to the REAL real, leading white space is
	 ignored, returns FALSE if str does not conform to following
	 syntax:
	    ["+" | "-"] digit { digit } ["." digit { digit } ]
	    ["E" ["+" | "-"] digit [digit] ]
      *)

END StrToReal.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.32 ulm-lib-gm2/std/Strings

 
DEFINITION MODULE Strings; (* AFB 7/84 *)

   PROCEDURE StrLen(s: ARRAY OF CHAR) : CARDINAL;

   PROCEDURE StrCat(VAR s: ARRAY OF CHAR; s1: ARRAY OF CHAR);

   PROCEDURE StrCmp(s1, s2: ARRAY OF CHAR) : INTEGER;

   PROCEDURE StrCpy(VAR s: ARRAY OF CHAR; s1: ARRAY OF CHAR);

END Strings.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.33 ulm-lib-gm2/std/SysConf

 
DEFINITION MODULE SysConf; (* AFB 2/97 *)

   (* configuration parameters of the installation *)

   PROCEDURE GetLibDir(VAR libdirBuf: ARRAY OF CHAR);
      (* GetLibDir returns the directory where the Modula-2 library
         has been installed to; it does not honour the MODLIB
	 environment variable
      *)

   PROCEDURE GetRelease(VAR releaseBuf: ARRAY OF CHAR);
      (* returns the release of the Modula-2 installation *)

END SysConf.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.34 ulm-lib-gm2/std/SysPerror

 
DEFINITION MODULE SysPerror; (* AFB 2/84 *)

   PROCEDURE Perror(str: ARRAY OF CHAR);

   PROCEDURE GetErrorString(errno: CARDINAL; VAR str: ARRAY OF CHAR);

END SysPerror.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.35 ulm-lib-gm2/std/Terminal

 
DEFINITION MODULE Terminal; (* A. Borchert *)

   (* read and write from/to standard input/output channel *)

   VAR Done: BOOLEAN;

   PROCEDURE Read(VAR ch: CHAR);

   PROCEDURE ReadAgain;

   PROCEDURE Write(ch: CHAR);

   PROCEDURE WriteLn;

   PROCEDURE WriteString(s: ARRAY OF CHAR);

END Terminal.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6.36 ulm-lib-gm2/std/TimeIO

 
DEFINITION MODULE TimeIO; (* AFB 9/88 *)

   FROM Calendar IMPORT Time, Date;
   FROM StdIO IMPORT FILE;

   TYPE
      Style = (date,	(* date(1) and ctime(3) standard format *)
	       ls,	(* like the ls-command *)
	       env);	(* see for TIMEFMT in environment *)
   VAR
      Done: BOOLEAN;
      termCH: CHAR;

   PROCEDURE WriteTime(format: ARRAY OF CHAR; time: Time);
      (* the output format is very close to date(1): *)
      (* each field descriptor is preceded by % and will be *)
      (* replaced in the output by its corresponding value. *)
      (* WriteTime does not append a newline automatically  *)
      (* like date(1).                                      *)
      (* output is directed to StdIO.stdout                 *)

   PROCEDURE FwriteTime(file: FILE; format: ARRAY OF CHAR; time: Time);
      (* like WriteTime but output is directed to file      *)

   PROCEDURE SwriteTime(VAR string: ARRAY OF CHAR;
			format: ARRAY OF CHAR;
			time: Time);
      (* like WriteTime but output is put into string       *)

   PROCEDURE WriteTimeLike(style: Style; time: Time);
      (* write time to StdIO.stdout according to the given  *)
      (* style.                                             *)

   PROCEDURE FwriteTimeLike(file: FILE; style: Style; time: Time);

   PROCEDURE SwriteTimeLike(VAR string: ARRAY OF CHAR;
			    style: Style; time: Time);

   PROCEDURE ReadTime(VAR time: Time);
      (* read time from StdIO.stdin *)

   PROCEDURE FreadTime(file: FILE; VAR time: Time);

   PROCEDURE SreadTime(string: ARRAY OF CHAR; VAR time: Time);

   PROCEDURE WriteDate(format: ARRAY OF CHAR; date: Date);

   PROCEDURE FwriteDate(file: FILE; format: ARRAY OF CHAR; date: Date);

   PROCEDURE SwriteDate(VAR string: ARRAY OF CHAR;
			format: ARRAY OF CHAR; date: Date);

   PROCEDURE ReadDate(VAR date: Date);

   PROCEDURE FreadDate(file: FILE; VAR date: Date);

   PROCEDURE SreadDate(string: ARRAY OF CHAR; VAR date: Date);

   (* Reading  depends on a set of pattern describing valid      *)
   (* input formats. This formats are stored in an ordered list. *)
   (* If more than one pattern matches the input the first will  *)
   (* be chosen.                                                 *)
   (* Pattern consists of a sequence of letters and some special *)
   (* chars which must match the input. Whitespace (except nl)   *)
   (* is skipped by ReadTime and must not be given inside a      *)
   (* pattern.                                                   *)
   (* Legal Letters:                                             *)
   (*   'y': year, 'm': month,  'd': day                         *)
   (*   'H': hour, 'M': minute, 'S': second                      *)
   (* Examples:                                                  *)
   (*   m/d/yH:M:S        us-date, matches 10/22/86 13:12:14     *)
   (*   d.m.yH:M:S        german date, matches 22.10.86 13:12:14 *)
   (*   md,y              matches Oct 22, 1986                   *)

   PROCEDURE Append(pattern: ARRAY OF CHAR);
      (* appends a new pattern to the end of the list *)

   PROCEDURE Insert(pattern: ARRAY OF CHAR);
      (* inserts a pattern before the beginning of the list *)

   PROCEDURE ReleaseList;
      (* causes the list to be emptied *)

   PROCEDURE DefaultList;
      (* appends a list of standard patterns to the list *)
      (* this procedure is called during initialization of TimeIO *)

END TimeIO.
Jump to:   A   B   C   D   E   F   G   H   I   K   L   M   N   O   P   Q   R   S   T   U   V   W  
Index Entry Section

A
abort5.1.35 gm2-libs/libc
abs5.4.4 gm2-iso/ComplexMath
ABS1.7.1 Standard procedures and functions common to PIM and ISO
abs5.4.12 gm2-iso/LongComplex
acos5.1.36 gm2-libs/libm
acosf5.1.36 gm2-libs/libm
acosl5.1.36 gm2-libs/libm
Activate5.4.21 gm2-iso/Processes
ActualParameters (ebnf)4. EBNF of GNU Modula-2
Add5.1.8 gm2-libs/DynamicStrings
ADDADR5.4.35 gm2-iso/SYSTEM
AddOperator (ebnf)4. EBNF of GNU Modula-2
ADR5.4.35 gm2-iso/SYSTEM
Again5.2.9 gm2-libs-pim/FileSystem
Alarm5.5.5 ulm-lib-gm2/sys/SysAlarm
AllArgs5.6.3 ulm-lib-gm2/std/Arguments
alloca5.1.5 gm2-libs/Builtins
alloca5.1.34 gm2-libs/cbuiltin
ALLOCATE5.1.26 gm2-libs/Storage
ALLOCATE5.1.31 gm2-libs/SysStorage
ALLOCATE5.4.39 gm2-iso/Storage
ALLOCATE5.6.28 ulm-lib-gm2/std/Storage
AllocateDeviceId5.4.10 gm2-iso/IOLink
AllocateSource5.4.6 gm2-iso/EXCEPTIONS
Append5.4.41 gm2-iso/Strings
Append5.6.36 ulm-lib-gm2/std/TimeIO
Arc5.6.19 ulm-lib-gm2/std/Plot
arccos5.4.4 gm2-iso/ComplexMath
arccos5.4.12 gm2-iso/LongComplex
arccos5.4.15 gm2-iso/LongMath
arccos5.4.26 gm2-iso/RealMath
ArchiveClose5.6.2 ulm-lib-gm2/std/Archive
ArchiveOpen5.6.2 ulm-lib-gm2/std/Archive
ArchiveRead5.6.2 ulm-lib-gm2/std/Archive
ArchiveReopen5.6.2 ulm-lib-gm2/std/Archive
ArchiveStat5.6.2 ulm-lib-gm2/std/Archive
arcsin5.4.4 gm2-iso/ComplexMath
arcsin5.4.12 gm2-iso/LongComplex
arcsin5.4.15 gm2-iso/LongMath
arcsin5.4.26 gm2-iso/RealMath
arctan5.1.15 gm2-libs/MathLib0
arctan5.4.4 gm2-iso/ComplexMath
arctan5.4.12 gm2-iso/LongComplex
arctan5.4.15 gm2-iso/LongMath
arctan5.4.26 gm2-iso/RealMath
arctans5.1.15 gm2-libs/MathLib0
arg5.4.4 gm2-iso/ComplexMath
arg5.4.12 gm2-iso/LongComplex
ArgChan5.4.22 gm2-iso/ProgramArgs
ArmEvent5.3.6 gm2-libs-coroutines/TimerHandler
ArraySubscriptError5.1.14 gm2-libs/M2RTS
ArraySubscriptError5.4.20 gm2-iso/M2RTS
ArrayType (ebnf)4. EBNF of GNU Modula-2
asin5.1.36 gm2-libs/libm
asinf5.1.36 gm2-libs/libm
asinl5.1.36 gm2-libs/libm
AsmElement (ebnf)4. EBNF of GNU Modula-2
AsmList (ebnf)4. EBNF of GNU Modula-2
AsmOperands (ebnf)4. EBNF of GNU Modula-2
AsmStatement (ebnf)4. EBNF of GNU Modula-2
Assert5.1.3 gm2-libs/Assertion
Assign5.1.8 gm2-libs/DynamicStrings
Assign5.2.17 gm2-libs-pim/Strings
Assign5.4.41 gm2-iso/Strings
AssignmentOrProcedureCall (ebnf)4. EBNF of GNU Modula-2
AssignRead5.2.18 gm2-libs-pim/Termbase
AssignWrite5.2.18 gm2-libs-pim/Termbase
atan5.1.36 gm2-libs/libm
atanf5.1.36 gm2-libs/libm
atanl5.1.36 gm2-libs/libm
Attach5.4.21 gm2-iso/Processes
ATTACH5.4.1 gm2-iso/COROUTINES
AttachVector5.3.5 gm2-libs-coroutines/SysVec
Available5.1.26 gm2-libs/Storage
Available5.1.31 gm2-libs/SysStorage

B
Baudrate5.5.16 ulm-lib-gm2/sys/SysIoctl
Baudrate5.5.29 ulm-lib-gm2/sys/SysTermIO
BinToStr5.1.17 gm2-libs/NumberIO
Block (ebnf)4. EBNF of GNU Modula-2
Break5.5.6 ulm-lib-gm2/sys/SysBreak
bstoc5.1.30 gm2-libs/StringConvert
bstoi5.1.30 gm2-libs/StringConvert
Builtin (ebnf)4. EBNF of GNU Modula-2

C
CanAppendAll5.4.41 gm2-iso/Strings
CanAssignAll5.4.41 gm2-iso/Strings
Cancel5.3.6 gm2-libs-coroutines/TimerHandler
CanConcatAll5.4.41 gm2-iso/Strings
CanDeleteAll5.4.41 gm2-iso/Strings
CanExtractAll5.4.41 gm2-iso/Strings
CanGetClock5.4.42 gm2-iso/SysClock
CanInsertAll5.4.41 gm2-iso/Strings
CanReplaceAll5.4.41 gm2-iso/Strings
CanSetClock5.4.42 gm2-iso/SysClock
CAP1.7.1 Standard procedures and functions common to PIM and ISO
Cap5.1.27 gm2-libs/StrCase
Capitalize5.4.41 gm2-iso/Strings
CardinalToString5.1.30 gm2-libs/StringConvert
CardToStr5.1.17 gm2-libs/NumberIO
CardToStr5.4.48 gm2-iso/WholeStr
Case (ebnf)4. EBNF of GNU Modula-2
CaseElseError5.1.14 gm2-libs/M2RTS
CaseElseError5.4.20 gm2-iso/M2RTS
CaseLabelList (ebnf)4. EBNF of GNU Modula-2
CaseLabels (ebnf)4. EBNF of GNU Modula-2
CaseStatement (ebnf)4. EBNF of GNU Modula-2
CAST5.4.35 gm2-iso/SYSTEM
CDate5.6.4 ulm-lib-gm2/std/Calendar
ceil5.1.36 gm2-libs/libm
ceilf5.1.36 gm2-libs/libm
ceill5.1.36 gm2-libs/libm
cfgetispeed5.5.36 ulm-lib-gm2/sys/termios
cfgetospeed5.5.36 ulm-lib-gm2/sys/termios
cfsetispeed5.5.36 ulm-lib-gm2/sys/termios
cfsetospeed5.5.36 ulm-lib-gm2/sys/termios
cfsetspeed5.5.36 ulm-lib-gm2/sys/termios
ChanException5.4.8 gm2-iso/IOChan
char5.1.8 gm2-libs/DynamicStrings
CharMod5.6.19 ulm-lib-gm2/std/Plot
chown5.1.35 gm2-libs/libc
CHR1.7.1 Standard procedures and functions common to PIM and ISO
Circle5.6.19 ulm-lib-gm2/std/Plot
Claim5.4.36 gm2-iso/Semaphores
Close5.1.10 gm2-libs/FIO
close5.1.35 gm2-libs/libc
Close5.1.18 gm2-libs/PushBackInput
Close5.2.9 gm2-libs-pim/FileSystem
Close5.4.28 gm2-iso/RndFile
Close5.4.37 gm2-iso/SeqFile
Close5.4.40 gm2-iso/StreamFile
Close5.4.44 gm2-iso/TermFile
Close5.6.11 ulm-lib-gm2/std/Files
CloseAll5.6.27 ulm-lib-gm2/std/StdIO
CloseDir5.6.8 ulm-lib-gm2/std/Directories
CloseGr5.6.10 ulm-lib-gm2/std/EtcGroup
CloseInput5.2.11 gm2-libs-pim/InOut
CloseOutput5.2.11 gm2-libs-pim/InOut
ClosePlot5.6.19 ulm-lib-gm2/std/Plot
ClosePw5.6.17 ulm-lib-gm2/std/Passwd
CloseSource5.1.23 gm2-libs/Scan
Compare5.4.41 gm2-iso/Strings
CompareStr5.2.17 gm2-libs-pim/Strings
CompareTime5.2.20 gm2-libs-pim/TimeDate
ConCat5.1.8 gm2-libs/DynamicStrings
Concat5.4.41 gm2-iso/Strings
ConCat5.2.17 gm2-libs-pim/Strings
ConCatChar5.1.8 gm2-libs/DynamicStrings
CondClaim5.4.36 gm2-iso/Semaphores
conj5.4.4 gm2-iso/ComplexMath
conj5.4.12 gm2-iso/LongComplex
ConstActualParameters (ebnf)4. EBNF of GNU Modula-2
ConstantDeclaration (ebnf)4. EBNF of GNU Modula-2
ConstAttribute (ebnf)4. EBNF of GNU Modula-2
ConstExpression (ebnf)4. EBNF of GNU Modula-2
ConstFactor (ebnf)4. EBNF of GNU Modula-2
ConstSetOrQualidentOrFunction (ebnf)4. EBNF of GNU Modula-2
ConstString (ebnf)4. EBNF of GNU Modula-2
ConstTerm (ebnf)4. EBNF of GNU Modula-2
Cont5.6.19 ulm-lib-gm2/std/Plot
ConvertCald5.6.4 ulm-lib-gm2/std/Calendar
ConvertCardinal5.2.3 gm2-libs-pim/Conversions
ConvertCardinal5.6.7 ulm-lib-gm2/std/Conversions
ConvertDate5.6.4 ulm-lib-gm2/std/Calendar
ConvertHex5.2.3 gm2-libs-pim/Conversions
ConvertHex5.6.7 ulm-lib-gm2/std/Conversions
ConvertInteger5.2.3 gm2-libs-pim/Conversions
ConvertInteger5.6.7 ulm-lib-gm2/std/Conversions
ConvertLongInt5.2.3 gm2-libs-pim/Conversions
ConvertOctal5.2.3 gm2-libs-pim/Conversions
ConvertShortInt5.2.3 gm2-libs-pim/Conversions
ConvertTime5.6.4 ulm-lib-gm2/std/Calendar
Copy5.2.17 gm2-libs-pim/Strings
Copy5.5.35 ulm-lib-gm2/sys/UnixString
CopyOut5.1.8 gm2-libs/DynamicStrings
cos5.1.5 gm2-libs/Builtins
cos5.1.15 gm2-libs/MathLib0
cos5.1.34 gm2-libs/cbuiltin
cos5.1.36 gm2-libs/libm
cos5.4.4 gm2-iso/ComplexMath
cos5.4.12 gm2-iso/LongComplex
cos5.4.15 gm2-iso/LongMath
cos5.4.26 gm2-iso/RealMath
cos5.6.16 ulm-lib-gm2/std/MathLib
cosf5.1.5 gm2-libs/Builtins
cosf5.1.34 gm2-libs/cbuiltin
cosf5.1.36 gm2-libs/libm
cosl5.1.5 gm2-libs/Builtins
cosl5.1.15 gm2-libs/MathLib0
cosl5.1.34 gm2-libs/cbuiltin
cosl5.1.36 gm2-libs/libm
coss5.1.15 gm2-libs/MathLib0
CPUTime5.6.6 ulm-lib-gm2/std/Clock
creat5.1.35 gm2-libs/libc
Create5.2.9 gm2-libs-pim/FileSystem
Create5.4.21 gm2-iso/Processes
Create5.4.36 gm2-iso/Semaphores
CTime5.6.4 ulm-lib-gm2/std/Calendar
ctos5.1.30 gm2-libs/StringConvert
CUltimo5.6.4 ulm-lib-gm2/std/Calendar
CURRENT5.4.1 gm2-iso/COROUTINES
CurrentFlags5.4.8 gm2-iso/IOChan
currentMode5.4.17 gm2-iso/LowLong
currentMode5.4.18 gm2-iso/LowReal
CurrentNumber5.4.6 gm2-iso/EXCEPTIONS
CurrentPos5.4.28 gm2-iso/RndFile
CurrentTime5.6.4 ulm-lib-gm2/std/Calendar
CWeekday5.6.4 ulm-lib-gm2/std/Calendar

D
DateOK5.6.4 ulm-lib-gm2/std/Calendar
DEALLOCATE5.1.26 gm2-libs/Storage
DEALLOCATE5.1.31 gm2-libs/SysStorage
DEALLOCATE5.4.39 gm2-iso/Storage
DEALLOCATE5.6.28 ulm-lib-gm2/std/Storage
DebugProcess5.3.2 gm2-libs-coroutines/Executive
DebugString5.1.7 gm2-libs/Debug
DebugString5.3.1 gm2-libs-coroutines/Debug
DEC1.7.1 Standard procedures and functions common to PIM and ISO
Declaration (ebnf)4. EBNF of GNU Modula-2
DefaultList5.6.36 ulm-lib-gm2/std/TimeIO
DefExtendedFP (ebnf)4. EBNF of GNU Modula-2
DefFormalParameters (ebnf)4. EBNF of GNU Modula-2
DefineBuiltinProcedure (ebnf)4. EBNF of GNU Modula-2
DefineComments5.1.23 gm2-libs/Scan
Definition (ebnf)4. EBNF of GNU Modula-2
DefinitionModule (ebnf)4. EBNF of GNU Modula-2
DefMultiFPSection (ebnf)4. EBNF of GNU Modula-2
DefOptArg (ebnf)4. EBNF of GNU Modula-2
DefProcedureHeading (ebnf)4. EBNF of GNU Modula-2
Delay5.2.6 gm2-libs-pim/Delay
Delete5.2.9 gm2-libs-pim/FileSystem
Delete5.2.17 gm2-libs-pim/Strings
Delete5.4.41 gm2-iso/Strings
Delete5.6.11 ulm-lib-gm2/std/Files
Designator (ebnf)4. EBNF of GNU Modula-2
Destroy5.4.36 gm2-iso/Semaphores
DETACH5.4.1 gm2-iso/COROUTINES
Detach5.4.21 gm2-iso/Processes
DeviceError5.4.8 gm2-iso/IOChan
DeviceTablePtrValue5.4.10 gm2-iso/IOLink
DIFADR5.4.35 gm2-iso/SYSTEM
DisableBreak5.2.1 gm2-libs-pim/Break
DISPOSE1.7.1 Standard procedures and functions common to PIM and ISO
DisposeFunction5.6.13 ulm-lib-gm2/std/Functions
Doio5.2.9 gm2-libs-pim/FileSystem
Dup5.1.8 gm2-libs/DynamicStrings
dup5.1.35 gm2-libs/libc
Dup25.5.9 ulm-lib-gm2/sys/SysDup

E
Element (ebnf)4. EBNF of GNU Modula-2
EnableBreak5.2.1 gm2-libs-pim/Break
EndPos5.4.28 gm2-iso/RndFile
EnterCleanup5.5.11 ulm-lib-gm2/sys/SysExit
entier5.1.15 gm2-libs/MathLib0
entiers5.1.15 gm2-libs/MathLib0
Enumeration (ebnf)4. EBNF of GNU Modula-2
EnvPar5.6.9 ulm-lib-gm2/std/Environment
EOF5.1.10 gm2-libs/FIO
EOLN5.1.10 gm2-libs/FIO
Equal5.1.8 gm2-libs/DynamicStrings
Equal5.4.41 gm2-iso/Strings
EqualArray5.1.8 gm2-libs/DynamicStrings
EqualCharStar5.1.8 gm2-libs/DynamicStrings
Erase5.6.19 ulm-lib-gm2/std/Plot
ErrChan5.4.38 gm2-iso/StdChans
Error5.1.13 gm2-libs/IO
Error5.1.18 gm2-libs/PushBackInput
EvalFunction5.6.13 ulm-lib-gm2/std/Functions
EXCL1.7.1 Standard procedures and functions common to PIM and ISO
ExcludeVector5.3.5 gm2-libs-coroutines/SysVec
Exec5.5.10 ulm-lib-gm2/sys/SysExec
Exece5.5.10 ulm-lib-gm2/sys/SysExec
Exists5.1.10 gm2-libs/FIO
exists5.1.10 gm2-libs/FIO
Exists5.1.21 gm2-libs/SFIO
exit5.1.35 gm2-libs/libc
ExitOnHalt5.1.14 gm2-libs/M2RTS
ExitOnHalt5.4.20 gm2-iso/M2RTS
ExitToOS5.2.8 gm2-libs-pim/ErrorCode
exp5.1.5 gm2-libs/Builtins
exp5.1.15 gm2-libs/MathLib0
exp5.1.34 gm2-libs/cbuiltin
exp5.1.36 gm2-libs/libm
exp5.4.4 gm2-iso/ComplexMath
exp5.4.12 gm2-iso/LongComplex
exp5.4.15 gm2-iso/LongMath
exp5.4.26 gm2-iso/RealMath
exp5.6.16 ulm-lib-gm2/std/MathLib
expf5.1.5 gm2-libs/Builtins
expf5.1.34 gm2-libs/cbuiltin
expf5.1.36 gm2-libs/libm
expl5.1.5 gm2-libs/Builtins
expl5.1.34 gm2-libs/cbuiltin
expl5.1.36 gm2-libs/libm
ExpList (ebnf)4. EBNF of GNU Modula-2
exponent5.4.17 gm2-iso/LowLong
exponent5.4.18 gm2-iso/LowReal
Export (ebnf)4. EBNF of GNU Modula-2
Expression (ebnf)4. EBNF of GNU Modula-2
exps5.1.15 gm2-libs/MathLib0
ExtendedFP (ebnf)4. EBNF of GNU Modula-2
Extract5.4.41 gm2-iso/Strings

F
fabs5.1.5 gm2-libs/Builtins
fabs5.1.34 gm2-libs/cbuiltin
fabsf5.1.5 gm2-libs/Builtins
fabsf5.1.34 gm2-libs/cbuiltin
fabsl5.1.5 gm2-libs/Builtins
fabsl5.1.34 gm2-libs/cbuiltin
Factor (ebnf)4. EBNF of GNU Modula-2
Fclose5.6.27 ulm-lib-gm2/std/StdIO
Fcntl5.5.12 ulm-lib-gm2/sys/SysFcntl
FdClr5.1.24 gm2-libs/Selective
FdIsSet5.1.24 gm2-libs/Selective
Fdopen5.6.27 ulm-lib-gm2/std/StdIO
FdSet5.1.24 gm2-libs/Selective
FdZero5.1.24 gm2-libs/Selective
Feof5.6.27 ulm-lib-gm2/std/StdIO
Ferror5.6.27 ulm-lib-gm2/std/StdIO
FetchCard5.6.3 ulm-lib-gm2/std/Arguments
FetchGrgid5.6.10 ulm-lib-gm2/std/EtcGroup
FetchGrnam5.6.10 ulm-lib-gm2/std/EtcGroup
FetchHex5.6.3 ulm-lib-gm2/std/Arguments
FetchInt5.6.3 ulm-lib-gm2/std/Arguments
FetchOct5.6.3 ulm-lib-gm2/std/Arguments
FetchPwnam5.6.17 ulm-lib-gm2/std/Passwd
FetchPwuid5.6.17 ulm-lib-gm2/std/Passwd
FetchString5.6.3 ulm-lib-gm2/std/Arguments
Fflush5.6.27 ulm-lib-gm2/std/StdIO
Fgetc5.6.27 ulm-lib-gm2/std/StdIO
FieldList (ebnf)4. EBNF of GNU Modula-2
FieldListSequence (ebnf)4. EBNF of GNU Modula-2
FieldListStatement (ebnf)4. EBNF of GNU Modula-2
filemtime5.1.37 gm2-libs/wrapc
FileNameChar5.2.9 gm2-libs-pim/FileSystem
FileNo5.6.27 ulm-lib-gm2/std/StdIO
filesize5.1.37 gm2-libs/wrapc
FileUnit (ebnf)4. EBNF of GNU Modula-2
Fin5.1.8 gm2-libs/DynamicStrings
FindDiff5.4.41 gm2-iso/Strings
FindNext5.4.41 gm2-iso/Strings
FindPosition5.1.10 gm2-libs/FIO
FindPrev5.4.41 gm2-iso/Strings
FirstParam5.6.13 ulm-lib-gm2/std/Functions
Flip5.6.21 ulm-lib-gm2/std/RandomGenerator
Float5.2.10 gm2-libs-pim/FloatingUtilities
Floatl5.2.10 gm2-libs-pim/FloatingUtilities
floor5.1.36 gm2-libs/libm
floorf5.1.36 gm2-libs/libm
floorl5.1.36 gm2-libs/libm
Flush5.4.8 gm2-iso/IOChan
Fopen5.6.27 ulm-lib-gm2/std/StdIO
Fork5.5.13 ulm-lib-gm2/sys/SysFork
FormalParameters (ebnf)4. EBNF of GNU Modula-2
FormalReturn (ebnf)4. EBNF of GNU Modula-2
FormalType (ebnf)4. EBNF of GNU Modula-2
FormalTypeList (ebnf)4. EBNF of GNU Modula-2
FormatCard5.4.46 gm2-iso/WholeConv
FormatInt5.4.46 gm2-iso/WholeConv
FormatReal5.4.13 gm2-iso/LongConv
FormatReal5.4.24 gm2-iso/RealConv
ForStatement (ebnf)4. EBNF of GNU Modula-2
FPSection (ebnf)4. EBNF of GNU Modula-2
Fputc5.6.27 ulm-lib-gm2/std/StdIO
Frac5.2.10 gm2-libs-pim/FloatingUtilities
Fracl5.2.10 gm2-libs-pim/FloatingUtilities
fraction5.4.17 gm2-iso/LowLong
fraction5.4.18 gm2-iso/LowReal
fractpart5.4.17 gm2-iso/LowLong
fractpart5.4.18 gm2-iso/LowReal
Fread5.6.12 ulm-lib-gm2/std/FtdIO
Fread5.6.27 ulm-lib-gm2/std/StdIO
FreadCard5.6.12 ulm-lib-gm2/std/FtdIO
FreadChar5.6.12 ulm-lib-gm2/std/FtdIO
FreadDate5.6.36 ulm-lib-gm2/std/TimeIO
FreadInt5.6.12 ulm-lib-gm2/std/FtdIO
FreadReal5.6.24 ulm-lib-gm2/std/RealInOut
FreadString5.6.12 ulm-lib-gm2/std/FtdIO
FreadTime5.6.36 ulm-lib-gm2/std/TimeIO
FreadWord5.6.12 ulm-lib-gm2/std/FtdIO
free5.1.35 gm2-libs/libc
Fseek5.6.27 ulm-lib-gm2/std/StdIO
Fstat5.5.28 ulm-lib-gm2/sys/SysStat
Ftell5.6.27 ulm-lib-gm2/std/StdIO
FunctionReturnError5.1.14 gm2-libs/M2RTS
FunctionReturnError5.4.20 gm2-iso/M2RTS
Fungetc5.6.27 ulm-lib-gm2/std/StdIO
Fwrite5.6.12 ulm-lib-gm2/std/FtdIO
Fwrite5.6.27 ulm-lib-gm2/std/StdIO
FwriteCard5.6.12 ulm-lib-gm2/std/FtdIO
FwriteChar5.6.12 ulm-lib-gm2/std/FtdIO
FwriteDate5.6.36 ulm-lib-gm2/std/TimeIO
FwriteFloat5.6.24 ulm-lib-gm2/std/RealInOut
FwriteInt5.6.12 ulm-lib-gm2/std/FtdIO
FwriteLn5.6.12 ulm-lib-gm2/std/FtdIO
FwriteReal5.6.24 ulm-lib-gm2/std/RealInOut
FwriteRealHex5.6.24 ulm-lib-gm2/std/RealInOut
FwriteRealOct5.6.24 ulm-lib-gm2/std/RealInOut
FwriteString5.6.12 ulm-lib-gm2/std/FtdIO
FwriteTime5.6.36 ulm-lib-gm2/std/TimeIO
FwriteTimeLike5.6.36 ulm-lib-gm2/std/TimeIO
FwriteWord5.6.12 ulm-lib-gm2/std/FtdIO

G
GeneralException5.4.7 gm2-iso/GeneralUser
GetArg5.1.2 gm2-libs/Args
GetArg5.1.6 gm2-libs/CmdArgs
GetArg5.1.19 gm2-libs/SArgs
GetArg5.6.3 ulm-lib-gm2/std/Arguments
GetCh5.1.18 gm2-libs/PushBackInput
GetChar5.5.36 ulm-lib-gm2/sys/termios
GetClock5.4.42 gm2-iso/SysClock
GetColumnPosition5.1.18 gm2-libs/PushBackInput
GetCurrentLine5.1.18 gm2-libs/PushBackInput
GetCurrentOutput5.1.25 gm2-libs/StdIO
GetCurrentProcess5.3.2 gm2-libs-coroutines/Executive
getcwd5.1.35 gm2-libs/libc
Getegid5.5.15 ulm-lib-gm2/sys/SysGetuid
getenv5.1.35 gm2-libs/libc
GetEnvironment5.1.9 gm2-libs/Environment
GetEnvironment5.1.20 gm2-libs/SEnvironment
GetErrorCode5.2.8 gm2-libs-pim/ErrorCode
GetErrorString5.6.34 ulm-lib-gm2/std/SysPerror
Geteuid5.5.15 ulm-lib-gm2/sys/SysGetuid
GetExitStatus5.1.18 gm2-libs/PushBackInput
GetFlag5.5.36 ulm-lib-gm2/sys/termios
GetFlag5.6.3 ulm-lib-gm2/std/Arguments
Getgid5.5.15 ulm-lib-gm2/sys/SysGetuid
GetGrent5.6.10 ulm-lib-gm2/std/EtcGroup
GetGrgid5.6.10 ulm-lib-gm2/std/EtcGroup
GetGrnam5.6.10 ulm-lib-gm2/std/EtcGroup
GetLibDir5.6.33 ulm-lib-gm2/std/SysConf
GetLocaltime5.6.4 ulm-lib-gm2/std/Calendar
GetMessage5.4.6 gm2-iso/EXCEPTIONS
GetName5.4.8 gm2-iso/IOChan
getnameuidgid5.1.37 gm2-libs/wrapc
GetNextSymbol5.1.23 gm2-libs/Scan
GetNumber5.6.25 ulm-lib-gm2/std/ScanPwfile
GetOpt5.6.3 ulm-lib-gm2/std/Arguments
getpid5.1.35 gm2-libs/libc
Getpid5.5.14 ulm-lib-gm2/sys/SysGetpid
GetPos5.2.9 gm2-libs-pim/FileSystem
GetPos5.6.11 ulm-lib-gm2/std/Files
GetPwent5.6.17 ulm-lib-gm2/std/Passwd
GetPwnam5.6.17 ulm-lib-gm2/std/Passwd
GetPwuid5.6.17 ulm-lib-gm2/std/Passwd
getrand5.1.37 gm2-libs/wrapc
GetRelease5.6.33 ulm-lib-gm2/std/SysConf
GetTermIO5.5.29 ulm-lib-gm2/sys/SysTermIO
GetText5.6.25 ulm-lib-gm2/std/ScanPwfile
GetTicks5.3.6 gm2-libs-coroutines/TimerHandler
GetTime5.1.24 gm2-libs/Selective
GetTime5.2.20 gm2-libs-pim/TimeDate
GetTimeOfDay5.1.24 gm2-libs/Selective
GetTimeString5.1.32 gm2-libs/TimeString
GetTimeVector5.3.5 gm2-libs-coroutines/SysVec
GetTimezone5.6.4 ulm-lib-gm2/std/Calendar
GetUnixFileDescriptor5.1.10 gm2-libs/FIO
getusername5.1.37 gm2-libs/wrapc
GetWinsize5.5.16 ulm-lib-gm2/sys/SysIoctl
Gtty5.5.16 ulm-lib-gm2/sys/SysIoctl

H
HALT1.7.1 Standard procedures and functions common to PIM and ISO
Halt5.1.7 gm2-libs/Debug
HALT5.1.14 gm2-libs/M2RTS
Halt5.1.14 gm2-libs/M2RTS
HALT5.4.20 gm2-iso/M2RTS
Halt5.3.1 gm2-libs-coroutines/Debug
Halt5.4.20 gm2-iso/M2RTS
HANDLER5.4.1 gm2-iso/COROUTINES
Handler5.4.21 gm2-iso/Processes
HasHalted5.4.43 gm2-iso/TERMINATION
HexToStr5.1.17 gm2-libs/NumberIO
HIGH1.7.1 Standard procedures and functions common to PIM and ISO
hstoc5.1.30 gm2-libs/StringConvert
hstoi5.1.30 gm2-libs/StringConvert
huge_val5.1.5 gm2-libs/Builtins
huge_valf5.1.5 gm2-libs/Builtins
huge_vall5.1.5 gm2-libs/Builtins

I
Ident (ebnf)4. EBNF of GNU Modula-2
IdentList (ebnf)4. EBNF of GNU Modula-2
IdentScope (ebnf)4. EBNF of GNU Modula-2
IdentScopeList (ebnf)4. EBNF of GNU Modula-2
IfStatement (ebnf)4. EBNF of GNU Modula-2
ImplementationModule (ebnf)4. EBNF of GNU Modula-2
ImplementationOrProgramModule (ebnf)4. EBNF of GNU Modula-2
Import (ebnf)4. EBNF of GNU Modula-2
INC1.7.1 Standard procedures and functions common to PIM and ISO
InChan5.4.38 gm2-iso/StdChans
INCL1.7.1 Standard procedures and functions common to PIM and ISO
IncludeVector5.3.5 gm2-libs-coroutines/SysVec
index5.1.5 gm2-libs/Builtins
Index5.1.8 gm2-libs/DynamicStrings
index5.1.34 gm2-libs/cbuiltin
Init5.1.31 gm2-libs/SysStorage
Init5.6.21 ulm-lib-gm2/std/RandomGenerator
InitArgs5.6.3 ulm-lib-gm2/std/Arguments
InitInputVector5.3.5 gm2-libs-coroutines/SysVec
InitOutputVector5.3.5 gm2-libs-coroutines/SysVec
InitProcess5.3.2 gm2-libs-coroutines/Executive
InitSemaphore5.3.2 gm2-libs-coroutines/Executive
InitSet5.1.24 gm2-libs/Selective
InitString5.1.8 gm2-libs/DynamicStrings
InitStringChar5.1.8 gm2-libs/DynamicStrings
InitStringCharStar5.1.8 gm2-libs/DynamicStrings
InitTermios5.5.36 ulm-lib-gm2/sys/termios
InitTime5.1.24 gm2-libs/Selective
InitTimeVector5.3.5 gm2-libs-coroutines/SysVec
Insert5.2.17 gm2-libs-pim/Strings
Insert5.4.41 gm2-iso/Strings
Insert5.6.36 ulm-lib-gm2/std/TimeIO
InstallBreak5.2.1 gm2-libs-pim/Break
InstallStdConst5.6.13 ulm-lib-gm2/std/Functions
InstallStdFunc15.6.13 ulm-lib-gm2/std/Functions
InstallStdFunc25.6.13 ulm-lib-gm2/std/Functions
InstallTerminationProcedure5.1.14 gm2-libs/M2RTS
InstallTerminationProcedure5.4.20 gm2-iso/M2RTS
Int5.2.10 gm2-libs-pim/FloatingUtilities
Integer (ebnf)4. EBNF of GNU Modula-2
IntegerToString5.1.30 gm2-libs/StringConvert
Intl5.2.10 gm2-libs-pim/FloatingUtilities
intpart5.4.17 gm2-iso/LowLong
intpart5.4.18 gm2-iso/LowReal
IntToStr5.1.17 gm2-libs/NumberIO
IntToStr5.4.48 gm2-iso/WholeStr
IntVal5.6.21 ulm-lib-gm2/std/RandomGenerator
InvalidChan5.4.8 gm2-iso/IOChan
Ioctl5.5.16 ulm-lib-gm2/sys/SysIoctl
IOException5.4.10 gm2-iso/IOLink
IOInBufferedMode5.1.13 gm2-libs/IO
IOInRawMode5.1.13 gm2-libs/IO
IOTRANSFER5.3.4 gm2-libs-coroutines/SYSTEM
IOTRANSFER5.4.1 gm2-iso/COROUTINES
IsArgPresent5.4.22 gm2-iso/ProgramArgs
IsATTACHED5.4.1 gm2-iso/COROUTINES
IsAttached5.4.21 gm2-iso/Processes
Isatty5.5.16 ulm-lib-gm2/sys/SysIoctl
isatty5.1.35 gm2-libs/libc
Isatty5.5.29 ulm-lib-gm2/sys/SysTermIO
IsChanException5.4.8 gm2-iso/IOChan
IsCMathException5.4.4 gm2-iso/ComplexMath
IsCMathException5.4.12 gm2-iso/LongComplex
IsControl5.4.3 gm2-iso/CharClass
IsCurrentSource5.4.6 gm2-iso/EXCEPTIONS
IsDevice5.4.10 gm2-iso/IOLink
IsExceptionalExecution5.4.6 gm2-iso/EXCEPTIONS
IsGeneralException5.4.7 gm2-iso/GeneralUser
IsIOException5.4.10 gm2-iso/IOLink
IsLetter5.4.3 gm2-iso/CharClass
IsLower5.4.3 gm2-iso/CharClass
IsLowException5.4.17 gm2-iso/LowLong
IsLowException5.4.18 gm2-iso/LowReal
IsM2Exception5.4.19 gm2-iso/M2EXCEPTION
IsNoError5.1.10 gm2-libs/FIO
IsNumeric5.4.3 gm2-iso/CharClass
IsProcessesException5.4.21 gm2-iso/Processes
IsRConvException5.4.13 gm2-iso/LongConv
IsRConvException5.4.24 gm2-iso/RealConv
IsRMathException5.4.15 gm2-iso/LongMath
IsRMathException5.4.26 gm2-iso/RealMath
IsRndFile5.4.28 gm2-iso/RndFile
IsRndFileException5.4.28 gm2-iso/RndFile
IsSeqFile5.4.37 gm2-iso/SeqFile
IsStorageException5.4.39 gm2-iso/Storage
IsStreamFile5.4.40 gm2-iso/StreamFile
IsSubString5.1.29 gm2-libs/StrLib
IsTermFile5.4.44 gm2-iso/TermFile
IsTerminating5.4.43 gm2-iso/TERMINATION
IsUpper5.4.3 gm2-iso/CharClass
IsValidDateTime5.4.42 gm2-iso/SysClock
IsWhiteSpace5.4.3 gm2-iso/CharClass
IsWholeConvException5.4.46 gm2-iso/WholeConv
itos5.1.30 gm2-libs/StringConvert

K
KeyPressed5.2.12 gm2-libs-pim/Keyboard
KeyPressed5.2.18 gm2-libs-pim/Termbase
KeyPressed5.2.19 gm2-libs-pim/Terminal
Kill5.5.17 ulm-lib-gm2/sys/SysKill
KillProcess5.3.2 gm2-libs-coroutines/Executive
KillSet5.1.24 gm2-libs/Selective
KillString5.1.8 gm2-libs/DynamicStrings
KillTermios5.5.36 ulm-lib-gm2/sys/termios
KillTime5.1.24 gm2-libs/Selective

L
Length5.1.8 gm2-libs/DynamicStrings
LENGTH1.7.2 ISO specific standard procedures and functions
Length5.1.14 gm2-libs/M2RTS
Length5.2.9 gm2-libs-pim/FileSystem
Length5.2.17 gm2-libs-pim/Strings
Length5.4.20 gm2-iso/M2RTS
Length5.4.41 gm2-iso/Strings
LengthCard5.4.46 gm2-iso/WholeConv
LengthEngReal5.4.13 gm2-iso/LongConv
LengthEngReal5.4.24 gm2-iso/RealConv
LengthFixedReal5.4.13 gm2-iso/LongConv
LengthFixedReal5.4.24 gm2-iso/RealConv
LengthFloatReal5.4.13 gm2-iso/LongConv
LengthFloatReal5.4.24 gm2-iso/RealConv
LengthInt5.4.46 gm2-iso/WholeConv
Line5.6.19 ulm-lib-gm2/std/Plot
LineMod5.6.19 ulm-lib-gm2/std/Plot
Listen5.3.5 gm2-libs-coroutines/SysVec
LISTEN5.3.4 gm2-libs-coroutines/SYSTEM
LISTEN5.4.1 gm2-iso/COROUTINES
ListenLoop5.3.4 gm2-libs-coroutines/SYSTEM
ln5.1.15 gm2-libs/MathLib0
ln5.4.4 gm2-iso/ComplexMath
ln5.4.12 gm2-iso/LongComplex
ln5.4.15 gm2-iso/LongMath
ln5.4.26 gm2-iso/RealMath
ln5.6.16 ulm-lib-gm2/std/MathLib
lns5.1.15 gm2-libs/MathLib0
localtime5.1.35 gm2-libs/libc
log5.1.5 gm2-libs/Builtins
log5.1.34 gm2-libs/cbuiltin
log5.1.36 gm2-libs/libm
logf5.1.5 gm2-libs/Builtins
logf5.1.34 gm2-libs/cbuiltin
logf5.1.36 gm2-libs/libm
logl5.1.5 gm2-libs/Builtins
logl5.1.34 gm2-libs/cbuiltin
logl5.1.36 gm2-libs/libm
LongCardinalToString5.1.30 gm2-libs/StringConvert
LongIntegerToString5.1.30 gm2-libs/StringConvert
LongIntToStr5.1.12 gm2-libs/FpuIO
LongRealToStr5.1.12 gm2-libs/FpuIO
LongRealToString5.2.15 gm2-libs-pim/RealConversions
LongrealToString5.1.30 gm2-libs/StringConvert
Look5.4.8 gm2-iso/IOChan
Lookup5.2.9 gm2-libs-pim/FileSystem
LoopStatement (ebnf)4. EBNF of GNU Modula-2
Lower5.1.27 gm2-libs/StrCase
lseek5.1.35 gm2-libs/libc
Lseek5.5.20 ulm-lib-gm2/sys/SysLseek

M
M2Exception5.4.19 gm2-iso/M2EXCEPTION
MAKEADR5.4.35 gm2-iso/SYSTEM
MakeChan5.4.10 gm2-iso/IOLink
malloc5.1.35 gm2-libs/libc
Mark5.1.8 gm2-libs/DynamicStrings
MAX1.7.1 Standard procedures and functions common to PIM and ISO
MaxFdsPlusOne5.1.24 gm2-libs/Selective
Me5.4.21 gm2-iso/Processes
memcmp5.1.5 gm2-libs/Builtins
memcmp5.1.34 gm2-libs/cbuiltin
MemCopy5.1.16 gm2-libs/MemUtils
memcpy5.1.5 gm2-libs/Builtins
memcpy5.1.34 gm2-libs/cbuiltin
memcpy5.1.35 gm2-libs/libc
memset5.1.5 gm2-libs/Builtins
memset5.1.34 gm2-libs/cbuiltin
memset5.1.35 gm2-libs/libc
MemZero5.1.16 gm2-libs/MemUtils
MIN1.7.1 Standard procedures and functions common to PIM and ISO
ModuleDeclaration (ebnf)4. EBNF of GNU Modula-2
Move5.6.19 ulm-lib-gm2/std/Plot
MulOperator (ebnf)4. EBNF of GNU Modula-2
Mult5.1.8 gm2-libs/DynamicStrings
MultiFPSection (ebnf)4. EBNF of GNU Modula-2
MyParam5.4.21 gm2-iso/Processes

N
Narg5.1.2 gm2-libs/Args
Narg5.1.6 gm2-libs/CmdArgs
Narg5.1.19 gm2-libs/SArgs
NEW1.7.1 Standard procedures and functions common to PIM and ISO
NEWCOROUTINE1.9.1 Optional procedure parameter
NEWCOROUTINE5.4.1 gm2-iso/COROUTINES
NewPos5.4.28 gm2-iso/RndFile
NEWPROCESS5.3.4 gm2-libs-coroutines/SYSTEM
NextArg5.4.22 gm2-iso/ProgramArgs
NextParam5.6.13 ulm-lib-gm2/std/Functions
NilPointerError5.1.14 gm2-libs/M2RTS
NilPointerError5.4.20 gm2-iso/M2RTS
NonVarFPSection (ebnf)4. EBNF of GNU Modula-2
Notify5.6.20 ulm-lib-gm2/std/RTErrors
NullChan5.4.38 gm2-iso/StdChans
Number (ebnf)4. EBNF of GNU Modula-2

O
OctToStr5.1.17 gm2-libs/NumberIO
ODD1.7.1 Standard procedures and functions common to PIM and ISO
Open5.1.18 gm2-libs/PushBackInput
open5.1.35 gm2-libs/libc
Open5.4.40 gm2-iso/StreamFile
Open5.4.44 gm2-iso/TermFile
Open5.5.21 ulm-lib-gm2/sys/SysOpen
OpenAppend5.4.37 gm2-iso/SeqFile
OpenClean5.4.28 gm2-iso/RndFile
OpenCreat5.5.21 ulm-lib-gm2/sys/SysOpen
OpenDir5.6.8 ulm-lib-gm2/std/Directories
OpenForRandom5.1.10 gm2-libs/FIO
openForRandom5.1.10 gm2-libs/FIO
OpenForRandom5.1.21 gm2-libs/SFIO
OpenGr5.6.10 ulm-lib-gm2/std/EtcGroup
OpenInput5.2.11 gm2-libs-pim/InOut
OpenOld5.4.28 gm2-iso/RndFile
OpenOutput5.2.11 gm2-libs-pim/InOut
OpenPlot5.6.19 ulm-lib-gm2/std/Plot
OpenPw5.6.17 ulm-lib-gm2/std/Passwd
OpenRead5.4.37 gm2-iso/SeqFile
OpenRead5.6.11 ulm-lib-gm2/std/Files
OpenSource5.1.23 gm2-libs/Scan
openToRead5.1.10 gm2-libs/FIO
OpenToRead5.1.10 gm2-libs/FIO
OpenToRead5.1.21 gm2-libs/SFIO
OpenToWrite5.1.10 gm2-libs/FIO
openToWrite5.1.10 gm2-libs/FIO
OpenToWrite5.1.21 gm2-libs/SFIO
OpenWrite5.4.37 gm2-iso/SeqFile
OpenWrite5.6.11 ulm-lib-gm2/std/Files
OptArg (ebnf)4. EBNF of GNU Modula-2
ostoc5.1.30 gm2-libs/StringConvert
ostoi5.1.30 gm2-libs/StringConvert
OutChan5.4.38 gm2-iso/StdChans

P
Panic5.5.22 ulm-lib-gm2/sys/SysPanic
ParseFunction5.6.13 ulm-lib-gm2/std/Functions
Pclose5.6.18 ulm-lib-gm2/std/PipeIO
perror5.1.35 gm2-libs/libc
Point5.6.19 ulm-lib-gm2/std/Plot
PointerType (ebnf)4. EBNF of GNU Modula-2
polarToComplex5.4.4 gm2-iso/ComplexMath
polarToComplex5.4.12 gm2-iso/LongComplex
Polygon5.6.19 ulm-lib-gm2/std/Plot
Popen5.6.18 ulm-lib-gm2/std/PipeIO
PopOutput5.1.25 gm2-libs/StdIO
PopOutput5.3.1 gm2-libs-coroutines/Debug
Pos5.2.17 gm2-libs-pim/Strings
PossiblyExportIdent (ebnf)4. EBNF of GNU Modula-2
PossiblyExportIdentList (ebnf)4. EBNF of GNU Modula-2
pow5.1.36 gm2-libs/libm
power5.4.4 gm2-iso/ComplexMath
power5.4.12 gm2-iso/LongComplex
power5.4.15 gm2-iso/LongMath
power5.4.26 gm2-iso/RealMath
powf5.1.36 gm2-libs/libm
powl5.1.36 gm2-libs/libm
pred5.4.17 gm2-iso/LowLong
pred5.4.18 gm2-iso/LowReal
printf5.1.35 gm2-libs/libc
Priority (ebnf)4. EBNF of GNU Modula-2
ProcedureBlock (ebnf)4. EBNF of GNU Modula-2
ProcedureDeclaration (ebnf)4. EBNF of GNU Modula-2
ProcedureHeading (ebnf)4. EBNF of GNU Modula-2
ProcedureParameter (ebnf)4. EBNF of GNU Modula-2
ProcedureParameters (ebnf)4. EBNF of GNU Modula-2
ProcedureType (ebnf)4. EBNF of GNU Modula-2
ProcessesException5.4.21 gm2-iso/Processes
ProcessName5.3.2 gm2-libs-coroutines/Executive
ProgramModule (ebnf)4. EBNF of GNU Modula-2
PROT5.4.1 gm2-iso/COROUTINES
Ps5.3.2 gm2-libs-coroutines/Executive
pth_abort5.3.7 gm2-libs-coroutines/pth
pth_accept5.3.7 gm2-libs-coroutines/pth
pth_accept_ev5.3.7 gm2-libs-coroutines/pth
pth_atfork_pop5.3.7 gm2-libs-coroutines/pth
pth_attr_destroy5.3.7 gm2-libs-coroutines/pth
pth_attr_get5.3.7 gm2-libs-coroutines/pth
pth_attr_init5.3.7 gm2-libs-coroutines/pth
pth_attr_new5.3.7 gm2-libs-coroutines/pth
pth_attr_of5.3.7 gm2-libs-coroutines/pth
pth_attr_set5.3.7 gm2-libs-coroutines/pth
pth_barrier_init5.3.7 gm2-libs-coroutines/pth
pth_barrier_reach5.3.7 gm2-libs-coroutines/pth
pth_cancel5.3.7 gm2-libs-coroutines/pth
pth_cancel_point5.3.7 gm2-libs-coroutines/pth
pth_cancel_state5.3.7 gm2-libs-coroutines/pth
pth_cleanup_pop5.3.7 gm2-libs-coroutines/pth
pth_cleanup_push5.3.7 gm2-libs-coroutines/pth
pth_cond_await5.3.7 gm2-libs-coroutines/pth
pth_cond_init5.3.7 gm2-libs-coroutines/pth
pth_cond_notify5.3.7 gm2-libs-coroutines/pth
pth_connect5.3.7 gm2-libs-coroutines/pth
pth_connect_ev5.3.7 gm2-libs-coroutines/pth
pth_ctrl5.3.7 gm2-libs-coroutines/pth
pth_event5.3.7 gm2-libs-coroutines/pth
pth_event_concat5.3.7 gm2-libs-coroutines/pth
pth_event_extract5.3.7 gm2-libs-coroutines/pth
pth_event_free5.3.7 gm2-libs-coroutines/pth
pth_event_isolate5.3.7 gm2-libs-coroutines/pth
pth_event_occurred5.3.7 gm2-libs-coroutines/pth
pth_event_typeof5.3.7 gm2-libs-coroutines/pth
pth_event_walk5.3.7 gm2-libs-coroutines/pth
pth_exit5.3.7 gm2-libs-coroutines/pth
pth_fdmode5.3.7 gm2-libs-coroutines/pth
pth_fork5.3.7 gm2-libs-coroutines/pth
pth_init5.3.7 gm2-libs-coroutines/pth
pth_join5.3.7 gm2-libs-coroutines/pth
pth_key_create5.3.7 gm2-libs-coroutines/pth
pth_key_delete5.3.7 gm2-libs-coroutines/pth
pth_key_getdata5.3.7 gm2-libs-coroutines/pth
pth_key_setdata5.3.7 gm2-libs-coroutines/pth
pth_kill5.3.7 gm2-libs-coroutines/pth
pth_msgport_create5.3.7 gm2-libs-coroutines/pth
pth_msgport_destroy5.3.7 gm2-libs-coroutines/pth
pth_msgport_find5.3.7 gm2-libs-coroutines/pth
pth_msgport_get5.3.7 gm2-libs-coroutines/pth
pth_msgport_pending5.3.7 gm2-libs-coroutines/pth
pth_msgport_put5.3.7 gm2-libs-coroutines/pth
pth_msgport_reply5.3.7 gm2-libs-coroutines/pth
pth_mutex_acquire5.3.7 gm2-libs-coroutines/pth
pth_mutex_init5.3.7 gm2-libs-coroutines/pth
pth_mutex_release5.3.7 gm2-libs-coroutines/pth
pth_nap5.3.7 gm2-libs-coroutines/pth
pth_once5.3.7 gm2-libs-coroutines/pth
pth_poll5.3.7 gm2-libs-coroutines/pth
pth_poll_ev5.3.7 gm2-libs-coroutines/pth
pth_pread5.3.7 gm2-libs-coroutines/pth
pth_pwrite5.3.7 gm2-libs-coroutines/pth
pth_raise5.3.7 gm2-libs-coroutines/pth
pth_read5.3.7 gm2-libs-coroutines/pth
pth_read_ev5.3.7 gm2-libs-coroutines/pth
pth_readv5.3.7 gm2-libs-coroutines/pth
pth_readv_ev5.3.7 gm2-libs-coroutines/pth
pth_recv5.3.7 gm2-libs-coroutines/pth
pth_recv_ev5.3.7 gm2-libs-coroutines/pth
pth_recvfrom5.3.7 gm2-libs-coroutines/pth
pth_recvfrom_ev5.3.7 gm2-libs-coroutines/pth
pth_resume5.3.7 gm2-libs-coroutines/pth
pth_rwlock_acquire5.3.7 gm2-libs-coroutines/pth
pth_rwlock_init5.3.7 gm2-libs-coroutines/pth
pth_rwlock_release5.3.7 gm2-libs-coroutines/pth
pth_select5.3.7 gm2-libs-coroutines/pth
pth_select_ev5.3.7 gm2-libs-coroutines/pth
pth_self5.3.7 gm2-libs-coroutines/pth
pth_send5.3.7 gm2-libs-coroutines/pth
pth_send_ev5.3.7 gm2-libs-coroutines/pth
pth_sendto5.3.7 gm2-libs-coroutines/pth
pth_sendto_ev5.3.7 gm2-libs-coroutines/pth
pth_sfiodisc5.3.7 gm2-libs-coroutines/pth
pth_sigmask5.3.7 gm2-libs-coroutines/pth
pth_sigwait5.3.7 gm2-libs-coroutines/pth
pth_sigwait_ev5.3.7 gm2-libs-coroutines/pth
pth_sleep5.3.7 gm2-libs-coroutines/pth
pth_spawn5.3.7 gm2-libs-coroutines/pth
pth_suspend5.3.7 gm2-libs-coroutines/pth
pth_system5.3.7 gm2-libs-coroutines/pth
pth_time5.3.7 gm2-libs-coroutines/pth
pth_timeout5.3.7 gm2-libs-coroutines/pth
pth_uctx_create5.3.7 gm2-libs-coroutines/pth
pth_uctx_destroy5.3.7 gm2-libs-coroutines/pth
pth_uctx_make5.3.7 gm2-libs-coroutines/pth
pth_uctx_restore5.3.7 gm2-libs-coroutines/pth
pth_uctx_save5.3.7 gm2-libs-coroutines/pth
pth_uctx_switch5.3.7 gm2-libs-coroutines/pth
pth_usleep5.3.7 gm2-libs-coroutines/pth
pth_version5.3.7 gm2-libs-coroutines/pth
pth_wait5.3.7 gm2-libs-coroutines/pth
pth_waitpid5.3.7 gm2-libs-coroutines/pth
pth_write5.3.7 gm2-libs-coroutines/pth
pth_write_ev5.3.7 gm2-libs-coroutines/pth
pth_writev5.3.7 gm2-libs-coroutines/pth
pth_writev_ev5.3.7 gm2-libs-coroutines/pth
pth_yield5.3.7 gm2-libs-coroutines/pth
PushOutput5.1.25 gm2-libs/StdIO
PushOutput5.3.1 gm2-libs-coroutines/Debug
PutCh5.1.18 gm2-libs/PushBackInput
PutString5.1.18 gm2-libs/PushBackInput

Q
Qualident (ebnf)4. EBNF of GNU Modula-2
QualidentOrSet (ebnf)4. EBNF of GNU Modula-2

R
RAISE5.4.6 gm2-iso/EXCEPTIONS
RAISEdevException5.4.10 gm2-iso/IOLink
RaiseGeneralException5.4.7 gm2-iso/GeneralUser
rand5.1.35 gm2-libs/libc
Random5.6.21 ulm-lib-gm2/std/RandomGenerator
RandomBytes5.2.14 gm2-libs-pim/Random
RandomCard5.2.14 gm2-libs-pim/Random
RandomInit5.2.14 gm2-libs-pim/Random
RandomInt5.2.14 gm2-libs-pim/Random
Randomize5.2.14 gm2-libs-pim/Random
RandomLongReal5.2.14 gm2-libs-pim/Random
RandomReal5.2.14 gm2-libs-pim/Random
RawRead5.4.8 gm2-iso/IOChan
RawWrite5.4.8 gm2-iso/IOChan
Read5.1.13 gm2-libs/IO
read5.1.35 gm2-libs/libc
Read5.1.25 gm2-libs/StdIO
Read5.2.11 gm2-libs-pim/InOut
Read5.2.12 gm2-libs-pim/Keyboard
Read5.2.18 gm2-libs-pim/Termbase
Read5.2.19 gm2-libs-pim/Terminal
Read5.4.23 gm2-iso/RawIO
Read5.4.31 gm2-iso/SRawIO
Read5.5.25 ulm-lib-gm2/sys/SysRead
Read5.6.15 ulm-lib-gm2/std/InOut
Read5.6.22 ulm-lib-gm2/std/ReadIntCard
Read5.6.35 ulm-lib-gm2/std/Terminal
ReadAgain5.2.19 gm2-libs-pim/Terminal
ReadAgain5.6.35 ulm-lib-gm2/std/Terminal
ReadAny5.1.10 gm2-libs/FIO
ReadBin5.1.17 gm2-libs/NumberIO
ReadByte5.2.9 gm2-libs-pim/FileSystem
ReadCard5.1.17 gm2-libs/NumberIO
ReadCard5.2.11 gm2-libs-pim/InOut
ReadCard5.4.34 gm2-iso/SWholeIO
ReadCard5.4.47 gm2-iso/WholeIO
ReadCard5.6.15 ulm-lib-gm2/std/InOut
ReadCardinal5.1.10 gm2-libs/FIO
ReadCardinal5.2.2 gm2-libs-pim/CardinalIO
ReadChar5.1.10 gm2-libs/FIO
ReadChar5.2.9 gm2-libs-pim/FileSystem
ReadChar5.4.33 gm2-iso/STextIO
ReadChar5.4.45 gm2-iso/TextIO
ReadCharRaw5.1.24 gm2-libs/Selective
ReadDate5.6.36 ulm-lib-gm2/std/TimeIO
ReadDir5.6.8 ulm-lib-gm2/std/Directories
ReadHex5.1.17 gm2-libs/NumberIO
ReadHex5.2.2 gm2-libs-pim/CardinalIO
ReadInt5.1.17 gm2-libs/NumberIO
ReadInt5.2.11 gm2-libs-pim/InOut
ReadInt5.4.34 gm2-iso/SWholeIO
ReadInt5.4.47 gm2-iso/WholeIO
ReadInt5.6.15 ulm-lib-gm2/std/InOut
ReadLongCardinal5.2.2 gm2-libs-pim/CardinalIO
ReadLongHex5.2.2 gm2-libs-pim/CardinalIO
ReadLongInt5.1.12 gm2-libs/FpuIO
ReadLongInt5.2.13 gm2-libs-pim/LongIO
ReadLongReal5.1.12 gm2-libs/FpuIO
ReadLongReal5.2.16 gm2-libs-pim/RealInOut
ReadNBytes5.1.10 gm2-libs/FIO
ReadNBytes5.2.9 gm2-libs-pim/FileSystem
ReadOct5.1.17 gm2-libs/NumberIO
ReadReal5.1.12 gm2-libs/FpuIO
ReadReal5.2.16 gm2-libs-pim/RealInOut
ReadReal5.4.14 gm2-iso/LongIO
ReadReal5.4.25 gm2-iso/RealIO
ReadReal5.4.30 gm2-iso/SLongIO
ReadReal5.4.32 gm2-iso/SRealIO
ReadReal5.6.23 ulm-lib-gm2/std/RealConv
ReadReal5.6.24 ulm-lib-gm2/std/RealInOut
ReadRestLine5.4.33 gm2-iso/STextIO
ReadRestLine5.4.45 gm2-iso/TextIO
ReadResult5.4.8 gm2-iso/IOChan
ReadResult5.4.11 gm2-iso/IOResult
ReadResult5.4.29 gm2-iso/SIOResult
ReadS5.1.21 gm2-libs/SFIO
ReadS5.2.11 gm2-libs-pim/InOut
ReadShortCardinal5.2.2 gm2-libs-pim/CardinalIO
ReadShortHex5.2.2 gm2-libs-pim/CardinalIO
ReadShortReal5.2.16 gm2-libs-pim/RealInOut
ReadString5.1.10 gm2-libs/FIO
ReadString5.1.28 gm2-libs/StrIO
ReadString5.2.11 gm2-libs-pim/InOut
ReadString5.2.19 gm2-libs-pim/Terminal
ReadString5.4.33 gm2-iso/STextIO
ReadString5.4.45 gm2-iso/TextIO
ReadString5.6.15 ulm-lib-gm2/std/InOut
ReadTime5.6.36 ulm-lib-gm2/std/TimeIO
ReadToken5.4.33 gm2-iso/STextIO
ReadToken5.4.45 gm2-iso/TextIO
readv5.1.35 gm2-libs/libc
ReadWord5.2.9 gm2-libs-pim/FileSystem
Real (ebnf)4. EBNF of GNU Modula-2
realloc5.1.35 gm2-libs/libc
REALLOCATE5.1.26 gm2-libs/Storage
REALLOCATE5.1.31 gm2-libs/SysStorage
RealTime5.6.6 ulm-lib-gm2/std/Clock
RealToEng5.4.16 gm2-iso/LongStr
RealToEng5.4.27 gm2-iso/RealStr
RealToFixed5.4.16 gm2-iso/LongStr
RealToFixed5.4.27 gm2-iso/RealStr
RealToFloat5.4.16 gm2-iso/LongStr
RealToFloat5.4.27 gm2-iso/RealStr
RealToStr5.1.12 gm2-libs/FpuIO
RealToStr5.4.16 gm2-iso/LongStr
RealToStr5.4.27 gm2-iso/RealStr
RealToString5.2.15 gm2-libs-pim/RealConversions
RealVal5.6.21 ulm-lib-gm2/std/RandomGenerator
ReArmEvent5.3.6 gm2-libs-coroutines/TimerHandler
ReArmTimeVector5.3.5 gm2-libs-coroutines/SysVec
RecordType (ebnf)4. EBNF of GNU Modula-2
Relation (ebnf)4. EBNF of GNU Modula-2
Release5.4.36 gm2-iso/Semaphores
ReleaseList5.6.36 ulm-lib-gm2/std/TimeIO
RemoveWhitePrefix5.1.8 gm2-libs/DynamicStrings
Rename5.2.9 gm2-libs-pim/FileSystem
Rename5.6.11 ulm-lib-gm2/std/Files
ReopenGr5.6.10 ulm-lib-gm2/std/EtcGroup
ReopenPw5.6.17 ulm-lib-gm2/std/Passwd
RepeatStatement (ebnf)4. EBNF of GNU Modula-2
Replace5.4.41 gm2-iso/Strings
Reread5.4.37 gm2-iso/SeqFile
ReRead5.6.25 ulm-lib-gm2/std/ScanPwfile
Reset5.2.9 gm2-libs-pim/FileSystem
Reset5.4.8 gm2-iso/IOChan
Reset5.6.11 ulm-lib-gm2/std/Files
Resume5.3.2 gm2-libs-coroutines/Executive
Reverse5.6.19 ulm-lib-gm2/std/Plot
RewindDir5.6.8 ulm-lib-gm2/std/Directories
Rewrite5.4.37 gm2-iso/SeqFile
RIndex5.1.8 gm2-libs/DynamicStrings
rindex5.1.5 gm2-libs/Builtins
rindex5.1.34 gm2-libs/cbuiltin
ROTATE5.4.35 gm2-iso/SYSTEM
RotateLeft5.4.35 gm2-iso/SYSTEM
RotateRight5.4.35 gm2-iso/SYSTEM
RotateRunQueue5.3.2 gm2-libs-coroutines/Executive
RotateVal5.4.35 gm2-iso/SYSTEM
Round5.2.10 gm2-libs-pim/FloatingUtilities
round5.4.15 gm2-iso/LongMath
round5.4.17 gm2-iso/LowLong
round5.4.18 gm2-iso/LowReal
round5.4.26 gm2-iso/RealMath
Roundl5.2.10 gm2-libs-pim/FloatingUtilities

S
Sbreak5.5.6 ulm-lib-gm2/sys/SysBreak
scalarMult5.4.4 gm2-iso/ComplexMath
scalarMult5.4.12 gm2-iso/LongComplex
scale5.4.17 gm2-iso/LowLong
scale5.4.18 gm2-iso/LowReal
ScanCard5.4.46 gm2-iso/WholeConv
ScanInt5.4.46 gm2-iso/WholeConv
ScanReal5.4.13 gm2-iso/LongConv
ScanReal5.4.24 gm2-iso/RealConv
SeekDir5.6.8 ulm-lib-gm2/std/Directories
Select5.1.24 gm2-libs/Selective
SetChar5.5.36 ulm-lib-gm2/sys/termios
SetClock5.4.42 gm2-iso/SysClock
SetDebug5.1.18 gm2-libs/PushBackInput
SetErrChan5.4.38 gm2-iso/StdChans
SetErrorCode5.2.8 gm2-libs-pim/ErrorCode
SetFirstOfWeek5.6.4 ulm-lib-gm2/std/Calendar
SetFlag5.5.36 ulm-lib-gm2/sys/termios
SetFuncParam5.6.13 ulm-lib-gm2/std/Functions
Setgid5.5.26 ulm-lib-gm2/sys/SysSetuid
SetHandler5.6.20 ulm-lib-gm2/std/RTErrors
SetInChan5.4.38 gm2-iso/StdChans
SetLocaltime5.6.4 ulm-lib-gm2/std/Calendar
Setmode5.6.28 ulm-lib-gm2/std/Storage
setMode5.4.17 gm2-iso/LowLong
setMode5.4.18 gm2-iso/LowReal
SetModify5.2.9 gm2-libs-pim/FileSystem
SetOpen5.2.9 gm2-libs-pim/FileSystem
SetOrDesignatorOrFunction (ebnf)4. EBNF of GNU Modula-2
SetOutChan5.4.38 gm2-iso/StdChans
SetPos5.2.9 gm2-libs-pim/FileSystem
SetPos5.4.28 gm2-iso/RndFile
SetPos5.6.11 ulm-lib-gm2/std/Files
SetPositionFromBeginning5.1.10 gm2-libs/FIO
SetRead5.2.9 gm2-libs-pim/FileSystem
SetReadResult5.4.8 gm2-iso/IOChan
SetTermIO5.5.29 ulm-lib-gm2/sys/SysTermIO
SetTime5.1.24 gm2-libs/Selective
SetTime5.2.20 gm2-libs-pim/TimeDate
SetTimezone5.6.4 ulm-lib-gm2/std/Calendar
SetType (ebnf)4. EBNF of GNU Modula-2
SetWrite5.2.9 gm2-libs-pim/FileSystem
SHIFT5.4.35 gm2-iso/SYSTEM
ShiftLeft5.4.35 gm2-iso/SYSTEM
ShiftRight5.4.35 gm2-iso/SYSTEM
ShiftVal5.4.35 gm2-iso/SYSTEM
ShortCardinalToString5.1.30 gm2-libs/StringConvert
sign5.4.17 gm2-iso/LowLong
sign5.4.18 gm2-iso/LowReal
Signal5.3.2 gm2-libs-coroutines/Executive
Signal5.5.27 ulm-lib-gm2/sys/SysSignal
SimpleConstExpr (ebnf)4. EBNF of GNU Modula-2
SimpleDes (ebnf)4. EBNF of GNU Modula-2
SimpleExpression (ebnf)4. EBNF of GNU Modula-2
SimpleSet (ebnf)4. EBNF of GNU Modula-2
SimpleType (ebnf)4. EBNF of GNU Modula-2
sin5.1.5 gm2-libs/Builtins
sin5.1.15 gm2-libs/MathLib0
sin5.1.34 gm2-libs/cbuiltin
sin5.1.36 gm2-libs/libm
sin5.4.4 gm2-iso/ComplexMath
sin5.4.12 gm2-iso/LongComplex
sin5.4.15 gm2-iso/LongMath
sin5.4.26 gm2-iso/RealMath
sin5.6.16 ulm-lib-gm2/std/MathLib
sinf5.1.5 gm2-libs/Builtins
sinf5.1.34 gm2-libs/cbuiltin
sinf5.1.36 gm2-libs/libm
sinl5.1.5 gm2-libs/Builtins
sinl5.1.15 gm2-libs/MathLib0
sinl5.1.34 gm2-libs/cbuiltin
sinl5.1.36 gm2-libs/libm
sins5.1.15 gm2-libs/MathLib0
Skip5.4.8 gm2-iso/IOChan
SkipLine5.4.33 gm2-iso/STextIO
SkipLine5.4.45 gm2-iso/TextIO
SkipLook5.4.8 gm2-iso/IOChan
Sleep5.3.6 gm2-libs-coroutines/TimerHandler
Slice5.1.8 gm2-libs/DynamicStrings
Space5.6.19 ulm-lib-gm2/std/Plot
Sprintf05.1.11 gm2-libs/FormatStrings
Sprintf15.1.11 gm2-libs/FormatStrings
Sprintf25.1.11 gm2-libs/FormatStrings
Sprintf35.1.11 gm2-libs/FormatStrings
Sprintf45.1.11 gm2-libs/FormatStrings
sqrt5.1.5 gm2-libs/Builtins
sqrt5.1.15 gm2-libs/MathLib0
sqrt5.1.34 gm2-libs/cbuiltin
sqrt5.1.36 gm2-libs/libm
sqrt5.4.4 gm2-iso/ComplexMath
sqrt5.4.12 gm2-iso/LongComplex
sqrt5.4.15 gm2-iso/LongMath
sqrt5.4.26 gm2-iso/RealMath
sqrt5.6.16 ulm-lib-gm2/std/MathLib
sqrtf5.1.5 gm2-libs/Builtins
sqrtf5.1.34 gm2-libs/cbuiltin
sqrtf5.1.36 gm2-libs/libm
sqrtl5.1.5 gm2-libs/Builtins
sqrtl5.1.15 gm2-libs/MathLib0
sqrtl5.1.34 gm2-libs/cbuiltin
sqrtl5.1.36 gm2-libs/libm
sqrts5.1.15 gm2-libs/MathLib0
srand5.1.35 gm2-libs/libc
SreadDate5.6.36 ulm-lib-gm2/std/TimeIO
SreadTime5.6.36 ulm-lib-gm2/std/TimeIO
Start5.4.21 gm2-iso/Processes
StartPos5.4.28 gm2-iso/RndFile
Stat5.5.28 ulm-lib-gm2/sys/SysStat
Statement (ebnf)4. EBNF of GNU Modula-2
StatementSequence (ebnf)4. EBNF of GNU Modula-2
StdErrChan5.4.38 gm2-iso/StdChans
StdInChan5.4.38 gm2-iso/StdChans
StdOutChan5.4.38 gm2-iso/StdChans
stoc5.1.30 gm2-libs/StringConvert
stoi5.1.30 gm2-libs/StringConvert
stolr5.1.30 gm2-libs/StringConvert
StopMe5.4.21 gm2-iso/Processes
stor5.1.30 gm2-libs/StringConvert
StorageException5.4.39 gm2-iso/Storage
StrCat5.6.32 ulm-lib-gm2/std/Strings
strcat5.1.5 gm2-libs/Builtins
strcat5.1.34 gm2-libs/cbuiltin
strchr5.1.5 gm2-libs/Builtins
strchr5.1.34 gm2-libs/cbuiltin
strcmp5.1.5 gm2-libs/Builtins
StrCmp5.6.32 ulm-lib-gm2/std/Strings
strcmp5.1.34 gm2-libs/cbuiltin
StrConCat5.1.29 gm2-libs/StrLib
StrCopy5.1.29 gm2-libs/StrLib
StrCpy5.6.32 ulm-lib-gm2/std/Strings
strcpy5.1.5 gm2-libs/Builtins
strcpy5.1.34 gm2-libs/cbuiltin
strcpy5.1.35 gm2-libs/libc
strcspn5.1.5 gm2-libs/Builtins
strcspn5.1.34 gm2-libs/cbuiltin
StrDel5.6.29 ulm-lib-gm2/std/StrSpec
StrEqual5.1.29 gm2-libs/StrLib
String5.6.19 ulm-lib-gm2/std/Plot
string5.1.8 gm2-libs/DynamicStrings
string (ebnf)4. EBNF of GNU Modula-2
StringToCardinal5.1.30 gm2-libs/StringConvert
StringToInteger5.1.30 gm2-libs/StringConvert
StringToLongCardinal5.1.30 gm2-libs/StringConvert
StringToLongInteger5.1.30 gm2-libs/StringConvert
StringToLongReal5.2.15 gm2-libs-pim/RealConversions
StringToLongreal5.1.30 gm2-libs/StringConvert
StringToReal5.2.15 gm2-libs-pim/RealConversions
StringToShortCardinal5.1.30 gm2-libs/StringConvert
StrIns5.6.29 ulm-lib-gm2/std/StrSpec
strlen5.1.5 gm2-libs/Builtins
StrLen5.1.29 gm2-libs/StrLib
strlen5.1.34 gm2-libs/cbuiltin
strlen5.1.35 gm2-libs/libc
StrLess5.1.29 gm2-libs/StrLib
strncat5.1.5 gm2-libs/Builtins
strncat5.1.34 gm2-libs/cbuiltin
strncmp5.1.5 gm2-libs/Builtins
strncmp5.1.34 gm2-libs/cbuiltin
strncpy5.1.5 gm2-libs/Builtins
strncpy5.1.34 gm2-libs/cbuiltin
strncpy5.1.35 gm2-libs/libc
strpbrk5.1.5 gm2-libs/Builtins
strpbrk5.1.34 gm2-libs/cbuiltin
StrPos5.6.29 ulm-lib-gm2/std/StrSpec
strrchr5.1.5 gm2-libs/Builtins
strrchr5.1.34 gm2-libs/cbuiltin
StrRemoveWhitePrefix5.1.29 gm2-libs/StrLib
strspn5.1.5 gm2-libs/Builtins
strspn5.1.34 gm2-libs/cbuiltin
strstr5.1.5 gm2-libs/Builtins
strstr5.1.34 gm2-libs/cbuiltin
strtime5.1.37 gm2-libs/wrapc
StrToBin5.1.17 gm2-libs/NumberIO
StrToBinInt5.1.17 gm2-libs/NumberIO
StrToCard5.1.17 gm2-libs/NumberIO
StrToCard5.4.48 gm2-iso/WholeStr
StrToHex5.1.17 gm2-libs/NumberIO
StrToHex5.6.30 ulm-lib-gm2/std/StrToNum
StrToHexInt5.1.17 gm2-libs/NumberIO
StrToInt5.1.17 gm2-libs/NumberIO
StrToInt5.4.48 gm2-iso/WholeStr
StrToInt5.6.30 ulm-lib-gm2/std/StrToNum
StrToLongInt5.1.12 gm2-libs/FpuIO
StrToLongReal5.1.12 gm2-libs/FpuIO
StrToLowerCase5.1.27 gm2-libs/StrCase
StrToOct5.1.17 gm2-libs/NumberIO
StrToOct5.6.30 ulm-lib-gm2/std/StrToNum
StrToOctInt5.1.17 gm2-libs/NumberIO
StrToReal5.1.12 gm2-libs/FpuIO
StrToReal5.4.16 gm2-iso/LongStr
StrToReal5.4.27 gm2-iso/RealStr
StrToUpperCase5.1.27 gm2-libs/StrCase
Stty5.5.16 ulm-lib-gm2/sys/SysIoctl
SUBADR5.4.35 gm2-iso/SYSTEM
SubDesignator (ebnf)4. EBNF of GNU Modula-2
SubrangeAssignmentError5.1.14 gm2-libs/M2RTS
SubrangeAssignmentError5.4.20 gm2-iso/M2RTS
SubrangeType (ebnf)4. EBNF of GNU Modula-2
succ5.4.17 gm2-iso/LowLong
succ5.4.18 gm2-iso/LowReal
Suspend5.3.2 gm2-libs-coroutines/Executive
SuspendMe5.4.21 gm2-iso/Processes
SuspendMeAndActivate5.4.21 gm2-iso/Processes
Switch5.4.21 gm2-iso/Processes
SwitchCaps5.3.3 gm2-libs-coroutines/KeyBoardLEDs
SwitchLeds5.3.3 gm2-libs-coroutines/KeyBoardLEDs
SwitchNum5.3.3 gm2-libs-coroutines/KeyBoardLEDs
SwitchScroll5.3.3 gm2-libs-coroutines/KeyBoardLEDs
SwriteDate5.6.36 ulm-lib-gm2/std/TimeIO
SwriteTime5.6.36 ulm-lib-gm2/std/TimeIO
SwriteTimeLike5.6.36 ulm-lib-gm2/std/TimeIO
synthesize5.4.17 gm2-iso/LowLong
synthesize5.4.18 gm2-iso/LowReal
system5.1.35 gm2-libs/libc

T
TagIdent (ebnf)4. EBNF of GNU Modula-2
tan5.1.15 gm2-libs/MathLib0
tan5.1.36 gm2-libs/libm
tan5.4.4 gm2-iso/ComplexMath
tan5.4.12 gm2-iso/LongComplex
tan5.4.15 gm2-iso/LongMath
tan5.4.26 gm2-iso/RealMath
tanf5.1.36 gm2-libs/libm
tanl5.1.36 gm2-libs/libm
tans5.1.15 gm2-libs/MathLib0
tcdrain5.5.36 ulm-lib-gm2/sys/termios
tcflowoffi5.5.36 ulm-lib-gm2/sys/termios
tcflowoffo5.5.36 ulm-lib-gm2/sys/termios
tcflowoni5.5.36 ulm-lib-gm2/sys/termios
tcflowono5.5.36 ulm-lib-gm2/sys/termios
tcflushi5.5.36 ulm-lib-gm2/sys/termios
tcflushio5.5.36 ulm-lib-gm2/sys/termios
tcflusho5.5.36 ulm-lib-gm2/sys/termios
tcgetattr5.5.36 ulm-lib-gm2/sys/termios
tcsdrain5.5.36 ulm-lib-gm2/sys/termios
tcsendbreak5.5.36 ulm-lib-gm2/sys/termios
tcsetattr5.5.36 ulm-lib-gm2/sys/termios
tcsflush5.5.36 ulm-lib-gm2/sys/termios
tcsnow5.5.36 ulm-lib-gm2/sys/termios
Tell5.5.20 ulm-lib-gm2/sys/SysLseek
TellDir5.6.8 ulm-lib-gm2/std/Directories
Term (ebnf)4. EBNF of GNU Modula-2
Terminate5.1.14 gm2-libs/M2RTS
Terminate5.4.20 gm2-iso/M2RTS
TerminateOnError5.1.23 gm2-libs/Scan
TextRead5.4.8 gm2-iso/IOChan
TextWrite5.4.8 gm2-iso/IOChan
time5.1.35 gm2-libs/libc
Time5.5.30 ulm-lib-gm2/sys/SysTime
TimeToString5.2.20 gm2-libs-pim/TimeDate
TimeToString5.6.4 ulm-lib-gm2/std/Calendar
TimeToZero5.2.20 gm2-libs-pim/TimeDate
ToLower5.1.8 gm2-libs/DynamicStrings
ToUpper5.1.8 gm2-libs/DynamicStrings
TRANSFER5.3.4 gm2-libs-coroutines/SYSTEM
TRANSFER5.4.1 gm2-iso/COROUTINES
TrashList (ebnf)4. EBNF of GNU Modula-2
Trunc5.2.10 gm2-libs-pim/FloatingUtilities
trunc5.4.17 gm2-iso/LowLong
trunc5.4.18 gm2-iso/LowReal
Truncl5.2.10 gm2-libs-pim/FloatingUtilities
TSIZE5.4.35 gm2-iso/SYSTEM
TurnInterrupts5.3.4 gm2-libs-coroutines/SYSTEM
Type (ebnf)4. EBNF of GNU Modula-2
TypeDeclaration (ebnf)4. EBNF of GNU Modula-2

U
ulp5.4.17 gm2-iso/LowLong
ulp5.4.18 gm2-iso/LowReal
UnaryOrConstTerm (ebnf)4. EBNF of GNU Modula-2
UnAssignRead5.2.18 gm2-libs-pim/Termbase
UnAssignWrite5.2.18 gm2-libs-pim/Termbase
UngetArg5.6.3 ulm-lib-gm2/std/Arguments
UngetOpt5.6.3 ulm-lib-gm2/std/Arguments
UnInstallBreak5.2.1 gm2-libs-pim/Break
UNIXCALL5.5.2 ulm-lib-gm2/sys/SYSTEM
UNIXFORK5.5.2 ulm-lib-gm2/sys/SYSTEM
UNIXSIGNAL5.5.2 ulm-lib-gm2/sys/SYSTEM
unlink5.1.35 gm2-libs/libc
UnMakeChan5.4.10 gm2-iso/IOLink
UnReadChar5.1.10 gm2-libs/FIO
UrgencyOf5.4.21 gm2-iso/Processes
Usage5.6.3 ulm-lib-gm2/std/Arguments

V
VAL1.7.1 Standard procedures and functions common to PIM and ISO
ValueCard5.4.46 gm2-iso/WholeConv
ValueInt5.4.46 gm2-iso/WholeConv
ValueReal5.4.13 gm2-iso/LongConv
ValueReal5.4.24 gm2-iso/RealConv
VarFPSection (ebnf)4. EBNF of GNU Modula-2
VariableDeclaration (ebnf)4. EBNF of GNU Modula-2
VarIdent (ebnf)4. EBNF of GNU Modula-2
VarIdentList (ebnf)4. EBNF of GNU Modula-2
Varient (ebnf)4. EBNF of GNU Modula-2

W
Wait5.3.2 gm2-libs-coroutines/Executive
Wait5.4.21 gm2-iso/Processes
WaitForIO5.3.2 gm2-libs-coroutines/Executive
WaitOn5.3.6 gm2-libs-coroutines/TimerHandler
WarnError5.1.18 gm2-libs/PushBackInput
WarnString5.1.18 gm2-libs/PushBackInput
WhileStatement (ebnf)4. EBNF of GNU Modula-2
WithStatement (ebnf)4. EBNF of GNU Modula-2
Write5.1.13 gm2-libs/IO
write5.1.35 gm2-libs/libc
Write5.1.25 gm2-libs/StdIO
Write5.2.7 gm2-libs-pim/Display
Write5.2.11 gm2-libs-pim/InOut
Write5.2.18 gm2-libs-pim/Termbase
Write5.2.19 gm2-libs-pim/Terminal
Write5.4.23 gm2-iso/RawIO
Write5.4.31 gm2-iso/SRawIO
Write5.5.33 ulm-lib-gm2/sys/SysWrite
Write5.6.15 ulm-lib-gm2/std/InOut
Write5.6.35 ulm-lib-gm2/std/Terminal
WriteAny5.1.10 gm2-libs/FIO
WriteBin5.1.17 gm2-libs/NumberIO
WriteByte5.2.9 gm2-libs-pim/FileSystem
WriteCard5.1.17 gm2-libs/NumberIO
WriteCard5.2.11 gm2-libs-pim/InOut
WriteCard5.4.34 gm2-iso/SWholeIO
WriteCard5.4.47 gm2-iso/WholeIO
WriteCard5.6.15 ulm-lib-gm2/std/InOut
WriteCardinal5.1.10 gm2-libs/FIO
WriteCardinal5.2.2 gm2-libs-pim/CardinalIO
WriteChar5.1.10 gm2-libs/FIO
WriteChar5.2.9 gm2-libs-pim/FileSystem
WriteChar5.4.33 gm2-iso/STextIO
WriteChar5.4.45 gm2-iso/TextIO
WriteCharRaw5.1.24 gm2-libs/Selective
WriteDate5.6.36 ulm-lib-gm2/std/TimeIO
WriteEng5.4.14 gm2-iso/LongIO
WriteEng5.4.25 gm2-iso/RealIO
WriteEng5.4.30 gm2-iso/SLongIO
WriteEng5.4.32 gm2-iso/SRealIO
WriteError5.1.23 gm2-libs/Scan
WriteFix5.6.23 ulm-lib-gm2/std/RealConv
WriteFixed5.4.14 gm2-iso/LongIO
WriteFixed5.4.25 gm2-iso/RealIO
WriteFixed5.4.30 gm2-iso/SLongIO
WriteFixed5.4.32 gm2-iso/SRealIO
WriteFloat5.4.14 gm2-iso/LongIO
WriteFloat5.4.25 gm2-iso/RealIO
WriteFloat5.4.30 gm2-iso/SLongIO
WriteFloat5.4.32 gm2-iso/SRealIO
WriteFloat5.6.23 ulm-lib-gm2/std/RealConv
WriteFloat5.6.24 ulm-lib-gm2/std/RealInOut
WriteHex5.1.17 gm2-libs/NumberIO
WriteHex5.2.2 gm2-libs-pim/CardinalIO
WriteHex5.2.11 gm2-libs-pim/InOut
WriteHex5.6.15 ulm-lib-gm2/std/InOut
WriteInt5.1.17 gm2-libs/NumberIO
WriteInt5.2.11 gm2-libs-pim/InOut
WriteInt5.4.34 gm2-iso/SWholeIO
WriteInt5.4.47 gm2-iso/WholeIO
WriteInt5.6.15 ulm-lib-gm2/std/InOut
WriteLine5.1.10 gm2-libs/FIO
WriteLn5.1.28 gm2-libs/StrIO
WriteLn5.2.11 gm2-libs-pim/InOut
WriteLn5.2.19 gm2-libs-pim/Terminal
WriteLn5.4.8 gm2-iso/IOChan
WriteLn5.4.33 gm2-iso/STextIO
WriteLn5.4.45 gm2-iso/TextIO
WriteLn5.6.15 ulm-lib-gm2/std/InOut
WriteLn5.6.35 ulm-lib-gm2/std/Terminal
WriteLongCardinal5.2.2 gm2-libs-pim/CardinalIO
WriteLongHex5.2.2 gm2-libs-pim/CardinalIO
WriteLongInt5.1.12 gm2-libs/FpuIO
WriteLongInt5.2.13 gm2-libs-pim/LongIO
WriteLongReal5.1.12 gm2-libs/FpuIO
WriteLongReal5.2.16 gm2-libs-pim/RealInOut
WriteLongRealOct5.2.16 gm2-libs-pim/RealInOut
WriteNBytes5.1.10 gm2-libs/FIO
WriteNBytes5.2.9 gm2-libs-pim/FileSystem
WriteOct5.1.17 gm2-libs/NumberIO
WriteOct5.2.11 gm2-libs-pim/InOut
WriteOct5.6.15 ulm-lib-gm2/std/InOut
WriteReal5.1.12 gm2-libs/FpuIO
WriteReal5.2.16 gm2-libs-pim/RealInOut
WriteReal5.4.14 gm2-iso/LongIO
WriteReal5.4.25 gm2-iso/RealIO
WriteReal5.4.30 gm2-iso/SLongIO
WriteReal5.4.32 gm2-iso/SRealIO
WriteReal5.6.24 ulm-lib-gm2/std/RealInOut
WriteRealHex5.6.24 ulm-lib-gm2/std/RealInOut
WriteRealOct5.2.16 gm2-libs-pim/RealInOut
WriteRealOct5.6.24 ulm-lib-gm2/std/RealInOut
WriteS5.1.21 gm2-libs/SFIO
WriteS5.2.11 gm2-libs-pim/InOut
WriteShortCardinal5.2.2 gm2-libs-pim/CardinalIO
WriteShortHex5.2.2 gm2-libs-pim/CardinalIO
WriteShortReal5.2.16 gm2-libs-pim/RealInOut
WriteShortRealOct5.2.16 gm2-libs-pim/RealInOut
WriteString5.1.10 gm2-libs/FIO
WriteString5.1.28 gm2-libs/StrIO
WriteString5.2.11 gm2-libs-pim/InOut
WriteString5.2.19 gm2-libs-pim/Terminal
WriteString5.4.33 gm2-iso/STextIO
WriteString5.4.45 gm2-iso/TextIO
WriteString5.6.15 ulm-lib-gm2/std/InOut
WriteString5.6.35 ulm-lib-gm2/std/Terminal
WriteTime5.6.36 ulm-lib-gm2/std/TimeIO
WriteTimeLike5.6.36 ulm-lib-gm2/std/TimeIO
writev5.1.35 gm2-libs/libc
WriteWord5.2.9 gm2-libs-pim/FileSystem

Jump to:   A   B   C   D   E   F   G   H   I   K   L   M   N   O   P   Q   R   S   T   U   V   W  

[Top] [Contents] [Index] [ ? ]

Footnotes

(1)

To see all the compile actions taken by `gm2' users can also add the `-v' flag at the command line, for example:

`gm2 -v -g -I. -Wmakeall hello.mod'

This displays the subprocesses initiated by `gm2' which can be useful when trouble shooting.

(2)

See the excellent tutorial by Joachim Nadler translated by Tim Josling


[Top] [Contents] [Index] [ ? ]

Table of Contents


[Top] [Contents] [Index] [ ? ]

Short Table of Contents


[Top] [Contents] [Index] [ ? ]

About This Document

This document was generated by Gaius Mulley on December, 18 2006 using texi2html 1.76.

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ < ] Back previous section in reading order 1.2.2
[ > ] Forward next section in reading order 1.2.4
[ << ] FastBack beginning of this chapter or previous chapter 1
[ Up ] Up up section 1.2
[ >> ] FastForward next chapter 2
[Top] Top cover (top) of document  
[Contents] Contents table of contents  
[Index] Index index  
[ ? ] About about (help)  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:


This document was generated by Gaius Mulley on December, 18 2006 using texi2html 1.76.