next up previous contents index
Next: Unimplemented parts of SYSTEM Up: The built-in module SYSTEM Previous: The built-in module SYSTEM   Contents   Index

Commonly available parts of SYSTEM

Ulm's Modula-2 compiler supports the types BYTE, WORD, ADDRESS, and the procedures ADR, TSIZE, NEWPROCESS, TRANSFER.

BYTE2.4 is assignment compatible to all other types which occupy one byte while WORD is compatible to all other types which have a size of four bytes. Both, ARRAY OF BYTE and ARRAY OF WORD are supported as formal parameter types which accept any actual parameter. The only exception is that ARRAY OF WORD accepts only types which occupy a multiple of 4 bytes - this includes all arrays, records, and pointer types. Note, however, that many newer implementations do not offer WORD or ARRAY OF WORD while BYTE and ARRAY OF BYTE are to be expected on nearly all platforms.

ADDRESS is defined as

ADDRESS = POINTER TO WORD
which is assignment compatible to all pointer types and compatible to CARDINAL. Note that some implementations define ADDRESS as POINTER TO BYTE and define ADDRESS to be compatible to LONGCARD or LONGINT instead of CARDINAL. Therefore, it is fairly portable to accept generic pointers as ADDRESS and to pass it, for example, to Storage but it is very system-dependent to assume a size, a structure, or a compatibility to one of the integer types, or to perform address arithmetics. The duplication of unstructured byte quantities is best delegated to a library module which usually contains code which is tuned for the local implementation. In Ulm's Modula-2 library this is done by the module Bytes.

ADR is a function which returns the address of a given variable as value of type ADDRESS. TSIZE returns the number of bytes of the specified type (as value of type CARDINAL). Note that TSIZE like NEW accepts further constant arguments which select by their tag value specific variants of a record. This may be useful if some variants of a record occupy much less space than others but not all Modula-2 compilers support this feature.

Ulm's Modula-2 compiler supports coroutines and their associated procedures NEWPROCESS and TRANSFER. Regrettably, these procedures require some system-dependent knowledge about the necessary size of a coroutine stack and even TRANSFER is not without system dependencies [Borchert94b]. The SPARC-implementation of Ulm's Modula-2 compiler consumes much more stack space than other implementations and requires therefore a minimum size of 8192 bytes for stacks. Stacks which are too small may lead to compiler errors (if a constant is given) or to undefined effects at runtime (you are lucky if it is just a segmentation violation because the system is unable to redzone protect2.5stacks as long as they are given by the programmer and not allocated by the system). Currently, there are no runtime checks for stecks but they are not necessary if a redzone protected area is provided by the programmer (this is not a problem by using the mmap(2) system call).

Note that NEWPROCESS and TRANSFER expect coroutines to be of type ADDRESS. The older revisions of Modula-2 expect PROCESS as argument type of NEWPROCESS and TRANSFER which is provided if one of the older revisions is selected (option -r0 or -r1 at the command line of m2c).


next up previous contents index
Next: Unimplemented parts of SYSTEM Up: The built-in module SYSTEM Previous: The built-in module SYSTEM   Contents   Index
Andreas Borchert 2003-12-10