TOC PREV NEXT INDEX DOC LIST MASTER INDEX



Duo Programs

MARK Duo programs have the same issues as STANDARD duo programs. Some of these issues are listed below.


Ada is the Main Subprogram

A MARK program may reference C/C++ functions. The main subprogram must be written in Ada, the board support package must be initialized, as well as the Ada runtime.


Ada Calling to C Imported Functions

When calling from Ada to C use the Ada95:

Special code is generated at the Ada call site to invoke imported C functions. On some architectures, code to initialize the processor to known state after the call to C_Function is required.

For example, when calling imported C Code on the PowerPC, the additional instruction mcrxr is generated to clear sticky exception bits that might erroneously fire Ada exceptions at some later point as shown below:

Use the pragma Calling_Convention to configure other special code generated at the Ada call site. For example, if the C/C++ code is doing floating point do not forget:

This causes additional wrapping code to be generated around the C/C++ call site to save the floating point state that is valid for Ada processing and initialize the floating point unit for C/C++ processing. Rounding modes and exception conditions are often different between Ada and C.

For example, when calling imported C Code on the PowerPC the floating point state is first stored away and then the floating point state is initialized from the global variable __FP_CONTROL_FOR_C (configured in the v_usr_conf package) before the call to C_Function. After the C_Function returns the floating point state is restored.

This is shown below by the code fragment for calling the imported C function "cio" below:


Exported Ada Called From C Functions

When calling from C to Ada use the Ada95:

The Ada compiler generates stack checking code. When an Ada procedure is called from C, it is assumed that the stack limit needs to be initialized. A call to a runtime function to initialize the stack limit is generated in the prologue code for the external Ada subprogram.

For example, the PowerPC keeps the stack limit register in the r14 register and the prologue code stores away the existing r14 value before initializing it from the runtime call to TS_RELOAD_STACK_LIMIT_REG. The epilogue code restores the r14 register back to it's initial value:

Pragma Calling_Convention(Ada_Function, Stack_Limit => Defeated) can be used to initialize the PowerPC r14 register to 0. Stack_Limit => None can be used leave the r14 register untouched. The Rational C/C++ PowerPC compiler does not use the r14 register.

There is often a floating point state that must be initialized to particular values for Ada code to execute correctly. This is done in the prologue of the External Ada subprograms. The state may need to be restored in the epilogue.

If the Calling_Convention specifies Floating_Point_Status_Preserve => True, then the prologue will contain:

And the epilogue will contain the restore code:

The __FP_CONTROL_FOR_ADA is configured in the V_Usr_Conf package and will not normally require adjustment.


Ada Duo Rational Executive Issues

MARK Duo programs have the same issues as standard Rational Executive Duo programs. Some of these issues are listed below.


MARK Duo Issues

The malloc/free are supported in storage_management.ss. Even the .sm0. implementation supports malloc using AA_NO_EXCEPTION_GLOBAL_NEW on the runtime allocate only functions. The free calls are simply ignored. See the sm0 Description for more information.


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