OSDN Git Service

2012-01-10 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-dimmks.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --                        S Y S T E M . D I M _ M K S                       --
6 --                                                                          --
7 --                                  S p e c                                 --
8 --                                                                          --
9 --            Copyright (C) 2011, Free Software Foundation, Inc.            --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17 --                                                                          --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception,   --
20 -- version 3.1, as published by the Free Software Foundation.               --
21 --                                                                          --
22 -- You should have received a copy of the GNU General Public License and    --
23 -- a copy of the GCC Runtime Library Exception along with this program;     --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25 -- <http://www.gnu.org/licenses/>.                                          --
26 --                                                                          --
27 -- GNAT was originally developed  by the GNAT team at  New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
29 --                                                                          --
30 ------------------------------------------------------------------------------
31
32 --  Defines the MKS dimension system which is the SI system of units
33
34 --  Some other prefixes of this system are defined in a child package (see
35 --  System.Dim_Mks.Other_Prefixes) in order to avoid too many constant
36 --  declarations in this package.
37
38 with Ada.Numerics;
39
40 package System.Dim_Mks is
41
42    e  : constant := Ada.Numerics.e;
43    Pi : constant := Ada.Numerics.Pi;
44
45    --  Dimensioned type Mks_Type
46
47    type Mks_Type is new Long_Float
48      with
49       Dimension_System => ((Meter, 'm'),
50         (Kilogram, "kg"),
51         (Second,   's'),
52         (Ampere,   'A'),
53         (Kelvin,   'K'),
54         (Mole,     "mol"),
55         (Candela,  "cd"));
56
57    --  SI Base
58
59    subtype Length is Mks_Type
60      with
61       Dimension => ('m',
62         Meter =>  1,
63         others => 0);
64    subtype Mass is Mks_Type
65      with
66       Dimension => ("kg",
67         Kilogram => 1,
68         others =>   0);
69    subtype Time is Mks_Type
70      with
71       Dimension => ('s',
72         Second => 1,
73         others => 0);
74    subtype Electric_Current is Mks_Type
75      with
76       Dimension => ('A',
77         Ampere => 1,
78         others => 0);
79    subtype Thermodynamic_Temperature is Mks_Type
80      with
81       Dimension => ('K',
82         Kelvin => 1,
83         others => 0);
84    subtype Amount_Of_Substance is Mks_Type
85      with
86       Dimension => ("mol",
87         Mole =>   1,
88         others => 0);
89    subtype Luminous_Intensity is Mks_Type
90      with
91       Dimension => ("cd",
92         Candela => 1,
93         others =>  0);
94
95    --  SI Base units
96
97    m   : constant Length                    := 1.0;
98    kg  : constant Mass                      := 1.0;
99    s   : constant Time                      := 1.0;
100    A   : constant Electric_Current          := 1.0;
101    K   : constant Thermodynamic_Temperature := 1.0;
102    mol : constant Amount_Of_Substance       := 1.0;
103    cd  : constant Luminous_Intensity        := 1.0;
104
105    --  SI Derived dimensioned subtypes
106
107    subtype Angle is Mks_Type
108      with
109       Dimension => ("rad",
110         others => 0);
111
112    subtype Solid_Angle is Mks_Type
113      with
114       Dimension => ("sr",
115         others => 0);
116
117    subtype Frequency is Mks_Type
118      with
119       Dimension => ("Hz",
120         Second => -1,
121         others => 0);
122    subtype Force is Mks_Type
123      with
124       Dimension => ('N',
125         Meter =>    1,
126         Kilogram => 1,
127         Second =>  -2,
128         others =>   0);
129    subtype Pressure is Mks_Type
130      with
131       Dimension => ("Pa",
132         Meter =>    -1,
133         Kilogram => 1,
134         Second =>   -2,
135         others =>   0);
136    subtype Energy is Mks_Type
137      with
138       Dimension => ('J',
139         Meter =>    2,
140         Kilogram => 1,
141         Second =>   -2,
142         others =>   0);
143    subtype Power is Mks_Type
144      with
145       Dimension => ('W',
146         Meter =>    2,
147         Kilogram => 1,
148         Second =>   -3,
149         others =>   0);
150    subtype Electric_Charge is Mks_Type
151      with
152       Dimension => ('C',
153         Second => 1,
154         Ampere => 1,
155         others => 0);
156    subtype Electric_Potential_Difference is Mks_Type
157      with
158       Dimension => ('V',
159         Meter =>    2,
160         Kilogram => 1,
161         Second =>   -3,
162         Ampere =>   -1,
163         others =>   0);
164    subtype Electric_Capacitance is Mks_Type
165      with
166       Dimension => ('F',
167         Meter =>    -2,
168         Kilogram => -1,
169         Second =>   4,
170         Ampere =>   2,
171         others =>   0);
172    subtype Electric_Resistance is Mks_Type
173      with
174       Dimension => ("Ω",
175         Meter =>    2,
176         Kilogram => 1,
177         Second =>   -3,
178         Ampere =>   -2,
179         others =>   0);
180    subtype Electric_Conductance is Mks_Type
181      with
182       Dimension => ('S',
183         Meter =>    -2,
184         Kilogram => -1,
185         Second =>   3,
186         Ampere =>   2,
187         others =>   0);
188    subtype Magnetic_Flux is Mks_Type
189      with
190       Dimension => ("Wb",
191         Meter =>    2,
192         Kilogram => 1,
193         Second =>   -2,
194         Ampere =>   -1,
195         others =>   0);
196    subtype Magnetic_Flux_Density is Mks_Type
197      with
198       Dimension => ('T',
199         Kilogram => 1,
200         Second =>   -2,
201         Ampere =>   -1,
202         others =>   0);
203    subtype Inductance is Mks_Type
204      with
205       Dimension => ('H',
206         Meter =>    2,
207         Kilogram => 1,
208         Second =>   -2,
209         Ampere =>   -2,
210         others =>   0);
211    subtype Celsius_Temperature is Mks_Type
212      with
213       Dimension => ("°C",
214         Kelvin => 1,
215         others => 0);
216    subtype Luminous_Flux is Mks_Type
217      with
218       Dimension => ("lm",
219         Candela => 1,
220         others =>  0);
221    subtype Illuminance is Mks_Type
222      with
223       Dimension => ("lx",
224         Meter =>   -2,
225         Candela => 1,
226         others =>  0);
227    subtype Radioactivity is Mks_Type
228      with
229       Dimension => ("Bq",
230         Second => -1,
231         others => 0);
232    subtype Absorbed_Dose is Mks_Type
233      with
234       Dimension => ("Gy",
235         Meter =>  2,
236         Second => -2,
237         others => 0);
238    subtype Equivalent_Dose is Mks_Type
239      with
240       Dimension => ("Sv",
241         Meter =>  2,
242         Second => -2,
243         others => 0);
244    subtype Catalytic_Activity is Mks_Type
245      with
246       Dimension => ("kat",
247         Second => -1,
248         Mole =>   1,
249         others => 0);
250
251    rad : constant Angle                         := 1.0;
252    sr  : constant Solid_Angle                   := 1.0;
253    Hz  : constant Frequency                     := 1.0;
254    N   : constant Force                         := 1.0;
255    Pa  : constant Pressure                      := 1.0;
256    J   : constant Energy                        := 1.0;
257    W   : constant Power                         := 1.0;
258    C   : constant Electric_Charge               := 1.0;
259    V   : constant Electric_Potential_Difference := 1.0;
260    F   : constant Electric_Capacitance          := 1.0;
261    Ohm : constant Electric_Resistance           := 1.0;
262    Si  : constant Electric_Conductance          := 1.0;
263    Wb  : constant Magnetic_Flux                 := 1.0;
264    T   : constant Magnetic_Flux_Density         := 1.0;
265    H   : constant Inductance                    := 1.0;
266    dC  : constant Celsius_Temperature           := 273.15;
267    lm  : constant Luminous_Flux                 := 1.0;
268    lx  : constant Illuminance                   := 1.0;
269    Bq  : constant Radioactivity                 := 1.0;
270    Gy  : constant Absorbed_Dose                 := 1.0;
271    Sv  : constant Equivalent_Dose               := 1.0;
272    kat : constant Catalytic_Activity            := 1.0;
273
274    --  SI prefixes for Meter
275
276    um  : constant Length := 1.0E-06;  -- micro (u)
277    mm  : constant Length := 1.0E-03;  -- milli
278    cm  : constant Length := 1.0E-02;  -- centi
279    dm  : constant Length := 1.0E-01;  -- deci
280    dam : constant Length := 1.0E+01;  -- deka
281    hm  : constant Length := 1.0E+02;  -- hecto
282    km  : constant Length := 1.0E+03;  -- kilo
283    Mem : constant Length := 1.0E+06;  -- mega
284
285    --  SI prefixes for Kilogram
286
287    ug  : constant Mass := 1.0E-09;  -- micro (u)
288    mg  : constant Mass := 1.0E-06;  -- milli
289    cg  : constant Mass := 1.0E-05;  -- centi
290    dg  : constant Mass := 1.0E-04;  -- deci
291    g   : constant Mass := 1.0E-03;  -- gram
292    dag : constant Mass := 1.0E-02;  -- deka
293    hg  : constant Mass := 1.0E-01;  -- hecto
294    Meg : constant Mass := 1.0E+03;  -- mega
295
296    --  SI prefixes for Second
297
298    us  : constant Time := 1.0E-06;  -- micro (u)
299    ms  : constant Time := 1.0E-03;  -- milli
300    cs  : constant Time := 1.0E-02;  -- centi
301    ds  : constant Time := 1.0E-01;  -- deci
302    das : constant Time := 1.0E+01;  -- deka
303    hs  : constant Time := 1.0E+02;  -- hecto
304    ks  : constant Time := 1.0E+03;  -- kilo
305    Mes : constant Time := 1.0E+06;  -- mega
306
307    --  Other constants for Second
308
309    min  : constant Time := 60.0 * s;
310    hour : constant Time := 60.0 * min;
311    day  : constant Time := 24.0 * hour;
312    year : constant Time := 365.25 * day;
313
314    --  SI prefixes for Ampere
315
316    mA  : constant Electric_Current := 1.0E-03;  -- milli
317    cA  : constant Electric_Current := 1.0E-02;  -- centi
318    dA  : constant Electric_Current := 1.0E-01;  -- deci
319    daA : constant Electric_Current := 1.0E+01;  -- deka
320    hA  : constant Electric_Current := 1.0E+02;  -- hecto
321    kA  : constant Electric_Current := 1.0E+03;  -- kilo
322    MeA : constant Electric_Current := 1.0E+06;  -- mega
323
324 end System.Dim_Mks;