This is gnat_rm.info, produced by makeinfo version 7.1 from
gnat_rm.texi.

     GNAT Reference Manual , Dec 21, 2023

     AdaCore

     Copyright © 2008-2024, Free Software Foundation

INFO-DIR-SECTION GNU Ada Tools
START-INFO-DIR-ENTRY
* gnat_rm: (gnat_rm.info). gnat_rm
END-INFO-DIR-ENTRY


   Generated by Sphinx 5.3.0.


File: gnat_rm.info,  Node: Intrinsic Subprograms,  Next: Representation Clauses and Pragmas,  Prev: Implementation Defined Characteristics,  Up: Top

8 Intrinsic Subprograms
***********************

GNAT allows a user application program to write the declaration:

     pragma Import (Intrinsic, name);

providing that the name corresponds to one of the implemented intrinsic
subprograms in GNAT, and that the parameter profile of the referenced
subprogram meets the requirements.  This chapter describes the set of
implemented intrinsic subprograms, and the requirements on parameter
profiles.  Note that no body is supplied; as with other uses of pragma
Import, the body is supplied elsewhere (in this case by the compiler
itself).  Note that any use of this feature is potentially non-portable,
since the Ada standard does not require Ada compilers to implement this
feature.

* Menu:

* Intrinsic Operators::
* Compilation_ISO_Date::
* Compilation_Date::
* Compilation_Time::
* Enclosing_Entity::
* Exception_Information::
* Exception_Message::
* Exception_Name::
* File::
* Line::
* Shifts and Rotates::
* Source_Location::


File: gnat_rm.info,  Node: Intrinsic Operators,  Next: Compilation_ISO_Date,  Up: Intrinsic Subprograms

8.1 Intrinsic Operators
=======================

All the predefined numeric operators in package Standard in ‘pragma
Import (Intrinsic,..)’ declarations.  In the binary operator case, the
operands must have the same size.  The operand or operands must also be
appropriate for the operator.  For example, for addition, the operands
must both be floating-point or both be fixed-point, and the right
operand for ‘"**"’ must have a root type of ‘Standard.Integer'Base’.
You can use an intrinsic operator declaration as in the following
example:

     type Int1 is new Integer;
     type Int2 is new Integer;

     function "+" (X1 : Int1; X2 : Int2) return Int1;
     function "+" (X1 : Int1; X2 : Int2) return Int2;
     pragma Import (Intrinsic, "+");

This declaration would permit ‘mixed mode’ arithmetic on items of the
differing types ‘Int1’ and ‘Int2’.  It is also possible to specify such
operators for private types, if the full views are appropriate
arithmetic types.


File: gnat_rm.info,  Node: Compilation_ISO_Date,  Next: Compilation_Date,  Prev: Intrinsic Operators,  Up: Intrinsic Subprograms

8.2 Compilation_ISO_Date
========================

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Source_Info’.  The only useful use of the intrinsic import
in this case is the one in this unit, so an application program should
simply call the function ‘GNAT.Source_Info.Compilation_ISO_Date’ to
obtain the date of the current compilation (in local time format
YYYY-MM-DD).


File: gnat_rm.info,  Node: Compilation_Date,  Next: Compilation_Time,  Prev: Compilation_ISO_Date,  Up: Intrinsic Subprograms

8.3 Compilation_Date
====================

Same as Compilation_ISO_Date, except the string is in the form MMM DD
YYYY.


File: gnat_rm.info,  Node: Compilation_Time,  Next: Enclosing_Entity,  Prev: Compilation_Date,  Up: Intrinsic Subprograms

8.4 Compilation_Time
====================

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Source_Info’.  The only useful use of the intrinsic import
in this case is the one in this unit, so an application program should
simply call the function ‘GNAT.Source_Info.Compilation_Time’ to obtain
the time of the current compilation (in local time format HH:MM:SS).


File: gnat_rm.info,  Node: Enclosing_Entity,  Next: Exception_Information,  Prev: Compilation_Time,  Up: Intrinsic Subprograms

8.5 Enclosing_Entity
====================

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Source_Info’.  The only useful use of the intrinsic import
in this case is the one in this unit, so an application program should
simply call the function ‘GNAT.Source_Info.Enclosing_Entity’ to obtain
the name of the current subprogram, package, task, entry, or protected
subprogram.


File: gnat_rm.info,  Node: Exception_Information,  Next: Exception_Message,  Prev: Enclosing_Entity,  Up: Intrinsic Subprograms

8.6 Exception_Information
=========================

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Current_Exception’.  The only useful use of the intrinsic
import in this case is the one in this unit, so an application program
should simply call the function
‘GNAT.Current_Exception.Exception_Information’ to obtain the exception
information associated with the current exception.


File: gnat_rm.info,  Node: Exception_Message,  Next: Exception_Name,  Prev: Exception_Information,  Up: Intrinsic Subprograms

8.7 Exception_Message
=====================

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Current_Exception’.  The only useful use of the intrinsic
import in this case is the one in this unit, so an application program
should simply call the function
‘GNAT.Current_Exception.Exception_Message’ to obtain the message
associated with the current exception.


File: gnat_rm.info,  Node: Exception_Name,  Next: File,  Prev: Exception_Message,  Up: Intrinsic Subprograms

8.8 Exception_Name
==================

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Current_Exception’.  The only useful use of the intrinsic
import in this case is the one in this unit, so an application program
should simply call the function ‘GNAT.Current_Exception.Exception_Name’
to obtain the name of the current exception.


File: gnat_rm.info,  Node: File,  Next: Line,  Prev: Exception_Name,  Up: Intrinsic Subprograms

8.9 File
========

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Source_Info’.  The only useful use of the intrinsic import
in this case is the one in this unit, so an application program should
simply call the function ‘GNAT.Source_Info.File’ to obtain the name of
the current file.


File: gnat_rm.info,  Node: Line,  Next: Shifts and Rotates,  Prev: File,  Up: Intrinsic Subprograms

8.10 Line
=========

This intrinsic subprogram is used in the implementation of the library
package ‘GNAT.Source_Info’.  The only useful use of the intrinsic import
in this case is the one in this unit, so an application program should
simply call the function ‘GNAT.Source_Info.Line’ to obtain the number of
the current source line.


File: gnat_rm.info,  Node: Shifts and Rotates,  Next: Source_Location,  Prev: Line,  Up: Intrinsic Subprograms

8.11 Shifts and Rotates
=======================

In standard Ada, the shift and rotate functions are available only for
the predefined modular types in package ‘Interfaces’.  However, in GNAT
it is possible to define these functions for any integer type (signed or
modular), as in this example:

     function Shift_Left
       (Value  : T;
        Amount : Natural) return T
     with Import, Convention => Intrinsic;

The function name must be one of Shift_Left, Shift_Right,
Shift_Right_Arithmetic, Rotate_Left, or Rotate_Right.  T must be an
integer type.  T’Size must be 8, 16, 32 or 64 bits; if T is modular, the
modulus must be 2**8, 2**16, 2**32 or 2**64.  The result type must be
the same as the type of ‘Value’.  The shift amount must be Natural.  The
formal parameter names can be anything.

A more convenient way of providing these shift operators is to use the
Provide_Shift_Operators pragma, which provides the function declarations
and corresponding pragma Import’s for all five shift functions.  For
signed types the semantics of these operators is to interpret the
bitwise result of the corresponding operator for modular type.  In
particular, shifting a negative number may change its sign bit to
positive.


File: gnat_rm.info,  Node: Source_Location,  Prev: Shifts and Rotates,  Up: Intrinsic Subprograms

8.12 Source_Location
====================

This intrinsic subprogram is used in the implementation of the library
routine ‘GNAT.Source_Info’.  The only useful use of the intrinsic import
in this case is the one in this unit, so an application program should
simply call the function ‘GNAT.Source_Info.Source_Location’ to obtain
the current source file location.


File: gnat_rm.info,  Node: Representation Clauses and Pragmas,  Next: Standard Library Routines,  Prev: Intrinsic Subprograms,  Up: Top

9 Representation Clauses and Pragmas
************************************

This section describes the representation clauses accepted by GNAT, and
their effect on the representation of corresponding data objects.

GNAT fully implements Annex C (Systems Programming).  This means that
all the implementation advice sections in chapter 13 are fully
implemented.  However, these sections only require a minimal level of
support for representation clauses.  GNAT provides much more extensive
capabilities, and this section describes the additional capabilities
provided.

* Menu:

* Alignment Clauses::
* Size Clauses::
* Storage_Size Clauses::
* Size of Variant Record Objects::
* Biased Representation::
* Value_Size and Object_Size Clauses::
* Component_Size Clauses::
* Bit_Order Clauses::
* Effect of Bit_Order on Byte Ordering::
* Pragma Pack for Arrays::
* Pragma Pack for Records::
* Record Representation Clauses::
* Handling of Records with Holes::
* Enumeration Clauses::
* Address Clauses::
* Use of Address Clauses for Memory-Mapped I/O::
* Effect of Convention on Representation::
* Conventions and Anonymous Access Types::
* Determining the Representations chosen by GNAT::


File: gnat_rm.info,  Node: Alignment Clauses,  Next: Size Clauses,  Up: Representation Clauses and Pragmas

9.1 Alignment Clauses
=====================

GNAT requires that all alignment clauses specify 0 or a power of 2, and
all default alignments are always a power of 2.  Specifying 0 is the
same as specifying 1.

The default alignment values are as follows:

   * 'Elementary Types'.

     For elementary types, the alignment is the minimum of the actual
     size of objects of the type divided by ‘Storage_Unit’, and the
     maximum alignment supported by the target.  (This maximum alignment
     is given by the GNAT-specific attribute
     ‘Standard'Maximum_Alignment’; see *note Attribute
     Maximum_Alignment: 199.)

     For example, for type ‘Long_Float’, the object size is 8 bytes, and
     the default alignment will be 8 on any target that supports
     alignments this large, but on some targets, the maximum alignment
     may be smaller than 8, in which case objects of type ‘Long_Float’
     will be maximally aligned.

   * 'Arrays'.

     For arrays, the alignment is equal to the alignment of the
     component type for the normal case where no packing or component
     size is given.  If the array is packed, and the packing is
     effective (see separate section on packed arrays), then the
     alignment will be either 4, 2, or 1 for long packed arrays or
     arrays whose length is not known at compile time, depending on
     whether the component size is divisible by 4, 2, or is odd.  For
     short packed arrays, which are handled internally as modular types,
     the alignment will be as described for elementary types, e.g.  a
     packed array of length 31 bits will have an object size of four
     bytes, and an alignment of 4.

   * 'Records'.

     For the normal unpacked case, the alignment of a record is equal to
     the maximum alignment of any of its components.  For tagged
     records, this includes the implicit access type used for the tag.
     If a pragma ‘Pack’ is used and all components are packable (see
     separate section on pragma ‘Pack’), then the resulting alignment is
     1, unless the layout of the record makes it profitable to increase
     it.

     A special case is when:

        * the size of the record is given explicitly, or a full record
          representation clause is given, and

        * the size of the record is 2, 4, or 8 bytes.

     In this case, an alignment is chosen to match the size of the
     record.  For example, if we have:

          type Small is record
             A, B : Character;
          end record;
          for Small'Size use 16;

     then the default alignment of the record type ‘Small’ is 2, not 1.
     This leads to more efficient code when the record is treated as a
     unit, and also allows the type to specified as ‘Atomic’ on
     architectures requiring strict alignment.

