1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . F A T _ G E N --
9 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
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. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This generic package provides a target independent implementation of the
35 -- floating-point attributes that denote functions. The implementations here
36 -- are portable, but very slow. The runtime contains a set of instantiations
37 -- of this package for all predefined floating-point types, and these should
38 -- be replaced by efficient assembly language code where possible.
43 package System
.Fat_Gen
is
44 pragma Pure
(Fat_Gen
);
46 subtype UI
is Integer;
47 -- The runtime representation of universal integer for the purposes of
48 -- this package is integer. The expander generates conversions for the
49 -- actual type used. For functions returning universal integer, there
50 -- is no problem, since the result always is in range of integer. For
51 -- input arguments, the expander has to do some special casing to deal
52 -- with the (very annoying!) cases of out of range values. If we used
53 -- Long_Long_Integer to represent universal, then there would be no
54 -- problem, but the resulting inefficiency would be annoying.
56 function Adjacent
(X
, Towards
: T
) return T
;
58 function Ceiling
(X
: T
) return T
;
60 function Compose
(Fraction
: T
; Exponent
: UI
) return T
;
62 function Copy_Sign
(Value
, Sign
: T
) return T
;
64 function Exponent
(X
: T
) return UI
;
66 function Floor
(X
: T
) return T
;
68 function Fraction
(X
: T
) return T
;
70 function Leading_Part
(X
: T
; Radix_Digits
: UI
) return T
;
72 function Machine
(X
: T
) return T
;
74 function Model
(X
: T
) return T
;
76 function Pred
(X
: T
) return T
;
78 function Remainder
(X
, Y
: T
) return T
;
80 function Rounding
(X
: T
) return T
;
82 function Scaling
(X
: T
; Adjustment
: UI
) return T
;
84 function Succ
(X
: T
) return T
;
86 function Truncation
(X
: T
) return T
;
88 function Unbiased_Rounding
(X
: T
) return T
;
90 function Valid
(X
: access T
) return Boolean;
91 -- This function checks if the object of type T referenced by X
92 -- is valid, and returns True/False accordingly. The parameter is
93 -- passed by reference (access) here, as the object of type T may
94 -- be an abnormal value that cannot be passed in a floating-point
95 -- register, and the whole point of 'Valid is to prevent exceptions.
98 pragma Inline
(Machine
);
99 pragma Inline
(Model
);
100 pragma Inline_Always
(Valid
);