21. Runtime Library#

The runtime library routines provide basic runtime support. The source for these routines is in the lib_src directory of the release structure.

“Basic” runtime support means support for operations built in to the C++ language, like new and delete, and for operations for which code is generated by IL lowering, e.g., array initialization. (This includes code generated by the lowering of C99 constructs.) It does not mean support for all libraries required by the C++ standard, e.g., iostreams.

The front end supports two different runtime models. A configuration macro is used to select the runtime model to be used. The models supported are the IA-64 ABI and one that is an extension of the one used with cfront.

The IA-64 model is a complete implementation of the IA-64 ABI, except that the exception handling implementation does not conform to the ABI (because producing a conforming implementation of exception handling requires back end support).

The cfront runtime model is generally compatible with the one used by cfront version 3.0.2, and in fact the code generated by the front end in cfront object code compatibility mode will work with the libraries supplied with cfront (with one exception that is described below). Another way of saying the same thing: The runtime library is an independent implementation of the runtime interface defined by cfront.

One incompatibility between our runtime support library and the one provided with cfront is the handling of static destructors. The cfront static destruction mechanism does not conform to the C++ standard, which requires all static objects, including local static objects, to be destroyed in the reverse order of construction. The EDG static destruction mechanism relies on a new data structure called the needed destructions list. If a cfront runtime library is to be used, the dtor_list.o file from the EDG library must be included when a program is linked. This may be done by explicitly including dtor_list.o in the link command generated by the driver, or by adding dtor_list.o to the library file containing the cfront libraries.

In the area of exception handling, there is no standard cfront runtime model (because no version of cfront that supports exception handling was released by USL), so the model is invented by EDG, drawing on some published aspects of the implementation done by Hewlett-Packard.

The runtime routines should be considered to be a sample implementation of a runtime library. They are believed to be complete and to work correctly, but they might require adaptation to make them work correctly in a given environment, or to make them compatible with other runtime libraries or conventions on the target system. In particular, if runtime compatibility with cfront is not required, there are probably better ways of doing some of these things. Also, the target system may provide efficient support for things that can only be done in a clumsy way in a portable runtime library, e.g., getting start-up initialization code run automatically at the beginning of execution.

21.1. The --building_runtime option#

Like the front end, the runtime contains a number of configuration flags. In many cases, it is essential that the same values be used by both the front end and the runtime with which the generated code will be linked. To help make sure the runtime is configured properly the --building_runtime option should be specified when compiling the runtime. This causes additional preprocessing macros to be defined that pass the value of certain configuration flags from the front end to the runtime. The following preprocessing macros are defined when the --building_runtime option is used:

__EDG_JMP_BUF_ELEMENT_TYPE

The name of the integer or floating point type that is used as the element type of the jmp_buf array used by setjmp.
__EDG_JMP_BUF_NUM_ELEMENTS

The number of elements in the jmp_buf array used by setjmp.
__EDG_DELTA_TYPE
The name of the integer type that is used to represent the offset in a virtual function table entry.
__EDG_VIRTUAL_FUNCTION_INDEX_TYPE

The name of the integer type that is used to represent the index field in a virtual function table entry.
__EDG_VAR_HANDLE_TYPE

The name of the integer type that is used to represent a “handle” in exception handling tables. Defined only when GENERATE_EH_TABLES is TRUE.
__EDG_REGION_NUMBER_TYPE

The type of a region number field in the exception handling tables. Defined only when GENERATE_EH_TABLES is TRUE.
__EDG_ETS_FLAG_TYPE

The type used to pass exception types flags to the runtime library. Defined only when GENERATE_EH_TABLES is TRUE.
__EDG_NULL_EH_REGION_NUMBER

The value used as the null region number value in the exception handling tables. Defined only when GENERATE_EH_TABLES is TRUE.
__EDG_LOWER_VARIABLE_LENGTH_ARRAYS

Indicates whether or not the front end is configured to lower variable-length arrays. Set to the value of (VLA_ALLOWED && LOWER_VARIABLE_LENGTH_ARRAYS) in the front end.
__EDG_IA64_ABI_USE_VARIANT_ARRAY_COOKIES

Non-zero when the variant representation of array cookies is used in the IA-64 ABI. Defined only when IA64_ABI is TRUE.
__EDG_ELEM_COUNT_PARAM_TYPE

The type used to represent the number_of_elements argument in the Cfront-like ABI. Defined only when IA64_ABI is FALSE.
__EDG_ABI_COMPATIBILITY_VERSION

The value of ABI_COMPATIBILITY_VERSION used when the front end was built.
__EDG_ABI_CHANGES_FOR_RTTI

The value of ABI_CHANGES_FOR_RTTI used when the front end was built.
__EDG_ABI_CHANGES_FOR_ARRAY_NEW_AND_DELETE

The value of ABI_CHANGES_FOR_ARRAY_NEW_AND_DELETE used when the front end was built.
__EDG_ABI_CHANGES_FOR_PLACEMENT_DELETE

The value of ABI_CHANGES_FOR_PLACEMENT_DELETE used when the front end was built.
__EDG_BSD
The value of the __BSD__ macro when the front end was built.
__EDG_SYSV
The value of the __SYSV__ macro when the front end was built.
__EDG_ANSIC
The value of the__ANSIC__ macro when the front end was built.
__EDG_CPP11_IL_EXTENSIONS_SUPPORTED
The value of CPP11_IL_EXTENSIONS_SUPPORTED when the front end was built.