An alignment clause may specify a larger alignment than the default
value up to some maximum value dependent on the target (obtainable by
using the attribute reference ‘Standard'Maximum_Alignment’).  It may
also specify a smaller alignment than the default value for enumeration,
integer and fixed point types, as well as for record types, for example

     type V is record
        A : Integer;
     end record;

     for V'alignment use 1;

The default alignment for the type ‘V’ is 4, as a result of the Integer
field in the record, but it is permissible, as shown, to override the
default alignment of the record with a smaller value.

Note that according to the Ada standard, an alignment clause applies
only to the first named subtype.  If additional subtypes are declared,
then the compiler is allowed to choose any alignment it likes, and there
is no way to control this choice.  Consider:

     type R is range 1 .. 10_000;
     for R'Alignment use 1;
     subtype RS is R range 1 .. 1000;

The alignment clause specifies an alignment of 1 for the first named
subtype ‘R’ but this does not necessarily apply to ‘RS’.  When writing
portable Ada code, you should avoid writing code that explicitly or
implicitly relies on the alignment of such subtypes.

For the GNAT compiler, if an explicit alignment clause is given, this
value is also used for any subsequent subtypes.  So for GNAT, in the
above example, you can count on the alignment of ‘RS’ being 1.  But this
assumption is non-portable, and other compilers may choose different
alignments for the subtype ‘RS’.


File: gnat_rm.info,  Node: Size Clauses,  Next: Storage_Size Clauses,  Prev: Alignment Clauses,  Up: Representation Clauses and Pragmas

9.2 Size Clauses
================

The default size for a type ‘T’ is obtainable through the
language-defined attribute ‘T'Size’ and also through the equivalent
GNAT-defined attribute ‘T'Value_Size’.  For objects of type ‘T’, GNAT
will generally increase the type size so that the object size
(obtainable through the GNAT-defined attribute ‘T'Object_Size’) is a
multiple of ‘T'Alignment * Storage_Unit’.

For example:

     type Smallint is range 1 .. 6;

     type Rec is record
        Y1 : integer;
        Y2 : boolean;
     end record;

In this example, ‘Smallint'Size’ = ‘Smallint'Value_Size’ = 3, as
specified by the RM rules, but objects of this type will have a size of
8 (‘Smallint'Object_Size’ = 8), since objects by default occupy an
integral number of storage units.  On some targets, notably older
versions of the Digital Alpha, the size of stand alone objects of this
type may be 32, reflecting the inability of the hardware to do byte
load/stores.

Similarly, the size of type ‘Rec’ is 40 bits (‘Rec'Size’ =
‘Rec'Value_Size’ = 40), but the alignment is 4, so objects of this type
will have their size increased to 64 bits so that it is a multiple of
the alignment (in bits).  This decision is in accordance with the
specific Implementation Advice in RM 13.3(43):

     “A ‘Size’ clause should be supported for an object if the specified
     ‘Size’ is at least as large as its subtype’s ‘Size’, and
     corresponds to a size in storage elements that is a multiple of the
     object’s ‘Alignment’ (if the ‘Alignment’ is nonzero).”

An explicit size clause may be used to override the default size by
increasing it.  For example, if we have:

     type My_Boolean is new Boolean;
     for My_Boolean'Size use 32;

then values of this type will always be 32-bit long.  In the case of
discrete types, the size can be increased up to 64 bits on 32-bit
targets and 128 bits on 64-bit targets, with the effect that the entire
specified field is used to hold the value, sign- or zero-extended as
appropriate.  If more than 64 bits or 128 bits resp.  is specified, then
padding space is allocated after the value, and a warning is issued that
there are unused bits.

Similarly the size of records and arrays may be increased, and the
effect is to add padding bits after the value.  This also causes a
warning message to be generated.

The largest Size value permitted in GNAT is 2**31-1.  Since this is a
Size in bits, this corresponds to an object of size 256 megabytes (minus
one).  This limitation is true on all targets.  The reason for this
limitation is that it improves the quality of the code in many cases if
it is known that a Size value can be accommodated in an object of type
Integer.


File: gnat_rm.info,  Node: Storage_Size Clauses,  Next: Size of Variant Record Objects,  Prev: Size Clauses,  Up: Representation Clauses and Pragmas

9.3 Storage_Size Clauses
========================

For tasks, the ‘Storage_Size’ clause specifies the amount of space to be
allocated for the task stack.  This cannot be extended, and if the stack
is exhausted, then ‘Storage_Error’ will be raised (if stack checking is
enabled).  Use a ‘Storage_Size’ attribute definition clause, or a
‘Storage_Size’ pragma in the task definition to set the appropriate
required size.  A useful technique is to include in every task
definition a pragma of the form:

     pragma Storage_Size (Default_Stack_Size);

Then ‘Default_Stack_Size’ can be defined in a global package, and
modified as required.  Any tasks requiring stack sizes different from
the default can have an appropriate alternative reference in the pragma.

You can also use the '-d' binder switch to modify the default stack
size.

For access types, the ‘Storage_Size’ clause specifies the maximum space
available for allocation of objects of the type.  If this space is
exceeded then ‘Storage_Error’ will be raised by an allocation attempt.
In the case where the access type is declared local to a subprogram, the
use of a ‘Storage_Size’ clause triggers automatic use of a special
predefined storage pool (‘System.Pool_Size’) that ensures that all space
for the pool is automatically reclaimed on exit from the scope in which
the type is declared.

A special case recognized by the compiler is the specification of a
‘Storage_Size’ of zero for an access type.  This means that no items can
be allocated from the pool, and this is recognized at compile time, and
all the overhead normally associated with maintaining a fixed size
storage pool is eliminated.  Consider the following example:

     procedure p is
        type R is array (Natural) of Character;
        type P is access all R;
        for P'Storage_Size use 0;
        --  Above access type intended only for interfacing purposes

        y : P;

        procedure g (m : P);
        pragma Import (C, g);

        --  ...

     begin
        --  ...
        y := new R;
     end;

As indicated in this example, these dummy storage pools are often useful
in connection with interfacing where no object will ever be allocated.
If you compile the above example, you get the warning:

     p.adb:16:09: warning: allocation from empty storage pool
     p.adb:16:09: warning: Storage_Error will be raised at run time

Of course in practice, there will not be any explicit allocators in the
case of such an access declaration.


File: gnat_rm.info,  Node: Size of Variant Record Objects,  Next: Biased Representation,  Prev: Storage_Size Clauses,  Up: Representation Clauses and Pragmas

9.4 Size of Variant Record Objects
==================================

In the case of variant record objects, there is a question whether Size
gives information about a particular variant, or the maximum size
required for any variant.  Consider the following program

     with Text_IO; use Text_IO;
     procedure q is
        type R1 (A : Boolean := False) is record
          case A is
            when True  => X : Character;
            when False => null;
          end case;
        end record;

        V1 : R1 (False);
        V2 : R1;

     begin
        Put_Line (Integer'Image (V1'Size));
        Put_Line (Integer'Image (V2'Size));
     end q;

Here we are dealing with a variant record, where the True variant
requires 16 bits, and the False variant requires 8 bits.  In the above
example, both V1 and V2 contain the False variant, which is only 8 bits
long.  However, the result of running the program is:

     8
     16

The reason for the difference here is that the discriminant value of V1
is fixed, and will always be False.  It is not possible to assign a True
variant value to V1, therefore 8 bits is sufficient.  On the other hand,
in the case of V2, the initial discriminant value is False (from the
default), but it is possible to assign a True variant value to V2,
therefore 16 bits must be allocated for V2 in the general case, even
fewer bits may be needed at any particular point during the program
execution.

As can be seen from the output of this program, the ‘'Size’ attribute
applied to such an object in GNAT gives the actual allocated size of the
variable, which is the largest size of any of the variants.  The Ada
Reference Manual is not completely clear on what choice should be made
here, but the GNAT behavior seems most consistent with the language in
the RM.

In some cases, it may be desirable to obtain the size of the current
variant, rather than the size of the largest variant.  This can be
achieved in GNAT by making use of the fact that in the case of a
subprogram parameter, GNAT does indeed return the size of the current
variant (because a subprogram has no way of knowing how much space is
actually allocated for the actual).

Consider the following modified version of the above program:

     with Text_IO; use Text_IO;
     procedure q is
        type R1 (A : Boolean := False) is record
          case A is
            when True  => X : Character;
            when False => null;
          end case;
        end record;

        V2 : R1;

        function Size (V : R1) return Integer is
        begin
           return V'Size;
        end Size;

     begin
        Put_Line (Integer'Image (V2'Size));
        Put_Line (Integer'Image (Size (V2)));
        V2 := (True, 'x');
        Put_Line (Integer'Image (V2'Size));
        Put_Line (Integer'Image (Size (V2)));
     end q;

The output from this program is

     16
     8
     16
     16

Here we see that while the ‘'Size’ attribute always returns the maximum
size, regardless of the current variant value, the ‘Size’ function does
indeed return the size of the current variant value.


File: gnat_rm.info,  Node: Biased Representation,  Next: Value_Size and Object_Size Clauses,  Prev: Size of Variant Record Objects,  Up: Representation Clauses and Pragmas

9.5 Biased Representation
=========================

In the case of scalars with a range starting at other than zero, it is
possible in some cases to specify a size smaller than the default
minimum value, and in such cases, GNAT uses an unsigned biased
representation, in which zero is used to represent the lower bound, and
successive values represent successive values of the type.

For example, suppose we have the declaration:

     type Small is range -7 .. -4;
     for Small'Size use 2;

Although the default size of type ‘Small’ is 4, the ‘Size’ clause is
accepted by GNAT and results in the following representation scheme:

     -7 is represented as 2#00#
     -6 is represented as 2#01#
     -5 is represented as 2#10#
     -4 is represented as 2#11#

Biased representation is only used if the specified ‘Size’ clause cannot
be accepted in any other manner.  These reduced sizes that force biased
representation can be used for all discrete types except for enumeration
types for which a representation clause is given.


File: gnat_rm.info,  Node: Value_Size and Object_Size Clauses,  Next: Component_Size Clauses,  Prev: Biased Representation,  Up: Representation Clauses and Pragmas

9.6 Value_Size and Object_Size Clauses
======================================

In Ada 95 and Ada 2005, ‘T'Size’ for a type ‘T’ is the minimum number of
bits required to hold values of type ‘T’.  Although this interpretation
was allowed in Ada 83, it was not required, and this requirement in
practice can cause some significant difficulties.  For example, in most
Ada 83 compilers, ‘Natural'Size’ was 32.  However, in Ada 95 and Ada
2005, ‘Natural'Size’ is typically 31.  This means that code may change
in behavior when moving from Ada 83 to Ada 95 or Ada 2005.  For example,
consider:

     type Rec is record
        A : Natural;
        B : Natural;
     end record;

     for Rec use record
        A at 0 range 0 .. Natural'Size - 1;
        B at 0 range Natural'Size .. 2 * Natural'Size - 1;
     end record;

In the above code, since the typical size of ‘Natural’ objects is 32
bits and ‘Natural'Size’ is 31, the above code can cause unexpected
inefficient packing in Ada 95 and Ada 2005, and in general there are
cases where the fact that the object size can exceed the size of the
type causes surprises.

To help get around this problem GNAT provides two implementation defined
attributes, ‘Value_Size’ and ‘Object_Size’.  When applied to a type,
these attributes yield the size of the type (corresponding to the RM
defined size attribute), and the size of objects of the type
respectively.

The ‘Object_Size’ is used for determining the default size of objects
and components.  This size value can be referred to using the
‘Object_Size’ attribute.  The phrase ‘is used’ here means that it is the
basis of the determination of the size.  The backend is free to pad this
up if necessary for efficiency, e.g., an 8-bit stand-alone character
might be stored in 32 bits on a machine with no efficient byte access
instructions such as the Alpha.

The default rules for the value of ‘Object_Size’ for discrete types are
as follows:

   * The ‘Object_Size’ for base subtypes reflect the natural hardware
     size in bits (run the compiler with '-gnatS' to find those values
     for numeric types).  Enumeration types and fixed-point base
     subtypes have 8, 16, 32, or 64 bits for this size, depending on the
     range of values to be stored.

   * The ‘Object_Size’ of a subtype is the same as the ‘Object_Size’ of
     the type from which it is obtained.

   * The ‘Object_Size’ of a derived base type is copied from the parent
     base type, and the ‘Object_Size’ of a derived first subtype is
     copied from the parent first subtype.

The ‘Value_Size’ attribute is the (minimum) number of bits required to
store a value of the type.  This value is used to determine how tightly
to pack records or arrays with components of this type, and also affects
the semantics of unchecked conversion (unchecked conversions where the
‘Value_Size’ values differ generate a warning, and are potentially
target dependent).

The default rules for the value of ‘Value_Size’ are as follows:

   * The ‘Value_Size’ for a base subtype is the minimum number of bits
     required to store all values of the type (including the sign bit
     only if negative values are possible).

   * If a subtype statically matches the first subtype of a given type,
     then it has by default the same ‘Value_Size’ as the first subtype.
     (This is a consequence of RM 13.1(14): “if two subtypes statically
     match, then their subtype-specific aspects are the same”.)

   * All other subtypes have a ‘Value_Size’ corresponding to the minimum
     number of bits required to store all values of the subtype.  For
     dynamic bounds, it is assumed that the value can range down or up
     to the corresponding bound of the ancestor

The RM defined attribute ‘Size’ corresponds to the ‘Value_Size’
attribute.

The ‘Size’ attribute may be defined for a first-named subtype.  This
sets the ‘Value_Size’ of the first-named subtype to the given value, and
the ‘Object_Size’ of this first-named subtype to the given value padded
up to an appropriate boundary.  It is a consequence of the default rules
above that this ‘Object_Size’ will apply to all further subtypes.  On
the other hand, ‘Value_Size’ is affected only for the first subtype, any
dynamic subtypes obtained from it directly, and any statically matching
subtypes.  The ‘Value_Size’ of any other static subtypes is not
affected.

‘Value_Size’ and ‘Object_Size’ may be explicitly set for any subtype
using an attribute definition clause.  Note that the use of these
attributes can cause the RM 13.1(14) rule to be violated.  If two access
types reference aliased objects whose subtypes have differing
‘Object_Size’ values as a result of explicit attribute definition
clauses, then it is illegal to convert from one access subtype to the
other.  For a more complete description of this additional legality
rule, see the description of the ‘Object_Size’ attribute.

To get a feel for the difference, consider the following examples (note
that in each case the base is ‘Short_Short_Integer’ with a size of 8):

Type or subtype declaration                       Object_Size       Value_Size
                                                                    
--------------------------------------------------------------------------------------
                                                                    
‘type x1 is range 0 .. 5;’                        8                 3
                                                                    
                                                                    
‘type x2 is range 0 .. 5;’ ‘for x2'size use       16                12
12;’                                                                

‘subtype x3 is x2 range 0 .. 3;’                  16                2
                                                                    
                                                                    
‘subtype x4 is x2'base range 0 .. 10;’            8                 4
                                                                    
                                                                    
‘dynamic : x2'Base range -64 .. +63;’

‘subtype x5 is x2 range 0 .. dynamic;’            16                3*
                                                                    
                                                                    
‘subtype x6 is x2'base range 0 .. dynamic;’       8                 7*
                                                                    

Note: the entries marked ‘*’ are not actually specified by the Ada
Reference Manual, which has nothing to say about size in the dynamic
case.  What GNAT does is to allocate sufficient bits to accommodate any
possible dynamic values for the bounds at run-time.

So far, so good, but GNAT has to obey the RM rules, so the question is
under what conditions must the RM ‘Size’ be used.  The following is a
list of the occasions on which the RM ‘Size’ must be used:

   * Component size for packed arrays or records

   * Value of the attribute ‘Size’ for a type

   * Warning about sizes not matching for unchecked conversion

For record types, the ‘Object_Size’ is always a multiple of the
alignment of the type (this is true for all types).  In some cases the
‘Value_Size’ can be smaller.  Consider:

     type R is record
       X : Integer;
       Y : Character;
     end record;

On a typical 32-bit architecture, the X component will occupy four bytes
and the Y component will occupy one byte, for a total of 5 bytes.  As a
result ‘R'Value_Size’ will be 40 (bits) since this is the minimum size
required to store a value of this type.  For example, it is permissible
to have a component of type R in an array whose component size is
specified to be 40 bits.

However, ‘R'Object_Size’ will be 64 (bits).  The difference is due to
the alignment requirement for objects of the record type.  The X
component will require four-byte alignment because that is what type
Integer requires, whereas the Y component, a Character, will only
require 1-byte alignment.  Since the alignment required for X is the
greatest of all the components’ alignments, that is the alignment
required for the enclosing record type, i.e., 4 bytes or 32 bits.  As
indicated above, the actual object size must be rounded up so that it is
a multiple of the alignment value.  Therefore, 40 bits rounded up to the
next multiple of 32 yields 64 bits.

For all other types, the ‘Object_Size’ and ‘Value_Size’ are the same
(and equivalent to the RM attribute ‘Size’).  Only ‘Size’ may be
specified for such types.

Note that ‘Value_Size’ can be used to force biased representation for a
particular subtype.  Consider this example:

     type R is (A, B, C, D, E, F);
     subtype RAB is R range A .. B;
     subtype REF is R range E .. F;

By default, ‘RAB’ has a size of 1 (sufficient to accommodate the
representation of ‘A’ and ‘B’, 0 and 1), and ‘REF’ has a size of 3
(sufficient to accommodate the representation of ‘E’ and ‘F’, 4 and 5).
But if we add the following ‘Value_Size’ attribute definition clause:

     for REF'Value_Size use 1;

then biased representation is forced for ‘REF’, and 0 will represent ‘E’
and 1 will represent ‘F’.  A warning is issued when a ‘Value_Size’
attribute definition clause forces biased representation.  This warning
can be turned off using ‘-gnatw.B’.


File: gnat_rm.info,  Node: Component_Size Clauses,  Next: Bit_Order Clauses,  Prev: Value_Size and Object_Size Clauses,  Up: Representation Clauses and Pragmas

9.7 Component_Size Clauses
==========================

Normally, the value specified in a component size clause must be
consistent with the subtype of the array component with regard to size
and alignment.  In other words, the value specified must be at least
equal to the size of this subtype, and must be a multiple of the
alignment value.

In addition, component size clauses are allowed which cause the array to
be packed, by specifying a smaller value.  A first case is for component
size values in the range 1 through 63 on 32-bit targets, and 1 through
127 on 64-bit targets.  The value specified may not be smaller than the
Size of the subtype.  GNAT will accurately honor all packing requests in
this range.  For example, if we have:

     type r is array (1 .. 8) of Natural;
     for r'Component_Size use 31;

then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
Of course access to the components of such an array is considerably less
efficient than if the natural component size of 32 is used.  A second
case is when the subtype of the component is a record type padded
because of its default alignment.  For example, if we have:

     type r is record
       i : Integer;
       j : Integer;
       b : Boolean;
     end record;

     type a is array (1 .. 8) of r;
     for a'Component_Size use 72;

then the resulting array has a length of 72 bytes, instead of 96 bytes
if the alignment of the record (4) was obeyed.

Note that there is no point in giving both a component size clause and a
pragma Pack for the same array type.  if such duplicate clauses are
given, the pragma Pack will be ignored.


File: gnat_rm.info,  Node: Bit_Order Clauses,  Next: Effect of Bit_Order on Byte Ordering,  Prev: Component_Size Clauses,  Up: Representation Clauses and Pragmas

9.8 Bit_Order Clauses
=====================

For record subtypes, GNAT permits the specification of the ‘Bit_Order’
attribute.  The specification may either correspond to the default bit
order for the target, in which case the specification has no effect and
places no additional restrictions, or it may be for the non-standard
setting (that is the opposite of the default).

In the case where the non-standard value is specified, the effect is to
renumber bits within each byte, but the ordering of bytes is not
affected.  There are certain restrictions placed on component clauses as
follows:

   * Components fitting within a single storage unit.

     These are unrestricted, and the effect is merely to renumber bits.
     For example if we are on a little-endian machine with
     ‘Low_Order_First’ being the default, then the following two
     declarations have exactly the same effect:

          type R1 is record
             A : Boolean;
             B : Integer range 1 .. 120;
          end record;

          for R1 use record
             A at 0 range 0 .. 0;
             B at 0 range 1 .. 7;
          end record;

          type R2 is record
             A : Boolean;
             B : Integer range 1 .. 120;
          end record;

          for R2'Bit_Order use High_Order_First;

          for R2 use record
             A at 0 range 7 .. 7;
             B at 0 range 0 .. 6;
          end record;

     The useful application here is to write the second declaration with
     the ‘Bit_Order’ attribute definition clause, and know that it will
     be treated the same, regardless of whether the target is
     little-endian or big-endian.

   * Components occupying an integral number of bytes.

     These are components that exactly fit in two or more bytes.  Such
     component declarations are allowed, but have no effect, since it is
     important to realize that the ‘Bit_Order’ specification does not
     affect the ordering of bytes.  In particular, the following attempt
     at getting an endian-independent integer does not work:

          type R2 is record
             A : Integer;
          end record;

          for R2'Bit_Order use High_Order_First;

          for R2 use record
             A at 0 range 0 .. 31;
          end record;

     This declaration will result in a little-endian integer on a
     little-endian machine, and a big-endian integer on a big-endian
     machine.  If byte flipping is required for interoperability between
     big- and little-endian machines, this must be explicitly
     programmed.  This capability is not provided by ‘Bit_Order’.

   * Components that are positioned across byte boundaries.

     but do not occupy an integral number of bytes.  Given that bytes
     are not reordered, such fields would occupy a non-contiguous
     sequence of bits in memory, requiring non-trivial code to
     reassemble.  They are for this reason not permitted, and any
     component clause specifying such a layout will be flagged as
     illegal by GNAT.

Since the misconception that Bit_Order automatically deals with all
endian-related incompatibilities is a common one, the specification of a
component field that is an integral number of bytes will always generate
a warning.  This warning may be suppressed using ‘pragma Warnings (Off)’
if desired.  The following section contains additional details regarding
the issue of byte ordering.


File: gnat_rm.info,  Node: Effect of Bit_Order on Byte Ordering,  Next: Pragma Pack for Arrays,  Prev: Bit_Order Clauses,  Up: Representation Clauses and Pragmas

9.9 Effect of Bit_Order on Byte Ordering
========================================

In this section we will review the effect of the ‘Bit_Order’ attribute
definition clause on byte ordering.  Briefly, it has no effect at all,
but a detailed example will be helpful.  Before giving this example, let
us review the precise definition of the effect of defining ‘Bit_Order’.
The effect of a non-standard bit order is described in section 13.5.3 of
the Ada Reference Manual:

     “2 A bit ordering is a method of interpreting the meaning of the
     storage place attributes.”

To understand the precise definition of storage place attributes in this
context, we visit section 13.5.1 of the manual:

     “13 A record_representation_clause (without the mod_clause)
     specifies the layout.  The storage place attributes (see 13.5.2)
     are taken from the values of the position, first_bit, and last_bit
     expressions after normalizing those values so that first_bit is
     less than Storage_Unit.”

The critical point here is that storage places are taken from the values
after normalization, not before.  So the ‘Bit_Order’ interpretation
applies to normalized values.  The interpretation is described in the
later part of the 13.5.3 paragraph:

     “2 A bit ordering is a method of interpreting the meaning of the
     storage place attributes.  High_Order_First (known in the
     vernacular as ‘big endian’) means that the first bit of a storage
     element (bit 0) is the most significant bit (interpreting the
     sequence of bits that represent a component as an unsigned integer
     value).  Low_Order_First (known in the vernacular as ‘little
     endian’) means the opposite: the first bit is the least
     significant.”

Note that the numbering is with respect to the bits of a storage unit.
In other words, the specification affects only the numbering of bits
within a single storage unit.

We can make the effect clearer by giving an example.

Suppose that we have an external device which presents two bytes, the
first byte presented, which is the first (low addressed byte) of the two
byte record is called Master, and the second byte is called Slave.

The left most (most significant) bit is called Control for each byte,
and the remaining 7 bits are called V1, V2, … V7, where V7 is the
rightmost (least significant) bit.

On a big-endian machine, we can write the following representation
clause

     type Data is record
        Master_Control : Bit;
        Master_V1      : Bit;
        Master_V2      : Bit;
        Master_V3      : Bit;
        Master_V4      : Bit;
        Master_V5      : Bit;
        Master_V6      : Bit;
        Master_V7      : Bit;
        Slave_Control  : Bit;
        Slave_V1       : Bit;
        Slave_V2       : Bit;
        Slave_V3       : Bit;
        Slave_V4       : Bit;
        Slave_V5       : Bit;
        Slave_V6       : Bit;
        Slave_V7       : Bit;
     end record;

     for Data use record
        Master_Control at 0 range 0 .. 0;
        Master_V1      at 0 range 1 .. 1;
        Master_V2      at 0 range 2 .. 2;
        Master_V3      at 0 range 3 .. 3;
        Master_V4      at 0 range 4 .. 4;
        Master_V5      at 0 range 5 .. 5;
        Master_V6      at 0 range 6 .. 6;
        Master_V7      at 0 range 7 .. 7;
        Slave_Control  at 1 range 0 .. 0;
        Slave_V1       at 1 range 1 .. 1;
        Slave_V2       at 1 range 2 .. 2;
        Slave_V3       at 1 range 3 .. 3;
        Slave_V4       at 1 range 4 .. 4;
        Slave_V5       at 1 range 5 .. 5;
        Slave_V6       at 1 range 6 .. 6;
        Slave_V7       at 1 range 7 .. 7;
     end record;

Now if we move this to a little endian machine, then the bit ordering
within the byte is backwards, so we have to rewrite the record rep
clause as:

     for Data use record
        Master_Control at 0 range 7 .. 7;
        Master_V1      at 0 range 6 .. 6;
        Master_V2      at 0 range 5 .. 5;
        Master_V3      at 0 range 4 .. 4;
        Master_V4      at 0 range 3 .. 3;
        Master_V5      at 0 range 2 .. 2;
        Master_V6      at 0 range 1 .. 1;
        Master_V7      at 0 range 0 .. 0;
        Slave_Control  at 1 range 7 .. 7;
        Slave_V1       at 1 range 6 .. 6;
        Slave_V2       at 1 range 5 .. 5;
        Slave_V3       at 1 range 4 .. 4;
        Slave_V4       at 1 range 3 .. 3;
        Slave_V5       at 1 range 2 .. 2;
        Slave_V6       at 1 range 1 .. 1;
        Slave_V7       at 1 range 0 .. 0;
     end record;

It is a nuisance to have to rewrite the clause, especially if the code
has to be maintained on both machines.  However, this is a case that we
can handle with the ‘Bit_Order’ attribute if it is implemented.  Note
that the implementation is not required on byte addressed machines, but
it is indeed implemented in GNAT. This means that we can simply use the
first record clause, together with the declaration

     for Data'Bit_Order use High_Order_First;

and the effect is what is desired, namely the layout is exactly the
same, independent of whether the code is compiled on a big-endian or
little-endian machine.

The important point to understand is that byte ordering is not affected.
A ‘Bit_Order’ attribute definition never affects which byte a field ends
up in, only where it ends up in that byte.  To make this clear, let us
rewrite the record rep clause of the previous example as:

     for Data'Bit_Order use High_Order_First;
     for Data use record
        Master_Control at 0 range  0 .. 0;
        Master_V1      at 0 range  1 .. 1;
        Master_V2      at 0 range  2 .. 2;
        Master_V3      at 0 range  3 .. 3;
        Master_V4      at 0 range  4 .. 4;
        Master_V5      at 0 range  5 .. 5;
        Master_V6      at 0 range  6 .. 6;
        Master_V7      at 0 range  7 .. 7;
        Slave_Control  at 0 range  8 .. 8;
        Slave_V1       at 0 range  9 .. 9;
        Slave_V2       at 0 range 10 .. 10;
        Slave_V3       at 0 range 11 .. 11;
        Slave_V4       at 0 range 12 .. 12;
        Slave_V5       at 0 range 13 .. 13;
        Slave_V6       at 0 range 14 .. 14;
        Slave_V7       at 0 range 15 .. 15;
     end record;

This is exactly equivalent to saying (a repeat of the first example):

     for Data'Bit_Order use High_Order_First;
     for Data use record
        Master_Control at 0 range 0 .. 0;
        Master_V1      at 0 range 1 .. 1;
        Master_V2      at 0 range 2 .. 2;
        Master_V3      at 0 range 3 .. 3;
        Master_V4      at 0 range 4 .. 4;
        Master_V5      at 0 range 5 .. 5;
        Master_V6      at 0 range 6 .. 6;
        Master_V7      at 0 range 7 .. 7;
        Slave_Control  at 1 range 0 .. 0;
        Slave_V1       at 1 range 1 .. 1;
        Slave_V2       at 1 range 2 .. 2;
        Slave_V3       at 1 range 3 .. 3;
        Slave_V4       at 1 range 4 .. 4;
        Slave_V5       at 1 range 5 .. 5;
        Slave_V6       at 1 range 6 .. 6;
        Slave_V7       at 1 range 7 .. 7;
     end record;

Why are they equivalent?  Well take a specific field, the ‘Slave_V2’
field.  The storage place attributes are obtained by normalizing the
values given so that the ‘First_Bit’ value is less than 8.  After
normalizing the values (0,10,10) we get (1,2,2) which is exactly what we
specified in the other case.

Now one might expect that the ‘Bit_Order’ attribute might affect bit
numbering within the entire record component (two bytes in this case,
thus affecting which byte fields end up in), but that is not the way
this feature is defined, it only affects numbering of bits, not which
byte they end up in.

Consequently it never makes sense to specify a starting bit number
greater than 7 (for a byte addressable field) if an attribute definition
for ‘Bit_Order’ has been given, and indeed it may be actively confusing
to specify such a value, so the compiler generates a warning for such
usage.

If you do need to control byte ordering then appropriate conditional
values must be used.  If in our example, the slave byte came first on
some machines we might write:

     Master_Byte_First constant Boolean := ...;

     Master_Byte : constant Natural :=
                     1 - Boolean'Pos (Master_Byte_First);
     Slave_Byte  : constant Natural :=
                     Boolean'Pos (Master_Byte_First);

     for Data'Bit_Order use High_Order_First;
     for Data use record
        Master_Control at Master_Byte range 0 .. 0;
        Master_V1      at Master_Byte range 1 .. 1;
        Master_V2      at Master_Byte range 2 .. 2;
        Master_V3      at Master_Byte range 3 .. 3;
        Master_V4      at Master_Byte range 4 .. 4;
        Master_V5      at Master_Byte range 5 .. 5;
        Master_V6      at Master_Byte range 6 .. 6;
        Master_V7      at Master_Byte range 7 .. 7;
        Slave_Control  at Slave_Byte  range 0 .. 0;
        Slave_V1       at Slave_Byte  range 1 .. 1;
        Slave_V2       at Slave_Byte  range 2 .. 2;
        Slave_V3       at Slave_Byte  range 3 .. 3;
        Slave_V4       at Slave_Byte  range 4 .. 4;
        Slave_V5       at Slave_Byte  range 5 .. 5;
        Slave_V6       at Slave_Byte  range 6 .. 6;
        Slave_V7       at Slave_Byte  range 7 .. 7;
     end record;

Now to switch between machines, all that is necessary is to set the
boolean constant ‘Master_Byte_First’ in an appropriate manner.


File: gnat_rm.info,  Node: Pragma Pack for Arrays,  Next: Pragma Pack for Records,  Prev: Effect of Bit_Order on Byte Ordering,  Up: Representation Clauses and Pragmas

9.10 Pragma Pack for Arrays
===========================

Pragma ‘Pack’ applied to an array has an effect that depends upon
whether the component type is 'packable'.  For a component type to be
'packable', it must be one of the following cases:

   * Any elementary type.

   * Any small packed array type with a static size.

   * Any small simple record type with a static size.

For all these cases, if the component subtype size is in the range 1
through 63 on 32-bit targets, and 1 through 127 on 64-bit targets, then
the effect of the pragma ‘Pack’ is exactly as though a component size
were specified giving the component subtype size.

All other types are non-packable, they occupy an integral number of
storage units and the only effect of pragma Pack is to remove alignment
gaps.

For example if we have:

     type r is range 0 .. 17;

     type ar is array (1 .. 8) of r;
     pragma Pack (ar);

Then the component size of ‘ar’ will be set to 5 (i.e., to ‘r'size’, and
the size of the array ‘ar’ will be exactly 40 bits).

Note that in some cases this rather fierce approach to packing can
produce unexpected effects.  For example, in Ada 95 and Ada 2005,
subtype ‘Natural’ typically has a size of 31, meaning that if you pack
an array of ‘Natural’, you get 31-bit close packing, which saves a few
bits, but results in far less efficient access.  Since many other Ada
compilers will ignore such a packing request, GNAT will generate a
warning on some uses of pragma ‘Pack’ that it guesses might not be what
is intended.  You can easily remove this warning by using an explicit
‘Component_Size’ setting instead, which never generates a warning, since
the intention of the programmer is clear in this case.

GNAT treats packed arrays in one of two ways.  If the size of the array
is known at compile time and is at most 64 bits on 32-bit targets, and
at most 128 bits on 64-bit targets, then internally the array is
represented as a single modular type, of exactly the appropriate number
of bits.  If the length is greater than 64 bits on 32-bit targets, and
greater than 128 bits on 64-bit targets, or is not known at compile
time, then the packed array is represented as an array of bytes, and its
length is always a multiple of 8 bits.

Note that to represent a packed array as a modular type, the alignment
must be suitable for the modular type involved.  For example, on typical
machines a 32-bit packed array will be represented by a 32-bit modular
integer with an alignment of four bytes.  If you explicitly override the
default alignment with an alignment clause that is too small, the
modular representation cannot be used.  For example, consider the
following set of declarations:

     type R is range 1 .. 3;
     type S is array (1 .. 31) of R;
     for S'Component_Size use 2;
     for S'Size use 62;
     for S'Alignment use 1;

If the alignment clause were not present, then a 62-bit modular
representation would be chosen (typically with an alignment of 4 or 8
bytes depending on the target).  But the default alignment is overridden
with the explicit alignment clause.  This means that the modular
representation cannot be used, and instead the array of bytes
representation must be used, meaning that the length must be a multiple
of 8.  Thus the above set of declarations will result in a diagnostic
rejecting the size clause and noting that the minimum size allowed is
64.

One special case that is worth noting occurs when the base type of the
component size is 8/16/32 and the subtype is one bit less.  Notably this
occurs with subtype ‘Natural’.  Consider:

     type Arr is array (1 .. 32) of Natural;
     pragma Pack (Arr);

In all commonly used Ada 83 compilers, this pragma Pack would be
ignored, since typically ‘Natural'Size’ is 32 in Ada 83, and in any case
most Ada 83 compilers did not attempt 31 bit packing.

In Ada 95 and Ada 2005, ‘Natural'Size’ is required to be 31.
Furthermore, GNAT really does pack 31-bit subtype to 31 bits.  This may
result in a substantial unintended performance penalty when porting
legacy Ada 83 code.  To help prevent this, GNAT generates a warning in
such cases.  If you really want 31 bit packing in a case like this, you
can set the component size explicitly:

     type Arr is array (1 .. 32) of Natural;
     for Arr'Component_Size use 31;

Here 31-bit packing is achieved as required, and no warning is
generated, since in this case the programmer intention is clear.


File: gnat_rm.info,  Node: Pragma Pack for Records,  Next: Record Representation Clauses,  Prev: Pragma Pack for Arrays,  Up: Representation Clauses and Pragmas

9.11 Pragma Pack for Records
============================

Pragma ‘Pack’ applied to a record will pack the components to reduce
wasted space from alignment gaps and by reducing the amount of space
taken by components.  We distinguish between 'packable' components and
'non-packable' components.  Components of the following types are
considered packable:

   * Components of an elementary type are packable unless they are
     aliased, independent or atomic.

   * Small packed arrays, where the size is statically known, are
     represented internally as modular integers, and so they are also
     packable.

   * Small simple records, where the size is statically known, are also
     packable.

For all these cases, if the ‘'Size’ value is in the range 1 through 64
on 32-bit targets, and 1 through 128 on 64-bit targets, the components
occupy the exact number of bits corresponding to this value and are
packed with no padding bits, i.e.  they can start on an arbitrary bit
boundary.

All other types are non-packable, they occupy an integral number of
storage units and the only effect of pragma ‘Pack’ is to remove
alignment gaps.

For example, consider the record

     type Rb1 is array (1 .. 13) of Boolean;
     pragma Pack (Rb1);

     type Rb2 is array (1 .. 65) of Boolean;
     pragma Pack (Rb2);

     type AF is new Float with Atomic;

     type X2 is record
        L1 : Boolean;
        L2 : Duration;
        L3 : AF;
        L4 : Boolean;
        L5 : Rb1;
        L6 : Rb2;
     end record;
     pragma Pack (X2);

The representation for the record ‘X2’ is as follows on 32-bit targets:

     for X2'Size use 224;
     for X2 use record
        L1 at  0 range  0 .. 0;
        L2 at  0 range  1 .. 64;
        L3 at 12 range  0 .. 31;
        L4 at 16 range  0 .. 0;
        L5 at 16 range  1 .. 13;
        L6 at 18 range  0 .. 71;
     end record;

Studying this example, we see that the packable fields ‘L1’ and ‘L2’ are
of length equal to their sizes, and placed at specific bit boundaries
(and not byte boundaries) to eliminate padding.  But ‘L3’ is of a
non-packable float type (because it is aliased), so it is on the next
appropriate alignment boundary.

The next two fields are fully packable, so ‘L4’ and ‘L5’ are minimally
packed with no gaps.  However, type ‘Rb2’ is a packed array that is
longer than 64 bits, so it is itself non-packable on 32-bit targets.
Thus the ‘L6’ field is aligned to the next byte boundary, and takes an
integral number of bytes, i.e., 72 bits.


File: gnat_rm.info,  Node: Record Representation Clauses,  Next: Handling of Records with Holes,  Prev: Pragma Pack for Records,  Up: Representation Clauses and Pragmas

9.12 Record Representation Clauses
==================================

Record representation clauses may be given for all record types,
including types obtained by record extension.  Component clauses are
allowed for any static component.  The restrictions on component clauses
depend on the type of the component.

For all components of an elementary type, the only restriction on
component clauses is that the size must be at least the ‘'Size’ value of
the type (actually the Value_Size).  There are no restrictions due to
alignment, and such components may freely cross storage boundaries.

Packed arrays with a size up to and including 64 bits on 32-bit targets,
and up to and including 128 bits on 64-bit targets, are represented
internally using a modular type with the appropriate number of bits, and
thus the same lack of restriction applies.  For example, if you declare:

     type R is array (1 .. 49) of Boolean;
     pragma Pack (R);
     for R'Size use 49;

then a component clause for a component of type ‘R’ may start on any
specified bit boundary, and may specify a value of 49 bits or greater.

For packed bit arrays that are longer than 64 bits on 32-bit targets,
and longer than 128 bits on 64-bit targets, there are two cases.  If the
component size is a power of 2 (1,2,4,8,16,32,64 bits), including the
important case of single bits or boolean values, then there are no
limitations on placement of such components, and they may start and end
at arbitrary bit boundaries.

If the component size is not a power of 2 (e.g., 3 or 5), then an array
of this type must always be placed on on a storage unit (byte) boundary
and occupy an integral number of storage units (bytes).  Any component
clause that does not meet this requirement will be rejected.

Any aliased component, or component of an aliased type, must have its
normal alignment and size.  A component clause that does not meet this
requirement will be rejected.

The tag field of a tagged type always occupies an address sized field at
the start of the record.  No component clause may attempt to overlay
this tag.  When a tagged type appears as a component, the tag field must
have proper alignment

In the case of a record extension ‘T1’, of a type ‘T’, no component
clause applied to the type ‘T1’ can specify a storage location that
would overlap the first ‘T'Object_Size’ bits of the record.

For all other component types, including non-bit-packed arrays, the
component can be placed at an arbitrary bit boundary, so for example,
the following is permitted:

     type R is array (1 .. 10) of Boolean;
     for R'Size use 80;

     type Q is record
        G, H : Boolean;
        L, M : R;
     end record;

     for Q use record
        G at 0 range  0 ..   0;
        H at 0 range  1 ..   1;
        L at 0 range  2 ..  81;
        R at 0 range 82 .. 161;
     end record;


File: gnat_rm.info,  Node: Handling of Records with Holes,  Next: Enumeration Clauses,  Prev: Record Representation Clauses,  Up: Representation Clauses and Pragmas

9.13 Handling of Records with Holes
===================================

As a result of alignment considerations, records may contain “holes” or
gaps which do not correspond to the data bits of any of the components.
Record representation clauses can also result in holes in records.

GNAT does not attempt to clear these holes, so in record objects, they
should be considered to hold undefined rubbish.  The generated equality
routine just tests components so does not access these undefined bits,
and assignment and copy operations may or may not preserve the contents
of these holes (for assignments, the holes in the target will in
practice contain either the bits that are present in the holes in the
source, or the bits that were present in the target before the
assignment).

If it is necessary to ensure that holes in records have all zero bits,
then record objects for which this initialization is desired should be
explicitly set to all zero values using Unchecked_Conversion or address
overlays.  For example

     type HRec is record
        C : Character;
        I : Integer;
     end record;

On typical machines, integers need to be aligned on a four-byte
boundary, resulting in three bytes of undefined rubbish following the
8-bit field for C. To ensure that the hole in a variable of type HRec is
set to all zero bits, you could for example do:

     type Base is record
        Dummy1, Dummy2 : Integer := 0;
     end record;

     BaseVar : Base;
     RealVar : Hrec;
     for RealVar'Address use BaseVar'Address;

Now the 8-bytes of the value of RealVar start out containing all zero
bits.  A safer approach is to just define dummy fields, avoiding the
holes, as in:

     type HRec is record
        C      : Character;
        Dummy1 : Short_Short_Integer := 0;
        Dummy2 : Short_Short_Integer := 0;
        Dummy3 : Short_Short_Integer := 0;
        I      : Integer;
     end record;

And to make absolutely sure that the intent of this is followed, you can
use representation clauses:

     for Hrec use record
        C      at 0 range 0 .. 7;
        Dummy1 at 1 range 0 .. 7;
        Dummy2 at 2 range 0 .. 7;
        Dummy3 at 3 range 0 .. 7;
        I      at 4 range 0 .. 31;
     end record;
     for Hrec'Size use 64;


File: gnat_rm.info,  Node: Enumeration Clauses,  Next: Address Clauses,  Prev: Handling of Records with Holes,  Up: Representation Clauses and Pragmas

9.14 Enumeration Clauses
========================

The only restriction on enumeration clauses is that the range of values
must be representable.  For the signed case, if one or more of the
representation values are negative, all values must be in the range:

     System.Min_Int .. System.Max_Int

For the unsigned case, where all values are nonnegative, the values must
be in the range:

     0 .. System.Max_Binary_Modulus;

A 'confirming' representation clause is one in which the values range
from 0 in sequence, i.e., a clause that confirms the default
representation for an enumeration type.  Such a confirming
representation is permitted by these rules, and is specially recognized
by the compiler so that no extra overhead results from the use of such a
clause.

If an array has an index type which is an enumeration type to which an
enumeration clause has been applied, then the array is stored in a
compact manner.  Consider the declarations:

     type r is (A, B, C);
     for r use (A => 1, B => 5, C => 10);
     type t is array (r) of Character;

The array type t corresponds to a vector with exactly three elements and
has a default size equal to ‘3*Character'Size’.  This ensures efficient
use of space, but means that accesses to elements of the array will
incur the overhead of converting representation values to the
corresponding positional values, (i.e., the value delivered by the ‘Pos’
attribute).


File: gnat_rm.info,  Node: Address Clauses,  Next: Use of Address Clauses for Memory-Mapped I/O,  Prev: Enumeration Clauses,  Up: Representation Clauses and Pragmas

9.15 Address Clauses
====================

The reference manual allows a general restriction on representation
clauses, as found in RM 13.1(22):

     “An implementation need not support representation items containing
     nonstatic expressions, except that an implementation should support
     a representation item for a given entity if each nonstatic
     expression in the representation item is a name that statically
     denotes a constant declared before the entity.”

In practice this is applicable only to address clauses, since this is
the only case in which a nonstatic expression is permitted by the
syntax.  As the AARM notes in sections 13.1 (22.a-22.h):

     22.a Reason: This is to avoid the following sort of thing:

     22.b X : Integer := F(…); Y : Address := G(…); for X’Address use Y;

     22.c In the above, we have to evaluate the initialization
     expression for X before we know where to put the result.  This
     seems like an unreasonable implementation burden.

     22.d The above code should instead be written like this:

     22.e Y : constant Address := G(…); X : Integer := F(…); for
     X’Address use Y;

     22.f This allows the expression ‘Y’ to be safely evaluated before X
     is created.

     22.g The constant could be a formal parameter of mode in.

     22.h An implementation can support other nonstatic expressions if
     it wants to.  Expressions of type Address are hardly ever static,
     but their value might be known at compile time anyway in many
     cases.

GNAT does indeed permit many additional cases of nonstatic expressions.
In particular, if the type involved is elementary there are no
restrictions (since in this case, holding a temporary copy of the
initialization value, if one is present, is inexpensive).  In addition,
if there is no implicit or explicit initialization, then there are no
restrictions.  GNAT will reject only the case where all three of these
conditions hold:

   * The type of the item is non-elementary (e.g., a record or array).

   * There is explicit or implicit initialization required for the
     object.  Note that access values are always implicitly initialized.

   * The address value is nonstatic.  Here GNAT is more permissive than
     the RM, and allows the address value to be the address of a
     previously declared stand-alone variable, as long as it does not
     itself have an address clause.

          Anchor  : Some_Initialized_Type;
          Overlay : Some_Initialized_Type;
          for Overlay'Address use Anchor'Address;

     However, the prefix of the address clause cannot be an array
     component, or a component of a discriminated record.

As noted above in section 22.h, address values are typically nonstatic.
In particular the To_Address function, even if applied to a literal
value, is a nonstatic function call.  To avoid this minor annoyance,
GNAT provides the implementation defined attribute ‘To_Address.  The
following two expressions have identical values:

     To_Address (16#1234_0000#)
     System'To_Address (16#1234_0000#);

except that the second form is considered to be a static expression, and
thus when used as an address clause value is always permitted.

Additionally, GNAT treats as static an address clause that is an
unchecked_conversion of a static integer value.  This simplifies the
porting of legacy code, and provides a portable equivalent to the GNAT
attribute ‘To_Address’.

Another issue with address clauses is the interaction with alignment
requirements.  When an address clause is given for an object, the
address value must be consistent with the alignment of the object (which
is usually the same as the alignment of the type of the object).  If an
address clause is given that specifies an inappropriately aligned
address value, then the program execution is erroneous.

Since this source of erroneous behavior can have unfortunate effects on
machines with strict alignment requirements, GNAT checks (at compile
time if possible, generating a warning, or at execution time with a
run-time check) that the alignment is appropriate.  If the run-time
check fails, then ‘Program_Error’ is raised.  This run-time check is
suppressed if range checks are suppressed, or if the special GNAT check
Alignment_Check is suppressed, or if ‘pragma Restrictions
(No_Elaboration_Code)’ is in effect.  It is also suppressed by default
on non-strict alignment machines (such as the x86).

In some cases, GNAT does not support an address specification (using
either form of aspect specification syntax) for the declaration of an
object that has an indefinite nominal subtype.  An object declaration
has an indefinite nominal subtype if it takes its bounds (for an array
type), discriminant values (for a discriminated type whose discriminants
lack defaults), or tag (for a class-wide type) from its initial value,
as in

     X : String := Some_Function_Call;
     -- String has no constraint, so bounds for X come from function call

This restriction does not apply if the size of the object’s initial
value is known at compile time and the type of the object is not
class-wide.

An address clause cannot be given for an exported object.  More
understandably the real restriction is that objects with an address
clause cannot be exported.  This is because such variables are not
defined by the Ada program, so there is no external object to export.

It is permissible to give an address clause and a pragma Import for the
same object.  In this case, the variable is not really defined by the
Ada program, so there is no external symbol to be linked.  The link name
and the external name are ignored in this case.  The reason that we
allow this combination is that it provides a useful idiom to avoid
unwanted initializations on objects with address clauses.

When an address clause is given for an object that has implicit or
explicit initialization, then by default initialization takes place.
This means that the effect of the object declaration is to overwrite the
memory at the specified address.  This is almost always not what the
programmer wants, so GNAT will output a warning:

     with System;
     package G is
        type R is record
           M : Integer := 0;
        end record;

        Ext : R;
        for Ext'Address use System'To_Address (16#1234_1234#);
            |
     >>> warning: implicit initialization of "Ext" may
         modify overlaid storage
     >>> warning: use pragma Import for "Ext" to suppress
         initialization (RM B(24))

     end G;

As indicated by the warning message, the solution is to use a (dummy)
pragma Import to suppress this initialization.  The pragma tell the
compiler that the object is declared and initialized elsewhere.  The
following package compiles without warnings (and the initialization is
suppressed):

     with System;
     package G is
        type R is record
           M : Integer := 0;
        end record;

        Ext : R;
        for Ext'Address use System'To_Address (16#1234_1234#);
        pragma Import (Ada, Ext);
     end G;

A final issue with address clauses involves their use for overlaying
variables, as in the following example:

     A : Integer;
     B : Integer;
     for B'Address use A'Address;

or alternatively, using the form recommended by the RM:

     A    : Integer;
     Addr : constant Address := A'Address;
     B    : Integer;
     for B'Address use Addr;

In both of these cases, ‘A’ and ‘B’ become aliased to one another via
the address clause.  This use of address clauses to overlay variables,
achieving an effect similar to unchecked conversion was erroneous in Ada
83, but in Ada 95 and Ada 2005 the effect is implementation defined.
Furthermore, the Ada RM specifically recommends that in a situation like
this, ‘B’ should be subject to the following implementation advice (RM
13.3(19)):

     “19 If the Address of an object is specified, or it is imported or
     exported, then the implementation should not perform optimizations
     based on assumptions of no aliases.”

GNAT follows this recommendation, and goes further by also applying this
recommendation to the overlaid variable (‘A’ in the above example) in
this case.  This means that the overlay works “as expected”, in that a
modification to one of the variables will affect the value of the other.

More generally, GNAT interprets this recommendation conservatively for
address clauses: in the cases other than overlays, it considers that the
object is effectively subject to pragma ‘Volatile’ and implements the
associated semantics.

Note that when address clause overlays are used in this way, there is an
issue of unintentional initialization, as shown by this example:

     package Overwrite_Record is
        type R is record
           A : Character := 'C';
           B : Character := 'A';
        end record;
        X : Short_Integer := 3;
        Y : R;
        for Y'Address use X'Address;
            |
     >>> warning: default initialization of "Y" may
         modify "X", use pragma Import for "Y" to
         suppress initialization (RM B.1(24))

     end Overwrite_Record;

Here the default initialization of ‘Y’ will clobber the value of ‘X’,
which justifies the warning.  The warning notes that this effect can be
eliminated by adding a ‘pragma Import’ which suppresses the
initialization:

     package Overwrite_Record is
        type R is record
           A : Character := 'C';
           B : Character := 'A';
        end record;
        X : Short_Integer := 3;
        Y : R;
        for Y'Address use X'Address;
        pragma Import (Ada, Y);
     end Overwrite_Record;

Note that the use of ‘pragma Initialize_Scalars’ may cause variables to
be initialized when they would not otherwise have been in the absence of
the use of this pragma.  This may cause an overlay to have this
unintended clobbering effect.  The compiler avoids this for scalar
types, but not for composite objects (where in general the effect of
‘Initialize_Scalars’ is part of the initialization routine for the
composite object):

     pragma Initialize_Scalars;
     with Ada.Text_IO;  use Ada.Text_IO;
     procedure Overwrite_Array is
        type Arr is array (1 .. 5) of Integer;
        X : Arr := (others => 1);
        A : Arr;
        for A'Address use X'Address;
            |
     >>> warning: default initialization of "A" may
         modify "X", use pragma Import for "A" to
         suppress initialization (RM B.1(24))

     begin
        if X /= Arr'(others => 1) then
           Put_Line ("X was clobbered");
        else
           Put_Line ("X was not clobbered");
        end if;
     end Overwrite_Array;

The above program generates the warning as shown, and at execution time,
prints ‘X was clobbered’.  If the ‘pragma Import’ is added as suggested:

     pragma Initialize_Scalars;
     with Ada.Text_IO;  use Ada.Text_IO;
     procedure Overwrite_Array is
        type Arr is array (1 .. 5) of Integer;
        X : Arr := (others => 1);
        A : Arr;
        for A'Address use X'Address;
        pragma Import (Ada, A);
     begin
        if X /= Arr'(others => 1) then
           Put_Line ("X was clobbered");
        else
           Put_Line ("X was not clobbered");
        end if;
     end Overwrite_Array;

then the program compiles without the warning and when run will generate
the output ‘X was not clobbered’.


File: gnat_rm.info,  Node: Use of Address Clauses for Memory-Mapped I/O,  Next: Effect of Convention on Representation,  Prev: Address Clauses,  Up: Representation Clauses and Pragmas

9.16 Use of Address Clauses for Memory-Mapped I/O
=================================================

A common pattern is to use an address clause to map an atomic variable
to a location in memory that corresponds to a memory-mapped I/O
operation or operations, for example:

     type Mem_Word is record
        A,B,C,D : Byte;
     end record;
     pragma Atomic (Mem_Word);
     for Mem_Word_Size use 32;

     Mem : Mem_Word;
     for Mem'Address use some-address;
     ...
     Temp := Mem;
     Temp.A := 32;
     Mem := Temp;

For a full access (reference or modification) of the variable (Mem) in
this case, as in the above examples, GNAT guarantees that the entire
atomic word will be accessed, in accordance with the RM C.6(15) clause.

A problem arises with a component access such as:

     Mem.A := 32;

Note that the component A is not declared as atomic.  This means that it
is not clear what this assignment means.  It could correspond to full
word read and write as given in the first example, or on architectures
that supported such an operation it might be a single byte store
instruction.  The RM does not have anything to say in this situation,
and GNAT does not make any guarantee.  The code generated may vary from
target to target.  GNAT will issue a warning in such a case:

     Mem.A := 32;
     |
     >>> warning: access to non-atomic component of atomic array,
         may cause unexpected accesses to atomic object

It is best to be explicit in this situation, by either declaring the
components to be atomic if you want the byte store, or explicitly
writing the full word access sequence if that is what the hardware
requires.  Alternatively, if the full word access sequence is required,
GNAT also provides the pragma ‘Volatile_Full_Access’ which can be used
in lieu of pragma ‘Atomic’ and will give the additional guarantee.


File: gnat_rm.info,  Node: Effect of Convention on Representation,  Next: Conventions and Anonymous Access Types,  Prev: Use of Address Clauses for Memory-Mapped I/O,  Up: Representation Clauses and Pragmas

9.17 Effect of Convention on Representation
===========================================

Normally the specification of a foreign language convention for a type
or an object has no effect on the chosen representation.  In particular,
the representation chosen for data in GNAT generally meets the standard
system conventions, and for example records are laid out in a manner
that is consistent with C. This means that specifying convention C (for
example) has no effect.

There are four exceptions to this general rule:

   * 'Convention Fortran and array subtypes'.

     If pragma Convention Fortran is specified for an array subtype,
     then in accordance with the implementation advice in section
     3.6.2(11) of the Ada Reference Manual, the array will be stored in
     a Fortran-compatible column-major manner, instead of the normal
     default row-major order.

   * 'Convention C and enumeration types'

     GNAT normally stores enumeration types in 8, 16, or 32 bits as
     required to accommodate all values of the type.  For example, for
     the enumeration type declared by:

          type Color is (Red, Green, Blue);

     8 bits is sufficient to store all values of the type, so by
     default, objects of type ‘Color’ will be represented using 8 bits.
     However, normal C convention is to use 32 bits for all enum values
     in C, since enum values are essentially of type int.  If pragma
     ‘Convention C’ is specified for an Ada enumeration type, then the
     size is modified as necessary (usually to 32 bits) to be consistent
     with the C convention for enum values.

     Note that this treatment applies only to types.  If Convention C is
     given for an enumeration object, where the enumeration type is not
     Convention C, then Object_Size bits are allocated.  For example,
     for a normal enumeration type, with less than 256 elements, only 8
     bits will be allocated for the object.  Since this may be a
     surprise in terms of what C expects, GNAT will issue a warning in
     this situation.  The warning can be suppressed by giving an
     explicit size clause specifying the desired size.

   * 'Convention C/Fortran and Boolean types'

     In C, the usual convention for boolean values, that is values used
     for conditions, is that zero represents false, and nonzero values
     represent true.  In Ada, the normal convention is that two specific
     values, typically 0/1, are used to represent false/true
     respectively.

     Fortran has a similar convention for ‘LOGICAL’ values (any nonzero
     value represents true).

     To accommodate the Fortran and C conventions, if a pragma
     Convention specifies C or Fortran convention for a derived Boolean,
     as in the following example:

          type C_Switch is new Boolean;
          pragma Convention (C, C_Switch);

     then the GNAT generated code will treat any nonzero value as true.
     For truth values generated by GNAT, the conventional value 1 will
     be used for True, but when one of these values is read, any nonzero
     value is treated as True.


File: gnat_rm.info,  Node: Conventions and Anonymous Access Types,  Next: Determining the Representations chosen by GNAT,  Prev: Effect of Convention on Representation,  Up: Representation Clauses and Pragmas

9.18 Conventions and Anonymous Access Types
===========================================

The RM is not entirely clear on convention handling in a number of
cases, and in particular, it is not clear on the convention to be given
to anonymous access types in general, and in particular what is to be
done for the case of anonymous access-to-subprogram.

In GNAT, we decide that if an explicit Convention is applied to an
object or component, and its type is such an anonymous type, then the
convention will apply to this anonymous type as well.  This seems to
make sense since it is anomolous in any case to have a different
convention for an object and its type, and there is clearly no way to
explicitly specify a convention for an anonymous type, since it doesn’t
have a name to specify!

Furthermore, we decide that if a convention is applied to a record type,
then this convention is inherited by any of its components that are of
an anonymous access type which do not have an explicitly specified
convention.

The following program shows these conventions in action:

     package ConvComp is
        type Foo is range 1 .. 10;
        type T1 is record
           A : access function (X : Foo) return Integer;
           B : Integer;
        end record;
        pragma Convention (C, T1);

        type T2 is record
           A : access function (X : Foo) return Integer;
           pragma Convention  (C, A);
           B : Integer;
        end record;
        pragma Convention (COBOL, T2);

        type T3 is record
           A : access function (X : Foo) return Integer;
           pragma Convention  (COBOL, A);
           B : Integer;
        end record;
        pragma Convention (C, T3);

        type T4 is record
           A : access function (X : Foo) return Integer;
           B : Integer;
        end record;
        pragma Convention (COBOL, T4);

        function F (X : Foo) return Integer;
        pragma Convention (C, F);

        function F (X : Foo) return Integer is (13);

        TV1 : T1 := (F'Access, 12);  -- OK
        TV2 : T2 := (F'Access, 13);  -- OK

        TV3 : T3 := (F'Access, 13);  -- ERROR
                     |
     >>> subprogram "F" has wrong convention
     >>> does not match access to subprogram declared at line 17
          38.    TV4 : T4 := (F'Access, 13);  -- ERROR
                     |
     >>> subprogram "F" has wrong convention
     >>> does not match access to subprogram declared at line 24
          39. end ConvComp;


File: gnat_rm.info,  Node: Determining the Representations chosen by GNAT,  Prev: Conventions and Anonymous Access Types,  Up: Representation Clauses and Pragmas

9.19 Determining the Representations chosen by GNAT
===================================================

Although the descriptions in this section are intended to be complete,
it is often easier to simply experiment to see what GNAT accepts and
what the effect is on the layout of types and objects.

As required by the Ada RM, if a representation clause is not accepted,
then it must be rejected as illegal by the compiler.  However, when a
representation clause or pragma is accepted, there can still be
questions of what the compiler actually does.  For example, if a partial
record representation clause specifies the location of some components
and not others, then where are the non-specified components placed?  Or
if pragma ‘Pack’ is used on a record, then exactly where are the
resulting fields placed?  The section on pragma ‘Pack’ in this chapter
can be used to answer the second question, but it is often easier to
just see what the compiler does.

For this purpose, GNAT provides the option '-gnatR'. If you compile with
this option, then the compiler will output information on the actual
representations chosen, in a format similar to source representation
clauses.  For example, if we compile the package:

     package q is
        type r (x : boolean) is tagged record
           case x is
              when True => S : String (1 .. 100);
              when False => null;
           end case;
        end record;

        type r2 is new r (false) with record
           y2 : integer;
        end record;

        for r2 use record
           y2 at 16 range 0 .. 31;
        end record;

        type x is record
           y : character;
        end record;

        type x1 is array (1 .. 10) of x;
        for x1'component_size use 11;

        type ia is access integer;

        type Rb1 is array (1 .. 13) of Boolean;
        pragma Pack (rb1);

        type Rb2 is array (1 .. 65) of Boolean;
        pragma Pack (rb2);

        type x2 is record
           l1 : Boolean;
           l2 : Duration;
           l3 : Float;
           l4 : Boolean;
           l5 : Rb1;
           l6 : Rb2;
        end record;
        pragma Pack (x2);
     end q;

using the switch '-gnatR' we obtain the following output:

     Representation information for unit q
     -------------------------------------

     for r'Size use ??;
     for r'Alignment use 4;
     for r use record
        x    at 4 range  0 .. 7;
        _tag at 0 range  0 .. 31;
        s    at 5 range  0 .. 799;
     end record;

     for r2'Size use 160;
     for r2'Alignment use 4;
     for r2 use record
        x       at  4 range  0 .. 7;
        _tag    at  0 range  0 .. 31;
        _parent at  0 range  0 .. 63;
        y2      at 16 range  0 .. 31;
     end record;

     for x'Size use 8;
     for x'Alignment use 1;
     for x use record
        y at 0 range  0 .. 7;
     end record;

     for x1'Size use 112;
     for x1'Alignment use 1;
     for x1'Component_Size use 11;

     for rb1'Size use 13;
     for rb1'Alignment use 2;
     for rb1'Component_Size use 1;

     for rb2'Size use 72;
     for rb2'Alignment use 1;
     for rb2'Component_Size use 1;

     for x2'Size use 224;
     for x2'Alignment use 4;
     for x2 use record
        l1 at  0 range  0 .. 0;
        l2 at  0 range  1 .. 64;
        l3 at 12 range  0 .. 31;
        l4 at 16 range  0 .. 0;
        l5 at 16 range  1 .. 13;
        l6 at 18 range  0 .. 71;
     end record;

The Size values are actually the Object_Size, i.e., the default size
that will be allocated for objects of the type.  The ‘??’ size for type
r indicates that we have a variant record, and the actual size of
objects will depend on the discriminant value.

The Alignment values show the actual alignment chosen by the compiler
for each record or array type.

The record representation clause for type r shows where all fields are
placed, including the compiler generated tag field (whose location
cannot be controlled by the programmer).

The record representation clause for the type extension r2 shows all the
fields present, including the parent field, which is a copy of the
fields of the parent type of r2, i.e., r1.

The component size and size clauses for types rb1 and rb2 show the exact
effect of pragma ‘Pack’ on these arrays, and the record representation
clause for type x2 shows how pragma ‘Pack’ affects this record type.

In some cases, it may be useful to cut and paste the representation
clauses generated by the compiler into the original source to fix and
guarantee the actual representation to be used.


File: gnat_rm.info,  Node: Standard Library Routines,  Next: The Implementation of Standard I/O,  Prev: Representation Clauses and Pragmas,  Up: Top

10 Standard Library Routines
****************************

The Ada Reference Manual contains in Annex A a full description of an
extensive set of standard library routines that can be used in any Ada
program, and which must be provided by all Ada compilers.  They are
analogous to the standard C library used by C programs.

GNAT implements all of the facilities described in annex A, and for most
purposes the description in the Ada Reference Manual, or appropriate Ada
text book, will be sufficient for making use of these facilities.

In the case of the input-output facilities, *note The Implementation of
Standard I/O: f, gives details on exactly how GNAT interfaces to the
file system.  For the remaining packages, the Ada Reference Manual
should be sufficient.  The following is a list of the packages included,
together with a brief description of the functionality that is provided.

For completeness, references are included to other predefined library
routines defined in other sections of the Ada Reference Manual (these
are cross-indexed from Annex A). For further details see the relevant
package declarations in the run-time library.  In particular, a few
units are not implemented, as marked by the presence of pragma
Unimplemented_Unit, and in this case the package declaration contains
comments explaining why the unit is not implemented.

‘Ada’ '(A.2)'

     This is a parent package for all the standard library packages.  It
     is usually included implicitly in your program, and itself contains
     no useful data or routines.

‘Ada.Assertions’ '(11.4.2)'

     ‘Assertions’ provides the ‘Assert’ subprograms, and also the
     declaration of the ‘Assertion_Error’ exception.

‘Ada.Asynchronous_Task_Control’ '(D.11)'

     ‘Asynchronous_Task_Control’ provides low level facilities for task
     synchronization.  It is typically not implemented.  See package
     spec for details.

‘Ada.Calendar’ '(9.6)'

     ‘Calendar’ provides time of day access, and routines for
     manipulating times and durations.

‘Ada.Calendar.Arithmetic’ '(9.6.1)'

     This package provides additional arithmetic operations for
     ‘Calendar’.

‘Ada.Calendar.Formatting’ '(9.6.1)'

     This package provides formatting operations for ‘Calendar’.

‘Ada.Calendar.Time_Zones’ '(9.6.1)'

     This package provides additional ‘Calendar’ facilities for handling
     time zones.

‘Ada.Characters’ '(A.3.1)'

     This is a dummy parent package that contains no useful entities

‘Ada.Characters.Conversions’ '(A.3.2)'

     This package provides character conversion functions.

‘Ada.Characters.Handling’ '(A.3.2)'

     This package provides some basic character handling capabilities,
     including classification functions for classes of characters (e.g.,
     test for letters, or digits).

‘Ada.Characters.Latin_1’ '(A.3.3)'

     This package includes a complete set of definitions of the
     characters that appear in type CHARACTER. It is useful for writing
     programs that will run in international environments.  For example,
     if you want an upper case E with an acute accent in a string, it is
     often better to use the definition of ‘UC_E_Acute’ in this package.
     Then your program will print in an understandable manner even if
     your environment does not support these extended characters.

‘Ada.Command_Line’ '(A.15)'

     This package provides access to the command line parameters and the
     name of the current program (analogous to the use of ‘argc’ and
     ‘argv’ in C), and also allows the exit status for the program to be
     set in a system-independent manner.

‘Ada.Complex_Text_IO’ '(G.1.3)'

     This package provides text input and output of complex numbers.

‘Ada.Containers’ '(A.18.1)'

     A top level package providing a few basic definitions used by all
     the following specific child packages that provide specific kinds
     of containers.

‘Ada.Containers.Bounded_Priority_Queues’ '(A.18.31)'

‘Ada.Containers.Bounded_Synchronized_Queues’ '(A.18.29)'

‘Ada.Containers.Doubly_Linked_Lists’ '(A.18.3)'

‘Ada.Containers.Generic_Array_Sort’ '(A.18.26)'

‘Ada.Containers.Generic_Constrained_Array_Sort’ '(A.18.26)'

‘Ada.Containers.Generic_Sort’ '(A.18.26)'

‘Ada.Containers.Hashed_Maps’ '(A.18.5)'

‘Ada.Containers.Hashed_Sets’ '(A.18.8)'

‘Ada.Containers.Indefinite_Doubly_Linked_Lists’ '(A.18.12)'

‘Ada.Containers.Indefinite_Hashed_Maps’ '(A.18.13)'

‘Ada.Containers.Indefinite_Hashed_Sets’ '(A.18.15)'

‘Ada.Containers.Indefinite_Holders’ '(A.18.18)'

‘Ada.Containers.Indefinite_Multiway_Trees’ '(A.18.17)'

‘Ada.Containers.Indefinite_Ordered_Maps’ '(A.18.14)'

‘Ada.Containers.Indefinite_Ordered_Sets’ '(A.18.16)'

‘Ada.Containers.Indefinite_Vectors’ '(A.18.11)'

‘Ada.Containers.Multiway_Trees’ '(A.18.10)'

‘Ada.Containers.Ordered_Maps’ '(A.18.6)'

‘Ada.Containers.Ordered_Sets’ '(A.18.9)'

‘Ada.Containers.Synchronized_Queue_Interfaces’ '(A.18.27)'

‘Ada.Containers.Unbounded_Priority_Queues’ '(A.18.30)'

‘Ada.Containers.Unbounded_Synchronized_Queues’ '(A.18.28)'

‘Ada.Containers.Vectors’ '(A.18.2)'

‘Ada.Directories’ '(A.16)'

     This package provides operations on directories.

‘Ada.Directories.Hierarchical_File_Names’ '(A.16.1)'

     This package provides additional directory operations handling
     hierarchical file names.

‘Ada.Directories.Information’ '(A.16)'

     This is an implementation defined package for additional directory
     operations, which is not implemented in GNAT.

‘Ada.Decimal’ '(F.2)'

     This package provides constants describing the range of decimal
     numbers implemented, and also a decimal divide routine (analogous
     to the COBOL verb DIVIDE … GIVING … REMAINDER …)

‘Ada.Direct_IO’ '(A.8.4)'

     This package provides input-output using a model of a set of
     records of fixed-length, containing an arbitrary definite Ada type,
     indexed by an integer record number.

‘Ada.Dispatching’ '(D.2.1)'

     A parent package containing definitions for task dispatching
     operations.

‘Ada.Dispatching.EDF’ '(D.2.6)'

     Not implemented in GNAT.

‘Ada.Dispatching.Non_Preemptive’ '(D.2.4)'

     Not implemented in GNAT.

‘Ada.Dispatching.Round_Robin’ '(D.2.5)'

     Not implemented in GNAT.

‘Ada.Dynamic_Priorities’ '(D.5)'

     This package allows the priorities of a task to be adjusted
     dynamically as the task is running.

‘Ada.Environment_Variables’ '(A.17)'

     This package provides facilities for accessing environment
     variables.

‘Ada.Exceptions’ '(11.4.1)'

     This package provides additional information on exceptions, and
     also contains facilities for treating exceptions as data objects,
     and raising exceptions with associated messages.

‘Ada.Execution_Time’ '(D.14)'

     This package provides CPU clock functionalities.  It is not
     implemented on all targets (see package spec for details).

‘Ada.Execution_Time.Group_Budgets’ '(D.14.2)'

     Not implemented in GNAT.

‘Ada.Execution_Time.Timers’ '(D.14.1)’'

     Not implemented in GNAT.

‘Ada.Finalization’ '(7.6)'

     This package contains the declarations and subprograms to support
     the use of controlled types, providing for automatic initialization
     and finalization (analogous to the constructors and destructors of
     C++).

‘Ada.Float_Text_IO’ '(A.10.9)'

     A library level instantiation of Text_IO.Float_IO for type Float.

‘Ada.Float_Wide_Text_IO’ '(A.10.9)'

     A library level instantiation of Wide_Text_IO.Float_IO for type
     Float.

‘Ada.Float_Wide_Wide_Text_IO’ '(A.10.9)'

     A library level instantiation of Wide_Wide_Text_IO.Float_IO for
     type Float.

‘Ada.Integer_Text_IO’ '(A.10.9)'

     A library level instantiation of Text_IO.Integer_IO for type
     Integer.

‘Ada.Integer_Wide_Text_IO’ '(A.10.9)'

     A library level instantiation of Wide_Text_IO.Integer_IO for type
     Integer.

‘Ada.Integer_Wide_Wide_Text_IO’ '(A.10.9)'

     A library level instantiation of Wide_Wide_Text_IO.Integer_IO for
     type Integer.

‘Ada.Interrupts’ '(C.3.2)'

     This package provides facilities for interfacing to interrupts,
     which includes the set of signals or conditions that can be raised
     and recognized as interrupts.

‘Ada.Interrupts.Names’ '(C.3.2)'

     This package provides the set of interrupt names (actually signal
     or condition names) that can be handled by GNAT.

‘Ada.IO_Exceptions’ '(A.13)'

     This package defines the set of exceptions that can be raised by
     use of the standard IO packages.

‘Ada.Iterator_Interfaces’ '(5.5.1)'

     This package provides a generic interface to generalized iterators.

‘Ada.Locales’ '(A.19)'

     This package provides declarations providing information (Language
     and Country) about the current locale.

‘Ada.Numerics’

     This package contains some standard constants and exceptions used
     throughout the numerics packages.  Note that the constants pi and e
     are defined here, and it is better to use these definitions than
     rolling your own.

‘Ada.Numerics.Complex_Arrays’ '(G.3.2)'

     Provides operations on arrays of complex numbers.

‘Ada.Numerics.Complex_Elementary_Functions’

     Provides the implementation of standard elementary functions (such
     as log and trigonometric functions) operating on complex numbers
     using the standard ‘Float’ and the ‘Complex’ and ‘Imaginary’ types
     created by the package ‘Numerics.Complex_Types’.

‘Ada.Numerics.Complex_Types’

     This is a predefined instantiation of
     ‘Numerics.Generic_Complex_Types’ using ‘Standard.Float’ to build
     the type ‘Complex’ and ‘Imaginary’.

‘Ada.Numerics.Discrete_Random’

     This generic package provides a random number generator suitable
     for generating uniformly distributed values of a specified discrete
     subtype.

‘Ada.Numerics.Float_Random’

     This package provides a random number generator suitable for
     generating uniformly distributed floating point values in the unit
     interval.

‘Ada.Numerics.Generic_Complex_Elementary_Functions’

     This is a generic version of the package that provides the
     implementation of standard elementary functions (such as log and
     trigonometric functions) for an arbitrary complex type.

     The following predefined instantiations of this package are
     provided:

        * ‘Short_Float’

          ‘Ada.Numerics.Short_Complex_Elementary_Functions’

        * ‘Float’

          ‘Ada.Numerics.Complex_Elementary_Functions’

        * ‘Long_Float’

          ‘Ada.Numerics.Long_Complex_Elementary_Functions’

‘Ada.Numerics.Generic_Complex_Types’

     This is a generic package that allows the creation of complex
     types, with associated complex arithmetic operations.

     The following predefined instantiations of this package exist

        * ‘Short_Float’

          ‘Ada.Numerics.Short_Complex_Complex_Types’

        * ‘Float’

          ‘Ada.Numerics.Complex_Complex_Types’

        * ‘Long_Float’

          ‘Ada.Numerics.Long_Complex_Complex_Types’

‘Ada.Numerics.Generic_Elementary_Functions’

     This is a generic package that provides the implementation of
     standard elementary functions (such as log an trigonometric
     functions) for an arbitrary float type.

     The following predefined instantiations of this package exist

        * ‘Short_Float’

          ‘Ada.Numerics.Short_Elementary_Functions’

        * ‘Float’

          ‘Ada.Numerics.Elementary_Functions’

        * ‘Long_Float’

          ‘Ada.Numerics.Long_Elementary_Functions’

‘Ada.Numerics.Generic_Real_Arrays’ '(G.3.1)'

     Generic operations on arrays of reals

‘Ada.Numerics.Real_Arrays’ '(G.3.1)'

     Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).

‘Ada.Real_Time’ '(D.8)'

     This package provides facilities similar to those of ‘Calendar’,
     but operating with a finer clock suitable for real time control.
     Note that annex D requires that there be no backward clock jumps,
     and GNAT generally guarantees this behavior, but of course if the
     external clock on which the GNAT runtime depends is deliberately
     reset by some external event, then such a backward jump may occur.

‘Ada.Real_Time.Timing_Events’ '(D.15)'

     Not implemented in GNAT.

‘Ada.Sequential_IO’ '(A.8.1)'

     This package provides input-output facilities for sequential files,
     which can contain a sequence of values of a single type, which can
     be any Ada type, including indefinite (unconstrained) types.

‘Ada.Storage_IO’ '(A.9)'

     This package provides a facility for mapping arbitrary Ada types to
     and from a storage buffer.  It is primarily intended for the
     creation of new IO packages.

‘Ada.Streams’ '(13.13.1)'

     This is a generic package that provides the basic support for the
     concept of streams as used by the stream attributes (‘Input’,
     ‘Output’, ‘Read’ and ‘Write’).

‘Ada.Streams.Stream_IO’ '(A.12.1)'

     This package is a specialization of the type ‘Streams’ defined in
     package ‘Streams’ together with a set of operations providing
     Stream_IO capability.  The Stream_IO model permits both random and
     sequential access to a file which can contain an arbitrary set of
     values of one or more Ada types.

‘Ada.Strings’ '(A.4.1)'

     This package provides some basic constants used by the string
     handling packages.

‘Ada.Strings.Bounded’ '(A.4.4)'

     This package provides facilities for handling variable length
     strings.  The bounded model requires a maximum length.  It is thus
     somewhat more limited than the unbounded model, but avoids the use
     of dynamic allocation or finalization.

‘Ada.Strings.Bounded.Equal_Case_Insensitive’ '(A.4.10)'

     Provides case-insensitive comparisons of bounded strings

‘Ada.Strings.Bounded.Hash’ '(A.4.9)'

     This package provides a generic hash function for bounded strings

‘Ada.Strings.Bounded.Hash_Case_Insensitive’ '(A.4.9)'

     This package provides a generic hash function for bounded strings
     that converts the string to be hashed to lower case.

‘Ada.Strings.Bounded.Less_Case_Insensitive’ '(A.4.10)'

     This package provides a comparison function for bounded strings
     that works in a case insensitive manner by converting to lower case
     before the comparison.

‘Ada.Strings.Fixed’ '(A.4.3)'

     This package provides facilities for handling fixed length strings.

‘Ada.Strings.Fixed.Equal_Case_Insensitive’ '(A.4.10)'

     This package provides an equality function for fixed strings that
     compares the strings after converting both to lower case.

‘Ada.Strings.Fixed.Hash_Case_Insensitive’ '(A.4.9)'

     This package provides a case insensitive hash function for fixed
     strings that converts the string to lower case before computing the
     hash.

‘Ada.Strings.Fixed.Less_Case_Insensitive’ '(A.4.10)'

     This package provides a comparison function for fixed strings that
     works in a case insensitive manner by converting to lower case
     before the comparison.

‘Ada.Strings.Hash’ '(A.4.9)'

     This package provides a hash function for strings.

‘Ada.Strings.Hash_Case_Insensitive’ '(A.4.9)'

     This package provides a hash function for strings that is case
     insensitive.  The string is converted to lower case before
     computing the hash.

‘Ada.Strings.Less_Case_Insensitive’ '(A.4.10)'

     This package provides a comparison function for\strings that works
     in a case insensitive manner by converting to lower case before the
     comparison.

‘Ada.Strings.Maps’ '(A.4.2)'

     This package provides facilities for handling character mappings
     and arbitrarily defined subsets of characters.  For instance it is
     useful in defining specialized translation tables.

‘Ada.Strings.Maps.Constants’ '(A.4.6)'

     This package provides a standard set of predefined mappings and
     predefined character sets.  For example, the standard upper to
     lower case conversion table is found in this package.  Note that
     upper to lower case conversion is non-trivial if you want to take
     the entire set of characters, including extended characters like E
     with an acute accent, into account.  You should use the mappings in
     this package (rather than adding 32 yourself) to do case mappings.

‘Ada.Strings.Unbounded’ '(A.4.5)'

     This package provides facilities for handling variable length
     strings.  The unbounded model allows arbitrary length strings, but
     requires the use of dynamic allocation and finalization.

‘Ada.Strings.Unbounded.Equal_Case_Insensitive’ '(A.4.10)'

     Provides case-insensitive comparisons of unbounded strings

‘Ada.Strings.Unbounded.Hash’ '(A.4.9)'

     This package provides a generic hash function for unbounded strings

‘Ada.Strings.Unbounded.Hash_Case_Insensitive’ '(A.4.9)'

     This package provides a generic hash function for unbounded strings
     that converts the string to be hashed to lower case.

‘Ada.Strings.Unbounded.Less_Case_Insensitive’ '(A.4.10)'

     This package provides a comparison function for unbounded strings
     that works in a case insensitive manner by converting to lower case
     before the comparison.

‘Ada.Strings.UTF_Encoding’ '(A.4.11)'

     This package provides basic definitions for dealing with
     UTF-encoded strings.

‘Ada.Strings.UTF_Encoding.Conversions’ '(A.4.11)'

     This package provides conversion functions for UTF-encoded strings.

‘Ada.Strings.UTF_Encoding.Strings’ '(A.4.11)'

‘Ada.Strings.UTF_Encoding.Wide_Strings’ '(A.4.11)'

‘Ada.Strings.UTF_Encoding.Wide_Wide_Strings’ '(A.4.11)'

     These packages provide facilities for handling UTF encodings for
     Strings, Wide_Strings and Wide_Wide_Strings.

‘Ada.Strings.Wide_Bounded’ '(A.4.7)'

‘Ada.Strings.Wide_Fixed’ '(A.4.7)'

‘Ada.Strings.Wide_Maps’ '(A.4.7)'

‘Ada.Strings.Wide_Unbounded’ '(A.4.7)'

     These packages provide analogous capabilities to the corresponding
     packages without ‘Wide_’ in the name, but operate with the types
     ‘Wide_String’ and ‘Wide_Character’ instead of ‘String’ and
     ‘Character’.  Versions of all the child packages are available.

‘Ada.Strings.Wide_Wide_Bounded’ '(A.4.7)'

‘Ada.Strings.Wide_Wide_Fixed’ '(A.4.7)'

‘Ada.Strings.Wide_Wide_Maps’ '(A.4.7)'

‘Ada.Strings.Wide_Wide_Unbounded’ '(A.4.7)'

     These packages provide analogous capabilities to the corresponding
     packages without ‘Wide_’ in the name, but operate with the types
     ‘Wide_Wide_String’ and ‘Wide_Wide_Character’ instead of ‘String’
     and ‘Character’.

‘Ada.Synchronous_Barriers’ '(D.10.1)'

     This package provides facilities for synchronizing tasks at a low
     level with barriers.

‘Ada.Synchronous_Task_Control’ '(D.10)'

     This package provides some standard facilities for controlling task
     communication in a synchronous manner.

‘Ada.Synchronous_Task_Control.EDF’ '(D.10)'

     Not implemented in GNAT.

‘Ada.Tags’

     This package contains definitions for manipulation of the tags of
     tagged values.

‘Ada.Tags.Generic_Dispatching_Constructor’ '(3.9)'

     This package provides a way of constructing tagged class-wide
     values given only the tag value.

‘Ada.Task_Attributes’ '(C.7.2)'

     This package provides the capability of associating arbitrary
     task-specific data with separate tasks.

‘Ada.Task_Identification’ '(C.7.1)'

     This package provides capabilities for task identification.

‘Ada.Task_Termination’ '(C.7.3)'

     This package provides control over task termination.

‘Ada.Text_IO’

     This package provides basic text input-output capabilities for
     character, string and numeric data.  The subpackages of this
     package are listed next.  Note that although these are defined as
     subpackages in the RM, they are actually transparently implemented
     as child packages in GNAT, meaning that they are only loaded if
     needed.

‘Ada.Text_IO.Decimal_IO’

     Provides input-output facilities for decimal fixed-point types

‘Ada.Text_IO.Enumeration_IO’

     Provides input-output facilities for enumeration types.

‘Ada.Text_IO.Fixed_IO’

     Provides input-output facilities for ordinary fixed-point types.

‘Ada.Text_IO.Float_IO’

     Provides input-output facilities for float types.  The following
     predefined instantiations of this generic package are available:

        * ‘Short_Float’

          ‘Short_Float_Text_IO’

        * ‘Float’

          ‘Float_Text_IO’

        * ‘Long_Float’

          ‘Long_Float_Text_IO’

‘Ada.Text_IO.Integer_IO’

     Provides input-output facilities for integer types.  The following
     predefined instantiations of this generic package are available:

        * ‘Short_Short_Integer’

          ‘Ada.Short_Short_Integer_Text_IO’

        * ‘Short_Integer’

          ‘Ada.Short_Integer_Text_IO’

        * ‘Integer’

          ‘Ada.Integer_Text_IO’

        * ‘Long_Integer’

          ‘Ada.Long_Integer_Text_IO’

        * ‘Long_Long_Integer’

          ‘Ada.Long_Long_Integer_Text_IO’

‘Ada.Text_IO.Modular_IO’

     Provides input-output facilities for modular (unsigned) types.

‘Ada.Text_IO.Bounded_IO (A.10.11)’

     Provides input-output facilities for bounded strings.

‘Ada.Text_IO.Complex_IO (G.1.3)’

     This package provides basic text input-output capabilities for
     complex data.

‘Ada.Text_IO.Editing (F.3.3)’

     This package contains routines for edited output, analogous to the
     use of pictures in COBOL. The picture formats used by this package
     are a close copy of the facility in COBOL.

‘Ada.Text_IO.Text_Streams (A.12.2)’

     This package provides a facility that allows Text_IO files to be
     treated as streams, so that the stream attributes can be used for
     writing arbitrary data, including binary data, to Text_IO files.

‘Ada.Text_IO.Unbounded_IO (A.10.12)’

     This package provides input-output facilities for unbounded
     strings.

‘Ada.Unchecked_Conversion (13.9)’

     This generic package allows arbitrary conversion from one type to
     another of the same size, providing for breaking the type safety in
     special circumstances.

     If the types have the same Size (more accurately the same
     Value_Size), then the effect is simply to transfer the bits from
     the source to the target type without any modification.  This usage
     is well defined, and for simple types whose representation is
     typically the same across all implementations, gives a portable
     method of performing such conversions.

     If the types do not have the same size, then the result is
     implementation defined, and thus may be non-portable.  The
     following describes how GNAT handles such unchecked conversion
     cases.

     If the types are of different sizes, and are both discrete types,
     then the effect is of a normal type conversion without any
     constraint checking.  In particular if the result type has a larger
     size, the result will be zero or sign extended.  If the result type
     has a smaller size, the result will be truncated by ignoring high
     order bits.

     If the types are of different sizes, and are not both discrete
     types, then the conversion works as though pointers were created to
     the source and target, and the pointer value is converted.  The
     effect is that bits are copied from successive low order storage
     units and bits of the source up to the length of the target type.

     A warning is issued if the lengths differ, since the effect in this
     case is implementation dependent, and the above behavior may not
     match that of some other compiler.

     A pointer to one type may be converted to a pointer to another type
     using unchecked conversion.  The only case in which the effect is
     undefined is when one or both pointers are pointers to
     unconstrained array types.  In this case, the bounds information
     may get incorrectly transferred, and in particular, GNAT uses
     double size pointers for such types, and it is meaningless to
     convert between such pointer types.  GNAT will issue a warning if
     the alignment of the target designated type is more strict than the
     alignment of the source designated type (since the result may be
     unaligned in this case).

     A pointer other than a pointer to an unconstrained array type may
     be converted to and from System.Address.  Such usage is common in
     Ada 83 programs, but note that Ada.Address_To_Access_Conversions is
     the preferred method of performing such conversions in Ada 95 and
     Ada 2005.  Neither unchecked conversion nor
     Ada.Address_To_Access_Conversions should be used in conjunction
     with pointers to unconstrained objects, since the bounds
     information cannot be handled correctly in this case.

‘Ada.Unchecked_Deallocation’ '(13.11.2)'

     This generic package allows explicit freeing of storage previously
     allocated by use of an allocator.

‘Ada.Wide_Text_IO’ '(A.11)'

     This package is similar to ‘Ada.Text_IO’, except that the external
     file supports wide character representations, and the internal
     types are ‘Wide_Character’ and ‘Wide_String’ instead of ‘Character’
     and ‘String’.  The corresponding set of nested packages and child
     packages are defined.

‘Ada.Wide_Wide_Text_IO’ '(A.11)'

     This package is similar to ‘Ada.Text_IO’, except that the external
     file supports wide character representations, and the internal
     types are ‘Wide_Character’ and ‘Wide_String’ instead of ‘Character’
     and ‘String’.  The corresponding set of nested packages and child
     packages are defined.

For packages in Interfaces and System, all the RM defined packages are
available in GNAT, see the Ada 2012 RM for full details.


File: gnat_rm.info,  Node: The Implementation of Standard I/O,  Next: The GNAT Library,  Prev: Standard Library Routines,  Up: Top

11 The Implementation of Standard I/O
*************************************

GNAT implements all the required input-output facilities described in
A.6 through A.14.  These sections of the Ada Reference Manual describe
the required behavior of these packages from the Ada point of view, and
if you are writing a portable Ada program that does not need to know the
exact manner in which Ada maps to the outside world when it comes to
reading or writing external files, then you do not need to read this
chapter.  As long as your files are all regular files (not pipes or
devices), and as long as you write and read the files only from Ada, the
description in the Ada Reference Manual is sufficient.

However, if you want to do input-output to pipes or other devices, such
as the keyboard or screen, or if the files you are dealing with are
either generated by some other language, or to be read by some other
language, then you need to know more about the details of how the GNAT
implementation of these input-output facilities behaves.

In this chapter we give a detailed description of exactly how GNAT
interfaces to the file system.  As always, the sources of the system are
available to you for answering questions at an even more detailed level,
but for most purposes the information in this chapter will suffice.

Another reason that you may need to know more about how input-output is
implemented arises when you have a program written in mixed languages
where, for example, files are shared between the C and Ada sections of
the same program.  GNAT provides some additional facilities, in the form
of additional child library packages, that facilitate this sharing, and
these additional facilities are also described in this chapter.

* Menu:

* Standard I/O Packages::
* FORM Strings::
* Direct_IO::
* Sequential_IO::
* Text_IO::
* Wide_Text_IO::
* Wide_Wide_Text_IO::
* Stream_IO::
* Text Translation::
* Shared Files::
* Filenames encoding::
* File content encoding::
* Open Modes::
* Operations on C Streams::
* Interfacing to C Streams::


File: gnat_rm.info,  Node: Standard I/O Packages,  Next: FORM Strings,  Up: The Implementation of Standard I/O

11.1 Standard I/O Packages
==========================

The Standard I/O packages described in Annex A for

   * Ada.Text_IO

   * Ada.Text_IO.Complex_IO

   * Ada.Text_IO.Text_Streams

   * Ada.Wide_Text_IO

   * Ada.Wide_Text_IO.Complex_IO

   * Ada.Wide_Text_IO.Text_Streams

   * Ada.Wide_Wide_Text_IO

   * Ada.Wide_Wide_Text_IO.Complex_IO

   * Ada.Wide_Wide_Text_IO.Text_Streams

   * Ada.Stream_IO

   * Ada.Sequential_IO

   * Ada.Direct_IO

are implemented using the C library streams facility; where

   * All files are opened using ‘fopen’.

   * All input/output operations use ‘fread’/‘fwrite’.

There is no internal buffering of any kind at the Ada library level.
The only buffering is that provided at the system level in the
implementation of the library routines that support streams.  This
facilitates shared use of these streams by mixed language programs.
Note though that system level buffering is explicitly enabled at
elaboration of the standard I/O packages and that can have an impact on
mixed language programs, in particular those using I/O before calling
the Ada elaboration routine (e.g., adainit).  It is recommended to call
the Ada elaboration routine before performing any I/O or when
impractical, flush the common I/O streams and in particular
Standard_Output before elaborating the Ada code.


File: gnat_rm.info,  Node: FORM Strings,  Next: Direct_IO,  Prev: Standard I/O Packages,  Up: The Implementation of Standard I/O

11.2 FORM Strings
=================

The format of a FORM string in GNAT is:

     "keyword=value,keyword=value,...,keyword=value"

where letters may be in upper or lower case, and there are no spaces
between values.  The order of the entries is not important.  Currently
the following keywords defined.

     TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
     SHARED=[YES|NO]
     WCEM=[n|h|u|s|e|8|b]
     ENCODING=[UTF8|8BITS]

The use of these parameters is described later in this section.  If an
unrecognized keyword appears in a form string, it is silently ignored
and not considered invalid.


File: gnat_rm.info,  Node: Direct_IO,  Next: Sequential_IO,  Prev: FORM Strings,  Up: The Implementation of Standard I/O

11.3 Direct_IO
==============

Direct_IO can only be instantiated for definite types.  This is a
restriction of the Ada language, which means that the records are fixed
length (the length being determined by ‘type'Size’, rounded up to the
next storage unit boundary if necessary).

The records of a Direct_IO file are simply written to the file in index
sequence, with the first record starting at offset zero, and subsequent
records following.  There is no control information of any kind.  For
example, if 32-bit integers are being written, each record takes
4-bytes, so the record at index ‘K’ starts at offset ‘(K-1)*4’.

There is no limit on the size of Direct_IO files, they are expanded as
necessary to accommodate whatever records are written to the file.


File: gnat_rm.info,  Node: Sequential_IO,  Next: Text_IO,  Prev: Direct_IO,  Up: The Implementation of Standard I/O

11.4 Sequential_IO
==================

Sequential_IO may be instantiated with either a definite (constrained)
or indefinite (unconstrained) type.

For the definite type case, the elements written to the file are simply
the memory images of the data values with no control information of any
kind.  The resulting file should be read using the same type, no
validity checking is performed on input.

For the indefinite type case, the elements written consist of two parts.
First is the size of the data item, written as the memory image of a
‘Interfaces.C.size_t’ value, followed by the memory image of the data
value.  The resulting file can only be read using the same
(unconstrained) type.  Normal assignment checks are performed on these
read operations, and if these checks fail, ‘Data_Error’ is raised.  In
particular, in the array case, the lengths must match, and in the
variant record case, if the variable for a particular read operation is
constrained, the discriminants must match.

Note that it is not possible to use Sequential_IO to write variable
length array items, and then read the data back into different length
arrays.  For example, the following will raise ‘Data_Error’:

     package IO is new Sequential_IO (String);
     F : IO.File_Type;
     S : String (1..4);
     ...
     IO.Create (F)
     IO.Write (F, "hello!")
     IO.Reset (F, Mode=>In_File);
     IO.Read (F, S);
     Put_Line (S);

On some Ada implementations, this will print ‘hell’, but the program is
clearly incorrect, since there is only one element in the file, and that
element is the string ‘hello!’.

In Ada 95 and Ada 2005, this kind of behavior can be legitimately
achieved using Stream_IO, and this is the preferred mechanism.  In
particular, the above program fragment rewritten to use Stream_IO will
work correctly.


File: gnat_rm.info,  Node: Text_IO,  Next: Wide_Text_IO,  Prev: Sequential_IO,  Up: The Implementation of Standard I/O

11.5 Text_IO
============

Text_IO files consist of a stream of characters containing the following
special control characters:

     LF (line feed, 16#0A#) Line Mark
     FF (form feed, 16#0C#) Page Mark

A canonical Text_IO file is defined as one in which the following
conditions are met:

   * The character ‘LF’ is used only as a line mark, i.e., to mark the
     end of the line.

   * The character ‘FF’ is used only as a page mark, i.e., to mark the
     end of a page and consequently can appear only immediately
     following a ‘LF’ (line mark) character.

   * The file ends with either ‘LF’ (line mark) or ‘LF’-‘FF’ (line mark,
     page mark).  In the former case, the page mark is implicitly
     assumed to be present.

A file written using Text_IO will be in canonical form provided that no
explicit ‘LF’ or ‘FF’ characters are written using ‘Put’ or ‘Put_Line’.
There will be no ‘FF’ character at the end of the file unless an
explicit ‘New_Page’ operation was performed before closing the file.

A canonical Text_IO file that is a regular file (i.e., not a device or a
pipe) can be read using any of the routines in Text_IO. The semantics in
this case will be exactly as defined in the Ada Reference Manual, and
all the routines in Text_IO are fully implemented.

A text file that does not meet the requirements for a canonical Text_IO
file has one of the following:

   * The file contains ‘FF’ characters not immediately following a ‘LF’
     character.

   * The file contains ‘LF’ or ‘FF’ characters written by ‘Put’ or
     ‘Put_Line’, which are not logically considered to be line marks or
     page marks.

   * The file ends in a character other than ‘LF’ or ‘FF’, i.e., there
     is no explicit line mark or page mark at the end of the file.

Text_IO can be used to read such non-standard text files but subprograms
to do with line or page numbers do not have defined meanings.  In
particular, a ‘FF’ character that does not follow a ‘LF’ character may
or may not be treated as a page mark from the point of view of page and
line numbering.  Every ‘LF’ character is considered to end a line, and
there is an implied ‘LF’ character at the end of the file.

* Menu:

* Stream Pointer Positioning::
* Reading and Writing Non-Regular Files::
* Get_Immediate::
* Treating Text_IO Files as Streams::
* Text_IO Extensions::
* Text_IO Facilities for Unbounded Strings::


File: gnat_rm.info,  Node: Stream Pointer Positioning,  Next: Reading and Writing Non-Regular Files,  Up: Text_IO

11.5.1 Stream Pointer Positioning
---------------------------------

‘Ada.Text_IO’ has a definition of current position for a file that is
being read.  No internal buffering occurs in Text_IO, and usually the
physical position in the stream used to implement the file corresponds
to this logical position defined by Text_IO. There are two exceptions:

   * After a call to ‘End_Of_Page’ that returns ‘True’, the stream is
     positioned past the ‘LF’ (line mark) that precedes the page mark.
     Text_IO maintains an internal flag so that subsequent read
     operations properly handle the logical position which is unchanged
     by the ‘End_Of_Page’ call.

   * After a call to ‘End_Of_File’ that returns ‘True’, if the Text_IO
     file was positioned before the line mark at the end of file before
     the call, then the logical position is unchanged, but the stream is
     physically positioned right at the end of file (past the line mark,
     and past a possible page mark following the line mark.  Again
     Text_IO maintains internal flags so that subsequent read operations
     properly handle the logical position.

These discrepancies have no effect on the observable behavior of
Text_IO, but if a single Ada stream is shared between a C program and
Ada program, or shared (using ‘shared=yes’ in the form string) between
two Ada files, then the difference may be observable in some situations.


File: gnat_rm.info,  Node: Reading and Writing Non-Regular Files,  Next: Get_Immediate,  Prev: Stream Pointer Positioning,  Up: Text_IO

11.5.2 Reading and Writing Non-Regular Files
--------------------------------------------

A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
can be used for reading and writing.  Writing is not affected and the
sequence of characters output is identical to the normal file case, but
for reading, the behavior of Text_IO is modified to avoid undesirable
look-ahead as follows:

An input file that is not a regular file is considered to have no page
marks.  Any ‘Ascii.FF’ characters (the character normally used for a
page mark) appearing in the file are considered to be data characters.
In particular:

   * ‘Get_Line’ and ‘Skip_Line’ do not test for a page mark following a
     line mark.  If a page mark appears, it will be treated as a data
     character.

   * This avoids the need to wait for an extra character to be typed or
     entered from the pipe to complete one of these operations.

   * ‘End_Of_Page’ always returns ‘False’

   * ‘End_Of_File’ will return ‘False’ if there is a page mark at the
     end of the file.

Output to non-regular files is the same as for regular files.  Page
marks may be written to non-regular files using ‘New_Page’, but as noted
above they will not be treated as page marks on input if the output is
piped to another Ada program.

Another important discrepancy when reading non-regular files is that the
end of file indication is not ‘sticky’.  If an end of file is entered,
e.g., by pressing the ‘EOT’ key, then end of file is signaled once
(i.e., the test ‘End_Of_File’ will yield ‘True’, or a read will raise
‘End_Error’), but then reading can resume to read data past that end of
file indication, until another end of file indication is entered.


File: gnat_rm.info,  Node: Get_Immediate,  Next: Treating Text_IO Files as Streams,  Prev: Reading and Writing Non-Regular Files,  Up: Text_IO

11.5.3 Get_Immediate
--------------------

Get_Immediate returns the next character (including control characters)
from the input file.  In particular, Get_Immediate will return LF or FF
characters used as line marks or page marks.  Such operations leave the
file positioned past the control character, and it is thus not treated
as having its normal function.  This means that page, line and column
counts after this kind of Get_Immediate call are set as though the mark
did not occur.  In the case where a Get_Immediate leaves the file
positioned between the line mark and page mark (which is not normally
possible), it is undefined whether the FF character will be treated as a
page mark.


File: gnat_rm.info,  Node: Treating Text_IO Files as Streams,  Next: Text_IO Extensions,  Prev: Get_Immediate,  Up: Text_IO

11.5.4 Treating Text_IO Files as Streams
----------------------------------------

The package ‘Text_IO.Streams’ allows a ‘Text_IO’ file to be treated as a
stream.  Data written to a ‘Text_IO’ file in this stream mode is binary
data.  If this binary data contains bytes 16#0A# (‘LF’) or 16#0C#
(‘FF’), the resulting file may have non-standard format.  Similarly if
read operations are used to read from a Text_IO file treated as a
stream, then ‘LF’ and ‘FF’ characters may be skipped and the effect is
similar to that described above for ‘Get_Immediate’.


File: gnat_rm.info,  Node: Text_IO Extensions,  Next: Text_IO Facilities for Unbounded Strings,  Prev: Treating Text_IO Files as Streams,  Up: Text_IO

11.5.5 Text_IO Extensions
-------------------------

A package GNAT.IO_Aux in the GNAT library provides some useful
extensions to the standard ‘Text_IO’ package:

   * function File_Exists (Name : String) return Boolean; Determines if
     a file of the given name exists.

   * function Get_Line return String; Reads a string from the standard
     input file.  The value returned is exactly the length of the line
     that was read.

   * function Get_Line (File : Ada.Text_IO.File_Type) return String;
     Similar, except that the parameter File specifies the file from
     which the string is to be read.


File: gnat_rm.info,  Node: Text_IO Facilities for Unbounded Strings,  Prev: Text_IO Extensions,  Up: Text_IO

11.5.6 Text_IO Facilities for Unbounded Strings
-----------------------------------------------

The package ‘Ada.Strings.Unbounded.Text_IO’ in library files
‘a-suteio.ads/adb’ contains some GNAT-specific subprograms useful for
Text_IO operations on unbounded strings:

   * function Get_Line (File : File_Type) return Unbounded_String; Reads
     a line from the specified file and returns the result as an
     unbounded string.

   * procedure Put (File : File_Type; U : Unbounded_String); Writes the
     value of the given unbounded string to the specified file Similar
     to the effect of ‘Put (To_String (U))’ except that an extra copy is
     avoided.

   * procedure Put_Line (File : File_Type; U : Unbounded_String); Writes
     the value of the given unbounded string to the specified file,
     followed by a ‘New_Line’.  Similar to the effect of ‘Put_Line
     (To_String (U))’ except that an extra copy is avoided.

In the above procedures, ‘File’ is of type ‘Ada.Text_IO.File_Type’ and
is optional.  If the parameter is omitted, then the standard input or
output file is referenced as appropriate.

The package ‘Ada.Strings.Wide_Unbounded.Wide_Text_IO’ in library files
‘a-swuwti.ads’ and ‘a-swuwti.adb’ provides similar extended
‘Wide_Text_IO’ functionality for unbounded wide strings.

The package ‘Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO’ in
library files ‘a-szuzti.ads’ and ‘a-szuzti.adb’ provides similar
extended ‘Wide_Wide_Text_IO’ functionality for unbounded wide wide
strings.


File: gnat_rm.info,  Node: Wide_Text_IO,  Next: Wide_Wide_Text_IO,  Prev: Text_IO,  Up: The Implementation of Standard I/O

11.6 Wide_Text_IO
=================

‘Wide_Text_IO’ is similar in most respects to Text_IO, except that both
input and output files may contain special sequences that represent wide
character values.  The encoding scheme for a given file may be specified
using a FORM parameter:

     WCEM=`x`

as part of the FORM string (WCEM = wide character encoding method),
where ‘x’ is one of the following characters

Character      Encoding
               
----------------------------------------
               
'h'            Hex ESC encoding
               
               
'u'            Upper half encoding
               
               
's'            Shift-JIS encoding
               
               
'e'            EUC Encoding
               
               
'8'            UTF-8 encoding
               
               
'b'            Brackets encoding
               

The encoding methods match those that can be used in a source program,
but there is no requirement that the encoding method used for the source
program be the same as the encoding method used for files, and different
files may use different encoding methods.

The default encoding method for the standard files, and for opened files
for which no WCEM parameter is given in the FORM string matches the wide
character encoding specified for the main program (the default being
brackets encoding if no coding method was specified with -gnatW).

'Hex Coding'

     In this encoding, a wide character is represented by a five
     character sequence:

     ESC a b c d

     where ‘a’, ‘b’, ‘c’, ‘d’ are the four hexadecimal characters (using
     upper case letters) of the wide character code.  For example, ESC
     A345 is used to represent the wide character with code 16#A345#.
     This scheme is compatible with use of the full ‘Wide_Character’
     set.

'Upper Half Coding'

     The wide character with encoding 16#abcd#, where the upper bit is
     on (i.e., a is in the range 8-F) is represented as two bytes 16#ab#
     and 16#cd#.  The second byte may never be a format control
     character, but is not required to be in the upper half.  This
     method can be also used for shift-JIS or EUC where the internal
     coding matches the external coding.

'Shift JIS Coding'

     A wide character is represented by a two character sequence 16#ab#
     and 16#cd#, with the restrictions described for upper half encoding
     as described above.  The internal character code is the
     corresponding JIS character according to the standard algorithm for
     Shift-JIS conversion.  Only characters defined in the JIS code set
     table can be used with this encoding method.

'EUC Coding'

     A wide character is represented by a two character sequence 16#ab#
     and 16#cd#, with both characters being in the upper half.  The
     internal character code is the corresponding JIS character
     according to the EUC encoding algorithm.  Only characters defined
     in the JIS code set table can be used with this encoding method.

'UTF-8 Coding'

     A wide character is represented using UCS Transformation Format 8
     (UTF-8) as defined in Annex R of ISO 10646-1/Am.2.  Depending on
     the character value, the representation is a one, two, or three
     byte sequence:

     16#0000#-16#007f#: 2#0xxxxxxx#
     16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
     16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#

     where the ‘xxx’ bits correspond to the left-padded bits of the
     16-bit character value.  Note that all lower half ASCII characters
     are represented as ASCII bytes and all upper half characters and
     other wide characters are represented as sequences of upper-half
     (The full UTF-8 scheme allows for encoding 31-bit characters as
     6-byte sequences, but in this implementation, all UTF-8 sequences
     of four or more bytes length will raise a Constraint_Error, as will
     all invalid UTF-8 sequences.)

'Brackets Coding'

     In this encoding, a wide character is represented by the following
     eight character sequence:

     [ " a b c d " ]

     where ‘a’, ‘b’, ‘c’, ‘d’ are the four hexadecimal characters (using
     uppercase letters) of the wide character code.  For example,
     ‘["A345"]’ is used to represent the wide character with code
     ‘16#A345#’.  This scheme is compatible with use of the full
     Wide_Character set.  On input, brackets coding can also be used for
     upper half characters, e.g., ‘["C1"]’ for lower case a.  However,
     on output, brackets notation is only used for wide characters with
     a code greater than ‘16#FF#’.

     Note that brackets coding is not normally used in the context of
     Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed
     as a portable way of encoding source files.  In the context of
     Wide_Text_IO or Wide_Wide_Text_IO, it can only be used if the file
     does not contain any instance of the left bracket character other
     than to encode wide character values using the brackets encoding
     method.  In practice it is expected that some standard wide
     character encoding method such as UTF-8 will be used for text input
     output.

     If brackets notation is used, then any occurrence of a left bracket
     in the input file which is not the start of a valid wide character
     sequence will cause Constraint_Error to be raised.  It is possible
     to encode a left bracket as [“5B”] and Wide_Text_IO and
     Wide_Wide_Text_IO input will interpret this as a left bracket.

     However, when a left bracket is output, it will be output as a left
     bracket and not as [“5B”].  We make this decision because for
     normal use of Wide_Text_IO for outputting messages, it is
     unpleasant to clobber left brackets.  For example, if we write:

          Put_Line ("Start of output [first run]");

     we really do not want to have the left bracket in this message
     clobbered so that the output reads:

     Start of output ["5B"]first run]

     In practice brackets encoding is reasonably useful for normal
     Put_Line use since we won’t get confused between left brackets and
     wide character sequences in the output.  But for input, or when
     files are written out and read back in, it really makes better
     sense to use one of the standard encoding methods such as UTF-8.

For the coding schemes other than UTF-8, Hex, or Brackets encoding, not
all wide character values can be represented.  An attempt to output a
character that cannot be represented using the encoding scheme for the
file causes Constraint_Error to be raised.  An invalid wide character
sequence on input also causes Constraint_Error to be raised.

* Menu:

* Stream Pointer Positioning: Stream Pointer Positioning<2>.
* Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>.


File: gnat_rm.info,  Node: Stream Pointer Positioning<2>,  Next: Reading and Writing Non-Regular Files<2>,  Up: Wide_Text_IO

11.6.1 Stream Pointer Positioning
---------------------------------

‘Ada.Wide_Text_IO’ is similar to ‘Ada.Text_IO’ in its handling of stream
pointer positioning (*note Text_IO: 2bb.).  There is one additional
case:

If ‘Ada.Wide_Text_IO.Look_Ahead’ reads a character outside the normal
lower ASCII set, i.e.  a character in the range:

     Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)

then although the logical position of the file pointer is unchanged by
the ‘Look_Ahead’ call, the stream is physically positioned past the wide
character sequence.  Again this is to avoid the need for buffering or
backup, and all ‘Wide_Text_IO’ routines check the internal indication
that this situation has occurred so that this is not visible to a normal
program using ‘Wide_Text_IO’.  However, this discrepancy can be observed
if the wide text file shares a stream with another file.


File: gnat_rm.info,  Node: Reading and Writing Non-Regular Files<2>,  Prev: Stream Pointer Positioning<2>,  Up: Wide_Text_IO

11.6.2 Reading and Writing Non-Regular Files
--------------------------------------------

As in the case of Text_IO, when a non-regular file is read, it is
assumed that the file contains no page marks (any form characters are
treated as data characters), and ‘End_Of_Page’ always returns ‘False’.
Similarly, the end of file indication is not sticky, so it is possible
to read beyond an end of file.


File: gnat_rm.info,  Node: Wide_Wide_Text_IO,  Next: Stream_IO,  Prev: Wide_Text_IO,  Up: The Implementation of Standard I/O

11.7 Wide_Wide_Text_IO
======================

‘Wide_Wide_Text_IO’ is similar in most respects to Text_IO, except that
both input and output files may contain special sequences that represent
wide wide character values.  The encoding scheme for a given file may be
specified using a FORM parameter:

     WCEM=`x`

as part of the FORM string (WCEM = wide character encoding method),
where ‘x’ is one of the following characters

Character      Encoding
               
----------------------------------------
               
'h'            Hex ESC encoding
               
               
'u'            Upper half encoding
               
               
's'            Shift-JIS encoding
               
               
'e'            EUC Encoding
               
               
'8'            UTF-8 encoding
               
               
'b'            Brackets encoding
               

The encoding methods match those that can be used in a source program,
but there is no requirement that the encoding method used for the source
program be the same as the encoding method used for files, and different
files may use different encoding methods.

The default encoding method for the standard files, and for opened files
for which no WCEM parameter is given in the FORM string matches the wide
character encoding specified for the main program (the default being
brackets encoding if no coding method was specified with -gnatW).

'UTF-8 Coding'

     A wide character is represented using UCS Transformation Format 8
     (UTF-8) as defined in Annex R of ISO 10646-1/Am.2.  Depending on
     the character value, the representation is a one, two, three, or
     four byte sequence:

     16#000000#-16#00007f#: 2#0xxxxxxx#
     16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
     16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
     16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#

     where the ‘xxx’ bits correspond to the left-padded bits of the
     21-bit character value.  Note that all lower half ASCII characters
     are represented as ASCII bytes and all upper half characters and
     other wide characters are represented as sequences of upper-half
     characters.

'Brackets Coding'

     In this encoding, a wide wide character is represented by the
     following eight character sequence if is in wide character range

     [ " a b c d " ]

     and by the following ten character sequence if not

     [ " a b c d e f " ]

     where ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, and ‘f’ are the four or six
     hexadecimal characters (using uppercase letters) of the wide wide
     character code.  For example, ‘["01A345"]’ is used to represent the
     wide wide character with code ‘16#01A345#’.

     This scheme is compatible with use of the full Wide_Wide_Character
     set.  On input, brackets coding can also be used for upper half
     characters, e.g., ‘["C1"]’ for lower case a.  However, on output,
     brackets notation is only used for wide characters with a code
     greater than ‘16#FF#’.

If is also possible to use the other Wide_Character encoding methods,
such as Shift-JIS, but the other schemes cannot support the full range
of wide wide characters.  An attempt to output a character that cannot
be represented using the encoding scheme for the file causes
Constraint_Error to be raised.  An invalid wide character sequence on
input also causes Constraint_Error to be raised.

* Menu:

* Stream Pointer Positioning: Stream Pointer Positioning<3>.
* Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>.


File: gnat_rm.info,  Node: Stream Pointer Positioning<3>,  Next: Reading and Writing Non-Regular Files<3>,  Up: Wide_Wide_Text_IO

11.7.1 Stream Pointer Positioning
---------------------------------

‘Ada.Wide_Wide_Text_IO’ is similar to ‘Ada.Text_IO’ in its handling of
stream pointer positioning (*note Text_IO: 2bb.).  There is one
additional case:

If ‘Ada.Wide_Wide_Text_IO.Look_Ahead’ reads a character outside the
normal lower ASCII set, i.e.  a character in the range:

     Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)

then although the logical position of the file pointer is unchanged by
the ‘Look_Ahead’ call, the stream is physically positioned past the wide
character sequence.  Again this is to avoid the need for buffering or
backup, and all ‘Wide_Wide_Text_IO’ routines check the internal
indication that this situation has occurred so that this is not visible
to a normal program using ‘Wide_Wide_Text_IO’.  However, this
discrepancy can be observed if the wide text file shares a stream with
another file.


File: gnat_rm.info,  Node: Reading and Writing Non-Regular Files<3>,  Prev: Stream Pointer Positioning<3>,  Up: Wide_Wide_Text_IO

11.7.2 Reading and Writing Non-Regular Files
--------------------------------------------

As in the case of Text_IO, when a non-regular file is read, it is
assumed that the file contains no page marks (any form characters are
treated as data characters), and ‘End_Of_Page’ always returns ‘False’.
Similarly, the end of file indication is not sticky, so it is possible
to read beyond an end of file.


File: gnat_rm.info,  Node: Stream_IO,  Next: Text Translation,  Prev: Wide_Wide_Text_IO,  Up: The Implementation of Standard I/O

11.8 Stream_IO
==============

A stream file is a sequence of bytes, where individual elements are
written to the file as described in the Ada Reference Manual.  The type
‘Stream_Element’ is simply a byte.  There are two ways to read or write
a stream file.

   * The operations ‘Read’ and ‘Write’ directly read or write a sequence
     of stream elements with no control information.

   * The stream attributes applied to a stream file transfer data in the
     manner described for stream attributes.


File: gnat_rm.info,  Node: Text Translation,  Next: Shared Files,  Prev: Stream_IO,  Up: The Implementation of Standard I/O

11.9 Text Translation
=====================

‘Text_Translation=xxx’ may be used as the Form parameter passed to
Text_IO.Create and Text_IO.Open.  ‘Text_Translation=xxx’ has no effect
on Unix systems.  Possible values are:

   * ‘Yes’ or ‘Text’ is the default, which means to translate LF to/from
     CR/LF on Windows systems.

     ‘No’ disables this translation; i.e.  it uses binary mode.  For
     output files, ‘Text_Translation=No’ may be used to create
     Unix-style files on Windows.

   * ‘wtext’ translation enabled in Unicode mode.  (corresponds to
     _O_WTEXT).

   * ‘u8text’ translation enabled in Unicode UTF-8 mode.  (corresponds
     to O_U8TEXT).

   * ‘u16text’ translation enabled in Unicode UTF-16 mode.  (corresponds
     to_O_U16TEXT).


File: gnat_rm.info,  Node: Shared Files,  Next: Filenames encoding,  Prev: Text Translation,  Up: The Implementation of Standard I/O

11.10 Shared Files
==================

Section A.14 of the Ada Reference Manual allows implementations to
provide a wide variety of behavior if an attempt is made to access the
same external file with two or more internal files.

To provide a full range of functionality, while at the same time
minimizing the problems of portability caused by this implementation
dependence, GNAT handles file sharing as follows:

   * In the absence of a ‘shared=xxx’ form parameter, an attempt to open
     two or more files with the same full name is considered an error
     and is not supported.  The exception ‘Use_Error’ will be raised.
     Note that a file that is not explicitly closed by the program
     remains open until the program terminates.

   * If the form parameter ‘shared=no’ appears in the form string, the
     file can be opened or created with its own separate stream
     identifier, regardless of whether other files sharing the same
     external file are opened.  The exact effect depends on how the C
     stream routines handle multiple accesses to the same external files
     using separate streams.

   * If the form parameter ‘shared=yes’ appears in the form string for
     each of two or more files opened using the same full name, the same
     stream is shared between these files, and the semantics are as
     described in Ada Reference Manual, Section A.14.

When a program that opens multiple files with the same name is ported
from another Ada compiler to GNAT, the effect will be that ‘Use_Error’
is raised.

The documentation of the original compiler and the documentation of the
program should then be examined to determine if file sharing was
expected, and ‘shared=xxx’ parameters added to ‘Open’ and ‘Create’ calls
as required.

When a program is ported from GNAT to some other Ada compiler, no
special attention is required unless the ‘shared=xxx’ form parameter is
used in the program.  In this case, you must examine the documentation
of the new compiler to see if it supports the required file sharing
semantics, and form strings modified appropriately.  Of course it may be
the case that the program cannot be ported if the target compiler does
not support the required functionality.  The best approach in writing
portable code is to avoid file sharing (and hence the use of the
‘shared=xxx’ parameter in the form string) completely.

One common use of file sharing in Ada 83 is the use of instantiations of
Sequential_IO on the same file with different types, to achieve
heterogeneous input-output.  Although this approach will work in GNAT if
‘shared=yes’ is specified, it is preferable in Ada to use Stream_IO for
this purpose (using the stream attributes)


File: gnat_rm.info,  Node: Filenames encoding,  Next: File content encoding,  Prev: Shared Files,  Up: The Implementation of Standard I/O

11.11 Filenames encoding
========================

An encoding form parameter can be used to specify the filename encoding
‘encoding=xxx’.

   * If the form parameter ‘encoding=utf8’ appears in the form string,
     the filename must be encoded in UTF-8.

   * If the form parameter ‘encoding=8bits’ appears in the form string,
     the filename must be a standard 8bits string.

In the absence of a ‘encoding=xxx’ form parameter, the encoding is
controlled by the ‘GNAT_CODE_PAGE’ environment variable.  And if not set
‘utf8’ is assumed.

'CP_ACP'

     The current system Windows ANSI code page.

'CP_UTF8'

     UTF-8 encoding

This encoding form parameter is only supported on the Windows platform.
On the other Operating Systems the run-time is supporting UTF-8
natively.


File: gnat_rm.info,  Node: File content encoding,  Next: Open Modes,  Prev: Filenames encoding,  Up: The Implementation of Standard I/O

11.12 File content encoding
===========================

For text files it is possible to specify the encoding to use.  This is
controlled by the by the ‘GNAT_CCS_ENCODING’ environment variable.  And
if not set ‘TEXT’ is assumed.

The possible values are those supported on Windows:

'TEXT'

     Translated text mode

'WTEXT'

     Translated unicode encoding

'U16TEXT'

     Unicode 16-bit encoding

'U8TEXT'

     Unicode 8-bit encoding

This encoding is only supported on the Windows platform.


File: gnat_rm.info,  Node: Open Modes,  Next: Operations on C Streams,  Prev: File content encoding,  Up: The Implementation of Standard I/O

11.13 Open Modes
================

‘Open’ and ‘Create’ calls result in a call to ‘fopen’ using the mode
shown in the following table:

‘Open’ and ‘Create’ Call Modes

----------------------------------------------------------------------------
                                                     
                                 'OPEN'              'CREATE'
                                                     
                                                     
Append_File                      “r+”                “w+”
                                                     
                                                     
In_File                          “r”                 “w+”
                                                     
                                                     
Out_File (Direct_IO)             “r+”                “w”
                                                     
                                                     
Out_File (all other cases)       “w”                 “w”
                                                     
                                                     
Inout_File                       “r+”                “w+”
                                                     

If text file translation is required, then either ‘b’ or ‘t’ is added to
the mode, depending on the setting of Text.  Text file translation
refers to the mapping of CR/LF sequences in an external file to LF
characters internally.  This mapping only occurs in DOS and DOS-like
systems, and is not relevant to other systems.

A special case occurs with Stream_IO. As shown in the above table, the
file is initially opened in ‘r’ or ‘w’ mode for the ‘In_File’ and
‘Out_File’ cases.  If a ‘Set_Mode’ operation subsequently requires
switching from reading to writing or vice-versa, then the file is
reopened in ‘r+’ mode to permit the required operation.


File: gnat_rm.info,  Node: Operations on C Streams,  Next: Interfacing to C Streams,  Prev: Open Modes,  Up: The Implementation of Standard I/O

11.14 Operations on C Streams
=============================

The package ‘Interfaces.C_Streams’ provides an Ada program with direct
access to the C library functions for operations on C streams:

     package Interfaces.C_Streams is
       -- Note: the reason we do not use the types that are in
       -- Interfaces.C is that we want to avoid dragging in the
       -- code in this unit if possible.
       subtype chars is System.Address;
       -- Pointer to null-terminated array of characters
       subtype FILEs is System.Address;
       -- Corresponds to the C type FILE*
       subtype voids is System.Address;
       -- Corresponds to the C type void*
       subtype int is Integer;
       subtype long is Long_Integer;
       -- Note: the above types are subtypes deliberately, and it
       -- is part of this spec that the above correspondences are
       -- guaranteed.  This means that it is legitimate to, for
       -- example, use Integer instead of int.  We provide these
       -- synonyms for clarity, but in some cases it may be
       -- convenient to use the underlying types (for example to
       -- avoid an unnecessary dependency of a spec on the spec
       -- of this unit).
       type size_t is mod 2 ** Standard'Address_Size;
       NULL_Stream : constant FILEs;
       -- Value returned (NULL in C) to indicate an
       -- fdopen/fopen/tmpfile error
       ----------------------------------
       -- Constants Defined in stdio.h --
       ----------------------------------
       EOF : constant int;
       -- Used by a number of routines to indicate error or
       -- end of file
       IOFBF : constant int;
       IOLBF : constant int;
       IONBF : constant int;
       -- Used to indicate buffering mode for setvbuf call
       SEEK_CUR : constant int;
       SEEK_END : constant int;
       SEEK_SET : constant int;
       -- Used to indicate origin for fseek call
       function stdin return FILEs;
       function stdout return FILEs;
       function stderr return FILEs;
       -- Streams associated with standard files
       --------------------------
       -- Standard C functions --
       --------------------------
       -- The functions selected below are ones that are
       -- available in UNIX (but not necessarily in ANSI C).
       -- These are very thin interfaces
       -- which copy exactly the C headers.  For more
       -- documentation on these functions, see the Microsoft C
       -- "Run-Time Library Reference" (Microsoft Press, 1990,
       -- ISBN 1-55615-225-6), which includes useful information
       -- on system compatibility.
       procedure clearerr (stream : FILEs);
       function fclose (stream : FILEs) return int;
       function fdopen (handle : int; mode : chars) return FILEs;
       function feof (stream : FILEs) return int;
       function ferror (stream : FILEs) return int;
       function fflush (stream : FILEs) return int;
       function fgetc (stream : FILEs) return int;
       function fgets (strng : chars; n : int; stream : FILEs)
           return chars;
       function fileno (stream : FILEs) return int;
       function fopen (filename : chars; Mode : chars)
           return FILEs;
       -- Note: to maintain target independence, use
       -- text_translation_required, a boolean variable defined in
       -- a-sysdep.c to deal with the target dependent text
       -- translation requirement.  If this variable is set,
       -- then  b/t should be appended to the standard mode
       -- argument to set the text translation mode off or on
       -- as required.
       function fputc (C : int; stream : FILEs) return int;
       function fputs (Strng : chars; Stream : FILEs) return int;
       function fread
          (buffer : voids;
           size : size_t;
           count : size_t;
           stream : FILEs)
           return size_t;
       function freopen
          (filename : chars;
           mode : chars;
           stream : FILEs)
           return FILEs;
       function fseek
          (stream : FILEs;
           offset : long;
           origin : int)
           return int;
       function ftell (stream : FILEs) return long;
       function fwrite
          (buffer : voids;
           size : size_t;
           count : size_t;
           stream : FILEs)
           return size_t;
       function isatty (handle : int) return int;
       procedure mktemp (template : chars);
       -- The return value (which is just a pointer to template)
       -- is discarded
       procedure rewind (stream : FILEs);
       function rmtmp return int;
       function setvbuf
          (stream : FILEs;
           buffer : chars;
           mode : int;
           size : size_t)
           return int;

       function tmpfile return FILEs;
       function ungetc (c : int; stream : FILEs) return int;
       function unlink (filename : chars) return int;
       ---------------------
       -- Extra functions --
       ---------------------
       -- These functions supply slightly thicker bindings than
       -- those above.  They are derived from functions in the
       -- C Run-Time Library, but may do a bit more work than
       -- just directly calling one of the Library functions.
       function is_regular_file (handle : int) return int;
       -- Tests if given handle is for a regular file (result 1)
       -- or for a non-regular file (pipe or device, result 0).
       ---------------------------------
       -- Control of Text/Binary Mode --
       ---------------------------------
       -- If text_translation_required is true, then the following
       -- functions may be used to dynamically switch a file from
       -- binary to text mode or vice versa.  These functions have
       -- no effect if text_translation_required is false (i.e., in
       -- normal UNIX mode).  Use fileno to get a stream handle.
       procedure set_binary_mode (handle : int);
       procedure set_text_mode (handle : int);
       ----------------------------
       -- Full Path Name support --
       ----------------------------
       procedure full_name (nam : chars; buffer : chars);
       -- Given a NUL terminated string representing a file
       -- name, returns in buffer a NUL terminated string
       -- representing the full path name for the file name.
       -- On systems where it is relevant the   drive is also
       -- part of the full path name.  It is the responsibility
       -- of the caller to pass an actual parameter for buffer
       -- that is big enough for any full path name.  Use
       -- max_path_len given below as the size of buffer.
       max_path_len : integer;
       -- Maximum length of an allowable full path name on the
       -- system, including a terminating NUL character.
     end Interfaces.C_Streams;


File: gnat_rm.info,  Node: Interfacing to C Streams,  Prev: Operations on C Streams,  Up: The Implementation of Standard I/O

11.15 Interfacing to C Streams
==============================

The packages in this section permit interfacing Ada files to C Stream
operations.

     with Interfaces.C_Streams;
     package Ada.Sequential_IO.C_Streams is
        function C_Stream (F : File_Type)
           return Interfaces.C_Streams.FILEs;
        procedure Open
          (File : in out File_Type;
           Mode : in File_Mode;
           C_Stream : in Interfaces.C_Streams.FILEs;
           Form : in String := "");
     end Ada.Sequential_IO.C_Streams;

      with Interfaces.C_Streams;
      package Ada.Direct_IO.C_Streams is
         function C_Stream (F : File_Type)
            return Interfaces.C_Streams.FILEs;
         procedure Open
           (File : in out File_Type;
            Mode : in File_Mode;
            C_Stream : in Interfaces.C_Streams.FILEs;
            Form : in String := "");
      end Ada.Direct_IO.C_Streams;

      with Interfaces.C_Streams;
      package Ada.Text_IO.C_Streams is
         function C_Stream (F : File_Type)
            return Interfaces.C_Streams.FILEs;
         procedure Open
           (File : in out File_Type;
            Mode : in File_Mode;
            C_Stream : in Interfaces.C_Streams.FILEs;
            Form : in String := "");
      end Ada.Text_IO.C_Streams;

      with Interfaces.C_Streams;
      package Ada.Wide_Text_IO.C_Streams is
         function C_Stream (F : File_Type)
            return Interfaces.C_Streams.FILEs;
         procedure Open
           (File : in out File_Type;
            Mode : in File_Mode;
            C_Stream : in Interfaces.C_Streams.FILEs;
            Form : in String := "");
     end Ada.Wide_Text_IO.C_Streams;

      with Interfaces.C_Streams;
      package Ada.Wide_Wide_Text_IO.C_Streams is
         function C_Stream (F : File_Type)
            return Interfaces.C_Streams.FILEs;
         procedure Open
           (File : in out File_Type;
            Mode : in File_Mode;
            C_Stream : in Interfaces.C_Streams.FILEs;
            Form : in String := "");
     end Ada.Wide_Wide_Text_IO.C_Streams;

     with Interfaces.C_Streams;
     package Ada.Stream_IO.C_Streams is
        function C_Stream (F : File_Type)
           return Interfaces.C_Streams.FILEs;
        procedure Open
          (File : in out File_Type;
           Mode : in File_Mode;
           C_Stream : in Interfaces.C_Streams.FILEs;
           Form : in String := "");
     end Ada.Stream_IO.C_Streams;

In each of these six packages, the ‘C_Stream’ function obtains the
‘FILE’ pointer from a currently opened Ada file.  It is then possible to
use the ‘Interfaces.C_Streams’ package to operate on this stream, or the
stream can be passed to a C program which can operate on it directly.
Of course the program is responsible for ensuring that only appropriate
sequences of operations are executed.

One particular use of relevance to an Ada program is that the ‘setvbuf’
function can be used to control the buffering of the stream used by an
Ada file.  In the absence of such a call the standard default buffering
is used.

The ‘Open’ procedures in these packages open a file giving an existing C
Stream instead of a file name.  Typically this stream is imported from a
C program, allowing an Ada file to operate on an existing C file.


File: gnat_rm.info,  Node: The GNAT Library,  Next: Interfacing to Other Languages,  Prev: The Implementation of Standard I/O,  Up: Top

12 The GNAT Library
*******************

The GNAT library contains a number of general and special purpose
packages.  It represents functionality that the GNAT developers have
found useful, and which is made available to GNAT users.  The packages
described here are fully supported, and upwards compatibility will be
maintained in future releases, so you can use these facilities with the
confidence that the same functionality will be available in future
releases.

The chapter here simply gives a brief summary of the facilities
available.  The full documentation is found in the spec file for the
package.  The full sources of these library packages, including both
spec and body, are provided with all GNAT releases.  For example, to
find out the full specifications of the SPITBOL pattern matching
capability, including a full tutorial and extensive examples, look in
the ‘g-spipat.ads’ file in the library.

For each entry here, the package name (as it would appear in a ‘with’
clause) is given, followed by the name of the corresponding spec file in
parentheses.  The packages are children in four hierarchies, ‘Ada’,
‘Interfaces’, ‘System’, and ‘GNAT’, the latter being a GNAT-specific
hierarchy.

Note that an application program should only use packages in one of
these four hierarchies if the package is defined in the Ada Reference
Manual, or is listed in this section of the GNAT Programmers Reference
Manual.  All other units should be considered internal implementation
units and should not be directly ‘with’ed by application code.  The use
of a ‘with’ clause that references one of these internal implementation
units makes an application potentially dependent on changes in versions
of GNAT, and will generate a warning message.

* Menu:

* Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads.
* Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads.
* Ada.Characters.Wide_Latin_9 (a-cwila9.ads): Ada Characters Wide_Latin_9 a-cwila9 ads.
* Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads.
* Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads.
* Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads.
* Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads.
* Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads.
* Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads.
* Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads.
* Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads.
* Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads.
* Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads.
* Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads.
* Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads.
* Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads.
* Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads.
* Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads.
* Ada.Task_Initialization (a-tasini.ads): Ada Task_Initialization a-tasini ads.
* Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads.
* Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads.
* Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads.
* Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads.
* Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads.
* Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads.
* Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads.
* Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads.
* GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads.
* GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads.
* GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads.
* GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads.
* GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads.
* GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads.
* GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads.
* GNAT.Binary_Search (g-binsea.ads): GNAT Binary_Search g-binsea ads.
* GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads.
* GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads.
* GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads.
* GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads.
* GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads.
* GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads.
* GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads.
* GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads.
* GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads.
* GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads.
* GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads.
* GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads.
* GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads.
* GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads.
* GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads.
* GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads.
* GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads.
* GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads.
* GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads.
* GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads.
* GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads.
* GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads.
* GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads.
* GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads.
* GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads.
* GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads.
* GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads.
* GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads.
* GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads.
* GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads.
* GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads.
* GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads.
* GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads.
* GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads.
* GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads.
* GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads.
* GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads.
* GNAT.Generic_Fast_Math_Functions (g-gfmafu.ads): GNAT Generic_Fast_Math_Functions g-gfmafu ads.
* GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads.
* GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads.
* GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads.
* GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads.
* GNAT.IO (g-io.ads): GNAT IO g-io ads.
* GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads.
* GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads.
* GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads.
* GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads.
* GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads.
* GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads.
* GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads.
* GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads.
* GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads.
* GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads.
* GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads.
* GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads.
* GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads.
* GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads.
* GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads.
* GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads.
* GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads.
* GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads.
* GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads.
* GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads.
* GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads.
* GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads.
* GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads.
* GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads.
* GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads.
* GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads.
* GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads.
* GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads.
* GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads.
* GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads.
* GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads.
* GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads.
* GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads.
* GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads.
* GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads.
* GNAT.Strings (g-string.ads): GNAT Strings g-string ads.
* GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads.
* GNAT.Table (g-table.ads): GNAT Table g-table ads.
* GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads.
* GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads.
* GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads.
* GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads.
* GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads.
* GNAT.UTF_32 (g-utf_32.ads): GNAT UTF_32 g-utf_32 ads.
* GNAT.UTF_32_Spelling_Checker (g-u3spch.ads): GNAT UTF_32_Spelling_Checker g-u3spch ads.
* GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads.
* GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads.
* GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads.
* GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads.
* Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads.
* Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads.
* Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads.
* Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads.
* Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads.
* Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads.
* System.Address_Image (s-addima.ads): System Address_Image s-addima ads.
* System.Assertions (s-assert.ads): System Assertions s-assert ads.
* System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads.
* System.Memory (s-memory.ads): System Memory s-memory ads.
* System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads.
* System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads.
* System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads.
* System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads.
* System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads.
* System.Restrictions (s-restri.ads): System Restrictions s-restri ads.
* System.Rident (s-rident.ads): System Rident s-rident ads.
* System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads.
* System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads.
* System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads.
* System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads.


File: gnat_rm.info,  Node: Ada Characters Latin_9 a-chlat9 ads,  Next: Ada Characters Wide_Latin_1 a-cwila1 ads,  Up: The GNAT Library

12.1 ‘Ada.Characters.Latin_9’ (‘a-chlat9.ads’)
==============================================

This child of ‘Ada.Characters’ provides a set of definitions
corresponding to those in the RM-defined package
‘Ada.Characters.Latin_1’ but with the few modifications required for
‘Latin-9’.  The provision of such a package is specifically authorized
by the Ada Reference Manual (RM A.3.3(27)).


File: gnat_rm.info,  Node: Ada Characters Wide_Latin_1 a-cwila1 ads,  Next: Ada Characters Wide_Latin_9 a-cwila9 ads,  Prev: Ada Characters Latin_9 a-chlat9 ads,  Up: The GNAT Library

12.2 ‘Ada.Characters.Wide_Latin_1’ (‘a-cwila1.ads’)
===================================================

This child of ‘Ada.Characters’ provides a set of definitions
corresponding to those in the RM-defined package
‘Ada.Characters.Latin_1’ but with the types of the constants being
‘Wide_Character’ instead of ‘Character’.  The provision of such a
package is specifically authorized by the Ada Reference Manual (RM
A.3.3(27)).


File: gnat_rm.info,  Node: Ada Characters Wide_Latin_9 a-cwila9 ads,  Next: Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,  Prev: Ada Characters Wide_Latin_1 a-cwila1 ads,  Up: The GNAT Library

12.3 ‘Ada.Characters.Wide_Latin_9’ (‘a-cwila9.ads’)
===================================================

This child of ‘Ada.Characters’ provides a set of definitions
corresponding to those in the GNAT defined package
‘Ada.Characters.Latin_9’ but with the types of the constants being
‘Wide_Character’ instead of ‘Character’.  The provision of such a
package is specifically authorized by the Ada Reference Manual (RM
A.3.3(27)).


File: gnat_rm.info,  Node: Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,  Next: Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,  Prev: Ada Characters Wide_Latin_9 a-cwila9 ads,  Up: The GNAT Library

12.4 ‘Ada.Characters.Wide_Wide_Latin_1’ (‘a-chzla1.ads’)
========================================================

This child of ‘Ada.Characters’ provides a set of definitions
corresponding to those in the RM-defined package
‘Ada.Characters.Latin_1’ but with the types of the constants being
‘Wide_Wide_Character’ instead of ‘Character’.  The provision of such a
package is specifically authorized by the Ada Reference Manual (RM
A.3.3(27)).


File: gnat_rm.info,  Node: Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,  Next: Ada Containers Bounded_Holders a-coboho ads,  Prev: Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,  Up: The GNAT Library

12.5 ‘Ada.Characters.Wide_Wide_Latin_9’ (‘a-chzla9.ads’)
========================================================

This child of ‘Ada.Characters’ provides a set of definitions
corresponding to those in the GNAT defined package
‘Ada.Characters.Latin_9’ but with the types of the constants being
‘Wide_Wide_Character’ instead of ‘Character’.  The provision of such a
package is specifically authorized by the Ada Reference Manual (RM
A.3.3(27)).


File: gnat_rm.info,  Node: Ada Containers Bounded_Holders a-coboho ads,  Next: Ada Command_Line Environment a-colien ads,  Prev: Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,  Up: The GNAT Library

12.6 ‘Ada.Containers.Bounded_Holders’ (‘a-coboho.ads’)
======================================================

This child of ‘Ada.Containers’ defines a modified version of
Indefinite_Holders that avoids heap allocation.


File: gnat_rm.info,  Node: Ada Command_Line Environment a-colien ads,  Next: Ada Command_Line Remove a-colire ads,  Prev: Ada Containers Bounded_Holders a-coboho ads,  Up: The GNAT Library

12.7 ‘Ada.Command_Line.Environment’ (‘a-colien.ads’)
====================================================

This child of ‘Ada.Command_Line’ provides a mechanism for obtaining
environment values on systems where this concept makes sense.


File: gnat_rm.info,  Node: Ada Command_Line Remove a-colire ads,  Next: Ada Command_Line Response_File a-clrefi ads,  Prev: Ada Command_Line Environment a-colien ads,  Up: The GNAT Library

12.8 ‘Ada.Command_Line.Remove’ (‘a-colire.ads’)
===============================================

This child of ‘Ada.Command_Line’ provides a mechanism for logically
removing arguments from the argument list.  Once removed, an argument is
not visible to further calls to the subprograms in ‘Ada.Command_Line’.
These calls will not see the removed argument.


File: gnat_rm.info,  Node: Ada Command_Line Response_File a-clrefi ads,  Next: Ada Direct_IO C_Streams a-diocst ads,  Prev: Ada Command_Line Remove a-colire ads,  Up: The GNAT Library

12.9 ‘Ada.Command_Line.Response_File’ (‘a-clrefi.ads’)
======================================================

This child of ‘Ada.Command_Line’ provides a mechanism facilities for
getting command line arguments from a text file, called a “response
file”.  Using a response file allow passing a set of arguments to an
executable longer than the maximum allowed by the system on the command
line.


File: gnat_rm.info,  Node: Ada Direct_IO C_Streams a-diocst ads,  Next: Ada Exceptions Is_Null_Occurrence a-einuoc ads,  Prev: Ada Command_Line Response_File a-clrefi ads,  Up: The GNAT Library

12.10 ‘Ada.Direct_IO.C_Streams’ (‘a-diocst.ads’)
================================================

This package provides subprograms that allow interfacing between C
streams and ‘Direct_IO’.  The stream identifier can be extracted from a
file opened on the Ada side, and an Ada file can be constructed from a
stream opened on the C side.


File: gnat_rm.info,  Node: Ada Exceptions Is_Null_Occurrence a-einuoc ads,  Next: Ada Exceptions Last_Chance_Handler a-elchha ads,  Prev: Ada Direct_IO C_Streams a-diocst ads,  Up: The GNAT Library

12.11 ‘Ada.Exceptions.Is_Null_Occurrence’ (‘a-einuoc.ads’)
==========================================================

This child subprogram provides a way of testing for the null exception
occurrence (‘Null_Occurrence’) without raising an exception.


File: gnat_rm.info,  Node: Ada Exceptions Last_Chance_Handler a-elchha ads,  Next: Ada Exceptions Traceback a-exctra ads,  Prev: Ada Exceptions Is_Null_Occurrence a-einuoc ads,  Up: The GNAT Library

12.12 ‘Ada.Exceptions.Last_Chance_Handler’ (‘a-elchha.ads’)
===========================================================

This child subprogram is used for handling otherwise unhandled
exceptions (hence the name last chance), and perform clean ups before
terminating the program.  Note that this subprogram never returns.


File: gnat_rm.info,  Node: Ada Exceptions Traceback a-exctra ads,  Next: Ada Sequential_IO C_Streams a-siocst ads,  Prev: Ada Exceptions Last_Chance_Handler a-elchha ads,  Up: The GNAT Library

12.13 ‘Ada.Exceptions.Traceback’ (‘a-exctra.ads’)
=================================================

This child package provides the subprogram (‘Tracebacks’) to give a
traceback array of addresses based on an exception occurrence.


File: gnat_rm.info,  Node: Ada Sequential_IO C_Streams a-siocst ads,  Next: Ada Streams Stream_IO C_Streams a-ssicst ads,  Prev: Ada Exceptions Traceback a-exctra ads,  Up: The GNAT Library

12.14 ‘Ada.Sequential_IO.C_Streams’ (‘a-siocst.ads’)
====================================================

This package provides subprograms that allow interfacing between C
streams and ‘Sequential_IO’.  The stream identifier can be extracted
from a file opened on the Ada side, and an Ada file can be constructed
from a stream opened on the C side.


File: gnat_rm.info,  Node: Ada Streams Stream_IO C_Streams a-ssicst ads,  Next: Ada Strings Unbounded Text_IO a-suteio ads,  Prev: Ada Sequential_IO C_Streams a-siocst ads,  Up: The GNAT Library

12.15 ‘Ada.Streams.Stream_IO.C_Streams’ (‘a-ssicst.ads’)
========================================================

This package provides subprograms that allow interfacing between C
streams and ‘Stream_IO’.  The stream identifier can be extracted from a
file opened on the Ada side, and an Ada file can be constructed from a
stream opened on the C side.


File: gnat_rm.info,  Node: Ada Strings Unbounded Text_IO a-suteio ads,  Next: Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,  Prev: Ada Streams Stream_IO C_Streams a-ssicst ads,  Up: The GNAT Library

12.16 ‘Ada.Strings.Unbounded.Text_IO’ (‘a-suteio.ads’)
======================================================

This package provides subprograms for Text_IO for unbounded strings,
avoiding the necessity for an intermediate operation with ordinary
strings.


File: gnat_rm.info,  Node: Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,  Next: Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,  Prev: Ada Strings Unbounded Text_IO a-suteio ads,  Up: The GNAT Library

12.17 ‘Ada.Strings.Wide_Unbounded.Wide_Text_IO’ (‘a-swuwti.ads’)
================================================================

This package provides subprograms for Text_IO for unbounded wide
strings, avoiding the necessity for an intermediate operation with
ordinary wide strings.


File: gnat_rm.info,  Node: Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,  Next: Ada Task_Initialization a-tasini ads,  Prev: Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,  Up: The GNAT Library

12.18 ‘Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO’ (‘a-szuzti.ads’)
==========================================================================

This package provides subprograms for Text_IO for unbounded wide wide
strings, avoiding the necessity for an intermediate operation with
ordinary wide wide strings.


File: gnat_rm.info,  Node: Ada Task_Initialization a-tasini ads,  Next: Ada Text_IO C_Streams a-tiocst ads,  Prev: Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,  Up: The GNAT Library

12.19 ‘Ada.Task_Initialization’ (‘a-tasini.ads’)
================================================

This package provides a way to set a global initialization handler that
is automatically invoked whenever a task is activated.  Handlers are
parameterless procedures.  Note that such a handler is only invoked for
those tasks activated after the handler is set.


File: gnat_rm.info,  Node: Ada Text_IO C_Streams a-tiocst ads,  Next: Ada Text_IO Reset_Standard_Files a-tirsfi ads,  Prev: Ada Task_Initialization a-tasini ads,  Up: The GNAT Library

12.20 ‘Ada.Text_IO.C_Streams’ (‘a-tiocst.ads’)
==============================================

This package provides subprograms that allow interfacing between C
streams and ‘Text_IO’.  The stream identifier can be extracted from a
file opened on the Ada side, and an Ada file can be constructed from a
stream opened on the C side.


File: gnat_rm.info,  Node: Ada Text_IO Reset_Standard_Files a-tirsfi ads,  Next: Ada Wide_Characters Unicode a-wichun ads,  Prev: Ada Text_IO C_Streams a-tiocst ads,  Up: The GNAT Library

12.21 ‘Ada.Text_IO.Reset_Standard_Files’ (‘a-tirsfi.ads’)
=========================================================

This procedure is used to reset the status of the standard files used by
Ada.Text_IO. This is useful in a situation (such as a restart in an
embedded application) where the status of the files may change during
execution (for example a standard input file may be redefined to be
interactive).


File: gnat_rm.info,  Node: Ada Wide_Characters Unicode a-wichun ads,  Next: Ada Wide_Text_IO C_Streams a-wtcstr ads,  Prev: Ada Text_IO Reset_Standard_Files a-tirsfi ads,  Up: The GNAT Library

12.22 ‘Ada.Wide_Characters.Unicode’ (‘a-wichun.ads’)
====================================================

This package provides subprograms that allow categorization of
Wide_Character values according to Unicode categories.


File: gnat_rm.info,  Node: Ada Wide_Text_IO C_Streams a-wtcstr ads,  Next: Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,  Prev: Ada Wide_Characters Unicode a-wichun ads,  Up: The GNAT Library

12.23 ‘Ada.Wide_Text_IO.C_Streams’ (‘a-wtcstr.ads’)
===================================================

This package provides subprograms that allow interfacing between C
streams and ‘Wide_Text_IO’.  The stream identifier can be extracted from
a file opened on the Ada side, and an Ada file can be constructed from a
stream opened on the C side.


File: gnat_rm.info,  Node: Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,  Next: Ada Wide_Wide_Characters Unicode a-zchuni ads,  Prev: Ada Wide_Text_IO C_Streams a-wtcstr ads,  Up: The GNAT Library

12.24 ‘Ada.Wide_Text_IO.Reset_Standard_Files’ (‘a-wrstfi.ads’)
==============================================================

This procedure is used to reset the status of the standard files used by
Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
embedded application) where the status of the files may change during
execution (for example a standard input file may be redefined to be
interactive).


File: gnat_rm.info,  Node: Ada Wide_Wide_Characters Unicode a-zchuni ads,  Next: Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,  Prev: Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,  Up: The GNAT Library

12.25 ‘Ada.Wide_Wide_Characters.Unicode’ (‘a-zchuni.ads’)
=========================================================

This package provides subprograms that allow categorization of
Wide_Wide_Character values according to Unicode categories.


File: gnat_rm.info,  Node: Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,  Next: Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,  Prev: Ada Wide_Wide_Characters Unicode a-zchuni ads,  Up: The GNAT Library

12.26 ‘Ada.Wide_Wide_Text_IO.C_Streams’ (‘a-ztcstr.ads’)
========================================================

This package provides subprograms that allow interfacing between C
streams and ‘Wide_Wide_Text_IO’.  The stream identifier can be extracted
from a file opened on the Ada side, and an Ada file can be constructed
from a stream opened on the C side.


File: gnat_rm.info,  Node: Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,  Next: GNAT Altivec g-altive ads,  Prev: Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,  Up: The GNAT Library

12.27 ‘Ada.Wide_Wide_Text_IO.Reset_Standard_Files’ (‘a-zrstfi.ads’)
===================================================================

This procedure is used to reset the status of the standard files used by
Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a restart
in an embedded application) where the status of the files may change
during execution (for example a standard input file may be redefined to
be interactive).


File: gnat_rm.info,  Node: GNAT Altivec g-altive ads,  Next: GNAT Altivec Conversions g-altcon ads,  Prev: Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,  Up: The GNAT Library

12.28 ‘GNAT.Altivec’ (‘g-altive.ads’)
=====================================

This is the root package of the GNAT AltiVec binding.  It provides
definitions of constants and types common to all the versions of the
binding.


File: gnat_rm.info,  Node: GNAT Altivec Conversions g-altcon ads,  Next: GNAT Altivec Vector_Operations g-alveop ads,  Prev: GNAT Altivec g-altive ads,  Up: The GNAT Library

12.29 ‘GNAT.Altivec.Conversions’ (‘g-altcon.ads’)
=================================================

This package provides the Vector/View conversion routines.


File: gnat_rm.info,  Node: GNAT Altivec Vector_Operations g-alveop ads,  Next: GNAT Altivec Vector_Types g-alvety ads,  Prev: GNAT Altivec Conversions g-altcon ads,  Up: The GNAT Library

12.30 ‘GNAT.Altivec.Vector_Operations’ (‘g-alveop.ads’)
=======================================================

This package exposes the Ada interface to the AltiVec operations on
vector objects.  A soft emulation is included by default in the GNAT
library.  The hard binding is provided as a separate package.  This unit
is common to both bindings.


File: gnat_rm.info,  Node: GNAT Altivec Vector_Types g-alvety ads,  Next: GNAT Altivec Vector_Views g-alvevi ads,  Prev: GNAT Altivec Vector_Operations g-alveop ads,  Up: The GNAT Library

12.31 ‘GNAT.Altivec.Vector_Types’ (‘g-alvety.ads’)
==================================================

This package exposes the various vector types part of the Ada binding to
AltiVec facilities.


File: gnat_rm.info,  Node: GNAT Altivec Vector_Views g-alvevi ads,  Next: GNAT Array_Split g-arrspl ads,  Prev: GNAT Altivec Vector_Types g-alvety ads,  Up: The GNAT Library

12.32 ‘GNAT.Altivec.Vector_Views’ (‘g-alvevi.ads’)
==================================================

This package provides public ‘View’ data types from/to which private
vector representations can be converted via GNAT.Altivec.Conversions.
This allows convenient access to individual vector elements and provides
a simple way to initialize vector objects.


File: gnat_rm.info,  Node: GNAT Array_Split g-arrspl ads,  Next: GNAT AWK g-awk ads,  Prev: GNAT Altivec Vector_Views g-alvevi ads,  Up: The GNAT Library

12.33 ‘GNAT.Array_Split’ (‘g-arrspl.ads’)
=========================================

Useful array-manipulation routines: given a set of separators, split an
array wherever the separators appear, and provide direct access to the
resulting slices.


File: gnat_rm.info,  Node: GNAT AWK g-awk ads,  Next: GNAT Binary_Search g-binsea ads,  Prev: GNAT Array_Split g-arrspl ads,  Up: The GNAT Library

12.34 ‘GNAT.AWK’ (‘g-awk.ads’)
==============================

Provides AWK-like parsing functions, with an easy interface for parsing
one or more files containing formatted data.  The file is viewed as a
database where each record is a line and a field is a data element in
this line.


File: gnat_rm.info,  Node: GNAT Binary_Search g-binsea ads,  Next: GNAT Bind_Environment g-binenv ads,  Prev: GNAT AWK g-awk ads,  Up: The GNAT Library

12.35 ‘GNAT.Binary_Search’ (‘g-binsea.ads’)
===========================================

Allow binary search of a sorted array (or of an array-like container;
the generic does not reference the array directly).


File: gnat_rm.info,  Node: GNAT Bind_Environment g-binenv ads,  Next: GNAT Branch_Prediction g-brapre ads,  Prev: GNAT Binary_Search g-binsea ads,  Up: The GNAT Library

12.36 ‘GNAT.Bind_Environment’ (‘g-binenv.ads’)
==============================================

Provides access to key=value associations captured at bind time.  These
associations can be specified using the ‘-V’ binder command line switch.


File: gnat_rm.info,  Node: GNAT Branch_Prediction g-brapre ads,  Next: GNAT Bounded_Buffers g-boubuf ads,  Prev: GNAT Bind_Environment g-binenv ads,  Up: The GNAT Library

12.37 ‘GNAT.Branch_Prediction’ (‘g-brapre.ads’)
===============================================

Provides routines giving hints to the branch predictor of the code
generator.


File: gnat_rm.info,  Node: GNAT Bounded_Buffers g-boubuf ads,  Next: GNAT Bounded_Mailboxes g-boumai ads,  Prev: GNAT Branch_Prediction g-brapre ads,  Up: The GNAT Library

12.38 ‘GNAT.Bounded_Buffers’ (‘g-boubuf.ads’)
=============================================

Provides a concurrent generic bounded buffer abstraction.  Instances are
useful directly or as parts of the implementations of other
abstractions, such as mailboxes.


File: gnat_rm.info,  Node: GNAT Bounded_Mailboxes g-boumai ads,  Next: GNAT Bubble_Sort g-bubsor ads,  Prev: GNAT Bounded_Buffers g-boubuf ads,  Up: The GNAT Library

12.39 ‘GNAT.Bounded_Mailboxes’ (‘g-boumai.ads’)
===============================================

Provides a thread-safe asynchronous intertask mailbox communication
facility.


File: gnat_rm.info,  Node: GNAT Bubble_Sort g-bubsor ads,  Next: GNAT Bubble_Sort_A g-busora ads,  Prev: GNAT Bounded_Mailboxes g-boumai ads,  Up: The GNAT Library

12.40 ‘GNAT.Bubble_Sort’ (‘g-bubsor.ads’)
=========================================

Provides a general implementation of bubble sort usable for sorting
arbitrary data items.  Exchange and comparison procedures are provided
by passing access-to-procedure values.


File: gnat_rm.info,  Node: GNAT Bubble_Sort_A g-busora ads,  Next: GNAT Bubble_Sort_G g-busorg ads,  Prev: GNAT Bubble_Sort g-bubsor ads,  Up: The GNAT Library

12.41 ‘GNAT.Bubble_Sort_A’ (‘g-busora.ads’)
===========================================

Provides a general implementation of bubble sort usable for sorting
arbitrary data items.  Move and comparison procedures are provided by
passing access-to-procedure values.  This is an older version, retained
for compatibility.  Usually ‘GNAT.Bubble_Sort’ will be preferable.


File: gnat_rm.info,  Node: GNAT Bubble_Sort_G g-busorg ads,  Next: GNAT Byte_Order_Mark g-byorma ads,  Prev: GNAT Bubble_Sort_A g-busora ads,  Up: The GNAT Library

12.42 ‘GNAT.Bubble_Sort_G’ (‘g-busorg.ads’)
===========================================

Similar to ‘Bubble_Sort_A’ except that the move and sorting procedures
are provided as generic parameters, this improves efficiency, especially
if the procedures can be inlined, at the expense of duplicating code for
multiple instantiations.


File: gnat_rm.info,  Node: GNAT Byte_Order_Mark g-byorma ads,  Next: GNAT Byte_Swapping g-bytswa ads,  Prev: GNAT Bubble_Sort_G g-busorg ads,  Up: The GNAT Library

12.43 ‘GNAT.Byte_Order_Mark’ (‘g-byorma.ads’)
=============================================

Provides a routine which given a string, reads the start of the string
to see whether it is one of the standard byte order marks (BOM’s) which
signal the encoding of the string.  The routine includes detection of
special XML sequences for various UCS input formats.


File: gnat_rm.info,  Node: GNAT Byte_Swapping g-bytswa ads,  Next: GNAT Calendar g-calend ads,  Prev: GNAT Byte_Order_Mark g-byorma ads,  Up: The GNAT Library

12.44 ‘GNAT.Byte_Swapping’ (‘g-bytswa.ads’)
===========================================

General routines for swapping the bytes in 2-, 4-, and 8-byte
quantities.  Machine-specific implementations are available in some
cases.


File: gnat_rm.info,  Node: GNAT Calendar g-calend ads,  Next: GNAT Calendar Time_IO g-catiio ads,  Prev: GNAT Byte_Swapping g-bytswa ads,  Up: The GNAT Library

12.45 ‘GNAT.Calendar’ (‘g-calend.ads’)
======================================

Extends the facilities provided by ‘Ada.Calendar’ to include handling of
days of the week, an extended ‘Split’ and ‘Time_Of’ capability.  Also
provides conversion of ‘Ada.Calendar.Time’ values to and from the C
‘timeval’ format.


File: gnat_rm.info,  Node: GNAT Calendar Time_IO g-catiio ads,  Next: GNAT CRC32 g-crc32 ads,  Prev: GNAT Calendar g-calend ads,  Up: The GNAT Library

12.46 ‘GNAT.Calendar.Time_IO’ (‘g-catiio.ads’)
==============================================


File: gnat_rm.info,  Node: GNAT CRC32 g-crc32 ads,  Next: GNAT Case_Util g-casuti ads,  Prev: GNAT Calendar Time_IO g-catiio ads,  Up: The GNAT Library

12.47 ‘GNAT.CRC32’ (‘g-crc32.ads’)
==================================

This package implements the CRC-32 algorithm.  For a full description of
this algorithm see 'Computation of Cyclic Redundancy Checks via Table
Look-Up', ‘Communications of the ACM’, Vol.  31 No.  8, pp.  1008-1013,
Aug.  1988.  Sarwate, D.V.


File: gnat_rm.info,  Node: GNAT Case_Util g-casuti ads,  Next: GNAT CGI g-cgi ads,  Prev: GNAT CRC32 g-crc32 ads,  Up: The GNAT Library

12.48 ‘GNAT.Case_Util’ (‘g-casuti.ads’)
=======================================

A set of simple routines for handling upper and lower casing of strings
without the overhead of the full casing tables in
‘Ada.Characters.Handling’.


File: gnat_rm.info,  Node: GNAT CGI g-cgi ads,  Next: GNAT CGI Cookie g-cgicoo ads,  Prev: GNAT Case_Util g-casuti ads,  Up: The GNAT Library

12.49 ‘GNAT.CGI’ (‘g-cgi.ads’)
==============================

This is a package for interfacing a GNAT program with a Web server via
the Common Gateway Interface (CGI). Basically this package parses the
CGI parameters, which are a set of key/value pairs sent by the Web
server.  It builds a table whose index is the key and provides some
services to deal with this table.


File: gnat_rm.info,  Node: GNAT CGI Cookie g-cgicoo ads,  Next: GNAT CGI Debug g-cgideb ads,  Prev: GNAT CGI g-cgi ads,  Up: The GNAT Library

12.50 ‘GNAT.CGI.Cookie’ (‘g-cgicoo.ads’)
========================================

This is a package to interface a GNAT program with a Web server via the
Common Gateway Interface (CGI). It exports services to deal with Web
cookies (piece of information kept in the Web client software).


File: gnat_rm.info,  Node: GNAT CGI Debug g-cgideb ads,  Next: GNAT Command_Line g-comlin ads,  Prev: GNAT CGI Cookie g-cgicoo ads,  Up: The GNAT Library

12.51 ‘GNAT.CGI.Debug’ (‘g-cgideb.ads’)
=======================================

This is a package to help debugging CGI (Common Gateway Interface)
programs written in Ada.


File: gnat_rm.info,  Node: GNAT Command_Line g-comlin ads,  Next: GNAT Compiler_Version g-comver ads,  Prev: GNAT CGI Debug g-cgideb ads,  Up: The GNAT Library

12.52 ‘GNAT.Command_Line’ (‘g-comlin.ads’)
==========================================

Provides a high level interface to ‘Ada.Command_Line’ facilities,
including the ability to scan for named switches with optional
parameters and expand file names using wildcard notations.


File: gnat_rm.info,  Node: GNAT Compiler_Version g-comver ads,  Next: GNAT Ctrl_C g-ctrl_c ads,  Prev: GNAT Command_Line g-comlin ads,  Up: The GNAT Library

12.53 ‘GNAT.Compiler_Version’ (‘g-comver.ads’)
==============================================

Provides a routine for obtaining the version of the compiler used to
compile the program.  More accurately this is the version of the binder
used to bind the program (this will normally be the same as the version
of the compiler if a consistent tool set is used to compile all units of
a partition).


File: gnat_rm.info,  Node: GNAT Ctrl_C g-ctrl_c ads,  Next: GNAT Current_Exception g-curexc ads,  Prev: GNAT Compiler_Version g-comver ads,  Up: The GNAT Library

12.54 ‘GNAT.Ctrl_C’ (‘g-ctrl_c.ads’)
====================================

Provides a simple interface to handle Ctrl-C keyboard events.


File: gnat_rm.info,  Node: GNAT Current_Exception g-curexc ads,  Next: GNAT Debug_Pools g-debpoo ads,  Prev: GNAT Ctrl_C g-ctrl_c ads,  Up: The GNAT Library

12.55 ‘GNAT.Current_Exception’ (‘g-curexc.ads’)
===============================================

Provides access to information on the current exception that has been
raised without the need for using the Ada 95 / Ada 2005 exception choice
parameter specification syntax.  This is particularly useful in
simulating typical facilities for obtaining information about exceptions
provided by Ada 83 compilers.


File: gnat_rm.info,  Node: GNAT Debug_Pools g-debpoo ads,  Next: GNAT Debug_Utilities g-debuti ads,  Prev: GNAT Current_Exception g-curexc ads,  Up: The GNAT Library

12.56 ‘GNAT.Debug_Pools’ (‘g-debpoo.ads’)
=========================================

Provides a debugging storage pools that helps tracking memory corruption
problems.  See ‘The GNAT Debug_Pool Facility’ section in the ‘GNAT
User’s Guide’.


File: gnat_rm.info,  Node: GNAT Debug_Utilities g-debuti ads,  Next: GNAT Decode_String g-decstr ads,  Prev: GNAT Debug_Pools g-debpoo ads,  Up: The GNAT Library

12.57 ‘GNAT.Debug_Utilities’ (‘g-debuti.ads’)
=============================================

Provides a few useful utilities for debugging purposes, including
conversion to and from string images of address values.  Supports both C
and Ada formats for hexadecimal literals.


File: gnat_rm.info,  Node: GNAT Decode_String g-decstr ads,  Next: GNAT Decode_UTF8_String g-deutst ads,  Prev: GNAT Debug_Utilities g-debuti ads,  Up: The GNAT Library

12.58 ‘GNAT.Decode_String’ (‘g-decstr.ads’)
===========================================

A generic package providing routines for decoding wide character and
wide wide character strings encoded as sequences of 8-bit characters
using a specified encoding method.  Includes validation routines, and
also routines for stepping to next or previous encoded character in an
encoded string.  Useful in conjunction with Unicode character coding.
Note there is a preinstantiation for UTF-8.  See next entry.


File: gnat_rm.info,  Node: GNAT Decode_UTF8_String g-deutst ads,  Next: GNAT Directory_Operations g-dirope ads,  Prev: GNAT Decode_String g-decstr ads,  Up: The GNAT Library

12.59 ‘GNAT.Decode_UTF8_String’ (‘g-deutst.ads’)
================================================

A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.


File: gnat_rm.info,  Node: GNAT Directory_Operations g-dirope ads,  Next: GNAT Directory_Operations Iteration g-diopit ads,  Prev: GNAT Decode_UTF8_String g-deutst ads,  Up: The GNAT Library

12.60 ‘GNAT.Directory_Operations’ (‘g-dirope.ads’)
==================================================

Provides a set of routines for manipulating directories, including
changing the current directory, making new directories, and scanning the
files in a directory.


File: gnat_rm.info,  Node: GNAT Directory_Operations Iteration g-diopit ads,  Next: GNAT Dynamic_HTables g-dynhta ads,  Prev: GNAT Directory_Operations g-dirope ads,  Up: The GNAT Library

12.61 ‘GNAT.Directory_Operations.Iteration’ (‘g-diopit.ads’)
============================================================

A child unit of GNAT.Directory_Operations providing additional
operations for iterating through directories.


File: gnat_rm.info,  Node: GNAT Dynamic_HTables g-dynhta ads,  Next: GNAT Dynamic_Tables g-dyntab ads,  Prev: GNAT Directory_Operations Iteration g-diopit ads,  Up: The GNAT Library

12.62 ‘GNAT.Dynamic_HTables’ (‘g-dynhta.ads’)
=============================================

A generic implementation of hash tables that can be used to hash
arbitrary data.  Provided in two forms, a simple form with built in hash
functions, and a more complex form in which the hash function is
supplied.

This package provides a facility similar to that of ‘GNAT.HTable’,
except that this package declares a type that can be used to define
dynamic instances of the hash table, while an instantiation of
‘GNAT.HTable’ creates a single instance of the hash table.


File: gnat_rm.info,  Node: GNAT Dynamic_Tables g-dyntab ads,  Next: GNAT Encode_String g-encstr ads,  Prev: GNAT Dynamic_HTables g-dynhta ads,  Up: The GNAT Library

12.63 ‘GNAT.Dynamic_Tables’ (‘g-dyntab.ads’)
============================================

A generic package providing a single dimension array abstraction where
the length of the array can be dynamically modified.

This package provides a facility similar to that of ‘GNAT.Table’, except
that this package declares a type that can be used to define dynamic
instances of the table, while an instantiation of ‘GNAT.Table’ creates a
single instance of the table type.


File: gnat_rm.info,  Node: GNAT Encode_String g-encstr ads,  Next: GNAT Encode_UTF8_String g-enutst ads,  Prev: GNAT Dynamic_Tables g-dyntab ads,  Up: The GNAT Library

12.64 ‘GNAT.Encode_String’ (‘g-encstr.ads’)
===========================================

A generic package providing routines for encoding wide character and
wide wide character strings as sequences of 8-bit characters using a
specified encoding method.  Useful in conjunction with Unicode character
coding.  Note there is a preinstantiation for UTF-8.  See next entry.


File: gnat_rm.info,  Node: GNAT Encode_UTF8_String g-enutst ads,  Next: GNAT Exception_Actions g-excact ads,  Prev: GNAT Encode_String g-encstr ads,  Up: The GNAT Library

12.65 ‘GNAT.Encode_UTF8_String’ (‘g-enutst.ads’)
================================================

A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.


File: gnat_rm.info,  Node: GNAT Exception_Actions g-excact ads,  Next: GNAT Exception_Traces g-exctra ads,  Prev: GNAT Encode_UTF8_String g-enutst ads,  Up: The GNAT Library

12.66 ‘GNAT.Exception_Actions’ (‘g-excact.ads’)
===============================================

Provides callbacks when an exception is raised.  Callbacks can be
registered for specific exceptions, or when any exception is raised.
This can be used for instance to force a core dump to ease debugging.


File: gnat_rm.info,  Node: GNAT Exception_Traces g-exctra ads,  Next: GNAT Exceptions g-except ads,  Prev: GNAT Exception_Actions g-excact ads,  Up: The GNAT Library

12.67 ‘GNAT.Exception_Traces’ (‘g-exctra.ads’)
==============================================

Provides an interface allowing to control automatic output upon
exception occurrences.


File: gnat_rm.info,  Node: GNAT Exceptions g-except ads,  Next: GNAT Expect g-expect ads,  Prev: GNAT Exception_Traces g-exctra ads,  Up: The GNAT Library

12.68 ‘GNAT.Exceptions’ (‘g-except.ads’)
========================================

Normally it is not possible to raise an exception with a message from a
subprogram in a pure package, since the necessary types and subprograms
are in ‘Ada.Exceptions’ which is not a pure unit.  ‘GNAT.Exceptions’
provides a facility for getting around this limitation for a few
predefined exceptions, and for example allows raising ‘Constraint_Error’
with a message from a pure subprogram.


File: gnat_rm.info,  Node: GNAT Expect g-expect ads,  Next: GNAT Expect TTY g-exptty ads,  Prev: GNAT Exceptions g-except ads,  Up: The GNAT Library

12.69 ‘GNAT.Expect’ (‘g-expect.ads’)
====================================

Provides a set of subprograms similar to what is available with the
standard Tcl Expect tool.  It allows you to easily spawn and communicate
with an external process.  You can send commands or inputs to the
process, and compare the output with some expected regular expression.
Currently ‘GNAT.Expect’ is implemented on all native GNAT ports.  It is
not implemented for cross ports, and in particular is not implemented
for VxWorks or LynxOS.


File: gnat_rm.info,  Node: GNAT Expect TTY g-exptty ads,  Next: GNAT Float_Control g-flocon ads,  Prev: GNAT Expect g-expect ads,  Up: The GNAT Library

12.70 ‘GNAT.Expect.TTY’ (‘g-exptty.ads’)
========================================

As GNAT.Expect but using pseudo-terminal.  Currently ‘GNAT.Expect.TTY’
is implemented on all native GNAT ports.  It is not implemented for
cross ports, and in particular is not implemented for VxWorks or LynxOS.


File: gnat_rm.info,  Node: GNAT Float_Control g-flocon ads,  Next: GNAT Formatted_String g-forstr ads,  Prev: GNAT Expect TTY g-exptty ads,  Up: The GNAT Library

12.71 ‘GNAT.Float_Control’ (‘g-flocon.ads’)
===========================================

Provides an interface for resetting the floating-point processor into
the mode required for correct semantic operation in Ada.  Some third
party library calls may cause this mode to be modified, and the Reset
procedure in this package can be used to reestablish the required mode.


File: gnat_rm.info,  Node: GNAT Formatted_String g-forstr ads,  Next: GNAT Generic_Fast_Math_Functions g-gfmafu ads,  Prev: GNAT Float_Control g-flocon ads,  Up: The GNAT Library

12.72 ‘GNAT.Formatted_String’ (‘g-forstr.ads’)
==============================================

Provides support for C/C++ printf() formatted strings.  The format is
copied from the printf() routine and should therefore give identical
output.  Some generic routines are provided to be able to use types
derived from Integer, Float or enumerations as values for the formatted
string.


File: gnat_rm.info,  Node: GNAT Generic_Fast_Math_Functions g-gfmafu ads,  Next: GNAT Heap_Sort g-heasor ads,  Prev: GNAT Formatted_String g-forstr ads,  Up: The GNAT Library

12.73 ‘GNAT.Generic_Fast_Math_Functions’ (‘g-gfmafu.ads’)
=========================================================

Provides direct access to the underlying implementation of the common
mathematical functions, generally from the system mathematical library.
This differs from ‘Ada.Numerics.Generic_Elementary_Functions’ in that
the implementation may deviate from the semantics specified for these
functions in the Reference Manual, for example ‘Numerics.Argument_Error’
is not raised.  On selected platforms, some of these functions may also
have a vector implementation that can be automatically used by the
compiler when auto-vectorization is enabled.


File: gnat_rm.info,  Node: GNAT Heap_Sort g-heasor ads,  Next: GNAT Heap_Sort_A g-hesora ads,  Prev: GNAT Generic_Fast_Math_Functions g-gfmafu ads,  Up: The GNAT Library

12.74 ‘GNAT.Heap_Sort’ (‘g-heasor.ads’)
=======================================

Provides a general implementation of heap sort usable for sorting
arbitrary data items.  Exchange and comparison procedures are provided
by passing access-to-procedure values.  The algorithm used is a modified
heap sort that performs approximately N*log(N) comparisons in the worst
case.


File: gnat_rm.info,  Node: GNAT Heap_Sort_A g-hesora ads,  Next: GNAT Heap_Sort_G g-hesorg ads,  Prev: GNAT Heap_Sort g-heasor ads,  Up: The GNAT Library

12.75 ‘GNAT.Heap_Sort_A’ (‘g-hesora.ads’)
=========================================

Provides a general implementation of heap sort usable for sorting
arbitrary data items.  Move and comparison procedures are provided by
passing access-to-procedure values.  The algorithm used is a modified
heap sort that performs approximately N*log(N) comparisons in the worst
case.  This differs from ‘GNAT.Heap_Sort’ in having a less convenient
interface, but may be slightly more efficient.


File: gnat_rm.info,  Node: GNAT Heap_Sort_G g-hesorg ads,  Next: GNAT HTable g-htable ads,  Prev: GNAT Heap_Sort_A g-hesora ads,  Up: The GNAT Library

12.76 ‘GNAT.Heap_Sort_G’ (‘g-hesorg.ads’)
=========================================

Similar to ‘Heap_Sort_A’ except that the move and sorting procedures are
provided as generic parameters, this improves efficiency, especially if
the procedures can be inlined, at the expense of duplicating code for
multiple instantiations.


File: gnat_rm.info,  Node: GNAT HTable g-htable ads,  Next: GNAT IO g-io ads,  Prev: GNAT Heap_Sort_G g-hesorg ads,  Up: The GNAT Library

12.77 ‘GNAT.HTable’ (‘g-htable.ads’)
====================================

A generic implementation of hash tables that can be used to hash
arbitrary data.  Provides two approaches, one a simple static approach,
and the other allowing arbitrary dynamic hash tables.


File: gnat_rm.info,  Node: GNAT IO g-io ads,  Next: GNAT IO_Aux g-io_aux ads,  Prev: GNAT HTable g-htable ads,  Up: The GNAT Library

12.78 ‘GNAT.IO’ (‘g-io.ads’)
============================

A simple preelaborable input-output package that provides a subset of
simple Text_IO functions for reading characters and strings from
Standard_Input, and writing characters, strings and integers to either
Standard_Output or Standard_Error.


File: gnat_rm.info,  Node: GNAT IO_Aux g-io_aux ads,  Next: GNAT Lock_Files g-locfil ads,  Prev: GNAT IO g-io ads,  Up: The GNAT Library

12.79 ‘GNAT.IO_Aux’ (‘g-io_aux.ads’)
====================================

Provides some auxiliary functions for use with Text_IO, including a test
for whether a file exists, and functions for reading a line of text.


File: gnat_rm.info,  Node: GNAT Lock_Files g-locfil ads,  Next: GNAT MBBS_Discrete_Random g-mbdira ads,  Prev: GNAT IO_Aux g-io_aux ads,  Up: The GNAT Library

12.80 ‘GNAT.Lock_Files’ (‘g-locfil.ads’)
========================================

Provides a general interface for using files as locks.  Can be used for
providing program level synchronization.


File: gnat_rm.info,  Node: GNAT MBBS_Discrete_Random g-mbdira ads,  Next: GNAT MBBS_Float_Random g-mbflra ads,  Prev: GNAT Lock_Files g-locfil ads,  Up: The GNAT Library

12.81 ‘GNAT.MBBS_Discrete_Random’ (‘g-mbdira.ads’)
==================================================

The original implementation of ‘Ada.Numerics.Discrete_Random’.  Uses a
modified version of the Blum-Blum-Shub generator.


File: gnat_rm.info,  Node: GNAT MBBS_Float_Random g-mbflra ads,  Next: GNAT MD5 g-md5 ads,  Prev: GNAT MBBS_Discrete_Random g-mbdira ads,  Up: The GNAT Library

12.82 ‘GNAT.MBBS_Float_Random’ (‘g-mbflra.ads’)
===============================================

The original implementation of ‘Ada.Numerics.Float_Random’.  Uses a
modified version of the Blum-Blum-Shub generator.


File: gnat_rm.info,  Node: GNAT MD5 g-md5 ads,  Next: GNAT Memory_Dump g-memdum ads,  Prev: GNAT MBBS_Float_Random g-mbflra ads,  Up: The GNAT Library

12.83 ‘GNAT.MD5’ (‘g-md5.ads’)
==============================

Implements the MD5 Message-Digest Algorithm as described in RFC 1321,
and the HMAC-MD5 message authentication function as described in RFC
2104 and FIPS PUB 198.


File: gnat_rm.info,  Node: GNAT Memory_Dump g-memdum ads,  Next: GNAT Most_Recent_Exception g-moreex ads,  Prev: GNAT MD5 g-md5 ads,  Up: The GNAT Library

12.84 ‘GNAT.Memory_Dump’ (‘g-memdum.ads’)
=========================================

Provides a convenient routine for dumping raw memory to either the
standard output or standard error files.  Uses GNAT.IO for actual
output.


File: gnat_rm.info,  Node: GNAT Most_Recent_Exception g-moreex ads,  Next: GNAT OS_Lib g-os_lib ads,  Prev: GNAT Memory_Dump g-memdum ads,  Up: The GNAT Library

12.85 ‘GNAT.Most_Recent_Exception’ (‘g-moreex.ads’)
===================================================

Provides access to the most recently raised exception.  Can be used for
various logging purposes, including duplicating functionality of some
Ada 83 implementation dependent extensions.


File: gnat_rm.info,  Node: GNAT OS_Lib g-os_lib ads,  Next: GNAT Perfect_Hash_Generators g-pehage ads,  Prev: GNAT Most_Recent_Exception g-moreex ads,  Up: The GNAT Library

12.86 ‘GNAT.OS_Lib’ (‘g-os_lib.ads’)
====================================

Provides a range of target independent operating system interface
functions, including time/date management, file operations, subprocess
management, including a portable spawn procedure, and access to
environment variables and error return codes.


File: gnat_rm.info,  Node: GNAT Perfect_Hash_Generators g-pehage ads,  Next: GNAT Random_Numbers g-rannum ads,  Prev: GNAT OS_Lib g-os_lib ads,  Up: The GNAT Library

12.87 ‘GNAT.Perfect_Hash_Generators’ (‘g-pehage.ads’)
=====================================================

Provides a generator of static minimal perfect hash functions.  No
collisions occur and each item can be retrieved from the table in one
probe (perfect property).  The hash table size corresponds to the exact
size of the key set and no larger (minimal property).  The key set has
to be known in advance (static property).  The hash functions are also
order preserving.  If w2 is inserted after w1 in the generator, their
hashcode are in the same order.  These hashing functions are very
convenient for use with realtime applications.


File: gnat_rm.info,  Node: GNAT Random_Numbers g-rannum ads,  Next: GNAT Regexp g-regexp ads,  Prev: GNAT Perfect_Hash_Generators g-pehage ads,  Up: The GNAT Library

12.88 ‘GNAT.Random_Numbers’ (‘g-rannum.ads’)
============================================

Provides random number capabilities which extend those available in the
standard Ada library and are more convenient to use.


File: gnat_rm.info,  Node: GNAT Regexp g-regexp ads,  Next: GNAT Registry g-regist ads,  Prev: GNAT Random_Numbers g-rannum ads,  Up: The GNAT Library

12.89 ‘GNAT.Regexp’ (‘g-regexp.ads’)
====================================

A simple implementation of regular expressions, using a subset of
regular expression syntax copied from familiar Unix style utilities.
This is the simplest of the three pattern matching packages provided,
and is particularly suitable for ‘file globbing’ applications.


File: gnat_rm.info,  Node: GNAT Registry g-regist ads,  Next: GNAT Regpat g-regpat ads,  Prev: GNAT Regexp g-regexp ads,  Up: The GNAT Library

12.90 ‘GNAT.Registry’ (‘g-regist.ads’)
======================================

This is a high level binding to the Windows registry.  It is possible to
do simple things like reading a key value, creating a new key.  For full
registry API, but at a lower level of abstraction, refer to the
Win32.Winreg package provided with the Win32Ada binding


File: gnat_rm.info,  Node: GNAT Regpat g-regpat ads,  Next: GNAT Rewrite_Data g-rewdat ads,  Prev: GNAT Registry g-regist ads,  Up: The GNAT Library

12.91 ‘GNAT.Regpat’ (‘g-regpat.ads’)
====================================

A complete implementation of Unix-style regular expression matching,
copied from the original V7 style regular expression library written in
C by Henry Spencer (and binary compatible with this C library).


File: gnat_rm.info,  Node: GNAT Rewrite_Data g-rewdat ads,  Next: GNAT Secondary_Stack_Info g-sestin ads,  Prev: GNAT Regpat g-regpat ads,  Up: The GNAT Library

12.92 ‘GNAT.Rewrite_Data’ (‘g-rewdat.ads’)
==========================================

A unit to rewrite on-the-fly string occurrences in a stream of data.
The implementation has a very minimal memory footprint as the full
content to be processed is not loaded into memory all at once.  This
makes this interface usable for large files or socket streams.


File: gnat_rm.info,  Node: GNAT Secondary_Stack_Info g-sestin ads,  Next: GNAT Semaphores g-semaph ads,  Prev: GNAT Rewrite_Data g-rewdat ads,  Up: The GNAT Library

12.93 ‘GNAT.Secondary_Stack_Info’ (‘g-sestin.ads’)
==================================================

Provides the capability to query the high water mark of the current
task’s secondary stack.


File: gnat_rm.info,  Node: GNAT Semaphores g-semaph ads,  Next: GNAT Serial_Communications g-sercom ads,  Prev: GNAT Secondary_Stack_Info g-sestin ads,  Up: The GNAT Library

12.94 ‘GNAT.Semaphores’ (‘g-semaph.ads’)
========================================

Provides classic counting and binary semaphores using protected types.


File: gnat_rm.info,  Node: GNAT Serial_Communications g-sercom ads,  Next: GNAT SHA1 g-sha1 ads,  Prev: GNAT Semaphores g-semaph ads,  Up: The GNAT Library

12.95 ‘GNAT.Serial_Communications’ (‘g-sercom.ads’)
===================================================

Provides a simple interface to send and receive data over a serial port.
This is only supported on GNU/Linux and Windows.


File: gnat_rm.info,  Node: GNAT SHA1 g-sha1 ads,  Next: GNAT SHA224 g-sha224 ads,  Prev: GNAT Serial_Communications g-sercom ads,  Up: The GNAT Library

12.96 ‘GNAT.SHA1’ (‘g-sha1.ads’)
================================

Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB
180-3 and RFC 3174, and the HMAC-SHA1 message authentication function as
described in RFC 2104 and FIPS PUB 198.


File: gnat_rm.info,  Node: GNAT SHA224 g-sha224 ads,  Next: GNAT SHA256 g-sha256 ads,  Prev: GNAT SHA1 g-sha1 ads,  Up: The GNAT Library

12.97 ‘GNAT.SHA224’ (‘g-sha224.ads’)
====================================

Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB
180-3, and the HMAC-SHA224 message authentication function as described
in RFC 2104 and FIPS PUB 198.


File: gnat_rm.info,  Node: GNAT SHA256 g-sha256 ads,  Next: GNAT SHA384 g-sha384 ads,  Prev: GNAT SHA224 g-sha224 ads,  Up: The GNAT Library

12.98 ‘GNAT.SHA256’ (‘g-sha256.ads’)
====================================

Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB
180-3, and the HMAC-SHA256 message authentication function as described
in RFC 2104 and FIPS PUB 198.


File: gnat_rm.info,  Node: GNAT SHA384 g-sha384 ads,  Next: GNAT SHA512 g-sha512 ads,  Prev: GNAT SHA256 g-sha256 ads,  Up: The GNAT Library

12.99 ‘GNAT.SHA384’ (‘g-sha384.ads’)
====================================

Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB
180-3, and the HMAC-SHA384 message authentication function as described
in RFC 2104 and FIPS PUB 198.


File: gnat_rm.info,  Node: GNAT SHA512 g-sha512 ads,  Next: GNAT Signals g-signal ads,  Prev: GNAT SHA384 g-sha384 ads,  Up: The GNAT Library

12.100 ‘GNAT.SHA512’ (‘g-sha512.ads’)
=====================================

Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB
180-3, and the HMAC-SHA512 message authentication function as described
in RFC 2104 and FIPS PUB 198.


File: gnat_rm.info,  Node: GNAT Signals g-signal ads,  Next: GNAT Sockets g-socket ads,  Prev: GNAT SHA512 g-sha512 ads,  Up: The GNAT Library

12.101 ‘GNAT.Signals’ (‘g-signal.ads’)
======================================

Provides the ability to manipulate the blocked status of signals on
supported targets.


File: gnat_rm.info,  Node: GNAT Sockets g-socket ads,  Next: GNAT Source_Info g-souinf ads,  Prev: GNAT Signals g-signal ads,  Up: The GNAT Library

12.102 ‘GNAT.Sockets’ (‘g-socket.ads’)
======================================

A high level and portable interface to develop sockets based
applications.  This package is based on the sockets thin binding found
in ‘GNAT.Sockets.Thin’.  Currently ‘GNAT.Sockets’ is implemented on all
native GNAT ports and on VxWorks cross ports.  It is not implemented for
the LynxOS cross port.


File: gnat_rm.info,  Node: GNAT Source_Info g-souinf ads,  Next: GNAT Spelling_Checker g-speche ads,  Prev: GNAT Sockets g-socket ads,  Up: The GNAT Library

12.103 ‘GNAT.Source_Info’ (‘g-souinf.ads’)
==========================================

Provides subprograms that give access to source code information known
at compile time, such as the current file name and line number.  Also
provides subprograms yielding the date and time of the current
compilation (like the C macros ‘__DATE__’ and ‘__TIME__’)


File: gnat_rm.info,  Node: GNAT Spelling_Checker g-speche ads,  Next: GNAT Spelling_Checker_Generic g-spchge ads,  Prev: GNAT Source_Info g-souinf ads,  Up: The GNAT Library

12.104 ‘GNAT.Spelling_Checker’ (‘g-speche.ads’)
===============================================

Provides a function for determining whether one string is a plausible
near misspelling of another string.


File: gnat_rm.info,  Node: GNAT Spelling_Checker_Generic g-spchge ads,  Next: GNAT Spitbol Patterns g-spipat ads,  Prev: GNAT Spelling_Checker g-speche ads,  Up: The GNAT Library

12.105 ‘GNAT.Spelling_Checker_Generic’ (‘g-spchge.ads’)
=======================================================

Provides a generic function that can be instantiated with a string type
for determining whether one string is a plausible near misspelling of
another string.


File: gnat_rm.info,  Node: GNAT Spitbol Patterns g-spipat ads,  Next: GNAT Spitbol g-spitbo ads,  Prev: GNAT Spelling_Checker_Generic g-spchge ads,  Up: The GNAT Library

12.106 ‘GNAT.Spitbol.Patterns’ (‘g-spipat.ads’)
===============================================

A complete implementation of SNOBOL4 style pattern matching.  This is
the most elaborate of the pattern matching packages provided.  It fully
duplicates the SNOBOL4 dynamic pattern construction and matching
capabilities, using the efficient algorithm developed by Robert Dewar
for the SPITBOL system.


File: gnat_rm.info,  Node: GNAT Spitbol g-spitbo ads,  Next: GNAT Spitbol Table_Boolean g-sptabo ads,  Prev: GNAT Spitbol Patterns g-spipat ads,  Up: The GNAT Library

12.107 ‘GNAT.Spitbol’ (‘g-spitbo.ads’)
======================================

The top level package of the collection of SPITBOL-style functionality,
this package provides basic SNOBOL4 string manipulation functions, such
as Pad, Reverse, Trim, Substr capability, as well as a generic table
function useful for constructing arbitrary mappings from strings in the
style of the SNOBOL4 TABLE function.


File: gnat_rm.info,  Node: GNAT Spitbol Table_Boolean g-sptabo ads,  Next: GNAT Spitbol Table_Integer g-sptain ads,  Prev: GNAT Spitbol g-spitbo ads,  Up: The GNAT Library

12.108 ‘GNAT.Spitbol.Table_Boolean’ (‘g-sptabo.ads’)
====================================================

A library level of instantiation of ‘GNAT.Spitbol.Patterns.Table’ for
type ‘Standard.Boolean’, giving an implementation of sets of string
values.


File: gnat_rm.info,  Node: GNAT Spitbol Table_Integer g-sptain ads,  Next: GNAT Spitbol Table_VString g-sptavs ads,  Prev: GNAT Spitbol Table_Boolean g-sptabo ads,  Up: The GNAT Library

12.109 ‘GNAT.Spitbol.Table_Integer’ (‘g-sptain.ads’)
====================================================

A library level of instantiation of ‘GNAT.Spitbol.Patterns.Table’ for
type ‘Standard.Integer’, giving an implementation of maps from string to
integer values.


File: gnat_rm.info,  Node: GNAT Spitbol Table_VString g-sptavs ads,  Next: GNAT SSE g-sse ads,  Prev: GNAT Spitbol Table_Integer g-sptain ads,  Up: The GNAT Library

12.110 ‘GNAT.Spitbol.Table_VString’ (‘g-sptavs.ads’)
====================================================

A library level of instantiation of ‘GNAT.Spitbol.Patterns.Table’ for a
variable length string type, giving an implementation of general maps
from strings to strings.


File: gnat_rm.info,  Node: GNAT SSE g-sse ads,  Next: GNAT SSE Vector_Types g-ssvety ads,  Prev: GNAT Spitbol Table_VString g-sptavs ads,  Up: The GNAT Library

12.111 ‘GNAT.SSE’ (‘g-sse.ads’)
===============================

Root of a set of units aimed at offering Ada bindings to a subset of the
Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
targets.  It exposes vector component types together with a general
introduction to the binding contents and use.


File: gnat_rm.info,  Node: GNAT SSE Vector_Types g-ssvety ads,  Next: GNAT String_Hash g-strhas ads,  Prev: GNAT SSE g-sse ads,  Up: The GNAT Library

12.112 ‘GNAT.SSE.Vector_Types’ (‘g-ssvety.ads’)
===============================================

SSE vector types for use with SSE related intrinsics.


File: gnat_rm.info,  Node: GNAT String_Hash g-strhas ads,  Next: GNAT Strings g-string ads,  Prev: GNAT SSE Vector_Types g-ssvety ads,  Up: The GNAT Library

12.113 ‘GNAT.String_Hash’ (‘g-strhas.ads’)
==========================================

Provides a generic hash function working on arrays of scalars.  Both the
scalar type and the hash result type are parameters.


File: gnat_rm.info,  Node: GNAT Strings g-string ads,  Next: GNAT String_Split g-strspl ads,  Prev: GNAT String_Hash g-strhas ads,  Up: The GNAT Library

12.114 ‘GNAT.Strings’ (‘g-string.ads’)
======================================

Common String access types and related subprograms.  Basically it
defines a string access and an array of string access types.


File: gnat_rm.info,  Node: GNAT String_Split g-strspl ads,  Next: GNAT Table g-table ads,  Prev: GNAT Strings g-string ads,  Up: The GNAT Library

12.115 ‘GNAT.String_Split’ (‘g-strspl.ads’)
===========================================

Useful string manipulation routines: given a set of separators, split a
string wherever the separators appear, and provide direct access to the
resulting slices.  This package is instantiated from ‘GNAT.Array_Split’.


File: gnat_rm.info,  Node: GNAT Table g-table ads,  Next: GNAT Task_Lock g-tasloc ads,  Prev: GNAT String_Split g-strspl ads,  Up: The GNAT Library

12.116 ‘GNAT.Table’ (‘g-table.ads’)
===================================

A generic package providing a single dimension array abstraction where
the length of the array can be dynamically modified.

This package provides a facility similar to that of
‘GNAT.Dynamic_Tables’, except that this package declares a single
instance of the table type, while an instantiation of
‘GNAT.Dynamic_Tables’ creates a type that can be used to define dynamic
instances of the table.


File: gnat_rm.info,  Node: GNAT Task_Lock g-tasloc ads,  Next: GNAT Time_Stamp g-timsta ads,  Prev: GNAT Table g-table ads,  Up: The GNAT Library

12.117 ‘GNAT.Task_Lock’ (‘g-tasloc.ads’)
========================================

A very simple facility for locking and unlocking sections of code using
a single global task lock.  Appropriate for use in situations where
contention between tasks is very rarely expected.


File: gnat_rm.info,  Node: GNAT Time_Stamp g-timsta ads,  Next: GNAT Threads g-thread ads,  Prev: GNAT Task_Lock g-tasloc ads,  Up: The GNAT Library

12.118 ‘GNAT.Time_Stamp’ (‘g-timsta.ads’)
=========================================

Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS
that represents the current date and time in ISO 8601 format.  This is a
very simple routine with minimal code and there are no dependencies on
any other unit.


File: gnat_rm.info,  Node: GNAT Threads g-thread ads,  Next: GNAT Traceback g-traceb ads,  Prev: GNAT Time_Stamp g-timsta ads,  Up: The GNAT Library

12.119 ‘GNAT.Threads’ (‘g-thread.ads’)
======================================

Provides facilities for dealing with foreign threads which need to be
known by the GNAT run-time system.  Consult the documentation of this
package for further details if your program has threads that are created
by a non-Ada environment which then accesses Ada code.


File: gnat_rm.info,  Node: GNAT Traceback g-traceb ads,  Next: GNAT Traceback Symbolic g-trasym ads,  Prev: GNAT Threads g-thread ads,  Up: The GNAT Library

12.120 ‘GNAT.Traceback’ (‘g-traceb.ads’)
========================================

Provides a facility for obtaining non-symbolic traceback information,
useful in various debugging situations.


File: gnat_rm.info,  Node: GNAT Traceback Symbolic g-trasym ads,  Next: GNAT UTF_32 g-utf_32 ads,  Prev: GNAT Traceback g-traceb ads,  Up: The GNAT Library

12.121 ‘GNAT.Traceback.Symbolic’ (‘g-trasym.ads’)
=================================================


File: gnat_rm.info,  Node: GNAT UTF_32 g-utf_32 ads,  Next: GNAT UTF_32_Spelling_Checker g-u3spch ads,  Prev: GNAT Traceback Symbolic g-trasym ads,  Up: The GNAT Library

12.122 ‘GNAT.UTF_32’ (‘g-utf_32.ads’)
=====================================

This is a package intended to be used in conjunction with the
‘Wide_Character’ type in Ada 95 and the ‘Wide_Wide_Character’ type in
Ada 2005 (available in ‘GNAT’ in Ada 2005 mode).  This package contains
Unicode categorization routines, as well as lexical categorization
routines corresponding to the Ada 2005 lexical rules for identifiers and
strings, and also a lower case to upper case fold routine corresponding
to the Ada 2005 rules for identifier equivalence.


File: gnat_rm.info,  Node: GNAT UTF_32_Spelling_Checker g-u3spch ads,  Next: GNAT Wide_Spelling_Checker g-wispch ads,  Prev: GNAT UTF_32 g-utf_32 ads,  Up: The GNAT Library

12.123 ‘GNAT.UTF_32_Spelling_Checker’ (‘g-u3spch.ads’)
======================================================

Provides a function for determining whether one wide wide string is a
plausible near misspelling of another wide wide string, where the
strings are represented using the UTF_32_String type defined in
System.Wch_Cnv.


File: gnat_rm.info,  Node: GNAT Wide_Spelling_Checker g-wispch ads,  Next: GNAT Wide_String_Split g-wistsp ads,  Prev: GNAT UTF_32_Spelling_Checker g-u3spch ads,  Up: The GNAT Library

12.124 ‘GNAT.Wide_Spelling_Checker’ (‘g-wispch.ads’)
====================================================

Provides a function for determining whether one wide string is a
plausible near misspelling of another wide string.


File: gnat_rm.info,  Node: GNAT Wide_String_Split g-wistsp ads,  Next: GNAT Wide_Wide_Spelling_Checker g-zspche ads,  Prev: GNAT Wide_Spelling_Checker g-wispch ads,  Up: The GNAT Library

12.125 ‘GNAT.Wide_String_Split’ (‘g-wistsp.ads’)
================================================

Useful wide string manipulation routines: given a set of separators,
split a wide string wherever the separators appear, and provide direct
access to the resulting slices.  This package is instantiated from
‘GNAT.Array_Split’.


File: gnat_rm.info,  Node: GNAT Wide_Wide_Spelling_Checker g-zspche ads,  Next: GNAT Wide_Wide_String_Split g-zistsp ads,  Prev: GNAT Wide_String_Split g-wistsp ads,  Up: The GNAT Library

12.126 ‘GNAT.Wide_Wide_Spelling_Checker’ (‘g-zspche.ads’)
=========================================================

Provides a function for determining whether one wide wide string is a
plausible near misspelling of another wide wide string.


File: gnat_rm.info,  Node: GNAT Wide_Wide_String_Split g-zistsp ads,  Next: Interfaces C Extensions i-cexten ads,  Prev: GNAT Wide_Wide_Spelling_Checker g-zspche ads,  Up: The GNAT Library

12.127 ‘GNAT.Wide_Wide_String_Split’ (‘g-zistsp.ads’)
=====================================================

Useful wide wide string manipulation routines: given a set of
separators, split a wide wide string wherever the separators appear, and
provide direct access to the resulting slices.  This package is
instantiated from ‘GNAT.Array_Split’.


File: gnat_rm.info,  Node: Interfaces C Extensions i-cexten ads,  Next: Interfaces C Streams i-cstrea ads,  Prev: GNAT Wide_Wide_String_Split g-zistsp ads,  Up: The GNAT Library

12.128 ‘Interfaces.C.Extensions’ (‘i-cexten.ads’)
=================================================

This package contains additional C-related definitions, intended for use
with either manually or automatically generated bindings to C libraries.


File: gnat_rm.info,  Node: Interfaces C Streams i-cstrea ads,  Next: Interfaces Packed_Decimal i-pacdec ads,  Prev: Interfaces C Extensions i-cexten ads,  Up: The GNAT Library

12.129 ‘Interfaces.C.Streams’ (‘i-cstrea.ads’)
==============================================

This package is a binding for the most commonly used operations on C
streams.


File: gnat_rm.info,  Node: Interfaces Packed_Decimal i-pacdec ads,  Next: Interfaces VxWorks i-vxwork ads,  Prev: Interfaces C Streams i-cstrea ads,  Up: The GNAT Library

12.130 ‘Interfaces.Packed_Decimal’ (‘i-pacdec.ads’)
===================================================

This package provides a set of routines for conversions to and from a
packed decimal format compatible with that used on IBM mainframes.


File: gnat_rm.info,  Node: Interfaces VxWorks i-vxwork ads,  Next: Interfaces VxWorks Int_Connection i-vxinco ads,  Prev: Interfaces Packed_Decimal i-pacdec ads,  Up: The GNAT Library

12.131 ‘Interfaces.VxWorks’ (‘i-vxwork.ads’)
============================================

This package provides a limited binding to the VxWorks API. In
particular, it interfaces with the VxWorks hardware interrupt
facilities.


File: gnat_rm.info,  Node: Interfaces VxWorks Int_Connection i-vxinco ads,  Next: Interfaces VxWorks IO i-vxwoio ads,  Prev: Interfaces VxWorks i-vxwork ads,  Up: The GNAT Library

12.132 ‘Interfaces.VxWorks.Int_Connection’ (‘i-vxinco.ads’)
===========================================================

This package provides a way for users to replace the use of intConnect()
with a custom routine for installing interrupt handlers.


File: gnat_rm.info,  Node: Interfaces VxWorks IO i-vxwoio ads,  Next: System Address_Image s-addima ads,  Prev: Interfaces VxWorks Int_Connection i-vxinco ads,  Up: The GNAT Library

12.133 ‘Interfaces.VxWorks.IO’ (‘i-vxwoio.ads’)
===============================================

This package provides a binding to the ioctl (IO/Control) function of
VxWorks, defining a set of option values and function codes.  A
particular use of this package is to enable the use of Get_Immediate
under VxWorks.


File: gnat_rm.info,  Node: System Address_Image s-addima ads,  Next: System Assertions s-assert ads,  Prev: Interfaces VxWorks IO i-vxwoio ads,  Up: The GNAT Library

12.134 ‘System.Address_Image’ (‘s-addima.ads’)
==============================================

This function provides a useful debugging function that gives an
(implementation dependent) string which identifies an address.


File: gnat_rm.info,  Node: System Assertions s-assert ads,  Next: System Atomic_Counters s-atocou ads,  Prev: System Address_Image s-addima ads,  Up: The GNAT Library

12.135 ‘System.Assertions’ (‘s-assert.ads’)
===========================================

This package provides the declaration of the exception raised by an
run-time assertion failure, as well as the routine that is used
internally to raise this assertion.


File: gnat_rm.info,  Node: System Atomic_Counters s-atocou ads,  Next: System Memory s-memory ads,  Prev: System Assertions s-assert ads,  Up: The GNAT Library

12.136 ‘System.Atomic_Counters’ (‘s-atocou.ads’)
================================================

This package provides the declaration of an atomic counter type,
together with efficient routines (using hardware synchronization
primitives) for incrementing, decrementing, and testing of these
counters.  This package is implemented on most targets, including all
Alpha, AARCH64, ARM, ia64, PowerPC, SPARC V9, x86, and x86_64 platforms.


File: gnat_rm.info,  Node: System Memory s-memory ads,  Next: System Multiprocessors s-multip ads,  Prev: System Atomic_Counters s-atocou ads,  Up: The GNAT Library

12.137 ‘System.Memory’ (‘s-memory.ads’)
=======================================

This package provides the interface to the low level routines used by
the generated code for allocation and freeing storage for the default
storage pool (analogous to the C routines malloc and free).  It also
provides a reallocation interface analogous to the C routine realloc.
The body of this unit may be modified to provide alternative allocation
mechanisms for the default pool, and in addition, direct calls to this
unit may be made for low level allocation uses (for example see the body
of ‘GNAT.Tables’).


File: gnat_rm.info,  Node: System Multiprocessors s-multip ads,  Next: System Multiprocessors Dispatching_Domains s-mudido ads,  Prev: System Memory s-memory ads,  Up: The GNAT Library

12.138 ‘System.Multiprocessors’ (‘s-multip.ads’)
================================================

This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
technically an implementation-defined addition).


File: gnat_rm.info,  Node: System Multiprocessors Dispatching_Domains s-mudido ads,  Next: System Partition_Interface s-parint ads,  Prev: System Multiprocessors s-multip ads,  Up: The GNAT Library

12.139 ‘System.Multiprocessors.Dispatching_Domains’ (‘s-mudido.ads’)
====================================================================

This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
technically an implementation-defined addition).


File: gnat_rm.info,  Node: System Partition_Interface s-parint ads,  Next: System Pool_Global s-pooglo ads,  Prev: System Multiprocessors Dispatching_Domains s-mudido ads,  Up: The GNAT Library

12.140 ‘System.Partition_Interface’ (‘s-parint.ads’)
====================================================

This package provides facilities for partition interfacing.  It is used
primarily in a distribution context when using Annex E with ‘GLADE’.


File: gnat_rm.info,  Node: System Pool_Global s-pooglo ads,  Next: System Pool_Local s-pooloc ads,  Prev: System Partition_Interface s-parint ads,  Up: The GNAT Library

12.141 ‘System.Pool_Global’ (‘s-pooglo.ads’)
============================================

This package provides a storage pool that is equivalent to the default
storage pool used for access types for which no pool is specifically
declared.  It uses malloc/free to allocate/free and does not attempt to
do any automatic reclamation.


File: gnat_rm.info,  Node: System Pool_Local s-pooloc ads,  Next: System Restrictions s-restri ads,  Prev: System Pool_Global s-pooglo ads,  Up: The GNAT Library

12.142 ‘System.Pool_Local’ (‘s-pooloc.ads’)
===========================================

This package provides a storage pool that is intended for use with
locally defined access types.  It uses malloc/free for allocate/free,
and maintains a list of allocated blocks, so that all storage allocated
for the pool can be freed automatically when the pool is finalized.


File: gnat_rm.info,  Node: System Restrictions s-restri ads,  Next: System Rident s-rident ads,  Prev: System Pool_Local s-pooloc ads,  Up: The GNAT Library

12.143 ‘System.Restrictions’ (‘s-restri.ads’)
=============================================

This package provides facilities for accessing at run time the status of
restrictions specified at compile time for the partition.  Information
is available both with regard to actual restrictions specified, and with
regard to compiler determined information on which restrictions are
violated by one or more packages in the partition.


File: gnat_rm.info,  Node: System Rident s-rident ads,  Next: System Strings Stream_Ops s-ststop ads,  Prev: System Restrictions s-restri ads,  Up: The GNAT Library

12.144 ‘System.Rident’ (‘s-rident.ads’)
=======================================

This package provides definitions of the restrictions identifiers
supported by GNAT, and also the format of the restrictions provided in
package System.Restrictions.  It is not normally necessary to ‘with’
this generic package since the necessary instantiation is included in
package System.Restrictions.


File: gnat_rm.info,  Node: System Strings Stream_Ops s-ststop ads,  Next: System Unsigned_Types s-unstyp ads,  Prev: System Rident s-rident ads,  Up: The GNAT Library

12.145 ‘System.Strings.Stream_Ops’ (‘s-ststop.ads’)
===================================================

This package provides a set of stream subprograms for standard string
types.  It is intended primarily to support implicit use of such
subprograms when stream attributes are applied to string types, but the
subprograms in this package can be used directly by application
programs.


File: gnat_rm.info,  Node: System Unsigned_Types s-unstyp ads,  Next: System Wch_Cnv s-wchcnv ads,  Prev: System Strings Stream_Ops s-ststop ads,  Up: The GNAT Library

12.146 ‘System.Unsigned_Types’ (‘s-unstyp.ads’)
===============================================

This package contains definitions of standard unsigned types that
correspond in size to the standard signed types declared in Standard,
and (unlike the types in Interfaces) have corresponding names.  It also
contains some related definitions for other specialized types used by
the compiler in connection with packed array types.


File: gnat_rm.info,  Node: System Wch_Cnv s-wchcnv ads,  Next: System Wch_Con s-wchcon ads,  Prev: System Unsigned_Types s-unstyp ads,  Up: The GNAT Library

12.147 ‘System.Wch_Cnv’ (‘s-wchcnv.ads’)
========================================

This package provides routines for converting between wide and wide wide
characters and a representation as a value of type ‘Standard.String’,
using a specified wide character encoding method.  It uses definitions
in package ‘System.Wch_Con’.


File: gnat_rm.info,  Node: System Wch_Con s-wchcon ads,  Prev: System Wch_Cnv s-wchcnv ads,  Up: The GNAT Library

12.148 ‘System.Wch_Con’ (‘s-wchcon.ads’)
========================================

This package provides definitions and descriptions of the various
methods used for encoding wide characters in ordinary strings.  These
definitions are used by the package ‘System.Wch_Cnv’.


File: gnat_rm.info,  Node: Interfacing to Other Languages,  Next: Specialized Needs Annexes,  Prev: The GNAT Library,  Up: Top

13 Interfacing to Other Languages
*********************************

The facilities in Annex B of the Ada Reference Manual are fully
implemented in GNAT, and in addition, a full interface to C++ is
provided.

* Menu:

* Interfacing to C::
* Interfacing to C++::
* Interfacing to COBOL::
* Interfacing to Fortran::
* Interfacing to non-GNAT Ada code::


File: gnat_rm.info,  Node: Interfacing to C,  Next: Interfacing to C++,  Up: Interfacing to Other Languages

13.1 Interfacing to C
=====================

Interfacing to C with GNAT can use one of two approaches:

   * The types in the package ‘Interfaces.C’ may be used.

   * Standard Ada types may be used directly.  This may be less portable
     to other compilers, but will work on all GNAT compilers, which
     guarantee correspondence between the C and Ada types.

Pragma ‘Convention C’ may be applied to Ada types, but mostly has no
effect, since this is the default.  The following table shows the
correspondence between Ada scalar types and the corresponding C types.

Ada Type                     C Type
                             
----------------------------------------------------------------------------------------------------
                             
‘Integer’                    ‘int’
                             
                             
‘Short_Integer’              ‘short’
                             
                             
‘Short_Short_Integer’        ‘signed char’
                             
                             
‘Long_Integer’               ‘long’
                             
                             
‘Long_Long_Integer’          ‘long long’
                             
                             
‘Short_Float’                ‘float’
                             
                             
‘Float’                      ‘float’
                             
                             
‘Long_Float’                 ‘double’
                             
                             
‘Long_Long_Float’            This is the longest floating-point type supported by the hardware.
                             

Additionally, there are the following general correspondences between
Ada and C types:

   * Ada enumeration types map to C enumeration types directly if pragma
     ‘Convention C’ is specified, which causes them to have a length of
     32 bits, except for boolean types which map to C99 ‘bool’ and for
     which the length is 8 bits.  Without pragma ‘Convention C’, Ada
     enumeration types map to 8, 16, or 32 bits (i.e., C types ‘signed
     char’, ‘short’, ‘int’, respectively) depending on the number of
     values passed.  This is the only case in which pragma ‘Convention
     C’ affects the representation of an Ada type.

   * Ada access types map to C pointers, except for the case of pointers
     to unconstrained types in Ada, which have no direct C equivalent.

   * Ada arrays map directly to C arrays.

   * Ada records map directly to C structures.

   * Packed Ada records map to C structures where all members are bit
     fields of the length corresponding to the ‘type'Size’ value in Ada.


File: gnat_rm.info,  Node: Interfacing to C++,  Next: Interfacing to COBOL,  Prev: Interfacing to C,  Up: Interfacing to Other Languages

13.2 Interfacing to C++
=======================

The interface to C++ makes use of the following pragmas, which are
primarily intended to be constructed automatically using a binding
generator tool, although it is possible to construct them by hand.

Using these pragmas it is possible to achieve complete inter-operability
between Ada tagged types and C++ class definitions.  See *note
Implementation Defined Pragmas: 7, for more details.

‘pragma CPP_Class ([Entity =>] LOCAL_NAME)’

     The argument denotes an entity in the current declarative region
     that is declared as a tagged or untagged record type.  It indicates
     that the type corresponds to an externally declared C++ class type,
     and is to be laid out the same way that C++ would lay out the type.

     Note: Pragma ‘CPP_Class’ is currently obsolete.  It is supported
     for backward compatibility but its functionality is available using
     pragma ‘Import’ with ‘Convention’ = ‘CPP’.

‘pragma CPP_Constructor ([Entity =>] LOCAL_NAME)’

     This pragma identifies an imported function (imported in the usual
     way with pragma ‘Import’) as corresponding to a C++ constructor.

A few restrictions are placed on the use of the ‘Access’ attribute in
conjunction with subprograms subject to convention ‘CPP’: the attribute
may be used neither on primitive operations of a tagged record type with
convention ‘CPP’, imported or not, nor on subprograms imported with
pragma ‘CPP_Constructor’.

In addition, C++ exceptions are propagated and can be handled in an
‘others’ choice of an exception handler.  The corresponding Ada
occurrence has no message, and the simple name of the exception identity
contains ‘Foreign_Exception’.  Finalization and awaiting dependent tasks
works properly when such foreign exceptions are propagated.

It is also possible to import a C++ exception using the following
syntax:

     LOCAL_NAME : exception;
     pragma Import (Cpp,
       [Entity =>] LOCAL_NAME,
       [External_Name =>] static_string_EXPRESSION);

The ‘External_Name’ is the name of the C++ RTTI symbol.  You can then
cover a specific C++ exception in an exception handler.


File: gnat_rm.info,  Node: Interfacing to COBOL,  Next: Interfacing to Fortran,  Prev: Interfacing to C++,  Up: Interfacing to Other Languages

13.3 Interfacing to COBOL
=========================

Interfacing to COBOL is achieved as described in section B.4 of the Ada
Reference Manual.


File: gnat_rm.info,  Node: Interfacing to Fortran,  Next: Interfacing to non-GNAT Ada code,  Prev: Interfacing to COBOL,  Up: Interfacing to Other Languages

13.4 Interfacing to Fortran
===========================

Interfacing to Fortran is achieved as described in section B.5 of the
Ada Reference Manual.  The pragma ‘Convention Fortran’, applied to a
multi-dimensional array causes the array to be stored in column-major
order as required for convenient interface to Fortran.


File: gnat_rm.info,  Node: Interfacing to non-GNAT Ada code,  Prev: Interfacing to Fortran,  Up: Interfacing to Other Languages

13.5 Interfacing to non-GNAT Ada code
=====================================

It is possible to specify the convention ‘Ada’ in a pragma ‘Import’ or
pragma ‘Export’.  However this refers to the calling conventions used by
GNAT, which may or may not be similar enough to those used by some other
Ada 83 / Ada 95 / Ada 2005 compiler to allow interoperation.

If arguments types are kept simple, and if the foreign compiler
generally follows system calling conventions, then it may be possible to
integrate files compiled by other Ada compilers, provided that the
elaboration issues are adequately addressed (for example by eliminating
the need for any load time elaboration).

In particular, GNAT running on VMS is designed to be highly compatible
with the DEC Ada 83 compiler, so this is one case in which it is
possible to import foreign units of this type, provided that the data
items passed are restricted to simple scalar values or simple record
types without variants, or simple array types with fixed bounds.


File: gnat_rm.info,  Node: Specialized Needs Annexes,  Next: Implementation of Specific Ada Features,  Prev: Interfacing to Other Languages,  Up: Top

14 Specialized Needs Annexes
****************************

Ada 95, Ada 2005, and Ada 2012 define a number of Specialized Needs
Annexes, which are not required in all implementations.  However, as
described in this chapter, GNAT implements all of these annexes:

'Systems Programming (Annex C)'

     The Systems Programming Annex is fully implemented.

'Real-Time Systems (Annex D)'

     The Real-Time Systems Annex is fully implemented.

'Distributed Systems (Annex E)'

     Stub generation is fully implemented in the GNAT compiler.  In
     addition, a complete compatible PCS is available as part of the
     GLADE system, a separate product.  When the two products are used
     in conjunction, this annex is fully implemented.

'Information Systems (Annex F)'

     The Information Systems annex is fully implemented.

'Numerics (Annex G)'

     The Numerics Annex is fully implemented.

'Safety and Security / High-Integrity Systems (Annex H)'

     The Safety and Security Annex (termed the High-Integrity Systems
     Annex in Ada 2005) is fully implemented.


File: gnat_rm.info,  Node: Implementation of Specific Ada Features,  Next: Implementation of Ada 2012 Features,  Prev: Specialized Needs Annexes,  Up: Top

15 Implementation of Specific Ada Features
******************************************

This chapter describes the GNAT implementation of several Ada language
facilities.

* Menu:

* Machine Code Insertions::
* GNAT Implementation of Tasking::
* GNAT Implementation of Shared Passive Packages::
* Code Generation for Array Aggregates::
* The Size of Discriminated Records with Default Discriminants::
* Image Values For Nonscalar Types::
* Strict Conformance to the Ada Reference Manual::


File: gnat_rm.info,  Node: Machine Code Insertions,  Next: GNAT Implementation of Tasking,  Up: Implementation of Specific Ada Features

15.1 Machine Code Insertions
============================

Package ‘Machine_Code’ provides machine code support as described in the
Ada Reference Manual in two separate forms:

   * Machine code statements, consisting of qualified expressions that
     fit the requirements of RM section 13.8.

   * An intrinsic callable procedure, providing an alternative mechanism
     of including machine instructions in a subprogram.

The two features are similar, and both are closely related to the
mechanism provided by the asm instruction in the GNU C compiler.  Full
understanding and use of the facilities in this package requires
understanding the asm instruction, see the section on Extended Asm in
‘Using_the_GNU_Compiler_Collection_(GCC)’.

Calls to the function ‘Asm’ and the procedure ‘Asm’ have identical
semantic restrictions and effects as described below.  Both are provided
so that the procedure call can be used as a statement, and the function
call can be used to form a code_statement.

Consider this C ‘asm’ instruction:

     asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));

The equivalent can be written for GNAT as:

     Asm ("fsinx %1 %0",
          My_Float'Asm_Output ("=f", result),
          My_Float'Asm_Input  ("f",  angle));

The first argument to ‘Asm’ is the assembler template, and is identical
to what is used in GNU C. This string must be a static expression.  The
second argument is the output operand list.  It is either a single
‘Asm_Output’ attribute reference, or a list of such references enclosed
in parentheses (technically an array aggregate of such references).

The ‘Asm_Output’ attribute denotes a function that takes two parameters.
The first is a string, the second is the name of a variable of the type
designated by the attribute prefix.  The first (string) argument is
required to be a static expression and designates the constraint (see
the section on Constraints in ‘Using_the_GNU_Compiler_Collection_(GCC)’)
for the parameter; e.g., what kind of register is required.  The second
argument is the variable to be written or updated with the result.  The
possible values for constraint are the same as those used in the RTL,
and are dependent on the configuration file used to build the GCC back
end.  If there are no output operands, then this argument may either be
omitted, or explicitly given as ‘No_Output_Operands’.  No support is
provided for GNU C’s symbolic names for output parameters.

The second argument of ‘my_float'Asm_Output’ functions as though it were
an ‘out’ parameter, which is a little curious, but all names have the
form of expressions, so there is no syntactic irregularity, even though
normally functions would not be permitted ‘out’ parameters.  The third
argument is the list of input operands.  It is either a single
‘Asm_Input’ attribute reference, or a list of such references enclosed
in parentheses (technically an array aggregate of such references).

The ‘Asm_Input’ attribute denotes a function that takes two parameters.
The first is a string, the second is an expression of the type
designated by the prefix.  The first (string) argument is required to be
a static expression, and is the constraint for the parameter, (e.g.,
what kind of register is required).  The second argument is the value to
be used as the input argument.  The possible values for the constraint
are the same as those used in the RTL, and are dependent on the
configuration file used to built the GCC back end.  No support is
provided for GNU C’s symbolic names for input parameters.

If there are no input operands, this argument may either be omitted, or
explicitly given as ‘No_Input_Operands’.  The fourth argument, not
present in the above example, is a list of register names, called the
'clobber' argument.  This argument, if given, must be a static string
expression, and is a space or comma separated list of names of registers
that must be considered destroyed as a result of the ‘Asm’ call.  If
this argument is the null string (the default value), then the code
generator assumes that no additional registers are destroyed.  In
addition to registers, the special clobbers ‘memory’ and ‘cc’ as
described in the GNU C docs are both supported.

The fifth argument, not present in the above example, called the
'volatile' argument, is by default ‘False’.  It can be set to the
literal value ‘True’ to indicate to the code generator that all
optimizations with respect to the instruction specified should be
suppressed, and in particular an instruction that has outputs will still
be generated, even if none of the outputs are used.  See
‘Using_the_GNU_Compiler_Collection_(GCC)’ for the full description.
Generally it is strongly advisable to use Volatile for any ASM statement
that is missing either input or output operands or to avoid unwanted
optimizations.  A warning is generated if this advice is not followed.

No support is provided for GNU C’s ‘asm goto’ feature.

The ‘Asm’ subprograms may be used in two ways.  First the procedure
forms can be used anywhere a procedure call would be valid, and
correspond to what the RM calls ‘intrinsic’ routines.  Such calls can be
used to intersperse machine instructions with other Ada statements.
Second, the function forms, which return a dummy value of the limited
private type ‘Asm_Insn’, can be used in code statements, and indeed this
is the only context where such calls are allowed.  Code statements
appear as aggregates of the form:

     Asm_Insn'(Asm (...));
     Asm_Insn'(Asm_Volatile (...));

In accordance with RM rules, such code statements are allowed only
within subprograms whose entire body consists of such statements.  It is
not permissible to intermix such statements with other Ada statements.

Typically the form using intrinsic procedure calls is more convenient
and more flexible.  The code statement form is provided to meet the RM
suggestion that such a facility should be made available.  The following
is the exact syntax of the call to ‘Asm’.  As usual, if named notation
is used, the arguments may be given in arbitrary order, following the
normal rules for use of positional and named arguments:

     ASM_CALL ::= Asm (
                      [Template =>] static_string_EXPRESSION
                    [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
                    [,[Inputs   =>] INPUT_OPERAND_LIST       ]
                    [,[Clobber  =>] static_string_EXPRESSION ]
                    [,[Volatile =>] static_boolean_EXPRESSION] )

     OUTPUT_OPERAND_LIST ::=
       [PREFIX.]No_Output_Operands
     | OUTPUT_OPERAND_ATTRIBUTE
     | (OUTPUT_OPERAND_ATTRIBUTE {,OUTPUT_OPERAND_ATTRIBUTE})

     OUTPUT_OPERAND_ATTRIBUTE ::=
       SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)

     INPUT_OPERAND_LIST ::=
       [PREFIX.]No_Input_Operands
     | INPUT_OPERAND_ATTRIBUTE
     | (INPUT_OPERAND_ATTRIBUTE {,INPUT_OPERAND_ATTRIBUTE})

     INPUT_OPERAND_ATTRIBUTE ::=
       SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)

The identifiers ‘No_Input_Operands’ and ‘No_Output_Operands’ are
declared in the package ‘Machine_Code’ and must be referenced according
to normal visibility rules.  In particular if there is no ‘use’ clause
for this package, then appropriate package name qualification is
required.


File: gnat_rm.info,  Node: GNAT Implementation of Tasking,  Next: GNAT Implementation of Shared Passive Packages,  Prev: Machine Code Insertions,  Up: Implementation of Specific Ada Features

15.2 GNAT Implementation of Tasking
===================================

This chapter outlines the basic GNAT approach to tasking (in particular,
a multi-layered library for portability) and discusses issues related to
compliance with the Real-Time Systems Annex.

* Menu:

* Mapping Ada Tasks onto the Underlying Kernel Threads::
* Ensuring Compliance with the Real-Time Annex::
* Support for Locking Policies::


File: gnat_rm.info,  Node: Mapping Ada Tasks onto the Underlying Kernel Threads,  Next: Ensuring Compliance with the Real-Time Annex,  Up: GNAT Implementation of Tasking

15.2.1 Mapping Ada Tasks onto the Underlying Kernel Threads
-----------------------------------------------------------

GNAT’s run-time support comprises two layers:

   * GNARL (GNAT Run-time Layer)

   * GNULL (GNAT Low-level Library)

In GNAT, Ada’s tasking services rely on a platform and OS independent
layer known as GNARL. This code is responsible for implementing the
correct semantics of Ada’s task creation, rendezvous, protected
operations etc.

GNARL decomposes Ada’s tasking semantics into simpler lower level
operations such as create a thread, set the priority of a thread, yield,
create a lock, lock/unlock, etc.  The spec for these low-level
operations constitutes GNULLI, the GNULL Interface.  This interface is
directly inspired from the POSIX real-time API.

If the underlying executive or OS implements the POSIX standard
faithfully, the GNULL Interface maps as is to the services offered by
the underlying kernel.  Otherwise, some target dependent glue code maps
the services offered by the underlying kernel to the semantics expected
by GNARL.

Whatever the underlying OS (VxWorks, UNIX, Windows, etc.)  the key point
is that each Ada task is mapped on a thread in the underlying kernel.
For example, in the case of VxWorks, one Ada task = one VxWorks task.

In addition Ada task priorities map onto the underlying thread
priorities.  Mapping Ada tasks onto the underlying kernel threads has
several advantages:

   * The underlying scheduler is used to schedule the Ada tasks.  This
     makes Ada tasks as efficient as kernel threads from a scheduling
     standpoint.

   * Interaction with code written in C containing threads is eased
     since at the lowest level Ada tasks and C threads map onto the same
     underlying kernel concept.

   * When an Ada task is blocked during I/O the remaining Ada tasks are
     able to proceed.

   * On multiprocessor systems Ada tasks can execute in parallel.

Some threads libraries offer a mechanism to fork a new process, with the
child process duplicating the threads from the parent.  GNAT does not
support this functionality when the parent contains more than one task.


File: gnat_rm.info,  Node: Ensuring Compliance with the Real-Time Annex,  Next: Support for Locking Policies,  Prev: Mapping Ada Tasks onto the Underlying Kernel Threads,  Up: GNAT Implementation of Tasking

15.2.2 Ensuring Compliance with the Real-Time Annex
---------------------------------------------------

Although mapping Ada tasks onto the underlying threads has significant
advantages, it does create some complications when it comes to
respecting the scheduling semantics specified in the real-time annex
(Annex D).

For instance the Annex D requirement for the ‘FIFO_Within_Priorities’
scheduling policy states:

     'When the active priority of a ready task that is not running
     changes, or the setting of its base priority takes effect, the task
     is removed from the ready queue for its old active priority and is
     added at the tail of the ready queue for its new active priority,
     except in the case where the active priority is lowered due to the
     loss of inherited priority, in which case the task is added at the
     head of the ready queue for its new active priority.'

While most kernels do put tasks at the end of the priority queue when a
task changes its priority, (which respects the main
FIFO_Within_Priorities requirement), almost none keep a thread at the
beginning of its priority queue when its priority drops from the loss of
inherited priority.

As a result most vendors have provided incomplete Annex D
implementations.

The GNAT run-time, has a nice cooperative solution to this problem which
ensures that accurate FIFO_Within_Priorities semantics are respected.

The principle is as follows.  When an Ada task T is about to start
running, it checks whether some other Ada task R with the same priority
as T has been suspended due to the loss of priority inheritance.  If
this is the case, T yields and is placed at the end of its priority
queue.  When R arrives at the front of the queue it executes.

Note that this simple scheme preserves the relative order of the tasks
that were ready to execute in the priority queue where R has been placed
at the end.


File: gnat_rm.info,  Node: Support for Locking Policies,  Prev: Ensuring Compliance with the Real-Time Annex,  Up: GNAT Implementation of Tasking

15.2.3 Support for Locking Policies
-----------------------------------

This section specifies which policies specified by pragma Locking_Policy
are supported on which platforms.

GNAT supports the standard ‘Ceiling_Locking’ policy, and the
implementation defined ‘Inheritance_Locking’ and
‘Concurrent_Readers_Locking’ policies.

‘Ceiling_Locking’ is supported on all platforms if the operating system
supports it.  In particular, ‘Ceiling_Locking’ is not supported on
VxWorks.  ‘Inheritance_Locking’ is supported on Linux, Darwin (Mac OS
X), LynxOS 178, and VxWorks.  ‘Concurrent_Readers_Locking’ is supported
on Linux.

Notes about ‘Ceiling_Locking’ on Linux: If the process is running as
‘root’, ceiling locking is used.  If the capabilities facility is
installed (“sudo apt-get –assume-yes install libcap-dev” on Ubuntu, for
example), and the program is linked against that library (“-largs
-lcap”), and the executable file has the cap_sys_nice capability (“sudo
/sbin/setcap cap_sys_nice=ep executable_file_name”), then ceiling
locking is used.  Otherwise, the ‘Ceiling_Locking’ policy is ignored.


File: gnat_rm.info,  Node: GNAT Implementation of Shared Passive Packages,  Next: Code Generation for Array Aggregates,  Prev: GNAT Implementation of Tasking,  Up: Implementation of Specific Ada Features

15.3 GNAT Implementation of Shared Passive Packages
===================================================

GNAT fully implements the pragma ‘Shared_Passive’ for the purpose of
designating shared passive packages.  This allows the use of passive
partitions in the context described in the Ada Reference Manual; i.e.,
for communication between separate partitions of a distributed
application using the features in Annex E.

However, the implementation approach used by GNAT provides for more
extensive usage as follows:

'Communication between separate programs'

     This allows separate programs to access the data in passive
     partitions, using protected objects for synchronization where
     needed.  The only requirement is that the two programs have a
     common shared file system.  It is even possible for programs
     running on different machines with different architectures (e.g.,
     different endianness) to communicate via the data in a passive
     partition.

'Persistence between program runs'

     The data in a passive package can persist from one run of a program
     to another, so that a later program sees the final values stored by
     a previous run of the same program.

The implementation approach used is to store the data in files.  A
separate stream file is created for each object in the package, and an
access to an object causes the corresponding file to be read or written.

The environment variable ‘SHARED_MEMORY_DIRECTORY’ should be set to the
directory to be used for these files.  The files in this directory have
names that correspond to their fully qualified names.  For example, if
we have the package

     package X is
       pragma Shared_Passive (X);
       Y : Integer;
       Z : Float;
     end X;

and the environment variable is set to ‘/stemp/’, then the files created
will have the names:

     /stemp/x.y
     /stemp/x.z

These files are created when a value is initially written to the object,
and the files are retained until manually deleted.  This provides the
persistence semantics.  If no file exists, it means that no partition
has assigned a value to the variable; in this case the initial value
declared in the package will be used.  This model ensures that there are
no issues in synchronizing the elaboration process, since elaboration of
passive packages elaborates the initial values, but does not create the
files.

The files are written using normal ‘Stream_IO’ access.  If you want to
be able to communicate between programs or partitions running on
different architectures, then you should use the XDR versions of the
stream attribute routines, since these are architecture independent.

If active synchronization is required for access to the variables in the
shared passive package, then as described in the Ada Reference Manual,
the package may contain protected objects used for this purpose.  In
this case a lock file (whose name is ‘___lock’, with three underscores)
is created in the shared memory directory.

This is used to provide the required locking semantics for proper
protected object synchronization.


File: gnat_rm.info,  Node: Code Generation for Array Aggregates,  Next: The Size of Discriminated Records with Default Discriminants,  Prev: GNAT Implementation of Shared Passive Packages,  Up: Implementation of Specific Ada Features

15.4 Code Generation for Array Aggregates
=========================================

Aggregates have a rich syntax and allow the user to specify the values
of complex data structures by means of a single construct.  As a result,
the code generated for aggregates can be quite complex and involve
loops, case statements and multiple assignments.  In the simplest cases,
however, the compiler will recognize aggregates whose components and
constraints are fully static, and in those cases the compiler will
generate little or no executable code.  The following is an outline of
the code that GNAT generates for various aggregate constructs.  For
further details, you will find it useful to examine the output produced
by the -gnatG flag to see the expanded source that is input to the code
generator.  You may also want to examine the assembly code generated at
various levels of optimization.

The code generated for aggregates depends on the context, the component
values, and the type.  In the context of an object declaration the code
generated is generally simpler than in the case of an assignment.  As a
general rule, static component values and static subtypes also lead to
simpler code.

* Menu:

* Static constant aggregates with static bounds::
* Constant aggregates with unconstrained nominal types::
* Aggregates with static bounds::
* Aggregates with nonstatic bounds::
* Aggregates in assignment statements::


File: gnat_rm.info,  Node: Static constant aggregates with static bounds,  Next: Constant aggregates with unconstrained nominal types,  Up: Code Generation for Array Aggregates

15.4.1 Static constant aggregates with static bounds
----------------------------------------------------

For the declarations:

     type One_Dim is array (1..10) of integer;
     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);

GNAT generates no executable code: the constant ar0 is placed in static
memory.  The same is true for constant aggregates with named
associations:

     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
     Cr3 : constant One_Dim := (others => 7777);

The same is true for multidimensional constant arrays such as:

     type two_dim is array (1..3, 1..3) of integer;
     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));

