Runtime Library Overview

The library of modules provided with Stony Brook Modula-2 is extensive. The library includes ISO Standard modules, modules unique to Stony Brook Modula-2, and modules that are used internally by the compiler runtime system. Many of the ISO modules are implemented with calls to the Stony Brook specific modules. Full source code for all modules is provided, including low level compiler internal support procedures. The focus of the library are modules that are portable in nature from one operating system to another, and modules that are generally useful to all applications. Some modules are not available for all supported platforms. Unless otherwise specified all modules are available for all supported platforms. All modules are documented via their DEFINITION MODULE source files included with Stony Brook Modula-2. This section provides a list of the modules available in the runtime library and what functionality the module provides. For specific information on the module refer to the module source file.

SYSTEM modules

SYSTEM
EXCEPTIONS
M2EXCEPTION
M2OOEXCEPTION
TERMINATION
COROUTINES
GARBAGECOLLECTION

These modules are not real modules per se since they do not have direct source code, and many parts of the modules are implemented completely in the compiler and other parts are implemented via compiler runtime support procedures, and finally some declarations cannot be declared in normal Modula-2 source code. You import from these modules in the normal way. All ISO Modula-2 implementations will support these modules and all of their symbols, except the SYSTEM module. The ISO standard allows an implementation to add extensions to the SYSTEM module. The definitions of these modules are given here since no DEFINITION MODULE exists for these modules.

The following modules will exist in all ISO Modula-2 implementations. These modules are documented in the language reference help.

Storage

This module provides procedures for dynamic memory allocation and deallocation by calling the procedures directly or indirectly with the NEW and DISPOSE standard procedures. The ExStorage module is a more capable module.

CharClass

This module provides procedures to classify the value of a character type to a functional group. For example, to determine if a character is a numeric character.

LowReal

This module provides a very low level interface to the exact implementation details of the REAL type.

LowLong

This module provides a very low level interface to the exact implementation details of the LONGREAL type.

The following modules are part of the ISO Standard library, however an implementation does not have to provide these modules. If an implementation does have a module with the same name as one of the ISO Standard modules then that module must conform to the ISO definition of that module with no extensions, alterations or deletions. In general all ISO Modula-2 implementations will provide these modules.

Strings

This module provides procedures to manipulate ARRAY OF CHAR types, which are normally called Strings.

RealMath

This module provides various mathematical functions for type REAL.

LongMath

This module provides various mathematical functions for type LONGREAL.

ComplexMath

This module provides various mathematical functions for type COMPLEX.

LongComplexMath

This module provides various mathematical functions for type LONGCOMPLEX.

SysClock

This module provides procedure to access the system real time clock.

ConvTypes

This module defines type used by the following string conversion modules.

WholeStr

Procedures to convert INTEGER and CARDINAL types to strings and visa versa.

RealStr

Procedures to convert the REAL type to strings and visa versa.

LongStr

Procedures to convert the LONGREAL type to strings and visa versa.

WholeConv

Low level conversion procedures for INTEGER and CARDINAL.

RealConv

Low level conversion procedures for REAL.

LongConv

Low level conversion procedures for LONGREAL.

The ISO Modula-2 I/O library modules

IOResult, TextIO, WholeIO, RealIO, LongIO, RawIO
IOChan, IOConsts, StdChans
StreamFile, SeqFile, RndFile, TermFile, ProgramArgs
IOLink, ChanConsts

STextIO, SWholeIO, SRealIO, SLongIO, SRawIO, SIOResult

All of the following modules are specific to Stony Brook Modula-2.

Note: Full source code is supplied for all runtime library modules therefore portability should not be an issue.

ASCII

This module provides mnemonics for ASCII control codes.

Environment

This module provides procedures to access environment strings and the command line string.

RunProg

This module provides procedures to execute programs and command interpreter commands.

Conversions

This module provides numeric conversions for INTEGER, CARDINAL, LONGINT and LONGCARD types.

RConversions

This module provides numeric conversions for the REAL and LONGREAL types.

ElapsedTime

This module provides procedures for calculating an elapsed time between two procedure calls and executing timed delays.

RandomNumbers

This module provides procedures for generating fast pseudo random number sequences of type CARDINAL.

RealRandomNumbers

This module provides procedures for generating fast pseudo random number sequences to type REAL.

Terminal

This module provides procedures for reading and writing to a simple terminal device. On graphical operating systems a text mode window is used to simulate a text mode terminal.

