HP OpenVMS Systems

Content starts here

DEC Ada
Technical Overview and Comparison on DIGITAL Platforms


Previous Contents Index

The Ada language specifies that unrecognized pragmas are accepted but ignored. Therefore, programs using a Apex-only pragma on a DIGITAL implementation compile but do not necessarily run as expected.

D.8.1 Pragma-Related Restrictions

Restrictions on the Pragma INLINE

Apex applies the following restrictions to the pragma INLINE:

  • Recursive calls are expanded to maximum depth of 4.
  • Subprograms cannot declare the following:
    • Tasks
    • Packages
    • Exceptions
    • Types
    • Nested subprograms

DEC Ada applies the following restrictions to the pragma INLINE:

  • Parameters cannot be a task type.
  • Function results cannot be task types, unconstrained array types, or unconstrained types with discriminants.
  • Bodies cannot declare the following:
    • Subprogram body or stub (imported subprogram is allowed)
    • Tasks
    • Generic declarations
    • Instantiations
    • Exceptions
    • Access types (types derived from access types allowed)
    • Array or record types
    • Dependent tasks
    • Direct recursive calls of subprogram or containing subprogram, directly or via a renaming

Restrictions on the Pragma INTERFACE

Table D-7 describes the restrictions on the pragma INTERFACE on Apex and DEC Ada.

Table D-7 Restrictions on the Pragma INTERFACE
Restriction Apex DEC Ada
Languages accepted: Ada, C, Pascal, ASM, Fortran, unchecked. Ada, Bliss, C, Fortran. Default is C on DIGITAL UNIX.
Parameter passing: Language specifies default mechanism. Language specifies default mechanisms but can be overridden with an EXPORT pragma.
  Ada: use Ada rules. Ada: use internal Ada rules.
  C: parameters must be mode 'in'; scalar, access or SYSTEM.ADDRESS types for parameters and results. Bliss, C: parameters must be mode 'in'; cannot be record or task type. Result cannot be a string, an array, or a record.
  Fortran: pass by reference and must be of type ADDRESS. Result must be a scalar. Fortran: parameters cannot be a task. Result cannot be a string, an array, or a record.
  Unchecked: similar to the language Ada. Not available on DEC Ada for DIGITAL UNIX.

D.9 Library of Predefined Units

A library of predefined units is provided as part of the Apex and DEC Ada implementations. The following predefined units are provided by both implementations:

  • Package CALENDAR
  • Package DIRECT_IO
  • Package IO_EXCEPTIONS
  • Package SEQUENTIAL_IO
  • Package STANDARD
  • Package SYSTEM
  • Package TEXT_IO
  • Generic function UNCHECKED_CONVERSION
  • Generic procedure UNCHECKED_DEALLOCATION

In Apex, UNCHECKED_CONVERSION cannot be instantiated with a target type that is an unconstrained array type or an unconstrained record type with discriminants.

There are no restrictions on the types with which UNCHECKED_DEALLOCATION can be instantiated. No checks are performed on released objects.

In addition, Apex provides the package LOW_LEVEL_IO and the package MACHINE_CODE. Package MACHINE_CODE provides an assembly language interface for the target machine, including the necessary record types needed in the code statement, an enumeration type containing all the opcode mnemonics, a set of register definitions, and a set of addressing mode functions.

DEC Ada does not provide the package MACHINE_CODE. Instead, DEC Ada recommends importing assembler code.

D.9.1 Implementation-Defined Packages

Both VADS and DEC Ada provide packages beyond the minimum required by the Ada language standard.

The following packages are available on Apex:

  • Apex_BOUNDED (bounded variable strings)
  • Apex_COMMAND_LINE
  • Apex_SORT_UTILITIES
  • Apex_STRING_UTILITIES
  • Apex_TIME_UTILITIES
  • MATH, GENERIC_ELEMENTARY_FUNCTIONS (math packages)
  • UNSIGNED_TYPES, COMPLEX_ARITH (unsigned integers, complex numbers)

Package UNSIGNED_TYPES is supplied to illustrate the definition of and services for the unsigned types supplied. It is given with no warranty, expressed or implied, for the effectiveness or legality of the package.