The same is true for arrays of one-dimensional arrays: the following are
static:

     type ar1b  is array (1..3) of boolean;
     type ar_ar is array (1..3) of ar1b;
     None  : constant ar1b := (others => false);     --  fully static
     None2 : constant ar_ar := (1..3 => None);       --  fully static

However, for multidimensional aggregates with named associations, GNAT
will generate assignments and loops, even if all associations are
static.  The following two declarations generate a loop for the first
dimension, and individual component assignments for the second
dimension:

     Zero1: constant two_dim := (1..3 => (1..3 => 0));
     Zero2: constant two_dim := (others => (others => 0));


File: gnat_rm.info,  Node: Constant aggregates with unconstrained nominal types,  Next: Aggregates with static bounds,  Prev: Static constant aggregates with static bounds,  Up: Code Generation for Array Aggregates

15.4.2 Constant aggregates with unconstrained nominal types
-----------------------------------------------------------

In such cases the aggregate itself establishes the subtype, so that
associations with ‘others’ cannot be used.  GNAT determines the bounds
for the actual subtype of the aggregate, and allocates the aggregate
statically as well.  No code is generated for the following:

     type One_Unc is array (natural range <>) of integer;
     Cr_Unc : constant One_Unc := (12,24,36);


File: gnat_rm.info,  Node: Aggregates with static bounds,  Next: Aggregates with nonstatic bounds,  Prev: Constant aggregates with unconstrained nominal types,  Up: Code Generation for Array Aggregates

