Commit 08564036 by Arnaud Charlet

[multiple changes]

2010-09-10  Jose Ruiz  <ruiz@adacore.com>

	* exp_cg.adb (Is_Predefined_Dispatching_Operation): Add the "__" scope
	separator when trying the pattern matching to detect predefined
	primitive operations.

2010-09-10  Robert Dewar  <dewar@adacore.com>

	* bindgen.adb, atree.adb: Minor reformatting.

2010-09-10  Ben Brosgol  <brosgol@adacore.com>

	* ug_words, gnat_ugn.texi: Revised "Transitioning to 64-Bit GNAT for
	OpenVMS" section.

From-SVN: r164175
parent 8c4353b7
2010-09-10 Jose Ruiz <ruiz@adacore.com>
* exp_cg.adb (Is_Predefined_Dispatching_Operation): Add the "__" scope
separator when trying the pattern matching to detect predefined
primitive operations.
2010-09-10 Robert Dewar <dewar@adacore.com>
* bindgen.adb, atree.adb: Minor reformatting.
2010-09-10 Ben Brosgol <brosgol@adacore.com>
* ug_words, gnat_ugn.texi: Revised "Transitioning to 64-Bit GNAT for
OpenVMS" section.
2010-09-10 Doug Rupp <rupp@adacore.com> 2010-09-10 Doug Rupp <rupp@adacore.com>
* bindgen.adb: Minor comment fix for -H switch. * bindgen.adb: Minor comment fix for -H switch.
......
...@@ -1261,7 +1261,7 @@ package body Atree is ...@@ -1261,7 +1261,7 @@ package body Atree is
-- New_Node_Breakpoint -- -- New_Node_Breakpoint --
------------------------- -------------------------
procedure nn is -- New_Node_Breakpoint procedure nn is
begin begin
Write_Str ("Watched node "); Write_Str ("Watched node ");
Write_Int (Int (Watch_Node)); Write_Int (Int (Watch_Node));
...@@ -1273,7 +1273,7 @@ package body Atree is ...@@ -1273,7 +1273,7 @@ package body Atree is
-- New_Node_Debugging_Output -- -- New_Node_Debugging_Output --
------------------------------- -------------------------------
procedure nnd (N : Node_Id) is -- New_Node_Debugging_Output procedure nnd (N : Node_Id) is
Node_Is_Watched : constant Boolean := N = Watch_Node; Node_Is_Watched : constant Boolean := N = Watch_Node;
begin begin
...@@ -1666,7 +1666,7 @@ package body Atree is ...@@ -1666,7 +1666,7 @@ package body Atree is
-- Rewrite_Breakpoint -- -- Rewrite_Breakpoint --
------------------------- -------------------------
procedure rr is -- Rewrite_Breakpoint procedure rr is
begin begin
Write_Str ("Watched node "); Write_Str ("Watched node ");
Write_Int (Int (Watch_Node)); Write_Int (Int (Watch_Node));
...@@ -1678,7 +1678,7 @@ package body Atree is ...@@ -1678,7 +1678,7 @@ package body Atree is
-- Rewrite_Debugging_Output -- -- Rewrite_Debugging_Output --
------------------------------ ------------------------------
procedure rrd (Old_Node, New_Node : Node_Id) is -- Rewrite_Debugging_Output procedure rrd (Old_Node, New_Node : Node_Id) is
Node_Is_Watched : constant Boolean := Old_Node = Watch_Node; Node_Is_Watched : constant Boolean := Old_Node = Watch_Node;
begin begin
......
...@@ -792,8 +792,9 @@ package body Bindgen is ...@@ -792,8 +792,9 @@ package body Bindgen is
Write_Statement_Buffer; Write_Statement_Buffer;
-- Generate call to Install_Handler -- Generate call to Install_Handler
-- In .NET, when binding with -z, we don't install the signal
-- handler to let the caller handle the last exception handler. -- In .NET, when binding with -z, we don't install the signal handler
-- to let the caller handle the last exception handler.
if VM_Target /= CLI_Target if VM_Target /= CLI_Target
or else Bind_Main_Program or else Bind_Main_Program
......
...@@ -271,12 +271,21 @@ package body Exp_CG is ...@@ -271,12 +271,21 @@ package body Exp_CG is
for J in Predef_Names_95'Range loop for J in Predef_Names_95'Range loop
Get_Name_String (Predef_Names_95 (J)); Get_Name_String (Predef_Names_95 (J));
if Full_Name'Last - Suffix_Length > Name_Len -- The predefined primitive operations are identified by the
-- names "_size", "_alignment", etc. If we try a pattern
-- matching against this string, we can wrongly match other
-- primitive operations like "get_size". To avoid this, we
-- add the "__" scope separator, which can only prepend
-- predefined primitive operations because other primitive
-- operations can neither start with an underline nor
-- contain two consecutive underlines in its name.
if Full_Name'Last - Suffix_Length > Name_Len + 2
and then and then
Full_Name Full_Name
(Full_Name'Last - Name_Len - Suffix_Length + 1 (Full_Name'Last - Name_Len - 2 - Suffix_Length + 1
.. Full_Name'Last - Suffix_Length) = .. Full_Name'Last - Suffix_Length) =
Name_Buffer (1 .. Name_Len) "__" & Name_Buffer (1 .. Name_Len)
then then
-- For the equality operator the type of the two operands -- For the equality operator the type of the two operands
-- must also match. -- must also match.
...@@ -291,12 +300,12 @@ package body Exp_CG is ...@@ -291,12 +300,12 @@ package body Exp_CG is
for J in Predef_Names_05'Range loop for J in Predef_Names_05'Range loop
Get_Name_String (Predef_Names_05 (J)); Get_Name_String (Predef_Names_05 (J));
if Full_Name'Last - Suffix_Length > Name_Len if Full_Name'Last - Suffix_Length > Name_Len + 2
and then and then
Full_Name Full_Name
(Full_Name'Last - Name_Len - Suffix_Length + 1 (Full_Name'Last - Name_Len - 2 - Suffix_Length + 1
.. Full_Name'Last - Suffix_Length) = .. Full_Name'Last - Suffix_Length) =
Name_Buffer (1 .. Name_Len) "__" & Name_Buffer (1 .. Name_Len)
then then
return True; return True;
end if; end if;
......
...@@ -8057,6 +8057,7 @@ be presented in subsequent sections. ...@@ -8057,6 +8057,7 @@ be presented in subsequent sections.
* Binder Error Message Control:: * Binder Error Message Control::
* Elaboration Control:: * Elaboration Control::
* Output Control:: * Output Control::
* Dynamic Allocation Control::
* Binding with Non-Ada Main Programs:: * Binding with Non-Ada Main Programs::
* Binding Programs with No Main Subprogram:: * Binding Programs with No Main Subprogram::
@end menu @end menu
...@@ -8168,6 +8169,17 @@ flag checks are generated. ...@@ -8168,6 +8169,17 @@ flag checks are generated.
@cindex @option{^-h^/HELP^} (@command{gnatbind}) @cindex @option{^-h^/HELP^} (@command{gnatbind})
Output usage (help) information Output usage (help) information
@item ^-H32^/32_MALLOC^
@cindex @option{^-H32^/32_MALLOC^} (@command{gnatbind})
Use 32-bit allocations for @code{__gnat_malloc} (and thus for access types).
For further details see @ref{Dynamic Allocation Control}.
@item ^-H64^/64_MALLOC^
@cindex @option{^-H32^/32_MALLOC^} (@command{gnatbind})
Use 64-bit allocations for @code{__gnat_malloc} (and thus for access types).
@cindex @code{__gnat_malloc}
For further details see @ref{Dynamic Allocation Control}.
@item ^-I^/SEARCH^ @item ^-I^/SEARCH^
@cindex @option{^-I^/SEARCH^} (@command{gnatbind}) @cindex @option{^-I^/SEARCH^} (@command{gnatbind})
Specify directory to be searched for source and ALI files. Specify directory to be searched for source and ALI files.
...@@ -8596,6 +8608,35 @@ be used to improve code generation in some cases. ...@@ -8596,6 +8608,35 @@ be used to improve code generation in some cases.
@end table @end table
@node Dynamic Allocation Control
@subsection Dynamic Allocation Control
@noindent
The heap control switches -- @option{-H32} and @option{-H64} --
determine whether dynamic allocation uses 32-bit or 64-bit memory.
They only affect compiler-generated allocations via @code{__gnat_malloc};
explicit calls to @code{malloc} and related functions from the C
run-time library are unaffected.
@table @option
@item -H32
Allocate memory on 32-bit heap
@item -H64
Allocate memory on 64-bit heap. This is the default
unless explicitly overridden by a @code{'Size} clause on the access type.
@end table
@ifset vms
@noindent
See also @ref{Access types and 32/64-bit allocation}.
@end ifset
@ifclear vms
@noindent
These switches are only effective on VMS platforms.
@end ifclear
@node Binding with Non-Ada Main Programs @node Binding with Non-Ada Main Programs
@subsection Binding with Non-Ada Main Programs @subsection Binding with Non-Ada Main Programs
...@@ -26509,10 +26550,11 @@ Such code will be referred to below as @emph{64-bit code}. ...@@ -26509,10 +26550,11 @@ Such code will be referred to below as @emph{64-bit code}.
@menu @menu
* Address types:: * Address types::
* Access types:: * Access types and 32/64-bit allocation::
* Unchecked conversions:: * Unchecked conversions::
* Predefined constants:: * Predefined constants::
* Interfacing with C:: * Interfacing with C::
* 32/64-bit descriptors::
* Experience with source compatibility:: * Experience with source compatibility::
@end menu @end menu
...@@ -26527,9 +26569,13 @@ approach has been taken: ...@@ -26527,9 +26569,13 @@ approach has been taken:
@itemize @bullet @itemize @bullet
@item @item
@code{System.Address} always has a size of 64 bits @code{System.Address} always has a size of 64 bits
@cindex @code{System.Address} size
@cindex @code{Address} size
@item @item
@code{System.Short_Address} is a 32-bit subtype of @code{System.Address} @code{System.Short_Address} is a 32-bit subtype of @code{System.Address}
@cindex @code{System.Short_Address} size
@cindex @code{Short_Address} size
@end itemize @end itemize
@noindent @noindent
...@@ -26568,31 +26614,64 @@ required in any code setting or accessing the field; the compiler will ...@@ -26568,31 +26614,64 @@ required in any code setting or accessing the field; the compiler will
automatically perform any needed conversions between address automatically perform any needed conversions between address
formats. formats.
@node Access types @node Access types and 32/64-bit allocation
@subsubsection Access types @subsubsection Access types and 32/64-bit allocation
@cindex 32-bit allocation
@cindex 64-bit allocation
@noindent @noindent
By default, objects designated by access values are always By default, objects designated by access values are always allocated in
allocated in the 32-bit the 64-bit address space, and access values themselves are represented
address space. Thus legacy code will never contain in 64 bits. If these defaults are not appropriate, and 32-bit allocation
any objects that are not addressable with 32-bit addresses, and is required (for example if the address of an allocated object is assigned
the compiler will never raise exceptions as result of mixing to a @code{Short_Address} variable), then several alternatives are available:
32-bit and 64-bit addresses.
However, the access values themselves are represented in 64 bits, for optimum @itemize @bullet
performance and future compatibility with 64-bit code. As was @item
the case with @code{System.Address}, the compiler will give an error message A pool-specific access type (ie, an @w{Ada 83} access type, whose
if an object or record component has a representation clause that definition is @code{access T} versus @code{access all T} or
requires the access value to fit in 32 bits. In such a situation, @code{access constant T}), may be declared with a @code{'Size} representation
an explicit size clause for the access type, specifying 32 bits, clause that establishes the size as 32 bits.
will have the desired effect. In such circumstances allocations for that type will
be from the 32-bit heap. Such a clause is not permitted
for a general access type (declared with @code{access all} or
@code{access constant}) as values of such types must be able to refer
to any object of the designated type, including objects residing outside
the 32-bit address range. Existing @w{Ada 83} code will not contain such
type definitions, however, since general access types were introduced
in @w{Ada 95}.
@item
Switches for @command{GNAT BIND} control whether the internal GNAT
allocation routine @code{__gnat_malloc} uses 64-bit or 32-bit allocations.
@cindex @code{__gnat_malloc}
The switches are respectively @option{-H64} (the default) and
@option{-H32}.
@cindex @option{-H32} (@command{gnatbind})
@cindex @option{-H64} (@command{gnatbind})
@item
The environment variable (logical name) @code{GNAT$NO_MALLOC_64}
@cindex @code{GNAT$NO_MALLOC_64} environment variable
may be used to force @code{__gnat_malloc} to use 32-bit allocation.
If this variable is left
undefined, or defined as @code{"DISABLE"}, @code{"FALSE"}, or @code{"0"},
then the default (64-bit) allocation is used.
If defined as @code{"ENABLE"}, @code{"TRUE"}, or @code{"1"},
then 32-bit allocation is used. The gnatbind qualifiers described above
override this logical name.
@item
A ^gcc switch^gcc switch^ for OpenVMS, @option{-mno-malloc64}, operates
@cindex @option{-mno-malloc64} (^gcc^gcc^)
at a low level to convert explicit calls to @code{malloc} and related
functions from the C run-time library so that they perform allocations
in the 32-bit heap.
Since all internal allocations from GNAT use @code{__gnat_malloc},
this switch is not required unless the program makes explicit calls on
@code{malloc} (or related functions) from interfaced C code.
@end itemize
General access types (declared with @code{access all}) can never be
32 bits, as values of such types must be able to refer to any object
of the designated type,
including objects residing outside the 32-bit address range.
Existing Ada 83 code will not contain such type definitions,
however, since general access types were introduced in Ada 95.
@node Unchecked conversions @node Unchecked conversions
@subsubsection Unchecked conversions @subsubsection Unchecked conversions
...@@ -26665,6 +26744,20 @@ pragma Convention(C, int_star); ...@@ -26665,6 +26744,20 @@ pragma Convention(C, int_star);
for int_star'Size use 64; -- Necessary to get 64 and not 32 bits for int_star'Size use 64; -- Necessary to get 64 and not 32 bits
@end smallexample @end smallexample
@node 32/64-bit descriptors
@subsubsection 32/64-bit descriptors
@noindent
By default, GNAT uses a 64-bit descriptor mechanism. For an imported
subprogram (i.e., a subprogram identified by pragma @code{Import_Function},
@code{Import_Procedure}, or @code{Import_Valued_Procedure}) that specifies
@code{Short_Descriptor} as its mechanism, a 32-bit descriptor is used.
@cindex @code{Short_Descriptor} mechanism for imported subprograms
If the configuration pragma @code{Short_Descriptors} is supplied, then
all descriptors will be 32 bits.
@cindex pragma @code{Short_Descriptors}
@node Experience with source compatibility @node Experience with source compatibility
@subsubsection Experience with source compatibility @subsubsection Experience with source compatibility
...@@ -26697,8 +26790,6 @@ these sorts of potential source code porting problems. ...@@ -26697,8 +26790,6 @@ these sorts of potential source code porting problems.
* Making code 64 bit clean:: * Making code 64 bit clean::
* Allocating memory from the 64 bit storage pool:: * Allocating memory from the 64 bit storage pool::
* Restrictions on use of 64 bit objects:: * Restrictions on use of 64 bit objects::
* Using 64 bit storage pools by default::
* General access types::
* STARLET and other predefined libraries:: * STARLET and other predefined libraries::
@end menu @end menu
...@@ -26742,13 +26833,10 @@ Any attempt to do this will raise @code{Constraint_Error}. ...@@ -26742,13 +26833,10 @@ Any attempt to do this will raise @code{Constraint_Error}.
@subsubsection Allocating memory from the 64-bit storage pool @subsubsection Allocating memory from the 64-bit storage pool
@noindent @noindent
For any access type @code{T} that potentially requires memory allocations By default, all allocations -- for both pool-specific and general
beyond the 32-bit address space, access types -- use the 64-bit storage pool. To override
use the following representation clause: this default, for an individual access type or globally, see
@ref{Access types and 32/64-bit allocation}.
@smallexample @c ada
for T'Storage_Pool use System.Pool_64;
@end smallexample
@node Restrictions on use of 64 bit objects @node Restrictions on use of 64 bit objects
@subsubsection Restrictions on use of 64-bit objects @subsubsection Restrictions on use of 64-bit objects
...@@ -26763,46 +26851,6 @@ or assigning it to a variable of type @code{Short_Address}, will cause ...@@ -26763,46 +26851,6 @@ or assigning it to a variable of type @code{Short_Address}, will cause
no exception is raised and execution no exception is raised and execution
will become erroneous. will become erroneous.
@node Using 64 bit storage pools by default
@subsubsection Using 64-bit storage pools by default
@noindent
In some cases it may be desirable to have the compiler allocate
from 64-bit storage pools by default. This may be the case for
libraries that are 64-bit clean, but may be used in both 32-bit
and 64-bit contexts. For these cases the following configuration
pragma may be specified:
@smallexample @c ada
pragma Pool_64_Default;
@end smallexample
@noindent
Any code compiled in the context of this pragma will by default
use the @code{System.Pool_64} storage pool. This default may be overridden
for a specific access type @code{T} by the representation clause:
@smallexample @c ada
for T'Storage_Pool use System.Pool_32;
@end smallexample
@noindent
Any object whose address may be passed to a subprogram with a
@code{Short_Address} argument, or assigned to a variable of type
@code{Short_Address}, needs to be allocated from this pool.
@node General access types
@subsubsection General access types
@noindent
Objects designated by access values from a
general access type (declared with @code{access all}) are never allocated
from a 64-bit storage pool. Code that uses general access types will
accept objects allocated in either 32-bit or 64-bit address spaces,
but never allocate objects outside the 32-bit address space.
Using general access types ensures maximum compatibility with both
32-bit and 64-bit code.
@node STARLET and other predefined libraries @node STARLET and other predefined libraries
@subsubsection STARLET and other predefined libraries @subsubsection STARLET and other predefined libraries
......
...@@ -218,3 +218,5 @@ stderr ^ SYS$ERROR ...@@ -218,3 +218,5 @@ stderr ^ SYS$ERROR
-O1 ^ /OPTIMIZE=SOME -O1 ^ /OPTIMIZE=SOME
-O2 ^ /OPTIMIZE=ALL -O2 ^ /OPTIMIZE=ALL
-O3 ^ /OPTIMIZE=INLINING -O3 ^ /OPTIMIZE=INLINING
-H32 ^ /32_MALLOC
-H64 ^ /64_MALLOC
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment