VAX Ada Run-Time Reference Manual

*HyperReader

  CONTENTS

  Title Page

  Copyright Page

  Preface

  New and Changed Features

  1      Introduction

  2      Object Representation and Storage

  2.1     Type and Object Representations
    2.1.1      Enumeration Types and Objects
    2.1.2      Integer Types and Objects
    2.1.3      Floating-Point Types and Objects
      2.1.3.1      Pragma LONG_FLOAT
      2.1.3.2      VAX F_floating Representation
      2.1.3.3      VAX D_floating Representation
      2.1.3.4      VAX G_floating Representation
      2.1.3.5      VAX H_floating Representation
    2.1.4      Fixed-Point Types and Objects
    2.1.5      Array Types and Objects
    2.1.6      Record Types and Objects
    2.1.7      Access Types and Objects
    2.1.8      Address Types and Objects
    2.1.9      Task Types and Objects

  2.2     Data Optimization
    2.2.1      Pragma PACK
    2.2.2      Length Representation Clauses
    2.2.3      Enumeration Representation Clauses
    2.2.4      Record Representation Clauses
    2.2.5      Alignment Clauses
    2.2.6      Address Clauses
    2.2.7      Determining the Sizes of Types and Objects

  2.3     Storage Allocation and Deallocation
    2.3.1      Storage Allocation
    2.3.2      Storage Deallocation

  3      Input-Output Facilities

  3.1     Files and File Access
    3.1.1      Ada Sequential Files
    3.1.2      Ada Direct Files
    3.1.3      Ada Relative Files
    3.1.4      Ada Indexed Files
    3.1.5      Ada Text Files

  3.2     Naming External Files
    3.2.1      File Specification Syntax
    3.2.2      Logical Names

  3.3     Specifying External File Attributes
    3.3.1      The VMS File Definition Language (FDL): Primary and Secondary Attributes
    3.3.2      Creation-Time and Run-Time Attributes
    3.3.3      Default External File Attributes

  3.4     File Sharing

  3.5     Record Locking

  3.6     Binary Input-Output
    3.6.1      Sequential File Input-Output
    3.6.2      Direct File Input-Output
    3.6.3      Relative File Input-Output
    3.6.4      Indexed File Input-Output

  3.7     Text Input-Output
    3.7.1      Using the Package TEXT_IO for Terminal Input-Output
      3.7.1.1      Line-Oriented Method
      3.7.1.2      Data-Oriented Method
      3.7.1.3      Mixed Method
      3.7.1.4      Flexible Method
    3.7.2      Line Terminators, Page Terminators, and File Terminators
    3.7.3      Text Input-Output Buffering
    3.7.4      TEXT_IO Carriage Control
    3.7.5      Predefined Instantiations of TEXT_IO Packages

  3.8     Input-Output and Exception Handling

  3.9     Input-Output and Tasking
    3.9.1      Synchronization of Input-Output Operations
    3.9.2      Task Wait States Caused by Input-Output Operations

  4      Exception Handling

  4.1     Relationship Between Ada Exception Handling and VAX Condition Handling
    4.1.1      Naming and Encoding Ada Exceptions
    4.1.2      Copying Exception Signal Arguments
    4.1.3      The Matching of Ada Exceptions and System-Defined VAX Conditions

  4.2     Making the Best Use of Ada Exception Handling

  4.3     Suppressing Checks

  4.4     Mixed-Language Exception Handling
    4.4.1      Importing Exceptions
    4.4.2      Exporting Exceptions
    4.4.3      The Exception Choice NON_ADA_ERROR
    4.4.4      Signaling VAX Conditions
    4.4.5      Effects of Handling VAX Conditions from an Ada Program
    4.4.6      Fault Handlers

  4.5     Exceptions and Tasking

  5      Mixed-Language Programming

  5.1     Calling External Routines from Ada Subprograms

  5.2     Calling Ada Subprograms from External Routines

  5.3     Conventions for Passing Data in Mixed-Language Programs
    5.3.1      Ada Semantics
    5.3.2      VAX Calling Standard Conventions
      5.3.2.1      The Call Stack
      5.3.2.2      The Argument List
      5.3.2.3      Parameter-Passing Mechanisms
      5.3.2.4      Function Return
      5.3.2.5      The Call Frame and Register Usage
    5.3.3      VAX Ada Linkage Conventions
    5.3.4      The Importance of Data Representation

  5.4     VAX Ada Default Parameter-Passing Mechanisms
    5.4.1      Scalar Type Parameters
    5.4.2      Array Type Parameters
    5.4.3      Record Type Parameters
    5.4.4      Access Type Parameters
    5.4.5      Address Type Parameters
    5.4.6      Task Type Parameters
    5.4.7      Subprogram Parameters
    5.4.8      Entry Parameters
    5.4.9      VAX Ada Equivalents for VAX Data Types

  5.5     VAX Ada Default Function Return Mechanisms
    5.5.1      Scalar, Access, Address, and Task Type Results
    5.5.2      Array Type Results
    5.5.3      Record Type Results

  5.6     Controlling the Mechanisms for Imported Subprogram Parameters
    5.6.1      The VALUE Mechanism Option
    5.6.2      The REFERENCE Mechanism Option
    5.6.3      The DESCRIPTOR Mechanism Option

  5.7     Controlling the Return Mechanisms for Imported Function Results
    5.7.1      The VALUE Mechanism Option
    5.7.2      The REFERENCE Mechanism Option
    5.7.3      The DESCRIPTOR Mechanism Option

  5.8     Passing Parameters by Descriptor to Exported Subprograms

  5.9     Sharing Storage with Non-Ada Routines

  6      Calling System or Other Callable Routines

  6.1     Using the VAX Ada System-Routine Packages
    6.1.1      Parameter Types
    6.1.2      Parameter-Passing Mechanisms
    6.1.3      Naming Conventions
    6.1.4      Record Type Declarations
    6.1.5      Default and Optional Parameters
    6.1.6      Calling Asynchronous System Services
    6.1.7      Calling Mathematical Routines

  6.2     Writing Your Own Routine Interfaces
    6.2.1      Parameter Types
    6.2.2      Determining the Kind of Call
    6.2.3      Determining the Access Method
    6.2.4      Passing Parameters
    6.2.5      Passing Routines or Subprograms as Parameters
    6.2.6      Default and Optional Parameters

  6.3     Obtaining Symbol Definitions

  6.4     Testing Return Condition Values

  6.5     VMS Routine Examples

  7      Using the VAX Common Data Dictionary

  7.1     Using the VAX Ada-from-CDD Translator Utility

  7.2     Equivalent VAX Ada and CDDL Data Types

  7.3     Example of Using the Ada-from-CDD Translator

  8      Tasking

  8.1     Introduction to Using Ada Tasks on the VMS Operating System

  8.2     Task Storage Allocation
    8.2.1      Storage Created for a Task Object-The Task Control Block
    8.2.2      Storage Created for a Task Activation-The Task Stack
      8.2.2.1      Controlling the Stack Sizes of Task Objects
      8.2.2.2      Controlling the Size of a Main Task Stack
    8.2.3      Stack Overflow and Non-Ada Code

  8.3     Task Switching and Scheduling

  8.4     Special Tasking Considerations
    8.4.1      Deadlock
    8.4.2      Busy Waiting and Non-Ada Code
    8.4.3      Tentative Rendezvous
    8.4.4      Using Delay Statements
    8.4.5      Using Abort Statements
    8.4.6      Interrupting Your Program with CTRL/Y
    8.4.7      Using Shared Variables
    8.4.8      Reentrancy
      8.4.8.1      Reentrancy in Mixed-Language Tasking Programs
      8.4.8.2      Avoiding Nonreentrancy

  8.5     Calling VMS System Service Routines from Tasks
    8.5.1      Effects of System Service Calls on Tasks
    8.5.2      System Services Requiring Special Care

  8.6     Handling Asynchronous System Traps (ASTs)
    8.6.1      The Pragma AST_ENTRY and the AST_ENTRY Attribute
    8.6.2      Constraints on Handling ASTs
    8.6.3      Calling Ada Subprograms from Non-Ada AST Service Routines
    8.6.4      Examples of Handling ASTs from Ada Programs

  8.7     Measuring and Tuning Tasking Performance

  9      Improving Run-Time Performance

  9.1     Compiler Optimizations

  9.2     Using the Pragma INLINE
    9.2.1      Explicit Use
    9.2.2      Implicit Use
    9.2.3      Pragma INLINE Examples
      9.2.3.1      Inline Expansion of Subprogram Specifications and Bodies
      9.2.3.2      Inline Expansion of Generic Subprograms

  9.3     Making Use of Generics
    9.3.1      Using the Pragma INLINE_GENERIC
    9.3.2      Using the Pragma SHARE_GENERIC
    9.3.3      Library-Level Generic Instantiations

  9.4     Techniques for Reducing CPU Time and Elapsed Time
    9.4.1      Decreasing the CPU Time of a VAX Ada Program
      9.4.1.1      Eliminating Run-Time Checks
      9.4.1.2      Reducing Function and Procedure Call Costs
      9.4.1.3      Using Scalar Variables and Avoiding Expensive Operations on Composite Types
    9.4.2      Decreasing the Elapsed Time of a VAX Ada Program
      9.4.2.1      Controlling Paging Behavior
      9.4.2.2      Improving Input-Output Behavior
      9.4.2.3      Overlapping Unrelated Input-Output and Instruction Execution

  10     Additional Programming Considerations

  10.1    Working with Address Values

  10.2    Using Low-Level System Features
    10.2.1     The VAX Device and Processor Register and Interlocked Operations
    10.2.2     Unsigned Types in the Package SYSTEM

  10.3    Working with Varying Strings

  10.4    Assigning Array Values

  10.5    Sharing Memory Between VAX CPUs

  A   VAX Ada Predefined Instantiations

  B   VAX Ada Packages

  B.1     Packages ASSERT, ASSERT_EXCEPTIONS, and ASSERT_GENERIC

  B.2     Package CDD_TYPES

  B.3     Package CONDITION_HANDLING

  B.4     Package CONTROL_C_INTERCEPTION

  B.5     Package MATH_LIB

  B.6     Package STARLET

  B.7     Package SYSTEM_RUNTIME_TUNING

  B.8     Package TASKING_SERVICES

  EXAMPLES

  2-1        Using an Address Clause and LIB$GET_VM

  2-2        Using UNCHECKED_DEALLOCATION to Control Access Type Storage Deallocation

  3-1        Creating and Opening a Relative File for Read Sharing

  3-2        Using a Mixed-Type File

  3-3        Using the Package SEQUENTIAL_IO

  3-4        Using the Package DIRECT_MIXED_IO

  3-5        Using the Package RELATIVE_IO

  3-6        Using the Package INDEXED_IO

  3-7        Using the Package INDEXED_MIXED_IO

  3-8        Using the Package TEXT_IO

  3-9        Example of Line-Oriented TEXT_IO

  3-10       Example of Data-Oriented TEXT_IO

  3-11       Example of Flexible TEXT_IO

  4-1        Use of Pragma SUPPRESS_ALL

  4-2        Handling SYS$GETJPIW Status Values as Ada Exceptions

  4-3        Handling SYS$GETJPIW Status Values as VMS Conditions

  6-1        Calling SYS$TRNLNM Using the Package STARLET

  6-2        Calling SYS$GETQUI Using the Package STARLET

  6-3        Calling SYS$CRMPSC Using the Package STARLET

  6-4        Calling LIB$FILE_SCAN and LIB$FILE_SCAN_END Using the Package LIB

  6-5        Calling SMG Routines Using the Package SMG

  6-6        Calling SYS$TRNLNM Using an Import Pragma

  6-7        Using SYSTEM.IMPORT_VALUE to Obtain a Global Symbol Value

  8-1        Interactive Array Sort Using Tasks

  8-2        Leaving a Master to Release a Task Control Block

  8-3        Controlling the Size of a Task's Stack

  8-4        An Exception-Induced Deadlock

  8-5        A Self-Calling Deadlock

  8-6        A Circular-Calling Deadlock

  8-7        A Dynamic-Circular-Calling Deadlock

  8-8        A Nonreentrant Subprogram

  8-9        A Reentrant Subprogram

  8-10       Using a Serializing Task to Prevent Reentry

  8-11       Deadlock Caused by a Call to SYS$SETAST

  8-12       Unpredictability of SYS$EXIT

  8-13       Simple Use of the Pragma AST_ENTRY and the AST_ENTRY Attribute

  8-14       Using an AST Entry to Intercept a CTRL/C

  10-1       One Use of the Interlocked Queue Operations

  10-2       Sharing Memory Between Two or More Programs Running on One or More VAX CPUs

  FIGURES

  2-1        F_floating Representation

  2-2        D_floating Representation

  2-3        G_floating Representation

  2-4        H_floating Representation

  3-1        Using a Mixed-Type File

  3-2        Using a Uniform-Type File

  3-3        An Ada Text File, Showing Line, Page, and File Terminators

  4-1        Execution of a FORTRAN Program with FOR$UNDERFLOW_HANDLER

  4-2        The Effect of an Ada Procedure Containing an Others Handler

  4-3        FOR$UNDERFLOW_HANDLER Established for a FORTRAN Subroutine

  5-1        A Call Stack at Run Time

  5-2        An Argument List

  5-3        A Call Stack

  5-4        Area Control Block Used in Returning Some Function Results

  TABLES

  2-1        Range of Values and Storage Sizes for VAX Ada Predefined Integer Types

  2-2        VAX Type Representations and Storage Sizes for VAX Ada Predefined Floating-Point Types

  2-3        Model Numbers Defined for Each Floating-Point Type

  2-4        Safe Numbers Defined for Each Floating-Point Type

  2-5        Packable Types

  2-6        Effects of Packing the Components of Arrays and Records

  2-7        Comparison of SIZE and MACHINE_SIZE Attribute Results

  2-8        Results of Size Attributes for Various Types and Objects

  3-1        Predefined (Default) Logical Names

  3-2        Equivalence Strings for Default Logical Names for Process-Permanent Files

  3-3        FDL Primary and Secondary Attribute Descriptions

  3-4        Commonly Used FDL Attributes

  3-5        SEQUENTIAL_IO: Default File Attributes

  3-6        SEQUENTIAL_MIXED_IO: Default File Attributes

  3-7        DIRECT_IO: Default File Attributes

  3-8        DIRECT_MIXED_IO: Default File Attributes

  3-9        RELATIVE_IO: Default File Attributes

  3-10       RELATIVE_MIXED_IO: Default File Attributes

  3-11       INDEXED_IO: Default File Attributes

  3-12       INDEXED_MIXED_IO: Default File Attributes

  3-13       TEXT_IO: Default File Attributes

  3-14       VAX Ada Carriage-Control Options

  3-15       FORTRAN Carriage-Control Characters

  4-1        Relationship Between Ada Exception Handling and the CHF

  4-2        Ada Predefined Exceptions

  4-3        VAX Conditions that Match Ada Exceptions

  4-4        Run-Time Checks and Their Corresponding Predefined Exceptions

  5-1        VAX Registers

  5-2        Default Descriptor Classes Used by VAX Ada for Array Parameter Passing

  5-3        VAX Ada Equivalents for VAX Data Types and Their Valid Passing Mechanisms in VAX Ada

  5-4        Default Descriptor Class Names Used for the DESCRIPTOR Mechanism

  5-5        Type Requirements for Descriptor Classes Used by VAX Ada in Importing Routines

  5-6        Descriptor Data Types Used

  5-7        Program Section Properties

  6-1        VMS Data Structures

  6-2        VAX Ada Equivalents for VMS Access Methods

  7-1        Equivalent CDD and VAX Ada Data Types

  9-1        Comparison of the Effects of the Pragmas INLINE_GENERIC and SHARE_GENERIC

  B-1        VAX Ada Predefined Packages