Daily bump.
[official-gcc.git] / gcc / ada / libgnat / s-fatgen.ads
blobb4b990b8fc5e873f432e9a227d12307031c70b20
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S Y S T E M . F A T _ G E N --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2024, 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 -- This generic package provides a target independent implementation of the
33 -- floating-point attributes that denote functions. The implementations here
34 -- should be portable and reasonably efficient. The runtime contains a set of
35 -- instantiations of this package for all predefined floating-point types.
37 generic
38 type T is digits <>;
40 package System.Fat_Gen is
41 pragma Pure;
43 subtype UI is Integer;
44 -- The runtime representation of universal integer for the purposes of
45 -- this package is integer. The expander generates conversions for the
46 -- actual type used. For functions returning universal integer, there
47 -- is no problem, since the result always is in range of integer. For
48 -- input arguments, the expander has to do some special casing to deal
49 -- with the (very annoying) cases of out of range values. If we used
50 -- Long_Long_Integer to represent universal, then there would be no
51 -- problem, but the resulting inefficiency would be annoying.
53 function Adjacent (X, Towards : T) return T;
55 function Ceiling (X : T) return T;
57 function Compose (Fraction : T; Exponent : UI) return T;
59 function Copy_Sign (Value, Sign : T) return T;
61 function Exponent (X : T) return UI;
63 function Floor (X : T) return T;
65 function Fraction (X : T) return T;
67 function Leading_Part (X : T; Radix_Digits : UI) return T;
69 function Machine (X : T) return T;
71 function Machine_Rounding (X : T) return T;
73 function Model (X : T) return T;
75 function Pred (X : T) return T;
77 function Remainder (X, Y : T) return T;
79 function Rounding (X : T) return T;
81 function Scaling (X : T; Adjustment : UI) return T;
83 function Succ (X : T) return T;
85 function Truncation (X : T) return T;
87 function Unbiased_Rounding (X : T) return T;
89 function Valid (X : not null access T) return Boolean;
90 -- This function checks if the object of type T referenced by X is valid,
91 -- and returns True/False accordingly. The parameter is passed by reference
92 -- (access) here, as the object of type T may be an abnormal value that
93 -- cannot be passed in a floating-point register, and the whole point of
94 -- 'Valid is to prevent exceptions. Note that the object of type T must
95 -- have the natural alignment for type T.
97 type S is new String (1 .. T'Size / Character'Size);
98 type P is access all S with Storage_Size => 0;
99 -- Buffer and access types used to initialize temporaries for validity
100 -- checks, if the value to be checked has reverse scalar storage order, or
101 -- is not known to be properly aligned (for example it appears in a packed
102 -- record). In this case, we cannot call Valid since Valid assumes proper
103 -- full alignment. Instead, we copy the value to a temporary location using
104 -- type S (we cannot simply do a copy of a T value, because the value might
105 -- be invalid, in which case it might not be possible to copy it through a
106 -- floating point register).
108 private
109 pragma Inline (Compose);
110 pragma Inline (Copy_Sign);
111 pragma Inline (Exponent);
112 pragma Inline (Fraction);
113 pragma Inline (Machine);
114 pragma Inline (Model);
115 pragma Inline (Valid);
117 end System.Fat_Gen;