15.4.3 Aggregates with static bounds
------------------------------------

In all previous examples the aggregate was the initial (and immutable)
value of a constant.  If the aggregate initializes a variable, then code
is generated for it as a combination of individual assignments and loops
over the target object.  The declarations

     Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
     Cr_Var2 : One_Dim := (others > -1);

generate the equivalent of

     Cr_Var1 (1) := 2;
     Cr_Var1 (2) := 3;
     Cr_Var1 (3) := 5;
     Cr_Var1 (4) := 11;

     for I in Cr_Var2'range loop
        Cr_Var2 (I) := -1;
     end loop;


File: gnat_rm.info,  Node: Aggregates with nonstatic bounds,  Next: Aggregates in assignment statements,  Prev: Aggregates with static bounds,  Up: Code Generation for Array Aggregates

15.4.4 Aggregates with nonstatic bounds
---------------------------------------

If the bounds of the aggregate are not statically compatible with the
bounds of the nominal subtype of the target, then constraint checks have
to be generated on the bounds.  For a multidimensional array, constraint
checks may have to be applied to sub-arrays individually, if they do not
have statically compatible subtypes.


File: gnat_rm.info,  Node: Aggregates in assignment statements,  Prev: Aggregates with nonstatic bounds,  Up: Code Generation for Array Aggregates

15.4.5 Aggregates in assignment statements
------------------------------------------

In general, aggregate assignment requires the construction of a
temporary, and a copy from the temporary to the target of the
assignment.  This is because it is not always possible to convert the
assignment into a series of individual component assignments.  For
example, consider the simple case:

     A := (A(2), A(1));

This cannot be converted into:

     A(1) := A(2);
     A(2) := A(1);

So the aggregate has to be built first in a separate location, and then
copied into the target.  GNAT recognizes simple cases where this
intermediate step is not required, and the assignments can be performed
in place, directly into the target.  The following sufficient criteria
are applied:

   * The bounds of the aggregate are static, and the associations are
     static.

   * The components of the aggregate are static constants, names of
     simple variables that are not renamings, or expressions not
     involving indexed components whose operands obey these rules.

If any of these conditions are violated, the aggregate will be built in
a temporary (created either by the front-end or the code generator) and
then that temporary will be copied onto the target.


File: gnat_rm.info,  Node: The Size of Discriminated Records with Default Discriminants,  Next: Image Values For Nonscalar Types,  Prev: Code Generation for Array Aggregates,  Up: Implementation of Specific Ada Features

15.5 The Size of Discriminated Records with Default Discriminants
=================================================================

If a discriminated type ‘T’ has discriminants with default values, it is
possible to declare an object of this type without providing an explicit
constraint:

     type Size is range 1..100;

     type Rec (D : Size := 15) is record
        Name : String (1..D);
     end T;

     Word : Rec;