Note

UNSIGNED_TYPES is used at the user's own risk.

Rational recommends that instead of using the package UNSIGNED_TYPES, that users use the Ada95 “mod” syntax to define their own modulo types.

The following packages are available on DEC Ada:

  • ADDRESS_OPERATIONS
  • ASSERT, ASSERT_EXCEPTIONS, ASSERT_GENERIC
  • C_TYPES
  • CURRENT_EXCEPTION
  • ELEMENTARY_FUNCTIONS_EXCEPTIONS
  • ERRNO
  • GET_TASK_INFO
  • HEAP_SORT
  • MAIN_PROGRAM_ARGUMENT_LIST
  • MATH_LIB
  • POSIX
  • SET_TASK_PRIORITY
  • SYNCHRONIZE_NONREENTRANT_ACCESS
  • TIME_CONVERSION

The following list shows differences regarding packages as implemented on Apex:

  • On Apex, the package LANGUAGE has the following constants:
    • C_PREFIX
    • C_SUBP_PREFIX
    • FORTRAN_PREFIX
    • FORTRAN_SUFFIX
    • OBJECT_EXTENSION
    • LIBRARY_EXTENSION
    • EXECUTABLE_EXTENSION

Apex supports packages to interface to every facility in UNIX, sometimes with several different interfaces. DEC Ada has minimal interfaces to the command line and to signals.

Apex provides the packages MACHINE_TYPES and MACHINE_CODE. Also provided are the V_* packages designed for customizing the run-time system and the kernel run-time system.

D.10 Bindings

DEC Ada provides the following strongly typed bindings:

  • X Window System Version 11R4, 11R5, and 11R6 (X, XLIB interface)
  • X Windows Toolkit (XT interface)
  • Motif Version 1.1.3 and 1.2 (XM interface)

