[multiple changes]
2014-07-16 Robert Dewar <dewar@adacore.com> * gnat_ugn.texi: Document binder switch -Ra. * gnatbind.adb (List_Closure_Display): Implement -Ra switch (List_Closure_All). * opt.ads (List_Closure_All): New switch. * switch-b.adb (Scan_Binder_Switches): Recognize -Ra to set List_Closure_All. 2014-07-16 Ben Brosgol <brosgol@adacore.com> * gnat_rm.texi: Minor edits, to make case consistent in names of types and fields. From-SVN: r212654
This commit is contained in:
parent
3bd783ecb4
commit
904aac81db
|
@ -1,3 +1,17 @@
|
||||||
|
2014-07-16 Robert Dewar <dewar@adacore.com>
|
||||||
|
|
||||||
|
* gnat_ugn.texi: Document binder switch -Ra.
|
||||||
|
* gnatbind.adb (List_Closure_Display): Implement -Ra switch
|
||||||
|
(List_Closure_All).
|
||||||
|
* opt.ads (List_Closure_All): New switch.
|
||||||
|
* switch-b.adb (Scan_Binder_Switches): Recognize -Ra to set
|
||||||
|
List_Closure_All.
|
||||||
|
|
||||||
|
2014-07-16 Ben Brosgol <brosgol@adacore.com>
|
||||||
|
|
||||||
|
* gnat_rm.texi: Minor edits, to make case consistent in names
|
||||||
|
of types and fields.
|
||||||
|
|
||||||
2014-07-16 Robert Dewar <dewar@adacore.com>
|
2014-07-16 Robert Dewar <dewar@adacore.com>
|
||||||
|
|
||||||
* gnat_rm.texi: Document erroneous mixing of thin pointers and
|
* gnat_rm.texi: Document erroneous mixing of thin pointers and
|
||||||
|
|
|
@ -15542,51 +15542,51 @@ For example, consider the record
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
type Rb1 is array (1 .. 13) of Boolean;
|
type Rb1 is array (1 .. 13) of Boolean;
|
||||||
pragma Pack (rb1);
|
pragma Pack (Rb1);
|
||||||
|
|
||||||
type Rb2 is array (1 .. 65) of Boolean;
|
type Rb2 is array (1 .. 65) of Boolean;
|
||||||
pragma Pack (rb2);
|
pragma Pack (Rb2);
|
||||||
|
|
||||||
type AF is new Float with Atomic;
|
type AF is new Float with Atomic;
|
||||||
|
|
||||||
type x2 is record
|
type X2 is record
|
||||||
l1 : Boolean;
|
L1 : Boolean;
|
||||||
l2 : Duration;
|
L2 : Duration;
|
||||||
l3 : AF;
|
L3 : AF;
|
||||||
l4 : Boolean;
|
L4 : Boolean;
|
||||||
l5 : Rb1;
|
L5 : Rb1;
|
||||||
l6 : Rb2;
|
L6 : Rb2;
|
||||||
end record;
|
end record;
|
||||||
pragma Pack (x2);
|
pragma Pack (X2);
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
The representation for the record x2 is as follows:
|
The representation for the record X2 is as follows:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
for x2'Size use 224;
|
for X2'Size use 224;
|
||||||
for x2 use record
|
for X2 use record
|
||||||
l1 at 0 range 0 .. 0;
|
L1 at 0 range 0 .. 0;
|
||||||
l2 at 0 range 1 .. 64;
|
L2 at 0 range 1 .. 64;
|
||||||
l3 at 12 range 0 .. 31;
|
L3 at 12 range 0 .. 31;
|
||||||
l4 at 16 range 0 .. 0;
|
L4 at 16 range 0 .. 0;
|
||||||
l5 at 16 range 1 .. 13;
|
L5 at 16 range 1 .. 13;
|
||||||
l6 at 18 range 0 .. 71;
|
L6 at 18 range 0 .. 71;
|
||||||
end record;
|
end record;
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
Studying this example, we see that the packable fields @code{l1}
|
Studying this example, we see that the packable fields @code{L1}
|
||||||
and @code{l2} are
|
and @code{L2} are
|
||||||
of length equal to their sizes, and placed at specific bit boundaries (and
|
of length equal to their sizes, and placed at specific bit boundaries (and
|
||||||
not byte boundaries) to
|
not byte boundaries) to
|
||||||
eliminate padding. But @code{l3} is of a non-packable float type (because
|
eliminate padding. But @code{L3} is of a non-packable float type (because
|
||||||
it is aliased), so it is on the next appropriate alignment boundary.
|
it is aliased), so it is on the next appropriate alignment boundary.
|
||||||
|
|
||||||
The next two fields are fully packable, so @code{l4} and @code{l5} are
|
The next two fields are fully packable, so @code{L4} and @code{L5} are
|
||||||
minimally packed with no gaps. However, type @code{Rb2} is a packed
|
minimally packed with no gaps. However, type @code{Rb2} is a packed
|
||||||
array that is longer than 64 bits, so it is itself non-packable. Thus
|
array that is longer than 64 bits, so it is itself non-packable. Thus
|
||||||
the @code{l6} field is aligned to the next byte boundary, and takes an
|
the @code{L6} field is aligned to the next byte boundary, and takes an
|
||||||
integral number of bytes, i.e.@: 72 bits.
|
integral number of bytes, i.e.@: 72 bits.
|
||||||
|
|
||||||
@node Record Representation Clauses
|
@node Record Representation Clauses
|
||||||
|
|
|
@ -8451,7 +8451,12 @@ Generate binder file suitable for CodePeer.
|
||||||
|
|
||||||
@item ^-R^-R^
|
@item ^-R^-R^
|
||||||
@cindex @option{^-R^-R^} (@command{gnatbind})
|
@cindex @option{^-R^-R^} (@command{gnatbind})
|
||||||
Output closure source list.
|
Output closure source list, which includes all non-time-units that are
|
||||||
|
included in the bind.
|
||||||
|
|
||||||
|
@item ^-Ra^-Ra^
|
||||||
|
@cindex @option{^-Ra^-Ra^} (@command{gnatbind})
|
||||||
|
Like @option{-R} but the list includes run-time units.
|
||||||
|
|
||||||
@item ^-s^/READ_SOURCES=ALL^
|
@item ^-s^/READ_SOURCES=ALL^
|
||||||
@cindex @option{^-s^/READ_SOURCES=ALL^} (@command{gnatbind})
|
@cindex @option{^-s^/READ_SOURCES=ALL^} (@command{gnatbind})
|
||||||
|
@ -20126,6 +20131,8 @@ The tool currently does not support following features:
|
||||||
@c *********************************
|
@c *********************************
|
||||||
@node Performing Dimensionality Analysis in GNAT
|
@node Performing Dimensionality Analysis in GNAT
|
||||||
@chapter Performing Dimensionality Analysis in GNAT
|
@chapter Performing Dimensionality Analysis in GNAT
|
||||||
|
@cindex Dimensionality analysis
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
The GNAT compiler now supports dimensionality checking. The user can
|
The GNAT compiler now supports dimensionality checking. The user can
|
||||||
specify physical units for objects, and the compiler will verify that uses
|
specify physical units for objects, and the compiler will verify that uses
|
||||||
|
@ -20134,22 +20141,33 @@ familiar to engineering practice. The dimensions of algebraic expressions
|
||||||
(including powers with static exponents) are computed from their consistuents.
|
(including powers with static exponents) are computed from their consistuents.
|
||||||
|
|
||||||
This feature depends on Ada 2012 aspect specifications, and is available from
|
This feature depends on Ada 2012 aspect specifications, and is available from
|
||||||
version 7.0.1 of GNAT onwards. The GNAT-specific aspect Dimension_System allows
|
version 7.0.1 of GNAT onwards.
|
||||||
you to define a system of units; the aspect Dimension then allows the user
|
The GNAT-specific aspect @code{Dimension_System}
|
||||||
to declare dimensioned quantities within a given system.
|
@cindex @code{Dimension_System} aspect
|
||||||
|
allows you to define a system of units; the aspect @code{Dimension}
|
||||||
|
@cindex @code{Dimension} aspect
|
||||||
|
then allows the user to declare dimensioned quantities within a given system.
|
||||||
|
(These aspects are described in the @i{Implementation Defined Aspects}
|
||||||
|
chapter of the @i{GNAT Reference Manual}).
|
||||||
|
|
||||||
The major advantage of this model is that it does not require the declaration of
|
The major advantage of this model is that it does not require the declaration of
|
||||||
multiple operators for all possible combinations of types: it is only necessary
|
multiple operators for all possible combinations of types: it is only necessary
|
||||||
to use the proper subtypes in object declarations.
|
to use the proper subtypes in object declarations.
|
||||||
|
|
||||||
The simplest way to impose dimensionality checking on a computation is to make
|
The simplest way to impose dimensionality checking on a computation is to make
|
||||||
use of the package System.Dim.Mks, which is part of the GNAT library. This
|
use of the package @code{System.Dim.Mks},
|
||||||
package defines a floating-point type MKS_Type, for which a sequence of
|
@cindex @code{System.Dim.Mks} package (GNAT library)
|
||||||
|
which is part of the GNAT library. This
|
||||||
|
package defines a floating-point type @code{MKS_Type},
|
||||||
|
@cindex @code{MKS_Type} type
|
||||||
|
for which a sequence of
|
||||||
dimension names are specified, together with their conventional abbreviations.
|
dimension names are specified, together with their conventional abbreviations.
|
||||||
The following should be read together with the full specification of the
|
The following should be read together with the full specification of the
|
||||||
package, in file s-dimmks.ads.
|
package, in file @file{s-dimmks.ads}.
|
||||||
|
@cindex @file{s-dimmks.ads} file
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
type Mks_Type is new Long_Long_Float
|
type Mks_Type is new Long_Long_Float
|
||||||
with
|
with
|
||||||
Dimension_System => (
|
Dimension_System => (
|
||||||
|
@ -20160,40 +20178,49 @@ package, in file s-dimmks.ads.
|
||||||
(Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
|
(Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
|
||||||
(Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
|
(Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
|
||||||
(Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
|
(Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
The package then defines a series of subtypes that correspond to these
|
The package then defines a series of subtypes that correspond to these
|
||||||
conventional units. For example:
|
conventional units. For example:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
subtype Length is Mks_Type
|
subtype Length is Mks_Type
|
||||||
with
|
with
|
||||||
Dimension => (Symbol => 'm', Meter => 1, others => 0);
|
Dimension => (Symbol => 'm', Meter => 1, others => 0);
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
and similarly for Mass, Time, Electric_Current, Thermodynamic_Temperature,
|
and similarly for @code{Mass}, @code{Time}, @code{Electric_Current},
|
||||||
Amount_Of_Substance, and Luminous_Intensity (the standard set of units of
|
@code{Thermodynamic_Temperature}, @code{Amount_Of_Substance}, and
|
||||||
the SI system).
|
@code{Luminous_Intensity} (the standard set of units of the SI system).
|
||||||
|
|
||||||
The package also defines conventional names for values of each unit, for
|
The package also defines conventional names for values of each unit, for
|
||||||
example:
|
example:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
m : constant Length := 1.0;
|
m : constant Length := 1.0;
|
||||||
kg : constant Mass := 1.0;
|
kg : constant Mass := 1.0;
|
||||||
s : constant Time := 1.0;
|
s : constant Time := 1.0;
|
||||||
A : constant Electric_Current := 1.0;
|
A : constant Electric_Current := 1.0;
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
as well as useful multiples of these units:
|
as well as useful multiples of these units:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
cm : constant Length := 1.0E-02;
|
cm : constant Length := 1.0E-02;
|
||||||
g : constant Mass := 1.0E-03;
|
g : constant Mass := 1.0E-03;
|
||||||
min : constant Time := 60.0;
|
min : constant Time := 60.0;
|
||||||
day : constant TIme := 60.0 * 24.0 * min;
|
day : constant Time := 60.0 * 24.0 * min;
|
||||||
...
|
...
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
|
@ -20203,17 +20230,20 @@ specifies its dimensions within the MKS system, as well as the string to
|
||||||
be used for output of a value of that unit:
|
be used for output of a value of that unit:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
subtype Acceleration is Mks_Type
|
subtype Acceleration is Mks_Type
|
||||||
with Dimension => ("m/sec^^^2",
|
with Dimension => ("m/sec^^^2",
|
||||||
Meter => 1,
|
Meter => 1,
|
||||||
Second => -2,
|
Second => -2,
|
||||||
others => 0);
|
others => 0);
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
Here is a complete example of use:
|
Here is a complete example of use:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
with System.Dim.MKS; use System.Dim.Mks;
|
with System.Dim.MKS; use System.Dim.Mks;
|
||||||
with System.Dim.Mks_IO; use System.Dim.Mks_IO;
|
with System.Dim.Mks_IO; use System.Dim.Mks_IO;
|
||||||
with Text_IO; use Text_IO;
|
with Text_IO; use Text_IO;
|
||||||
|
@ -20223,6 +20253,8 @@ procedure Free_Fall is
|
||||||
G : constant acceleration := 9.81 * m / (s ** 2);
|
G : constant acceleration := 9.81 * m / (s ** 2);
|
||||||
T : Time := 10.0*s;
|
T : Time := 10.0*s;
|
||||||
Distance : Length;
|
Distance : Length;
|
||||||
|
@end group
|
||||||
|
@group
|
||||||
begin
|
begin
|
||||||
Put ("Gravitational constant: ");
|
Put ("Gravitational constant: ");
|
||||||
Put (G, Aft => 2, Exp => 0); Put_Line ("");
|
Put (G, Aft => 2, Exp => 0); Put_Line ("");
|
||||||
|
@ -20231,36 +20263,45 @@ begin
|
||||||
Put (Distance, Aft => 2, Exp => 0);
|
Put (Distance, Aft => 2, Exp => 0);
|
||||||
Put_Line ("");
|
Put_Line ("");
|
||||||
end Free_Fall;
|
end Free_Fall;
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
Execution of this program yields:
|
Execution of this program yields:
|
||||||
@smallexample
|
@smallexample
|
||||||
|
@group
|
||||||
Gravitational constant: 9.81 m/sec^^^2
|
Gravitational constant: 9.81 m/sec^^^2
|
||||||
distance travelled in 10 seconds of free fall 490.50 m
|
distance travelled in 10 seconds of free fall 490.50 m
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
However, incorrect assignments such as:
|
However, incorrect assignments such as:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
Distance := 5.0;
|
Distance := 5.0;
|
||||||
Distance := 5.0 * kg:
|
Distance := 5.0 * kg:
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
are rejected with the following diagnoses:
|
are rejected with the following diagnoses:
|
||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
|
@group
|
||||||
Distance := 5.0;
|
Distance := 5.0;
|
||||||
>>> dimensions mismatch in assignment
|
>>> dimensions mismatch in assignment
|
||||||
>>> left-hand side has dimension [L]
|
>>> left-hand side has dimension [L]
|
||||||
>>> right-hand side is dimensionless
|
>>> right-hand side is dimensionless
|
||||||
|
@end group
|
||||||
|
|
||||||
|
@group
|
||||||
Distance := 5.0 * kg:
|
Distance := 5.0 * kg:
|
||||||
>>> dimensions mismatch in assignment
|
>>> dimensions mismatch in assignment
|
||||||
>>> left-hand side has dimension [L]
|
>>> left-hand side has dimension [L]
|
||||||
>>> right-hand side has dimension [M]
|
>>> right-hand side has dimension [M]
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
|
@ -20268,9 +20309,11 @@ The dimensions of an expression are properly displayed, even if there is
|
||||||
no explicit subtype for it. If we add to the program:
|
no explicit subtype for it. If we add to the program:
|
||||||
|
|
||||||
@smallexample @c ada
|
@smallexample @c ada
|
||||||
|
@group
|
||||||
Put ("Final velocity: ");
|
Put ("Final velocity: ");
|
||||||
Put (G * T, Aft =>2, Exp =>0);
|
Put (G * T, Aft =>2, Exp =>0);
|
||||||
Put_Line ("");
|
Put_Line ("");
|
||||||
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
|
@ -20279,6 +20322,7 @@ then the output includes:
|
||||||
Final velocity: 98.10 m.s**(-1)
|
Final velocity: 98.10 m.s**(-1)
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
|
|
||||||
@c *********************************
|
@c *********************************
|
||||||
@node Generating Ada Bindings for C and C++ headers
|
@node Generating Ada Bindings for C and C++ headers
|
||||||
@chapter Generating Ada Bindings for C and C++ headers
|
@chapter Generating Ada Bindings for C and C++ headers
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
-- --
|
-- --
|
||||||
-- B o d y --
|
-- B o d y --
|
||||||
-- --
|
-- --
|
||||||
-- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
|
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
|
||||||
-- --
|
-- --
|
||||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||||
|
@ -913,7 +913,8 @@ begin
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
function Put_In_Sources
|
function Put_In_Sources
|
||||||
(S : File_Name_Type) return Boolean is
|
(S : File_Name_Type) return Boolean
|
||||||
|
is
|
||||||
begin
|
begin
|
||||||
for J in 1 .. Closure_Sources.Last loop
|
for J in 1 .. Closure_Sources.Last loop
|
||||||
if Closure_Sources.Table (J) = S then
|
if Closure_Sources.Table (J) = S then
|
||||||
|
@ -939,11 +940,14 @@ begin
|
||||||
for J in reverse Elab_Order.First .. Elab_Order.Last loop
|
for J in reverse Elab_Order.First .. Elab_Order.Last loop
|
||||||
Source := Units.Table (Elab_Order.Table (J)).Sfile;
|
Source := Units.Table (Elab_Order.Table (J)).Sfile;
|
||||||
|
|
||||||
-- Do not include the sources of the runtime and do not
|
-- Do not include same source more than once
|
||||||
-- include the same source several times.
|
|
||||||
|
|
||||||
if Put_In_Sources (Source)
|
if Put_In_Sources (Source)
|
||||||
and then not Is_Internal_File_Name (Source)
|
|
||||||
|
-- Do not include run-time units unless -Ra switch set
|
||||||
|
|
||||||
|
and then (List_Closure_All
|
||||||
|
or else not Is_Internal_File_Name (Source))
|
||||||
then
|
then
|
||||||
if not Zero_Formatting then
|
if not Zero_Formatting then
|
||||||
Write_Str (" ");
|
Write_Str (" ");
|
||||||
|
|
|
@ -885,7 +885,12 @@ package Opt is
|
||||||
|
|
||||||
List_Closure : Boolean := False;
|
List_Closure : Boolean := False;
|
||||||
-- GNATBIND
|
-- GNATBIND
|
||||||
-- List all sources in the closure of a main (-R gnatbind switch)
|
-- List all sources in the closure of a main (-R or -Ra gnatbind switch)
|
||||||
|
|
||||||
|
List_Closure_All : Boolean := False;
|
||||||
|
-- GNATBIND
|
||||||
|
-- List all sources in closure of main including run-time units (-Ra
|
||||||
|
-- gnatbind switch).
|
||||||
|
|
||||||
List_Dependencies : Boolean := False;
|
List_Dependencies : Boolean := False;
|
||||||
-- GNATMAKE
|
-- GNATMAKE
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
-- --
|
-- --
|
||||||
-- B o d y --
|
-- B o d y --
|
||||||
-- --
|
-- --
|
||||||
-- Copyright (C) 2001-2011, Free Software Foundation, Inc. --
|
-- Copyright (C) 2001-2014, Free Software Foundation, Inc. --
|
||||||
-- --
|
-- --
|
||||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||||
|
@ -379,6 +379,11 @@ package body Switch.B is
|
||||||
Ptr := Ptr + 1;
|
Ptr := Ptr + 1;
|
||||||
List_Closure := True;
|
List_Closure := True;
|
||||||
|
|
||||||
|
if Switch_Chars (Ptr) = 'a' then
|
||||||
|
Ptr := Ptr + 1;
|
||||||
|
List_Closure_All := True;
|
||||||
|
end if;
|
||||||
|
|
||||||
-- Processing for s switch
|
-- Processing for s switch
|
||||||
|
|
||||||
when 's' =>
|
when 's' =>
|
||||||
|
|
Loading…
Reference in New Issue