Such an object is said to be 'unconstrained'.  The discriminant of the
object can be modified by a full assignment to the object, as long as it
preserves the relation between the value of the discriminant, and the
value of the components that depend on it:

     Word := (3, "yes");

     Word := (5, "maybe");

     Word := (5, "no"); -- raises Constraint_Error

In order to support this behavior efficiently, an unconstrained object
is given the maximum size that any value of the type requires.  In the
case above, ‘Word’ has storage for the discriminant and for a ‘String’
of length 100.  It is important to note that unconstrained objects do
not require dynamic allocation.  It would be an improper implementation
to place on the heap those components whose size depends on
discriminants.  (This improper implementation was used by some Ada83
compilers, where the ‘Name’ component above would have been stored as a
pointer to a dynamic string).  Following the principle that dynamic
storage management should never be introduced implicitly, an Ada
compiler should reserve the full size for an unconstrained declared
object, and place it on the stack.

This maximum size approach has been a source of surprise to some users,
who expect the default values of the discriminants to determine the size
reserved for an unconstrained object: “If the default is 15, why should
the object occupy a larger size?” The answer, of course, is that the
discriminant may be later modified, and its full range of values must be
taken into account.  This is why the declaration:

     type Rec (D : Positive := 15) is record
        Name : String (1..D);
     end record;

     Too_Large : Rec;

