2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / ada / s-vaflop.adb
blob79e295f94c14451e01168bd6d7f47d428830542f
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . V A X _ F L O A T _ O P E R A T I O N S --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1997-2008, 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This is a dummy body for use on non-Alpha systems so that the library
35 -- can compile. This dummy version uses ordinary conversions and other
36 -- arithmetic operations. It is used only for testing purposes in the
37 -- case where the -gnatdm switch is used to force testing of VMS features
38 -- on non-VMS systems.
40 with System.IO;
42 package body System.Vax_Float_Operations is
43 pragma Warnings (Off);
44 -- Warnings about infinite recursion when the -gnatdm switch is used
46 -----------
47 -- Abs_F --
48 -----------
50 function Abs_F (X : F) return F is
51 begin
52 return abs X;
53 end Abs_F;
55 -----------
56 -- Abs_G --
57 -----------
59 function Abs_G (X : G) return G is
60 begin
61 return abs X;
62 end Abs_G;
64 -----------
65 -- Add_F --
66 -----------
68 function Add_F (X, Y : F) return F is
69 begin
70 return X + Y;
71 end Add_F;
73 -----------
74 -- Add_G --
75 -----------
77 function Add_G (X, Y : G) return G is
78 begin
79 return X + Y;
80 end Add_G;
82 ------------
83 -- D_To_G --
84 ------------
86 function D_To_G (X : D) return G is
87 begin
88 return G (X);
89 end D_To_G;
91 --------------------
92 -- Debug_Output_D --
93 --------------------
95 procedure Debug_Output_D (Arg : D) is
96 begin
97 System.IO.Put (D'Image (Arg));
98 end Debug_Output_D;
100 --------------------
101 -- Debug_Output_F --
102 --------------------
104 procedure Debug_Output_F (Arg : F) is
105 begin
106 System.IO.Put (F'Image (Arg));
107 end Debug_Output_F;
109 --------------------
110 -- Debug_Output_G --
111 --------------------
113 procedure Debug_Output_G (Arg : G) is
114 begin
115 System.IO.Put (G'Image (Arg));
116 end Debug_Output_G;
118 --------------------
119 -- Debug_String_D --
120 --------------------
122 Debug_String_Buffer : String (1 .. 32);
123 -- Buffer used by all Debug_String_x routines for returning result
125 function Debug_String_D (Arg : D) return System.Address is
126 Image_String : constant String := D'Image (Arg) & ASCII.NUL;
127 Image_Size : constant Integer := Image_String'Length;
129 begin
130 Debug_String_Buffer (1 .. Image_Size) := Image_String;
131 return Debug_String_Buffer (1)'Address;
132 end Debug_String_D;
134 --------------------
135 -- Debug_String_F --
136 --------------------
138 function Debug_String_F (Arg : F) return System.Address is
139 Image_String : constant String := F'Image (Arg) & ASCII.NUL;
140 Image_Size : constant Integer := Image_String'Length;
142 begin
143 Debug_String_Buffer (1 .. Image_Size) := Image_String;
144 return Debug_String_Buffer (1)'Address;
145 end Debug_String_F;
147 --------------------
148 -- Debug_String_G --
149 --------------------
151 function Debug_String_G (Arg : G) return System.Address is
152 Image_String : constant String := G'Image (Arg) & ASCII.NUL;
153 Image_Size : constant Integer := Image_String'Length;
155 begin
156 Debug_String_Buffer (1 .. Image_Size) := Image_String;
157 return Debug_String_Buffer (1)'Address;
158 end Debug_String_G;
160 -----------
161 -- Div_F --
162 -----------
164 function Div_F (X, Y : F) return F is
165 begin
166 return X / Y;
167 end Div_F;
169 -----------
170 -- Div_G --
171 -----------
173 function Div_G (X, Y : G) return G is
174 begin
175 return X / Y;
176 end Div_G;
178 ----------
179 -- Eq_F --
180 ----------
182 function Eq_F (X, Y : F) return Boolean is
183 begin
184 return X = Y;
185 end Eq_F;
187 ----------
188 -- Eq_G --
189 ----------
191 function Eq_G (X, Y : G) return Boolean is
192 begin
193 return X = Y;
194 end Eq_G;
196 ------------
197 -- F_To_G --
198 ------------
200 function F_To_G (X : F) return G is
201 begin
202 return G (X);
203 end F_To_G;
205 ------------
206 -- F_To_Q --
207 ------------
209 function F_To_Q (X : F) return Q is
210 begin
211 return Q (X);
212 end F_To_Q;
214 ------------
215 -- F_To_S --
216 ------------
218 function F_To_S (X : F) return S is
219 begin
220 return S (X);
221 end F_To_S;
223 ------------
224 -- G_To_D --
225 ------------
227 function G_To_D (X : G) return D is
228 begin
229 return D (X);
230 end G_To_D;
232 ------------
233 -- G_To_F --
234 ------------
236 function G_To_F (X : G) return F is
237 begin
238 return F (X);
239 end G_To_F;
241 ------------
242 -- G_To_Q --
243 ------------
245 function G_To_Q (X : G) return Q is
246 begin
247 return Q (X);
248 end G_To_Q;
250 ------------
251 -- G_To_T --
252 ------------
254 function G_To_T (X : G) return T is
255 begin
256 return T (X);
257 end G_To_T;
259 ----------
260 -- Le_F --
261 ----------
263 function Le_F (X, Y : F) return Boolean is
264 begin
265 return X <= Y;
266 end Le_F;
268 ----------
269 -- Le_G --
270 ----------
272 function Le_G (X, Y : G) return Boolean is
273 begin
274 return X <= Y;
275 end Le_G;
277 ----------
278 -- Lt_F --
279 ----------
281 function Lt_F (X, Y : F) return Boolean is
282 begin
283 return X < Y;
284 end Lt_F;
286 ----------
287 -- Lt_G --
288 ----------
290 function Lt_G (X, Y : G) return Boolean is
291 begin
292 return X < Y;
293 end Lt_G;
295 -----------
296 -- Mul_F --
297 -----------
299 function Mul_F (X, Y : F) return F is
300 begin
301 return X * Y;
302 end Mul_F;
304 -----------
305 -- Mul_G --
306 -----------
308 function Mul_G (X, Y : G) return G is
309 begin
310 return X * Y;
311 end Mul_G;
313 ----------
314 -- Ne_F --
315 ----------
317 function Ne_F (X, Y : F) return Boolean is
318 begin
319 return X /= Y;
320 end Ne_F;
322 ----------
323 -- Ne_G --
324 ----------
326 function Ne_G (X, Y : G) return Boolean is
327 begin
328 return X /= Y;
329 end Ne_G;
331 -----------
332 -- Neg_F --
333 -----------
335 function Neg_F (X : F) return F is
336 begin
337 return -X;
338 end Neg_F;
340 -----------
341 -- Neg_G --
342 -----------
344 function Neg_G (X : G) return G is
345 begin
346 return -X;
347 end Neg_G;
349 --------
350 -- pd --
351 --------
353 procedure pd (Arg : D) is
354 begin
355 System.IO.Put_Line (D'Image (Arg));
356 end pd;
358 --------
359 -- pf --
360 --------
362 procedure pf (Arg : F) is
363 begin
364 System.IO.Put_Line (F'Image (Arg));
365 end pf;
367 --------
368 -- pg --
369 --------
371 procedure pg (Arg : G) is
372 begin
373 System.IO.Put_Line (G'Image (Arg));
374 end pg;
376 ------------
377 -- Q_To_F --
378 ------------
380 function Q_To_F (X : Q) return F is
381 begin
382 return F (X);
383 end Q_To_F;
385 ------------
386 -- Q_To_G --
387 ------------
389 function Q_To_G (X : Q) return G is
390 begin
391 return G (X);
392 end Q_To_G;
394 ------------
395 -- S_To_F --
396 ------------
398 function S_To_F (X : S) return F is
399 begin
400 return F (X);
401 end S_To_F;
403 --------------
404 -- Return_D --
405 --------------
407 function Return_D (X : D) return D is
408 begin
409 return X;
410 end Return_D;
412 --------------
413 -- Return_F --
414 --------------
416 function Return_F (X : F) return F is
417 begin
418 return X;
419 end Return_F;
421 --------------
422 -- Return_G --
423 --------------
425 function Return_G (X : G) return G is
426 begin
427 return X;
428 end Return_G;
430 -----------
431 -- Sub_F --
432 -----------
434 function Sub_F (X, Y : F) return F is
435 begin
436 return X - Y;
437 end Sub_F;
439 -----------
440 -- Sub_G --
441 -----------
443 function Sub_G (X, Y : G) return G is
444 begin
445 return X - Y;
446 end Sub_G;
448 ------------
449 -- T_To_D --
450 ------------
452 function T_To_D (X : T) return D is
453 begin
454 return G_To_D (T_To_G (X));
455 end T_To_D;
457 ------------
458 -- T_To_G --
459 ------------
461 function T_To_G (X : T) return G is
462 begin
463 return G (X);
464 end T_To_G;
466 -------------
467 -- Valid_D --
468 -------------
470 -- For now, convert to IEEE and do Valid test on result. This is not quite
471 -- accurate, but is good enough in practice.
473 function Valid_D (Arg : D) return Boolean is
474 Val : constant T := G_To_T (D_To_G (Arg));
475 begin
476 return Val'Valid;
477 end Valid_D;
479 -------------
480 -- Valid_F --
481 -------------
483 -- For now, convert to IEEE and do Valid test on result. This is not quite
484 -- accurate, but is good enough in practice.
486 function Valid_F (Arg : F) return Boolean is
487 Val : constant S := F_To_S (Arg);
488 begin
489 return Val'Valid;
490 end Valid_F;
492 -------------
493 -- Valid_G --
494 -------------
496 -- For now, convert to IEEE and do Valid test on result. This is not quite
497 -- accurate, but is good enough in practice.
499 function Valid_G (Arg : G) return Boolean is
500 Val : constant T := G_To_T (Arg);
501 begin
502 return Val'Valid;
503 end Valid_G;
505 end System.Vax_Float_Operations;