LIBMON(7)

NAME
libmon - library of system call routines with EM calling sequence

DESCRIPTION
The modules in this library contain the UNIX system calls with EM calling sequence. This library is written in EM assembly language and can be used for interpreted programs, and a.out programs. If these routines are used in Pascal programs, then the calling sequence requires some attention. Some hints may be useful:

-   The c-option {$c+} allows declaration of zero-terminated string constants in Pascal like "/etc/passwd". Moreover, the identifier string is then defined as type identifier for a pointer to these zero-terminated strings.

-   The d-option {$d+} allows the use of double precision integers (longs). The lseek system call, for instance, needs a long argument and returns a long result.

-   If the system call requires a pointer as argument use a var parameter. For instance declare times as:
         procedure times(var t:timesbuf); extern;
    Note that a string is already a pointer.

-   When defining types, use packed records if two bytes must be allocated in a single word, as in
         device = packed record
                    minor,major:0..255;
                  end;

-   If a collection of bits is needed, then define an enumerated type and a set of this enumerated type. The create mode of a file, for example, can be declared as:
         modebits = (XHIM,WHIM,RHIM,
                     XYOU,WYOU,RYOU,
                     XME, WME, RME,
                     TEXT,SGID,SUID,... );
         creatmode = set of XHIM..SUID;

-   There are special system call routines uread and uwrite in libpc(7), because the names read and write are blocked by similar functions in Pascal.

The system call signal exists, but uses sigtrp. This EM system call has the following calling sequence:
     function sigtrp(signo,trapno:integer):integer;
The action values of signal, odd for ignore and zero for get back to default, may interfere with the EM procedure identification in some implementations. In most interpreters procedures in EM are numbered consecutively from zero up. The first argument of sigtrp is the signal number signo as for signal. The second argument is an integer trapno, indicating the action to be performed when the signal is issued:

-2  Reset the action for signal signo to the default.

-3  Ignore signal signo.

0-252
    Perform an EM instruction TRP with error code trapno, whenever the signal signo is issued. Note that the error codes 0-127 are reserved for EM machine errors and language runtime system errors.

The routine sigtrp returns the old trapno or -1 if an erroneous signal number is specified. Only the signal numbers 1, 2, 3, 13, 14, 15 and 16 may be used as argument for sigtrp.

FILES

~em/lib/*/tail_mon

SEE ALSO
em(1), ack(1), *(2), libpc(7)

DIAGNOSTICS
All routines put the UNIX error code in the global variable errno. Errno is not cleared by successful system calls, so it always gives the error of the last failed call. One exception: ptrace clears errno when successful.

AUTHOR
Ed Keizer, Vrije Universiteit

BUGS
There should be additional routines giving a fatal error when they fail. It would be pleasant to have routines, which print a nice message and stop execution for unexpected errors.