TOC PREV NEXT INDEX DOC LIST MASTER INDEX



UNIX Restrictions

This chapter provides information about restrictions on and functionality of Ada programs (a program containing one or more compilation units that are written in Ada) for the UNIX operating system. Topics covered in this chapter include:


Restrictions on UNIX Signals

Information about catching, blocking, or ignoring UNIX signals can be found in the Ada Runtime Guide.

The Rational Ada runtime system uses UNIX signals for processing certain features of Ada; as a result, restrictions are placed on the use (generation, catching, and/or blocking) of these signals. The restricted signals are listed in Table 3; detailed descriptions of the restrictions follow.


Warning: Components of Ada programs, whether written in Ada or another language such as C or C++, must not violate the restrictions placed on these signals. Violations might cause your program to execute incorrectly or to fail completely.

Table 3 Restricted UNIX Signals
UNIX signal
Runtime use
Restricted when:
SIGALRM
Preemptive tasking
Using preemptive tasking
SIGFPE
Exception handling
Always
SIGILL
Exception handling
Always
SIGIO
Nonblocking I/O
Always
SIGTRAP
Ada debugger
Always

SIGALRM

Do not block SIGALRM. The Ada tasking runtime system depends on SIGALRM signals for activities used to implement preemptive tasking, such as the scheduling of delays, timed entry calls, and selective waits with delay alternatives. Blocking SIGALRM could cause incorrect task scheduling or even deadlock.

You can catch SIGALRM using an interrupt-entry task if the Posix_Compliant argument on pragma Main is False. In this case, the runtime system processes the signal for tasking purposes and then passes control to your interrupt-entry signal handler. You can catch it with a procedural signal handler only if your program does not use preemptive or time-slice scheduling.

Generating extra SIGALRM signals will not affect the runtime system.

Note: If your program does not use preemptive or time-slice scheduling, these restrictions on SIGALRM do not apply.

SIGFPE and SIGILL

Do not generate, catch, or block SIGILL or SIGFPE. Rational's exception handling uses these signals. Generating either of these signals will result in a spurious exception, and catching or blocking them could result in a failure to handle an exception.

SIGIO

SIGIO is used to implement nonblocking I/O.

You can catch SIGIO using a task entry if the Posix_Compliant argument on pragma Main is False. In this case, the runtime system processes the signal for I/O purposes and then passes control to your task-entry signal handler. You cannot catch SIGIO using an Ada procedural signal handler.

SIGTRAP

Do not generate, catch, or block SIGTRAP. The Rational Ada debugger uses the SIGTRAP signal for communication between the debugger and the runtime debugger-support code. Generating a SIGTRAP signal may erroneously invoke the runtime debugger-support code, with unpredictable results. Catching or blocking it could cause the debugger to fail or not work at all.


Restrictions on UNIX System and Library Calls

Certain UNIX system and library calls operate in a manner that is inconsistent or incompatible with the execution of Rational Ada code. As a result, restrictions are placed on the use of certain UNIX calls. The restricted calls are listed in Table 4. Detailed descriptions of the restrictions are given in the following text.


Warning: Components of Ada programs, whether written in Ada or another language such as C or C++, must not violate the restrictions placed on these calls. Violations can result in a program that does not follow Ada runtime semantics, executes unreliably, or fails completely.


Warning: Any UNIX call that duplicates the restricted functionality of these calls is likewise restricted. Read the detailed descriptions, below, to ensure that violations do not occur.

Table 4 Restricted UNIX System and Library Calls
UNIX system call
Area of concern
Restricted when:
ieee_flags
Floating-point status
Always
ieee_handler
Floating-point exceptions
Always
longjmp
Ada state information
Always
setitimer
Preemptive tasking
Using preemptive tasking
setjmp
Ada state information
Always
sigfpe
Floating-point status
Always
siglongjmp
Ada state information
Always
sigprocmask
Signal management
Always
sigsetjmp
Ada state information
Always
sigstack
Stack management
Always

Ieee_Flags

Do not change (set or clear) the mode settings of the floating- point status register directly or indirectly. Changing these modes might cause incorrect results and/or inhibit exceptions for the floating-point computations in Ada code.

Ieee_Handler

Do not establish a handler for floating-point exceptions using ieee_handler. Establishing an IEEE handler for floating-point exceptions might disable Ada exceptions for the floating-point Constraint_Error exception.

Any other call that can handle floating-point exceptions, such as sigvec and signal, is also restricted for that functionality.

Longjmp, Setjmp, Siglongjmp, and Sigsetjmp

Do not invoke the functions longjmp, setjmp, siglongjmp, or sigsetjmp in Ada routines. These functions do not save and restore all the state required by the Ada runtime system.

Using either longjmp form also evades compiler-generated finalization code that must be executed upon exit from a subprogram to ensure proper Ada runtime semantics.


Warning: These functions can be called safely from another language only if no Ada code is executed between the time that a setjmp is first called and the corresponding longjmp is executed.

Setitimer

In a program that uses preemptive Ada tasking, do not use setitimer or any other command to change the value of any interval timer that generates SIGALRM. The Ada tasking runtime system depends on SIGALRM signals generated by the expiration of the interval timer to trigger scheduling events. Using setitimer to change the interval timer's value could cause your program to work incorrectly or not at all. Disabling the interval timer could cause your program to deadlock.

The calls alarm and ualarm do not affect the functioning of your program; however, you cannot catch or block the SIGALRM generated by these calls except as described on SIGALRM.

Sigfpe

Do not use sigfpe to change the manner in which floating-point errors are handled. Changing floating-point modes or error handling might cause incorrect results and/or inhibit exceptions for floating-point computations in Ada code.

Sigprocmask

Do not use sigprocmask to control the UNIX signal mask. If you need to control the masking, use the POSIX.5 interface; its signal-masking routines coordinate correctly with the Rational Ada runtime system.

Sigstack

Do not set up a signal stack using sigstack. The Ada LRM (11.1) requires that stack overflow conditions raise Storage-_Error, but UNIX signal-stack management does not always provide information about such overflow. To compensate, the Ada runtime system establishes and manages a signal stack. An attempt to establish another signal stack for a program will cause unpredictable results.


Rational Software Corporation 
http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2004, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX DOC LIST MASTER INDEX TECHNOTES APEX TIPS