HP OpenVMS Systems

Content starts here

DEC Ada
Technical Overview and Comparison on DIGITAL Platforms


Previous Contents Index

C.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 VADS:

  • BIT_FLG_FIX, HEX, V_BITS (operations on predefined types)
  • MATH, GENERIC_ELEMENTARY_FUNCTIONS (math packages)
  • ORDERING (sort routines)
  • A_STRINGS, VSTRINGS (variable-length strings)
  • UNSIGNED_TYPES, COMPLEX_ARITH (unsigned integers, complex numbers)
  • CLOSE_ALL, COMMAND_LINE, CURRENT EXCEPTION, LANGUAGE, MEMORY, RAW_DUMP, SHARED_IO
  • CURSES, ERRNO, FACNTL, IFACE_INTR, IOCTL, IOCTL_FMT, LIBC, PERROR, STATUS, TTY, TTY_SIZES, UNIX, UNIX_CALLS, UNIX_DIR, UNIX_LIMITS, UNIX_PRCS, U_ENV, U_RAND (UNIX packages)

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. UNSIGNED_TYPES is used at the user's own risk.

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 lists differences regarding packages as implemented on VADS:

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

VADS 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.

VADS 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.

C.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.

These bindings are compatible with VADS.

C.10.1 Interfaces to C

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

Table C-9 Interfaces to C
Type or Operation VADS 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
 

C.10.2 Other Features and Restrictions

VADS does not require that a generic declaration and the corresponding body be part of the same compilation, and they are not required to exist in the same VADS library.

The VADS 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 re-executing 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 VADS, the following restrictions are in effect:

  • An error occurs if one compilation has two versions of the same unit.
  • Strings by default have 2 bytes per character. If the pragma PACK applies, then 1 byte per character is the default.

Other differences between VADS and DEC Ada are as follows:

  • VADS 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. VADS 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 as described in the following:
    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 VADS 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 VADS, the type DURATION supports longer periods.
  • Alignment restrictions for records are as follows:
    • On VADS, power of 2 up to 24
    • On 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 following lists differences in the definition of a main program on VADS and DEC Ada:

  • On VADS, 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 (DIGITAL UNIX), main programs are defined to meet the following conditions:
    • Procedure with no formal parameters (returns 0 upon normal completion)
    • 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.

C.11 Implementation-Defined Attributes

VADS provides the implementation-defined attributes shown and briefly described in Table C-10.

Table C-10 VADS 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 C-11.

Table C-11 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.

C.12 Compiler and Run-Time Interfacing

To pass options to the linker, VADS 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 pragmas to control optimization:

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

VADS supplies the following pragmas to control optimization:

  • INLINE_ONLY
  • NO_IMAGE
  • NON_REENTRANT
  • OPTIMIZE_CODE
  • PASSIVE
  • SHARE_CODE

Optimization on both implementations can be controlled at the command-line level.

C.13 User Interface

VADS and DEC Ada provide a comparable set of commands to build programs and manage the program library. Table C-12 lists the VADS and DEC Ada commands and points out any differences as appropriate.

Table C-12 Comparison of VADS and DEC Ada Commands
VADS Command DEC Ada Command
ada ada
a.app N/A
a.cleanlib arm
a.cp acp
a.das setenv 1 adalisflags "+m"
a.db dbx 2 with the name of the main program
a.du du 2
a.error setenv ADAERRFLAGS with the desired options.
a.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.
a.info als
a.ld ald , amake
a.list 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. These environment variables can be set up ahead of time.
a.ls als
a.make amake
a.map odump 2
a.mklib amklib
a.mkvar tar 2
a.mv acp and arm
a.path or the -l option setenv adalib or the -a option; aprintlib
a.pr N/A
a.pragma N/A
a.report Send an internet mail message
a.rmlib armlib
a.rm arm
a.run Enter the name of the executable program at the system prompt.
a.tags N/A
a.to_srec N/A
a.vadsrc N/A
a.view Use a DIGITAL UNIX editor to create aliases in your .login file.
a.which als
xlink  
Pragma LINK_WITH or WITH n directives (may require use of pragmas INTERFACE and NOT_ELABORATED) aimport
N/A axargs
Use the a.which command to located the source file. 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.

VADS implementations supply optional products ( a.cvt and a.prof ), which are not listed in Table C-12.

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

Table C-13 Program Library Features
Feature VADS DEC Ada
Modifying a path Use the a.path -i command. This command generates a menu. Use any of the DIGITAL UNIX editors to modify the context file.
Specifying paths Use the a.path command. 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. Use the amklib -p command.

C.14 Input-Output

The VADS 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.

VADS 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 C-14.

Table C-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.

VADS also provides shareable generic instantiations of TEXT_IO packages for common data types in standard/shared_io.a . This package improves disk usage by ensuring that only one instantiation of the I/O packages exists for each VADS installation.

Shared generics cause a slight execution-time penalty because all type attributes must be referenced indirectly (as if an extra calling argument were added). However, it reduces compilation time substantially in most circumstances and it reduces program size.

C.15 Implementation Limits

The following table lists implementation limits for DEC Ada on DIGITAL UNIX systems.

Limit Value
In a subprogram or entry declaration, maximum number of formal parameters that are of an unconstrained record type 32
Maximum identifier length (number of characters) 255
Maximum number of characters in a source line 255
Maximum collection size (number of bytes) 2 63--1
Maximum number of discriminants for a record type 245
Maximum number of formal parameters in an entry or subprogram declaration 246
Maximum number of dimensions in an array type 255
Maximum number of library units and subunits in a compilation closure 1 4095
Maximum number of library units and subunits in an execution closure 2 16383
Maximum number of objects declared with the pragma COMMON_OBJECT or PSECT_OBJECT 32757
Maximum number of enumeration literals in an enumeration type definition 65535
Maximum number of lines in a source file 65534
Maximum number of bits in any object 2 31 --1
Maximum size of the static portion of a stack frame (approximate) 2 30

1The compilation closure of a given unit is the total set of units that the given unit depends on, directly and indirectly.
2The execution closure of a given unit is the compilation closure plus all associated secondary units (library bodies and subunits).


Previous Next Contents Index