On DIGITAL UNIX, DEC Ada also provides support for the POSIX Ada Language Interface bindings as required by IEEE Standard 1003.5-1992 (IEEE Standard for Information Technology, POSIX Ada Language Interfaces.

Rational provides an optional bindings package to X/Windows and Motif, called AXI.

Apex is shipped with the POSIX Ada Language Interfaces.

D.10.1 Interfaces to C

Both Apex and DEC Ada recognize the importance of interfacing to C and provide Ada types and operations, as shown in Table D-8.

Table D-8 Interfaces to C
Type or Operation Apex DEC Ada
C types package C_TO_A_TYPES C_TYPES
C strings C_STRINGS C_TYPES.NULL_TERMINATED
Other types SHORT SHORT_INT
Operations C_PRINTF
STRLEN
STRNCPY
 

D.10.2 Other Features and Restrictions

Other features and restrictions are as follows:

  • The Apex compiler generates code for a generic instantiation that can be shared by other instantiations of the same generic which reduces the size of the generated code and increases compilation speed. There is an overhead associated with the use of shared code instantiations because the generic actual parameters must be accessed indirectly and, in the case of a generic package instantiation, declarations in the package are also accessed indirectly. Greater optimization is possible for unshared instantiations because exact actual parameters are known. It is the responsibility of the programmer to decide whether space or time is the most critical in a specific application.
  • The compiler and other large dynamic compiled programs occasionally give problems due to the shell's stack limit. Altering the stack size and recompiling or reexecuting is sometime necessary. A process inherits its stack limit from the invoking process (usually the shell).
    The C shell allows the default stack size to be reset usually up to the limit of the process size. Most Bourne shell implementations do not permit the stack size to be altered.
  • On Apex, the following restriction is in effect: An error occurs if one compilation has two versions of the same unit.

Other differences between Apex and DEC Ada are as follows:

  • Apex allows the following type declaration, whereas, on DEC Ada, it is diagnosed as an error:


    type T16 is new SHORT_INTEGER range -32768 .. 32767
    

    In this declaration, DEC Ada interprets the numeric literals in the range of the declaration as having constraints that are of type SHORT_INTEGER. Therefore, it considers positive value 32768 to be of type SHORT_ INTEGER. The intention is to apply a hyphen (-) to it, but instead the compiler generates a constraint error. Apex as allowed by LRM 11.6(6), uses a larger type as the base type for the operation.
    On DEC Ada, the user can use attributes (such as SHORT_INTEGER'FIRST), create a nonderived type, or use an integer conversion. For example:


    type T16 is new SHORT_INTEGER range SHORT_INTEGER'FIRST .. SHORT_INTEGER'LAST
    
  • DEC Ada has restrictions on 'SIZE, 'STORAGE_SIZE, 'SMALL.
  • On DEC Ada, unchecked conversion does not work between machine addresses and access types that point to unconstrained arrays.
  • Record types having discriminants with default expressions are implemented on DEC Ada are described as follows:
    • On DEC Ada, the storage size for an unconstrained record object is large enough for any value that could be assigned to that object. This size is calculated using the lower and upper bounds of the subtypes of the discriminants. Assignment simply moves the value into the variable's storage.

    This approach can cause unnecessarily large amounts of storage to be used or even for STORAGE_ERROR to be raised. This might occur if the subtype of a discriminant is INTEGER and the discriminant is used within the record as a bound of an array. This would make the largest possible value very large.
    The workaround is to define a new subtype of INTEGER that has bounds that are smaller but large enough to hold the actual sizes encountered in your program.
  • Use of the Apex pragma EXTERNAL (C, subprogram_name) can be converted to DEC Ada by using a pragma EXPORT_FUNCTION or EXPORT_PROCEDURE and specifying mechanisms for parameters and results.
  • In DEC Ada, the subprogram 'ADDRESS is supported only for imported or exported subprograms. There are restrictions on the placement of exported subprograms. See the DEC Ada Language Reference Manual for more information.
  • On Apex, the type DURATION supports longer periods.
  • Alignment restrictions for records are as follows:
    • On Apex, power of 2 up to 24
    • DEC Ada, power of 2 up to 23
    • Address clauses are supported for objects and entries on both implementations; unnamed imported subprograms are supported on DEC Ada only.

The differences in the definition of a main program on Apex and DEC Ada are as follows:

  • On Apex, main programs are defined as follows:
    • Must be a non-generic, parameter-less subprogram that is either a procedure or function returning an Ada STANDARD.INTEGER (the predefined type)
    • Cannot be a generic subprogram or an instantiation of a generic subprogram
  • On DEC Ada for DIGITAL UNIX, main programs are defined to meet the following conditions:
    • Procedure with no formal parameters (returns 42 when unhandled exceptions are raised)
    • Function with no formal parameters whose returned value is of a discrete type
    • Procedure with one OUT formal of a discrete type for which a pragma EXPORT_VALUED_PROCEDURE is specified

When a main function or main procedure declared with the pragma EXPORT_VALUED_PROCEDURE returns a discrete value whose size is less than 64 bits (on Alpha systems), the value is zero- or sign-extended as appropriate.

D.11 Implementation-Defined Attributes

Apex provides the implementation-defined attributes shown and briefly described in Table D-9.

Table D-9 Apex Implementation-Defined Attributes
Attribute Description
COMPILER_KEY For a prefix N denoting the name of an entity, N'COMPILER_KEY yields the full path name of the compiler key, which indicates the compiler that was used to generate code for the unit containing the definition of N.
COMPILER_VERSION For a prefix N denoting the name of an entity, N'COMPILER_VERSION yields the version of the compiler that was used to generate code for the unit containing the definition of N.
DOPE_ADDRESS For an array object A, A'DOPE_ADDRESS yields the address of the dope vector that describes A.
DOPE_SIZE For an array object A, A'DOPE_SIZE yields the size in bits of the dope vector.
ENTRY_NUMBER For a prefix E denoting A TASK ENTRY OR GENERIC FORMAL SUBPROGRAM, E'ENTRY_NUMBER yields a UNIVERSAL_INTEGER value that uniquely identifies the entity denoted by E.
HOMOGENEOUS For a prefix T denoting an access type, T'HOMOGENEOUS yields a Boolean value.
REF The REF attribute denotes the effective address of the first of the storage units allocated to the object. Not supported for a package, task unit, or entry.
TASK_ID For a non-passive task object or value X, X'TASK_ID yields the unique task ID associated with the task.
TYPE_KEY For a prefix T denoting a type name, T'TYPE_KEY yields a string that uniquely_identifies_type_T.

DEC Ada provides the implementation-defined attributes shown and briefly described in Table D-10.

Table D-10 DEC Ada Implementation-Defined Attributes
Attribute Description
BIT For a prefix P that denotes an object, P'BIT yields the bit offset within the storage unit (byte) containing the first bit for the object P.
MACHINE_SIZE For a prefix P that denotes any type or subtype, P'MACHINE_SIZE yields the number of machine bits to be allocated for variables of the type or subtype.
NULL_PARAMETER For a prefix P that denotes any type or subtype, P'NULL_PARAMETER yields an (imaginary) object of type or subtype P allocated at (machine) address zero.
TYPE_CLASS For a prefix P that denotes a type or subtype,
P'TYPE_CLASS yields the value of the type class for the full type of P.

D.12 Compiler and Run-Time Interfacing

To pass options to the linker, Apex provides the pragma LINK_WITH. DEC Ada provides the following ways to pass options to the linker:

  • Enter the ald -L command specifying the options to be passed to the linker.
  • Define the environment variable LDFLAGS to provide the equivalent features.
  • Enter the aimport -a ldargs command to associate linker arguments with a library package or subprogram body that can later be linked.

DEC Ada supplies the following ways of controlling optimization:

  • OPTIMIZE
  • INLINE
  • INLINE_GENERIC
  • SUPPRESS_ALL
  • PASSIVE
  • Several compiler command options

Apex supplies the following pragmas to control optimization:

  • INLINE
  • INLINE_ONLY
  • INLINE_NEVER
  • OPTIMIZE

Optimization with Apex can be controlled through the use of library level switches, or through use of the above pragmas.

Optimization on DEC Ada can be controlled at the command-line level.

D.13 User Interface

Apex is a GUI based application that provides an entire development environment. There are command line equivalents for all GUI operations. Only a small subset of the available commands is listed here. This subset is made up of those commands that have a DEC Ada equivalent.

Apex and DEC Ada provide a comparable set of commands to build programs and manage the program library. Table Table D-11 lists the ADA and DEC Ada commands and points out any differences as appropriate.

Table D-11 Comparison of Apex and DEC Ada Commands
Apex Command DEC Ada Command
apex code ada
apex clean arm
apex copy acp
disassemble setenv 1 ADALISFLAGS "+m"
a_db DECladebug 2 with the name of the main program
apex_display help man 2 (with name of the appropriate command); also, the ada(1) reference page contains additional information on defining a context, getting started, and debugging.
apex report als
apex link ald , amake
N/A You can create a listing file in two ways:
  • Use the -V option with the ada command.
  • Define the ADALISFLAGS and ADALISDIR environment variables to control the information to the listing file and where it will be placed.
N/A als
Make is automatic when any compilation is run amake
Map file created automatically odump 2
apex create_view amklib
apex move acp and arm
Always derived from context of compilation setenv adalib or the -A option
N/A aprintlib
apex delete armlib
apex delete arm
N/A axargs
Directly viewed through the interactive Ada editor acat
N/A areport

1This is a csh(1) built-in command and not a DEC Ada command.
2This is a DIGITAL UNIX and not a DEC Ada command. See the online reference page for this command to obtain more information.

D.14 Apex Optional Products

Apex implementations supply optional products (for static analysis, cross compilation and so forth), as shown in Table D-12:

Table D-12 Apex Optional Products
Product Purpose
Ada Analyzer Static Analysis of user code. Locates coding violations and Potential maintenance problems.
AXI Bindings for X11 and MOTIF
Testmate Test management system, code coverage analysis
SoDA Automated document production
Rational/Rose Visual Modeling using UML. Supports code generation and reverse engineering.

Table D-13 briefly describes some of the features of the user interface.

Table D-13 User Interface Features
Feature Apex DEC Ada
Modifying a path Use Apex IMPORTS commands Use any of the DIGITAL UNIX editors to modify the context file.
Specifying paths Use Apex IMPORTS commands Define the environment variable (ADALIB) or use the -A option with a DEC Ada command.
Sublibraries Not supplied Allow you to create a sublibrary structure.

D.15 Input-Output

The Apex Ada I/O system is implemented using DIGITAL UNIX I/O. Both formatted and binary I/O are available. There are no restrictions on the types with which DIRECT_IO and SEQUENTIAL_IO can be instantiated except that the element size must be less than a maximum given by the variable SYSTEM.MAX_REC_SIZE. This variable can be set to any value prior to the generic instantiation. Therefore, you can use any element size.

DIRECT_IO can be instantiated with unconstrained types, but each element is padded out to the maximum possible for that type or to SYSTEM.MAX_REC_SIZE, whichever is smaller. No checking (other than normal static Ada type checking) is done to ensure that values from files are into correctly sized and typed objects.

Apex file and terminal input-output are identical in most respects and differ only in the frequency of buffer flushing. Output is buffered (buffer size is 1024 bytes). The buffer is always flushed after each write request if the destination is a terminal. The procedure FILE_SUPPORT.ALWAYS_FLUSH (file_ptr) causes flushing of the buffer associated with file_ptr after all subsequent output requests.

Instantiations of DIRECT_IO use the value MAX_REC_SIZE as the record size (expressed in STORAGE_UNITs) when the size of ELEMENT_TYPE exceeds that value. MAX_REC_SIZE is defined in package SYSTEM and can be changed before instantiating DIRECT_IO to provide an upper limit on the record size. The maximum record size supported is 1024*1024*STORAGE_UNIT bits.

Instantiations of SEQUENTIAL_IO use the value MAX_REC_SIZE as the record size (expressed in STORAGE_UNITs) when the size of ELEMENT_TYPE exceeds that value. MAX_REC_SIZE is defined in package SYSTEM and can be changed by a program before instantiating SEQUENTIAL_IO to provide an upper limit on the record size. SEQUENTIAL_IO imposes no limit on MAX_REC_SIZE.

On DIGITAL UNIX systems, DEC Ada predefined input-output packages and their operations are implemented using systems calls, which provide read sharing for the sequential and direct packages. DEC Ada provides no additional input-output packages specifically related to DIGITAL UNIX systems.

DEC Ada predefines the following input-output packages on DIGITAL UNIX:

  • DIRECT_IO
  • DIRECT_MIXED_IO
  • SEQUENTIAL_IO
  • TEXT_IO
  • IO_EXCEPTIONS

The packages DIRECT_IO, SEQUENTIAL_IO, AND TEXT_IO are predefined by the Ada language. The remaining packages are predefined by the Ada implementation.

To make the use of the generic TEXT_IO operations more convenient, DEC Ada provides predefined library packages that instantiate the integer and floating-point operations for the predefined integer and floating-point types as shown in Table D-14.

Table D-14 Predefined Instantiations of TEXT_IO Packages
Package Name Instantiation
LONG_INTEGER_TEXT_IO LONG_INTEGER_IO(INTEGER)
INTEGER_TEXT_IO INTEGER_IO(INTEGER)
SHORT_INTEGER_TEXT_IO INTEGER_IO(SHORT_INTEGER)
SHORT_SHORT_INTEGER_TEXT_IO INTEGER_IO(SHORT_SHORT_INTEGER)
FLOAT_TEXT_IO FLOAT_IO(FLOAT)
LONG_FLOAT_TEXT_IO FLOAT_IO(LONG_FLOAT)

The DEC Ada predefined packages and their operations are implemented using DIGITAL UNIX files and input-output facilities. DEC Ada supports asynchronous input-output on DIGITAL UNIX. Familiarity with the following is recommended:

  • DIGITAL UNIX files
  • DIGITAL UNIX input-output facilities

On DIGITAL UNIX, the value of the FORM parameter conforms to the description of the FORM parameter in IEEE Standard 1003.5-1992, IEEE Standard for Information Technology, POSIX Ada Language Interfaces.


Previous Next Contents Index