FileFunc

This module provides extensive flexibility and capability for dealing with disk storage devices and pipes.

TextFileFunc

The module provides procedures for reading and writing human readable formatted text files.

LWholeIO, SLWholeIO, LWholeStr

Similar to the functions found in WholeIO, SWholeIO, WholeStr except these modules apply to type LONGINT and LONGCARD.

ComplexIO, LongComplexIO, SComplexIO, SLongComplexIO

These module provide text input and output of COMPLEX and LONGCOMPLEX types. The modules follow, and integrate with, the format of the ISO standard I/O library.

FormatString

This module provides a procedure that will generate a formatted string from a format template string and a variable number of format items such as CARDINAL and ARRAY OF CHAR.

MemUtils

This module provides procedures for filling, scanning and moving memory regions.

ExStorage

This is a 100% compatible superset of the ISO Standard Storage module. Actually the ISO Storage module is implemented with calls to this module. This module provides extensive flexibility and capability in dealing with dynamic memory allocation.

ExStrings

This module provides case insensitive versions of the ISO Standard Strings module procedures, Unicode and UTF-8 string conversion and many other useful string functions.

TimeFunc

This module extends the ISO Standard SysClock module by providing functions for comparing DateTime values, and conversions to/from DateTime and the DOS file date time format, and to/from DateTime and the C/Unix runtime library date time format.

GenCRC

This module provides functions for generating a 32-bit CRC.

SortLib

This module provides functions for sorting data.

BitVectors

This module provides functions for manipulating bit vectors. Bit vectors are very similar to SET types, however these can be of an arbitrary size allocated at runtime.

SetExStorageDebugMode

This module provides a simple method of setting the default heap in ExStorage to debug mode. This module is useful when you have module initialization code that allocates memory. To use this module you simply import it as the first module imported in your main program.

ExtUtils

This module is only available for 32-bit DOS extended applications. It provides procedures for accessing real mode memory addresses from 32-bit protected mode. It isolates a program from differences between the FlashTek and PharLap DOS extenders should you want to run under both. The FlashTek extender is the one included Stony Brook Modula-2.

MD5, SHA1, SHA256, SHA384, SHA512, AreSee4, DES, AES, Blowfish, RSA, HMAC

These are used in cryptography and the names of the modules should tell you what they do.

CryptEncode

This module provides block encoding and decoding procedures used in encryption. RFC 1423, OAEP and PSS encoding are supported.

CryptKey

This module provides key derivation functions used with symmetric encryption algorithms. KDF1 and KDF2 are supported.

VLI

This module implements an integer type with an unlimited numeric range.

The following modules are only available on 32-bit Windows and Unix target systems.

Threads

This module provides procedures that support creating and controlling threads, inter-thread synchronization and inter-process synchronization.

PipedExec

This module provides procedures to allow you to execute a program asynchronous with your process and to redirect its standard input and standard output to a FileFunc File which can then be used with the FileFunc read/write procedures.

MemShare

This module provides procedures to allocate inter-process Shared memory.

FileMap

This module provides procedures to manipulate memory mapped files.

Pipes

This module provides procedures for controlling pipes used for inter-thread communication. Byte and message pipes are supported.

ConfigSettings

This module provides procedures to read and write configuration files in a portable manner. Both per machine (global) and per user (local) settings are supported.

Socket

This module provides a portable interface to the "sockets" API.

SMTP

This module provides an interface to the SMTP e-mail protocol.

Timers

This module provides a portable encapsulation for creating timers not associated with a GUI window.

Portable GUI modules.

These are the modules we use to develop the environment and debugger user interfaces. They are implemented for Win32 and Unix. They are also implemented for the Macintosh using the p1 compiler.

The following modules are only available on 32-bit Windows target systems.

Win32 API interface files

See Developing 32-bit Windows programs

SplitterControl

This module provides a control to split a window into to separate panes which can contain independent child windows. The proportion of the split can be controlled by the user by dragging the splitter bar.

Registry

This module provides procedures to greatly simplify using the Win32 registry.

StringCache

This module provides a procedure to read and cache in memory strings that are obtained from a string table resource.

NamedPipes

This module provides procedures for controlling pipes for inter-process and inter-computer(LAN) communication. Byte and message pipes are supported.

The following modules are only available on Unix target systems.

UNIX API interface files

See Developing Unix programs