is flagged by the compiler with a warning: an attempt to create
‘Too_Large’ will raise ‘Storage_Error’, because the required size
includes ‘Positive'Last’ bytes.  As the first example indicates, the
proper approach is to declare an index type of ‘reasonable’ range so
that unconstrained objects are not too large.

One final wrinkle: if the object is declared to be ‘aliased’, or if it
is created in the heap by means of an allocator, then it is 'not'
unconstrained: it is constrained by the default values of the
discriminants, and those values cannot be modified by full assignment.
This is because in the presence of aliasing all views of the object
(which may be manipulated by different tasks, say) must be consistent,
so it is imperative that the object, once created, remain invariant.


File: gnat_rm.info,  Node: Image Values For Nonscalar Types,  Next: Strict Conformance to the Ada Reference Manual,  Prev: The Size of Discriminated Records with Default Discriminants,  Up: Implementation of Specific Ada Features

15.6 Image Values For Nonscalar Types
=====================================

Ada 2022 defines the Image, Wide_Image, and Wide_Wide image attributes
for nonscalar types; earlier Ada versions defined these attributes only
for scalar types.  Ada RM 4.10 provides some general guidance regarding
the default implementation of these attributes and the GNAT compiler
follows that guidance.  However, beyond that the precise details of the
image text generated in these cases are deliberately not documented and
are subject to change.  In particular, users should not rely on
formatting details (such as spaces or line breaking), record field
order, image values for access types, image values for types that have
ancestor or subcomponent types declared in non-Ada2022 code, image
values for predefined types, or the compiler’s choices regarding the
implementation permissions described in Ada RM 4.10.  This list is not
intended to be exhaustive.  If more precise control of image text is
required for some type T, then T’Put_Image should be explicitly
specified.


File: gnat_rm.info,  Node: Strict Conformance to the Ada Reference Manual,  Prev: Image Values For Nonscalar Types,  Up: Implementation of Specific Ada Features

15.7 Strict Conformance to the Ada Reference Manual
===================================================

The dynamic semantics defined by the Ada Reference Manual impose a set
of run-time checks to be generated.  By default, the GNAT compiler will
insert many run-time checks into the compiled code, including most of
those required by the Ada Reference Manual.  However, there are two
checks that are not enabled in the default mode for efficiency reasons:
checks for access before elaboration on subprogram calls, and stack
overflow checking (most operating systems do not perform this check by
default).

Strict conformance to the Ada Reference Manual can be achieved by adding
two compiler options for dynamic checks for access-before-elaboration on
subprogram calls and generic instantiations ('-gnatE'), and stack
overflow checking ('-fstack-check').

Note that the result of a floating point arithmetic operation in
overflow and invalid situations, when the ‘Machine_Overflows’ attribute
of the result type is ‘False’, is to generate IEEE NaN and infinite
values.  This is the case for machines compliant with the IEEE
floating-point standard, but on machines that are not fully compliant
with this standard, such as Alpha, the '-mieee' compiler flag must be
used for achieving IEEE confirming behavior (although at the cost of a
significant performance penalty), so infinite and NaN values are
properly generated.


File: gnat_rm.info,  Node: Implementation of Ada 2012 Features,  Next: GNAT language extensions,  Prev: Implementation of Specific Ada Features,  Up: Top

16 Implementation of Ada 2012 Features
**************************************

This chapter contains a complete list of Ada 2012 features that have
been implemented.  Generally, these features are only available if the
'-gnat12' (Ada 2012 features enabled) option is set, which is the
default behavior, or if the configuration pragma ‘Ada_2012’ is used.

However, new pragmas, attributes, and restrictions are unconditionally
available, since the Ada 95 standard allows the addition of new pragmas,
attributes, and restrictions (there are exceptions, which are documented
in the individual descriptions), and also certain packages were made
available in earlier versions of Ada.

An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
This date shows the implementation date of the feature.  Any wavefront
subsequent to this date will contain the indicated feature, as will any
subsequent releases.  A date of 0000-00-00 means that GNAT has always
implemented the feature, or implemented it as soon as it appeared as a
binding interpretation.

Each feature corresponds to an Ada Issue (‘AI’) approved by the Ada
standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
The features are ordered based on the relevant sections of the Ada
Reference Manual (“RM”).  When a given AI relates to multiple points in
the RM, the earliest is used.

A complete description of the AIs may be found in
‘http://www.ada-auth.org/ai05-summary.html’.

   * 'AI-0176 Quantified expressions (2010-09-29)'

     Both universally and existentially quantified expressions are
     implemented.  They use the new syntax for iterators proposed in
     AI05-139-2, as well as the standard Ada loop syntax.

     RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)

   * 'AI-0079 Allow other_format characters in source (2010-07-10)'

     Wide characters in the unicode category 'other_format' are now
     allowed in source programs between tokens, but not within a token
     such as an identifier.

     RM References: 2.01 (4/2) 2.02 (7)

   * 'AI-0091 Do not allow other_format in identifiers (0000-00-00)'

     Wide characters in the unicode category 'other_format' are not
     permitted within an identifier, since this can be a security
     problem.  The error message for this case has been improved to be
     more specific, but GNAT has never allowed such characters to appear
     in identifiers.

     RM References: 2.03 (3.1/2) 2.03 (4/2) 2.03 (5/2) 2.03 (5.1/2) 2.03
     (5.2/2) 2.03 (5.3/2) 2.09 (2/2)

   * 'AI-0100 Placement of pragmas (2010-07-01)'

     This AI is an earlier version of AI-163.  It simplifies the rules
     for legal placement of pragmas.  In the case of lists that allow
     pragmas, if the list may have no elements, then the list may
     consist solely of pragmas.

     RM References: 2.08 (7)

   * 'AI-0163 Pragmas in place of null (2010-07-01)'

     A statement sequence may be composed entirely of pragmas.  It is no
     longer necessary to add a dummy ‘null’ statement to make the
     sequence legal.

     RM References: 2.08 (7) 2.08 (16)

   * 'AI-0080 ‘View of’ not needed if clear from context (0000-00-00)'

     This is an editorial change only, described as non-testable in the
     AI.

     RM References: 3.01 (7)

   * 'AI-0183 Aspect specifications (2010-08-16)'

     Aspect specifications have been fully implemented except for pre
     and post- conditions, and type invariants, which have their own
     separate AI’s.  All forms of declarations listed in the AI are
     supported.  The following is a list of the aspects supported (with
     GNAT implementation aspects marked)

