2015-05-12 Robert Dewar <dewar@adacore.com>
[official-gcc.git] / gcc / ada / s-dimmks.ads
blob48771d01c365ec0f10a8b49af4afbe9bbe619958
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-2013, 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 ------------------------------------------------------------------------------
32 -- Defines the MKS dimension system which is the SI system of units
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.
38 -- The dimension terminology is defined in System.Dim_IO package
40 with Ada.Numerics;
42 package System.Dim.Mks is
44 e : constant := Ada.Numerics.e;
45 Pi : constant := Ada.Numerics.Pi;
47 -- Dimensioned type Mks_Type
49 type Mks_Type is new Long_Long_Float
50 with
51 Dimension_System => (
52 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
53 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
54 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
55 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
56 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => '@'),
57 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
58 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
60 -- SI Base dimensioned subtypes
62 subtype Length is Mks_Type
63 with
64 Dimension => (Symbol => 'm',
65 Meter => 1,
66 others => 0);
68 subtype Mass is Mks_Type
69 with
70 Dimension => (Symbol => "kg",
71 Kilogram => 1,
72 others => 0);
74 subtype Time is Mks_Type
75 with
76 Dimension => (Symbol => 's',
77 Second => 1,
78 others => 0);
80 subtype Electric_Current is Mks_Type
81 with
82 Dimension => (Symbol => 'A',
83 Ampere => 1,
84 others => 0);
86 subtype Thermodynamic_Temperature is Mks_Type
87 with
88 Dimension => (Symbol => 'K',
89 Kelvin => 1,
90 others => 0);
92 subtype Amount_Of_Substance is Mks_Type
93 with
94 Dimension => (Symbol => "mol",
95 Mole => 1,
96 others => 0);
98 subtype Luminous_Intensity is Mks_Type
99 with
100 Dimension => (Symbol => "cd",
101 Candela => 1,
102 others => 0);
104 -- Initialize SI Base unit values
106 -- Turn off the all the dimension warnings for these basic assignments
107 -- since otherwise we would get complaints about assigning dimensionless
108 -- values to dimensioned subtypes (we can't assign 1.0*m to m).
110 pragma Warnings (Off, "*assumed to be*");
112 m : constant Length := 1.0;
113 kg : constant Mass := 1.0;
114 s : constant Time := 1.0;
115 A : constant Electric_Current := 1.0;
116 K : constant Thermodynamic_Temperature := 1.0;
117 mol : constant Amount_Of_Substance := 1.0;
118 cd : constant Luminous_Intensity := 1.0;
120 pragma Warnings (On, "*assumed to be*");
122 -- SI Derived dimensioned subtypes
124 subtype Absorbed_Dose is Mks_Type
125 with
126 Dimension => (Symbol => "Gy",
127 Meter => 2,
128 Second => -2,
129 others => 0);
131 subtype Angle is Mks_Type
132 with
133 Dimension => (Symbol => "rad",
134 others => 0);
136 subtype Area is Mks_Type
137 with
138 Dimension => (
139 Meter => 2,
140 others => 0);
142 subtype Catalytic_Activity is Mks_Type
143 with
144 Dimension => (Symbol => "kat",
145 Second => -1,
146 Mole => 1,
147 others => 0);
149 subtype Celsius_Temperature is Mks_Type
150 with
151 Dimension => (Symbol => "°C",
152 Kelvin => 1,
153 others => 0);
155 subtype Electric_Capacitance is Mks_Type
156 with
157 Dimension => (Symbol => 'F',
158 Meter => -2,
159 Kilogram => -1,
160 Second => 4,
161 Ampere => 2,
162 others => 0);
164 subtype Electric_Charge is Mks_Type
165 with
166 Dimension => (Symbol => 'C',
167 Second => 1,
168 Ampere => 1,
169 others => 0);
171 subtype Electric_Conductance is Mks_Type
172 with
173 Dimension => (Symbol => 'S',
174 Meter => -2,
175 Kilogram => -1,
176 Second => 3,
177 Ampere => 2,
178 others => 0);
180 subtype Electric_Potential_Difference is Mks_Type
181 with
182 Dimension => (Symbol => 'V',
183 Meter => 2,
184 Kilogram => 1,
185 Second => -3,
186 Ampere => -1,
187 others => 0);
189 subtype Electric_Resistance is Mks_Type
190 with
191 Dimension => (Symbol => "Ω",
192 Meter => 2,
193 Kilogram => 1,
194 Second => -3,
195 Ampere => -2,
196 others => 0);
198 subtype Energy is Mks_Type
199 with
200 Dimension => (Symbol => 'J',
201 Meter => 2,
202 Kilogram => 1,
203 Second => -2,
204 others => 0);
206 subtype Equivalent_Dose is Mks_Type
207 with
208 Dimension => (Symbol => "Sv",
209 Meter => 2,
210 Second => -2,
211 others => 0);
213 subtype Force is Mks_Type
214 with
215 Dimension => (Symbol => 'N',
216 Meter => 1,
217 Kilogram => 1,
218 Second => -2,
219 others => 0);
221 subtype Frequency is Mks_Type
222 with
223 Dimension => (Symbol => "Hz",
224 Second => -1,
225 others => 0);
227 subtype Illuminance is Mks_Type
228 with
229 Dimension => (Symbol => "lx",
230 Meter => -2,
231 Candela => 1,
232 others => 0);
234 subtype Inductance is Mks_Type
235 with
236 Dimension => (Symbol => 'H',
237 Meter => 2,
238 Kilogram => 1,
239 Second => -2,
240 Ampere => -2,
241 others => 0);
243 subtype Luminous_Flux is Mks_Type
244 with
245 Dimension => (Symbol => "lm",
246 Candela => 1,
247 others => 0);
249 subtype Magnetic_Flux is Mks_Type
250 with
251 Dimension => (Symbol => "Wb",
252 Meter => 2,
253 Kilogram => 1,
254 Second => -2,
255 Ampere => -1,
256 others => 0);
258 subtype Magnetic_Flux_Density is Mks_Type
259 with
260 Dimension => (Symbol => 'T',
261 Kilogram => 1,
262 Second => -2,
263 Ampere => -1,
264 others => 0);
266 subtype Power is Mks_Type
267 with
268 Dimension => (Symbol => 'W',
269 Meter => 2,
270 Kilogram => 1,
271 Second => -3,
272 others => 0);
274 subtype Pressure is Mks_Type
275 with
276 Dimension => (Symbol => "Pa",
277 Meter => -1,
278 Kilogram => 1,
279 Second => -2,
280 others => 0);
282 subtype Radioactivity is Mks_Type
283 with
284 Dimension => (Symbol => "Bq",
285 Second => -1,
286 others => 0);
288 subtype Solid_Angle is Mks_Type
289 with
290 Dimension => (Symbol => "sr",
291 others => 0);
293 subtype Speed is Mks_Type
294 with
295 Dimension => (
296 Meter => 1,
297 Second => -1,
298 others => 0);
300 subtype Volume is Mks_Type
301 with
302 Dimension => (
303 Meter => 3,
304 others => 0);
306 -- Initialize derived dimension values
308 -- Turn off the all the dimension warnings for these basic assignments
309 -- since otherwise we would get complaints about assigning dimensionless
310 -- values to dimensioned subtypes.
312 pragma Warnings (Off, "*assumed to be*");
314 rad : constant Angle := 1.0;
315 sr : constant Solid_Angle := 1.0;
316 Hz : constant Frequency := 1.0;
317 N : constant Force := 1.0;
318 Pa : constant Pressure := 1.0;
319 J : constant Energy := 1.0;
320 W : constant Power := 1.0;
321 C : constant Electric_Charge := 1.0;
322 V : constant Electric_Potential_Difference := 1.0;
323 F : constant Electric_Capacitance := 1.0;
324 Ohm : constant Electric_Resistance := 1.0;
325 Si : constant Electric_Conductance := 1.0;
326 Wb : constant Magnetic_Flux := 1.0;
327 T : constant Magnetic_Flux_Density := 1.0;
328 H : constant Inductance := 1.0;
329 dC : constant Celsius_Temperature := 273.15;
330 lm : constant Luminous_Flux := 1.0;
331 lx : constant Illuminance := 1.0;
332 Bq : constant Radioactivity := 1.0;
333 Gy : constant Absorbed_Dose := 1.0;
334 Sv : constant Equivalent_Dose := 1.0;
335 kat : constant Catalytic_Activity := 1.0;
337 -- SI prefixes for Meter
339 um : constant Length := 1.0E-06; -- micro (u)
340 mm : constant Length := 1.0E-03; -- milli
341 cm : constant Length := 1.0E-02; -- centi
342 dm : constant Length := 1.0E-01; -- deci
343 dam : constant Length := 1.0E+01; -- deka
344 hm : constant Length := 1.0E+02; -- hecto
345 km : constant Length := 1.0E+03; -- kilo
346 Mem : constant Length := 1.0E+06; -- mega
348 -- SI prefixes for Kilogram
350 ug : constant Mass := 1.0E-09; -- micro (u)
351 mg : constant Mass := 1.0E-06; -- milli
352 cg : constant Mass := 1.0E-05; -- centi
353 dg : constant Mass := 1.0E-04; -- deci
354 g : constant Mass := 1.0E-03; -- gram
355 dag : constant Mass := 1.0E-02; -- deka
356 hg : constant Mass := 1.0E-01; -- hecto
357 Meg : constant Mass := 1.0E+03; -- mega
359 -- SI prefixes for Second
361 us : constant Time := 1.0E-06; -- micro (u)
362 ms : constant Time := 1.0E-03; -- milli
363 cs : constant Time := 1.0E-02; -- centi
364 ds : constant Time := 1.0E-01; -- deci
365 das : constant Time := 1.0E+01; -- deka
366 hs : constant Time := 1.0E+02; -- hecto
367 ks : constant Time := 1.0E+03; -- kilo
368 Mes : constant Time := 1.0E+06; -- mega
370 -- Other constants for Second
372 min : constant Time := 60.0 * s;
373 hour : constant Time := 60.0 * min;
374 day : constant Time := 24.0 * hour;
375 year : constant Time := 365.25 * day;
377 -- SI prefixes for Ampere
379 mA : constant Electric_Current := 1.0E-03; -- milli
380 cA : constant Electric_Current := 1.0E-02; -- centi
381 dA : constant Electric_Current := 1.0E-01; -- deci
382 daA : constant Electric_Current := 1.0E+01; -- deka
383 hA : constant Electric_Current := 1.0E+02; -- hecto
384 kA : constant Electric_Current := 1.0E+03; -- kilo
385 MeA : constant Electric_Current := 1.0E+06; -- mega
387 pragma Warnings (On, "*assumed to be*");
388 end System.Dim.Mks;