Supported Aspect                         Source
                                         
---------------------------------------------------------
                                         
‘Ada_2005’                               – GNAT
                                         
                                         
‘Ada_2012’                               – GNAT
                                         
                                         
‘Address’

‘Alignment’

‘Atomic’

‘Atomic_Components’

‘Bit_Order’

‘Component_Size’

‘Contract_Cases’                         – GNAT
                                         
                                         
‘Discard_Names’

‘External_Tag’

‘Favor_Top_Level’                        – GNAT
                                         
                                         
‘Inline’

‘Inline_Always’                          – GNAT
                                         
                                         
‘Invariant’                              – GNAT
                                         
                                         
‘Machine_Radix’

‘No_Return’

‘Object_Size’                            – GNAT
                                         
                                         
‘Pack’

‘Persistent_BSS’                         – GNAT
                                         
                                         
‘Post’

‘Pre’

‘Predicate’

‘Preelaborable_Initialization’

‘Pure_Function’                          – GNAT
                                         
                                         
‘Remote_Access_Type’                     – GNAT
                                         
                                         
‘Shared’                                 – GNAT
                                         
                                         
‘Size’

‘Storage_Pool’

‘Storage_Size’

‘Stream_Size’

‘Suppress’

‘Suppress_Debug_Info’                    – GNAT
                                         
                                         
‘Test_Case’                              – GNAT
                                         
                                         
‘Thread_Local_Storage’                   – GNAT
                                         
                                         
‘Type_Invariant’

‘Unchecked_Union’

‘Universal_Aliasing’                     – GNAT
                                         
                                         
‘Unmodified’                             – GNAT
                                         
                                         
‘Unreferenced’                           – GNAT
                                         
                                         
‘Unreferenced_Objects’                   – GNAT
                                         
                                         
‘Unsuppress’

‘Value_Size’                             – GNAT
                                         
                                         
‘Volatile’

‘Volatile_Components’

‘Warnings’                               – GNAT
                                         

     Note that for aspects with an expression, e.g.  ‘Size’, the
     expression is treated like a default expression (visibility is
     analyzed at the point of occurrence of the aspect, but evaluation
     of the expression occurs at the freeze point of the entity
     involved).

     RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
     3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
     (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2) 9.05.02
     (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2) 12.06
     (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1) 13.03.01
     (0)

   * 'AI-0128 Inequality is a primitive operation (0000-00-00)'

     If an equality operator (“=”) is declared for a type, then the
     implicitly declared inequality operator (“/=”) is a primitive
     operation of the type.  This is the only reasonable interpretation,
     and is the one always implemented by GNAT, but the RM was not
     entirely clear in making this point.

     RM References: 3.02.03 (6) 6.06 (6)

   * 'AI-0003 Qualified expressions as names (2010-07-11)'

     In Ada 2012, a qualified expression is considered to be
     syntactically a name, meaning that constructs such as ‘A'(F(X)).B’
     are now legal.  This is useful in disambiguating some cases of
     overloading.

     RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3) 5.04
     (7)

   * 'AI-0120 Constant instance of protected object (0000-00-00)'

     This is an RM editorial change only.  The section that lists
     objects that are constant failed to include the current instance of
     a protected object within a protected function.  This has always
     been treated as a constant in GNAT.

     RM References: 3.03 (21)

   * 'AI-0008 General access to constrained objects (0000-00-00)'

     The wording in the RM implied that if you have a general access to
     a constrained object, it could be used to modify the discriminants.
     This was obviously not intended.  ‘Constraint_Error’ should be
     raised, and GNAT has always done so in this situation.

     RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17)
     8.05.01 (5/2)

   * 'AI-0093 Additional rules use immutably limited (0000-00-00)'

     This is an editorial change only, to make more widespread use of
     the Ada 2012 ‘immutably limited’.

     RM References: 3.03 (23.4/3)

   * 'AI-0096 Deriving from formal private types (2010-07-20)'

     In general it is illegal for a type derived from a formal limited
     type to be nonlimited.  This AI makes an exception to this rule:
     derivation is legal if it appears in the private part of the
     generic, and the formal type is not tagged.  If the type is tagged,
     the legality check must be applied to the private part of the
     package.

     RM References: 3.04 (5.1/2) 6.02 (7)

   * 'AI-0181 Soft hyphen is a non-graphic character (2010-07-23)'

     From Ada 2005 on, soft hyphen is considered a non-graphic
     character, which means that it has a special name (‘SOFT_HYPHEN’)
     in conjunction with the ‘Image’ and ‘Value’ attributes for the
     character types.  Strictly speaking this is an inconsistency with
     Ada 95, but in practice the use of these attributes is so obscure
     that it will not cause problems.

     RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)

   * 'AI-0182 Additional forms for' ‘Character'Value’ '(0000-00-00)'

     This AI allows ‘Character'Value’ to accept the string ‘'?'’ where
     ‘?’ is any character including non-graphic control characters.
     GNAT has always accepted such strings.  It also allows strings such
     as ‘HEX_00000041’ to be accepted, but GNAT does not take advantage
     of this permission and raises ‘Constraint_Error’, as is certainly
     still permitted.

     RM References: 3.05 (56/2)

   * 'AI-0214 Defaulted discriminants for limited tagged (2010-10-01)'

     Ada 2012 relaxes the restriction that forbids discriminants of
     tagged types to have default expressions by allowing them when the
     type is limited.  It is often useful to define a default value for
     a discriminant even though it can’t be changed by assignment.

     RM References: 3.07 (9.1/2) 3.07.02 (3)

   * 'AI-0102 Some implicit conversions are illegal (0000-00-00)'

     It is illegal to assign an anonymous access constant to an
     anonymous access variable.  The RM did not have a clear rule to
     prevent this, but GNAT has always generated an error for this
     usage.

     RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)

   * 'AI-0158 Generalizing membership tests (2010-09-16)'

     This AI extends the syntax of membership tests to simplify complex
     conditions that can be expressed as membership in a subset of
     values of any type.  It introduces syntax for a list of expressions
     that may be used in loop contexts as well.

     RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02
     (27)

   * 'AI-0173 Testing if tags represent abstract types (2010-07-03)'

     The function ‘Ada.Tags.Type_Is_Abstract’ returns ‘True’ if invoked
     with the tag of an abstract type, and ‘False’ otherwise.

     RM References: 3.09 (7.4/2) 3.09 (12.4/2)

   * 'AI-0076 function with controlling result (0000-00-00)'

     This is an editorial change only.  The RM defines calls with
     controlling results, but uses the term ‘function with controlling
     result’ without an explicit definition.

     RM References: 3.09.02 (2/2)

   * 'AI-0126 Dispatching with no declared operation (0000-00-00)'

     This AI clarifies dispatching rules, and simply confirms that
     dispatching executes the operation of the parent type when there is
     no explicitly or implicitly declared operation for the descendant
     type.  This has always been the case in all versions of GNAT.

     RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)

   * 'AI-0097 Treatment of abstract null extension (2010-07-19)'

     The RM as written implied that in some cases it was possible to
     create an object of an abstract type, by having an abstract
     extension inherit a non- abstract constructor from its parent type.
     This mistake has been corrected in GNAT and in the RM, and this
     construct is now illegal.

     RM References: 3.09.03 (4/2)

   * 'AI-0203 Extended return cannot be abstract (0000-00-00)'

     A return_subtype_indication cannot denote an abstract subtype.
     GNAT has never permitted such usage.

     RM References: 3.09.03 (8/3)

   * 'AI-0198 Inheriting abstract operators (0000-00-00)'

     This AI resolves a conflict between two rules involving inherited
     abstract operations and predefined operators.  If a derived numeric
     type inherits an abstract operator, it overrides the predefined
     one.  This interpretation was always the one implemented in GNAT.

     RM References: 3.09.03 (4/3)

   * 'AI-0073 Functions returning abstract types (2010-07-10)'

     This AI covers a number of issues regarding returning abstract
     types.  In particular generic functions cannot have abstract result
     types or access result types designated an abstract type.  There
     are some other cases which are detailed in the AI. Note that this
     binding interpretation has not been retrofitted to operate before
     Ada 2012 mode, since it caused a significant number of regressions.

     RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)

   * 'AI-0070 Elaboration of interface types (0000-00-00)'

     This is an editorial change only, there are no testable
     consequences short of checking for the absence of generated code
     for an interface declaration.

     RM References: 3.09.04 (18/2)

   * 'AI-0208 Characteristics of incomplete views (0000-00-00)'

     The wording in the Ada 2005 RM concerning characteristics of
     incomplete views was incorrect and implied that some programs
     intended to be legal were now illegal.  GNAT had never considered
     such programs illegal, so it has always implemented the intent of
     this AI.

     RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)

   * 'AI-0162 Incomplete type completed by partial view (2010-09-15)'

     Incomplete types are made more useful by allowing them to be
     completed by private types and private extensions.

     RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01
     (4/2)

   * 'AI-0098 Anonymous subprogram access restrictions (0000-00-00)'

     An unintentional omission in the RM implied some inconsistent
     restrictions on the use of anonymous access to subprogram values.
     These restrictions were not intentional, and have never been
     enforced by GNAT.

     RM References: 3.10.01 (6) 3.10.01 (9.2/2)

   * 'AI-0199 Aggregate with anonymous access components (2010-07-14)'

     A choice list in a record aggregate can include several components
     of (distinct) anonymous access types as long as they have matching
     designated subtypes.

     RM References: 4.03.01 (16)

   * 'AI-0220 Needed components for aggregates (0000-00-00)'

     This AI addresses a wording problem in the RM that appears to
     permit some complex cases of aggregates with nonstatic
     discriminants.  GNAT has always implemented the intended semantics.

     RM References: 4.03.01 (17)

   * 'AI-0147 Conditional expressions (2009-03-29)'

     Conditional expressions are permitted.  The form of such an
     expression is:

          (if expr then expr {elsif expr then expr} [else expr])

     The parentheses can be omitted in contexts where parentheses are
     present anyway, such as subprogram arguments and pragma arguments.
     If the 'else' clause is omitted, 'else' 'True' is assumed; thus
     ‘(if A then B)’ is a way to conveniently represent '(A implies B)'
     in standard logic.

     RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
     4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)

   * 'AI-0037 Out-of-range box associations in aggregate (0000-00-00)'

     This AI confirms that an association of the form ‘Indx => <>’ in an
     array aggregate must raise ‘Constraint_Error’ if ‘Indx’ is out of
     range.  The RM specified a range check on other associations, but
     not when the value of the association was defaulted.  GNAT has
     always inserted a constraint check on the index value.

     RM References: 4.03.03 (29)

   * 'AI-0123 Composability of equality (2010-04-13)'

     Equality of untagged record composes, so that the predefined
     equality for a composite type that includes a component of some
     untagged record type ‘R’ uses the equality operation of ‘R’ (which
     may be user-defined or predefined).  This makes the behavior of
     untagged records identical to that of tagged types in this respect.

     This change is an incompatibility with previous versions of Ada,
     but it corrects a non-uniformity that was often a source of
     confusion.  Analysis of a large number of industrial programs
     indicates that in those rare cases where a composite type had an
     untagged record component with a user-defined equality, either
     there was no use of the composite equality, or else the code
     expected the same composability as for tagged types, and thus had a
     bug that would be fixed by this change.

     RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02
     (24) 8.05.04 (8)

   * 'AI-0088 The value of exponentiation (0000-00-00)'

     This AI clarifies the equivalence rule given for the dynamic
     semantics of exponentiation: the value of the operation can be
     obtained by repeated multiplication, but the operation can be
     implemented otherwise (for example using the familiar
     divide-by-two-and-square algorithm, even if this is less accurate),
     and does not imply repeated reads of a volatile base.

     RM References: 4.05.06 (11)

   * 'AI-0188 Case expressions (2010-01-09)'

     Case expressions are permitted.  This allows use of constructs such
     as:

          X := (case Y is when 1 => 2, when 2 => 3, when others => 31)

     RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)

   * 'AI-0104 Null exclusion and uninitialized allocator (2010-07-15)'

     The assignment ‘Ptr := new not null Some_Ptr;’ will raise
     ‘Constraint_Error’ because the default value of the allocated
     object is 'null'.  This useless construct is illegal in Ada 2012.

     RM References: 4.08 (2)

   * 'AI-0157 Allocation/Deallocation from empty pool (2010-07-11)'

     Allocation and Deallocation from an empty storage pool (i.e.
     allocation or deallocation of a pointer for which a static storage
     size clause of zero has been given) is now illegal and is detected
     as such.  GNAT previously gave a warning but not an error.

     RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)

   * 'AI-0179 Statement not required after label (2010-04-10)'

     It is not necessary to have a statement following a label, so a
     label can appear at the end of a statement sequence without the
     need for putting a null statement afterwards, but it is not
     allowable to have only labels and no real statements in a statement
     sequence.

     RM References: 5.01 (2)

   * 'AI-0139-2 Syntactic sugar for iterators (2010-09-29)'

     The new syntax for iterating over arrays and containers is now
     implemented.  Iteration over containers is for now limited to
     read-only iterators.  Only default iterators are supported, with
     the syntax: ‘for Elem of C’.

     RM References: 5.05

   * 'AI-0134 Profiles must match for full conformance (0000-00-00)'

     For full conformance, the profiles of
     anonymous-access-to-subprogram parameters must match.  GNAT has
     always enforced this rule.

     RM References: 6.03.01 (18)

   * 'AI-0207 Mode conformance and access constant (0000-00-00)'

     This AI confirms that access_to_constant indication must match for
     mode conformance.  This was implemented in GNAT when the qualifier
     was originally introduced in Ada 2005.

     RM References: 6.03.01 (16/2)

   * 'AI-0046 Null exclusion match for full conformance (2010-07-17)'

     For full conformance, in the case of access parameters, the null
     exclusion must match (either both or neither must have ‘not null’).

     RM References: 6.03.02 (18)

   * 'AI-0118 The association of parameter associations (0000-00-00)'

     This AI clarifies the rules for named associations in subprogram
     calls and generic instantiations.  The rules have been in place
     since Ada 83.

     RM References: 6.04.01 (2) 12.03 (9)

   * 'AI-0196 Null exclusion tests for out parameters (0000-00-00)'

     Null exclusion checks are not made for ‘out’ parameters when
     evaluating the actual parameters.  GNAT has never generated these
     checks.

     RM References: 6.04.01 (13)

   * 'AI-0015 Constant return objects (0000-00-00)'

     The return object declared in an 'extended_return_statement' may be
     declared constant.  This was always intended, and GNAT has always
     allowed it.

     RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2) 6.05
     (5.7/2)

   * 'AI-0032 Extended return for class-wide functions (0000-00-00)'

     If a function returns a class-wide type, the object of an extended
     return statement can be declared with a specific type that is
     covered by the class- wide type.  This has been implemented in GNAT
     since the introduction of extended returns.  Note AI-0103
     complements this AI by imposing matching rules for constrained
     return types.

     RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
     6.05 (8/2)

   * 'AI-0103 Static matching for extended return (2010-07-23)'

     If the return subtype of a function is an elementary type or a
     constrained type, the subtype indication in an extended return
     statement must match statically this return subtype.

     RM References: 6.05 (5.2/2)

   * 'AI-0058 Abnormal completion of an extended return (0000-00-00)'

     The RM had some incorrect wording implying wrong treatment of
     abnormal completion in an extended return.  GNAT has always
     implemented the intended correct semantics as described by this AI.

     RM References: 6.05 (22/2)

   * 'AI-0050 Raising Constraint_Error early for function call
     (0000-00-00)'

     The implementation permissions for raising ‘Constraint_Error’ early
     on a function call when it was clear an exception would be raised
     were over-permissive and allowed mishandling of discriminants in
     some cases.  GNAT did not take advantage of these incorrect
     permissions in any case.

     RM References: 6.05 (24/2)

   * 'AI-0125 Nonoverridable operations of an ancestor (2010-09-28)'

     In Ada 2012, the declaration of a primitive operation of a type
     extension or private extension can also override an inherited
     primitive that is not visible at the point of this declaration.

     RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)

   * 'AI-0062 Null exclusions and deferred constants (0000-00-00)'

     A full constant may have a null exclusion even if its associated
     deferred constant does not.  GNAT has always allowed this.

     RM References: 7.04 (6/2) 7.04 (7.1/2)

   * 'AI-0178 Incomplete views are limited (0000-00-00)'

     This AI clarifies the role of incomplete views and plugs an
     omission in the RM. GNAT always correctly restricted the use of
     incomplete views and types.

     RM References: 7.05 (3/2) 7.05 (6/2)

   * 'AI-0087 Actual for formal nonlimited derived type (2010-07-15)'

     The actual for a formal nonlimited derived type cannot be limited.
     In particular, a formal derived type that extends a limited
     interface but which is not explicitly limited cannot be
     instantiated with a limited type.

     RM References: 7.05 (5/2) 12.05.01 (5.1/2)

   * 'AI-0099 Tag determines whether finalization needed (0000-00-00)'

     This AI clarifies that ‘needs finalization’ is part of dynamic
     semantics, and therefore depends on the run-time characteristics of
     an object (i.e.  its tag) and not on its nominal type.  As the AI
     indicates: “we do not expect this to affect any implementation’’.

     RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)

   * 'AI-0064 Redundant finalization rule (0000-00-00)'

     This is an editorial change only.  The intended behavior is already
     checked by an existing ACATS test, which GNAT has always executed
     correctly.

     RM References: 7.06.01 (17.1/1)

   * 'AI-0026 Missing rules for Unchecked_Union (2010-07-07)'

     Record representation clauses concerning Unchecked_Union types
     cannot mention the discriminant of the type.  The type of a
     component declared in the variant part of an Unchecked_Union cannot
     be controlled, have controlled components, nor have protected or
     task parts.  If an Unchecked_Union type is declared within the body
     of a generic unit or its descendants, then the type of a component
     declared in the variant part cannot be a formal private type or a
     formal private extension declared within the same generic unit.

     RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)

   * 'AI-0205 Extended return declares visible name (0000-00-00)'

     This AI corrects a simple omission in the RM. Return objects have
     always been visible within an extended return statement.

     RM References: 8.03 (17)

   * 'AI-0042 Overriding versus implemented-by (0000-00-00)'

     This AI fixes a wording gap in the RM. An operation of a
     synchronized interface can be implemented by a protected or task
     entry, but the abstract operation is not being overridden in the
     usual sense, and it must be stated separately that this
     implementation is legal.  This has always been the case in GNAT.

     RM References: 9.01 (9.2/2) 9.04 (11.1/2)

   * 'AI-0030 Requeue on synchronized interfaces (2010-07-19)'

     Requeue is permitted to a protected, synchronized or task interface
     primitive providing it is known that the overriding operation is an
     entry.  Otherwise the requeue statement has the same effect as a
     procedure call.  Use of pragma ‘Implemented’ provides a way to
     impose a static requirement on the overriding operation by adhering
     to one of the implementation kinds: entry, protected procedure or
     any of the above.

     RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5) 9.05.04
     (6) 9.05.04 (7) 9.05.04 (12)

   * 'AI-0201 Independence of atomic object components (2010-07-22)'

     If an Atomic object has a pragma ‘Pack’ or a ‘Component_Size’
     attribute, then individual components may not be addressable by
     independent tasks.  However, if the representation clause has no
     effect (is confirming), then independence is not compromised.
     Furthermore, in GNAT, specification of other appropriately
     addressable component sizes (e.g.  16 for 8-bit characters) also
     preserves independence.  GNAT now gives very clear warnings both
     for the declaration of such a type, and for any assignment to its
     components.

     RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)

   * 'AI-0009 Pragma Independent[_Components] (2010-07-23)'

     This AI introduces the new pragmas ‘Independent’ and
     ‘Independent_Components’, which control guaranteeing independence
     of access to objects and components.  The AI also requires
     independence not unaffected by confirming rep clauses.

     RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
     C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)

   * 'AI-0072 Task signalling using ‘Terminated (0000-00-00)'

     This AI clarifies that task signalling for reading ‘'Terminated’
     only occurs if the result is True.  GNAT semantics has always been
     consistent with this notion of task signalling.

     RM References: 9.10 (6.1/1)

   * 'AI-0108 Limited incomplete view and discriminants (0000-00-00)'

     This AI confirms that an incomplete type from a limited view does
     not have discriminants.  This has always been the case in GNAT.

     RM References: 10.01.01 (12.3/2)

   * 'AI-0129 Limited views and incomplete types (0000-00-00)'

     This AI clarifies the description of limited views: a limited view
     of a package includes only one view of a type that has an
     incomplete declaration and a full declaration (there is no possible
     ambiguity in a client package).  This AI also fixes an omission: a
     nested package in the private part has no limited view.  GNAT
     always implemented this correctly.

     RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)

   * 'AI-0077 Limited withs and scope of declarations (0000-00-00)'

     This AI clarifies that a declaration does not include a context
     clause, and confirms that it is illegal to have a context in which
     both a limited and a nonlimited view of a package are accessible.
     Such double visibility was always rejected by GNAT.

     RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)

   * 'AI-0122 Private with and children of generics (0000-00-00)'

     This AI clarifies the visibility of private children of generic
     units within instantiations of a parent.  GNAT has always handled
     this correctly.

     RM References: 10.01.02 (12/2)

   * 'AI-0040 Limited with clauses on descendant (0000-00-00)'

     This AI confirms that a limited with clause in a child unit cannot
     name an ancestor of the unit.  This has always been checked in
     GNAT.

     RM References: 10.01.02 (20/2)

   * 'AI-0132 Placement of library unit pragmas (0000-00-00)'

     This AI fills a gap in the description of library unit pragmas.
     The pragma clearly must apply to a library unit, even if it does
     not carry the name of the enclosing unit.  GNAT has always enforced
     the required check.

     RM References: 10.01.05 (7)

   * 'AI-0034 Categorization of limited views (0000-00-00)'

     The RM makes certain limited with clauses illegal because of
     categorization considerations, when the corresponding normal with
     would be legal.  This is not intended, and GNAT has always
     implemented the recommended behavior.

     RM References: 10.02.01 (11/1) 10.02.01 (17/2)

   * 'AI-0035 Inconsistencies with Pure units (0000-00-00)'

     This AI remedies some inconsistencies in the legality rules for
     Pure units.  Derived access types are legal in a pure unit (on the
     assumption that the rule for a zero storage pool size has been
     enforced on the ancestor type).  The rules are enforced in generic
     instances and in subunits.  GNAT has always implemented the
     recommended behavior.

     RM References: 10.02.01 (15.1/2) 10.02.01 (15.4/2) 10.02.01
     (15.5/2) 10.02.01 (17/2)

   * 'AI-0219 Pure permissions and limited parameters (2010-05-25)'

     This AI refines the rules for the cases with limited parameters
     which do not allow the implementations to omit ‘redundant’.  GNAT
     now properly conforms to the requirements of this binding
     interpretation.

     RM References: 10.02.01 (18/2)

   * 'AI-0043 Rules about raising exceptions (0000-00-00)'

     This AI covers various omissions in the RM regarding the raising of
     exceptions.  GNAT has always implemented the intended semantics.

     RM References: 11.04.01 (10.1/2) 11 (2)

   * 'AI-0200 Mismatches in formal package declarations (0000-00-00)'

     This AI plugs a gap in the RM which appeared to allow some
     obviously intended illegal instantiations.  GNAT has never allowed
     these instantiations.

     RM References: 12.07 (16)

   * 'AI-0112 Detection of duplicate pragmas (2010-07-24)'

     This AI concerns giving names to various representation aspects,
     but the practical effect is simply to make the use of duplicate
     ‘Atomic[_Components]’, ‘Volatile[_Components]’, and
     ‘Independent[_Components]’ pragmas illegal, and GNAT now performs
     this required check.

     RM References: 13.01 (8)

   * 'AI-0106 No representation pragmas on generic formals (0000-00-00)'

     The RM appeared to allow representation pragmas on generic formal
     parameters, but this was not intended, and GNAT has never permitted
     this usage.

     RM References: 13.01 (9.1/1)

   * 'AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)'

     It is now illegal to give an inappropriate component size or a
     pragma ‘Pack’ that attempts to change the component size in the
     case of atomic or aliased components.  Previously GNAT ignored such
     an attempt with a warning.

     RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06
     (21)

   * 'AI-0039 Stream attributes cannot be dynamic (0000-00-00)'

     The RM permitted the use of dynamic expressions (such as
     ‘ptr.all’)' for stream attributes, but these were never useful and
     are now illegal.  GNAT has always regarded such expressions as
     illegal.

     RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)

   * 'AI-0095 Address of intrinsic subprograms (0000-00-00)'

     The prefix of ‘'Address’ cannot statically denote a subprogram with
     convention ‘Intrinsic’.  The use of the ‘Address’ attribute raises
     ‘Program_Error’ if the prefix denotes a subprogram with convention
     ‘Intrinsic’.

     RM References: 13.03 (11/1)

   * 'AI-0116 Alignment of class-wide objects (0000-00-00)'

     This AI requires that the alignment of a class-wide object be no
     greater than the alignment of any type in the class.  GNAT has
     always followed this recommendation.

     RM References: 13.03 (29) 13.11 (16)

   * 'AI-0146 Type invariants (2009-09-21)'

     Type invariants may be specified for private types using the aspect
     notation.  Aspect ‘Type_Invariant’ may be specified for any private
     type, ‘Type_Invariant'Class’ can only be specified for tagged
     types, and is inherited by any descendent of the tagged types.  The
     invariant is a boolean expression that is tested for being true in
     the following situations: conversions to the private type, object
     declarations for the private type that are default initialized, and
     ['in'] 'out' parameters and returned result on return from any
     primitive operation for the type that is visible to a client.  GNAT
     defines the synonyms ‘Invariant’ for ‘Type_Invariant’ and
     ‘Invariant'Class’ for ‘Type_Invariant'Class’.

     RM References: 13.03.03 (00)

   * 'AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)'

     In Ada 2012, compilers are required to support unchecked conversion
     where the target alignment is a multiple of the source alignment.
     GNAT always supported this case (and indeed all cases of differing
     alignments, doing copies where required if the alignment was
     reduced).

     RM References: 13.09 (7)

   * 'AI-0195 Invalid value handling is implementation defined
     (2010-07-03)'

     The handling of invalid values is now designated to be
     implementation defined.  This is a documentation change only,
     requiring Annex M in the GNAT Reference Manual to document this
     handling.  In GNAT, checks for invalid values are made only when
     necessary to avoid erroneous behavior.  Operations like assignments
     which cannot cause erroneous behavior ignore the possibility of
     invalid values and do not do a check.  The date given above applies
     only to the documentation change, this behavior has always been
     implemented by GNAT.

     RM References: 13.09.01 (10)

   * 'AI-0193 Alignment of allocators (2010-09-16)'

     This AI introduces a new attribute ‘Max_Alignment_For_Allocation’,
     analogous to ‘Max_Size_In_Storage_Elements’, but for alignment
     instead of size.

     RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
     13.11.01 (2) 13.11.01 (3)

   * 'AI-0177 Parameterized expressions (2010-07-10)'

     The new Ada 2012 notion of parameterized expressions is
     implemented.  The form is:

          function-specification is (expression)

     This is exactly equivalent to the corresponding function body that
     returns the expression, but it can appear in a package spec.  Note
     that the expression must be parenthesized.

     RM References: 13.11.01 (3/2)

   * 'AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)'

     Neither of these two pragmas may appear within a generic template,
     because the generic might be instantiated at other than the library
     level.

     RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)

   * 'AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)'

     A new restriction ‘No_Default_Stream_Attributes’ prevents the use
     of any of the default stream attributes for elementary types.  If
     this restriction is in force, then it is necessary to provide
     explicit subprograms for any stream attributes used.

     RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)

   * 'AI-0194 Value of Stream_Size attribute (0000-00-00)'

     The ‘Stream_Size’ attribute returns the default number of bits in
     the stream representation of the given type.  This value is not
     affected by the presence of stream subprogram attributes for the
     type.  GNAT has always implemented this interpretation.

     RM References: 13.13.02 (1.2/2)

   * 'AI-0109 Redundant check in S’Class’Input (0000-00-00)'

     This AI is an editorial change only.  It removes the need for a tag
     check that can never fail.

     RM References: 13.13.02 (34/2)

   * 'AI-0007 Stream read and private scalar types (0000-00-00)'

     The RM as written appeared to limit the possibilities of declaring
     read attribute procedures for private scalar types.  This
     limitation was not intended, and has never been enforced by GNAT.

     RM References: 13.13.02 (50/2) 13.13.02 (51/2)

   * 'AI-0065 Remote access types and external streaming (0000-00-00)'

     This AI clarifies the fact that all remote access types support
     external streaming.  This fixes an obvious oversight in the
     definition of the language, and GNAT always implemented the
     intended correct rules.

     RM References: 13.13.02 (52/2)

   * 'AI-0019 Freezing of primitives for tagged types (0000-00-00)'

     The RM suggests that primitive subprograms of a specific tagged
     type are frozen when the tagged type is frozen.  This would be an
     incompatible change and is not intended.  GNAT has never attempted
     this kind of freezing and its behavior is consistent with the
     recommendation of this AI.

     RM References: 13.14 (2) 13.14 (3/1) 13.14 (8.1/1) 13.14 (10) 13.14
     (14) 13.14 (15.1/2)

   * 'AI-0017 Freezing and incomplete types (0000-00-00)'

     So-called ‘Taft-amendment types’ (i.e., types that are completed in
     package bodies) are not frozen by the occurrence of bodies in the
     enclosing declarative part.  GNAT always implemented this properly.

     RM References: 13.14 (3/1)

   * 'AI-0060 Extended definition of remote access types (0000-00-00)'

     This AI extends the definition of remote access types to include
     access to limited, synchronized, protected or task class-wide
     interface types.  GNAT already implemented this extension.

     RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2)
     E.02.02 (18)

   * 'AI-0114 Classification of letters (0000-00-00)'

     The code points 170 (‘FEMININE ORDINAL INDICATOR’), 181 (‘MICRO
     SIGN’), and 186 (‘MASCULINE ORDINAL INDICATOR’) are technically
     considered lower case letters by Unicode.  However, they are not
     allowed in identifiers, and they return ‘False’ to
     ‘Ada.Characters.Handling.Is_Letter/Is_Lower’.  This behavior is
     consistent with that defined in Ada 95.

     RM References: A.03.02 (59) A.04.06 (7)

   * 'AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)'

     Two new packages ‘Ada.Wide_[Wide_]Characters.Handling’ provide
     classification functions for ‘Wide_Character’ and
     ‘Wide_Wide_Character’, as well as providing case folding routines
     for ‘Wide_[Wide_]Character’ and ‘Wide_[Wide_]String’.

     RM References: A.03.05 (0) A.03.06 (0)

   * 'AI-0031 Add From parameter to Find_Token (2010-07-25)'

     A new version of ‘Find_Token’ is added to all relevant string
     packages, with an extra parameter ‘From’.  Instead of starting at
     the first character of the string, the search for a matching Token
     starts at the character indexed by the value of ‘From’.  These
     procedures are available in all versions of Ada but if used in
     versions earlier than Ada 2012 they will generate a warning that an
     Ada 2012 subprogram is being used.

     RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04
     (51) A.04.05 (46)

   * 'AI-0056 Index on null string returns zero (0000-00-00)'

     The wording in the Ada 2005 RM implied an incompatible handling of
     the ‘Index’ functions, resulting in raising an exception instead of
     returning zero in some situations.  This was not intended and has
     been corrected.  GNAT always returned zero, and is thus consistent
     with this AI.

     RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)

   * 'AI-0137 String encoding package (2010-03-25)'

     The packages ‘Ada.Strings.UTF_Encoding’, together with its child
     packages, ‘Conversions’, ‘Strings’, ‘Wide_Strings’, and
     ‘Wide_Wide_Strings’ have been implemented.  These packages (whose
     documentation can be found in the spec files ‘a-stuten.ads’,
     ‘a-suenco.ads’, ‘a-suenst.ads’, ‘a-suewst.ads’, ‘a-suezst.ads’)
     allow encoding and decoding of ‘String’, ‘Wide_String’, and
     ‘Wide_Wide_String’ values using UTF coding schemes (including
     UTF-8, UTF-16LE, UTF-16BE, and UTF-16), as well as conversions
     between the different UTF encodings.  With the exception of
     ‘Wide_Wide_Strings’, these packages are available in Ada 95 and Ada
     2005 mode as well as Ada 2012 mode.  The ‘Wide_Wide_Strings’
     package is available in Ada 2005 mode as well as Ada 2012 mode (but
     not in Ada 95 mode since it uses ‘Wide_Wide_Character’).

     RM References: A.04.11

   * 'AI-0038 Minor errors in Text_IO (0000-00-00)'

     These are minor errors in the description on three points.  The
     intent on all these points has always been clear, and GNAT has
     always implemented the correct intended semantics.

     RM References: A.10.05 (37) A.10.07 (8/1) A.10.07 (10) A.10.07 (12)
     A.10.08 (10) A.10.08 (24)

   * 'AI-0044 Restrictions on container instantiations (0000-00-00)'

     This AI places restrictions on allowed instantiations of generic
     containers.  These restrictions are not checked by the compiler, so
     there is nothing to change in the implementation.  This affects
     only the RM documentation.

     RM References: A.18 (4/2) A.18.02 (231/2) A.18.03 (145/2) A.18.06
     (56/2) A.18.08 (66/2) A.18.09 (79/2) A.18.26 (5/2) A.18.26 (9/2)

   * 'AI-0127 Adding Locale Capabilities (2010-09-29)'

     This package provides an interface for identifying the current
     locale.

     RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06 A.19.07
     A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13

   * 'AI-0002 Export C with unconstrained arrays (0000-00-00)'

     The compiler is not required to support exporting an Ada subprogram
     with convention C if there are parameters or a return type of an
     unconstrained array type (such as ‘String’).  GNAT allows such
     declarations but generates warnings.  It is possible, but
     complicated, to write the corresponding C code and certainly such
     code would be specific to GNAT and non-portable.

     RM References: B.01 (17) B.03 (62) B.03 (71.1/2)

   * 'AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)'

     It is clearly the intention that ‘No_Task_Hierarchy’ is intended to
     forbid tasks declared locally within subprograms, or functions
     returning task objects, and that is the implementation that GNAT
     has always provided.  However the language in the RM was not
     sufficiently clear on this point.  Thus this is a documentation
     change in the RM only.

     RM References: D.07 (3/3)

   * 'AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)'

     The restriction ‘No_Relative_Delays’ forbids any calls to the
     subprogram ‘Ada.Real_Time.Timing_Events.Set_Handler’.

     RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)

   * 'AI-0190 pragma Default_Storage_Pool (2010-09-15)'

     This AI introduces a new pragma ‘Default_Storage_Pool’, which can
     be used to control storage pools globally.  In particular, you can
     force every access type that is used for allocation ('new') to have
     an explicit storage pool, or you can declare a pool globally to be
     used for all access types that lack an explicit one.

     RM References: D.07 (8)

   * 'AI-0189 No_Allocators_After_Elaboration (2010-01-23)'

     This AI introduces a new restriction
     ‘No_Allocators_After_Elaboration’, which says that no dynamic
     allocation will occur once elaboration is completed.  In general
     this requires a run-time check, which is not required, and which
     GNAT does not attempt.  But the static cases of allocators in a
     task body or in the body of the main program are detected and
     flagged at compile or bind time.

     RM References: D.07 (19.1/2) H.04 (23.3/2)

   * 'AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)'

     A new package ‘System.Multiprocessors’ is added, together with the
     definition of pragma ‘CPU’ for controlling task affinity.  A new no
     dependence restriction, on
     ‘System.Multiprocessors.Dispatching_Domains’, is added to the
     Ravenscar profile.

     RM References: D.13.01 (4/2) D.16

   * 'AI-0210 Correct Timing_Events metric (0000-00-00)'

     This is a documentation only issue regarding wording of metric
     requirements, that does not affect the implementation of the
     compiler.

     RM References: D.15 (24/2)

   * 'AI-0206 Remote types packages and preelaborate (2010-07-24)'

     Remote types packages are now allowed to depend on preelaborated
     packages.  This was formerly considered illegal.

     RM References: E.02.02 (6)

   * 'AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)'

     Restriction ‘No_Anonymous_Allocators’ prevents the use of
     allocators where the type of the returned value is an anonymous
     access type.

     RM References: H.04 (8/1)

