File : s-gcmain-cert.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- S Y S T E M . G E N E R I C _ C _ M A T H _ I N T E R F A C E --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2015, 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 -- --
19 -- --
20 -- --
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 -- This is the Cert specific version of s-gcmain.ads.
33
34 -- The separate version is necessary, because this system does not
35 -- provide an implementation of tanh, among other hyperbolic functions.
36 -- The run time currently has no code to implement this function,
37 -- so the only short term option was to remove the hyperbolic functions.
38
39 -- This package is an implementation of the Ada elementary functions
40 -- using the C math library. The C library is assumed to be conforming
41 -- with ISO/IEC 9899:1999 (C99). In particular, all identities specified
42 -- in chapter F.9 must hold. Furthermore, the accuracy of the various
43 -- functions is assumed to be sufficient for the strict mode specified
44 -- in Annex G of the Ada standard.
45
46 -- For environments where this is not true, the generic Ada implementations
47 -- should be used. These only require the standard arithmetic operations.
48
49 -- Typically, the generic functions are imported from C as follows.
50 -- For the C type "float":
51 -- function Sin (X : Float) return Float;
52 -- pragma Import (C, Sin, "sinf");
53
54 -- or for the C type "double":
55 -- function Sin (X : Long_Float) return Long_Float;
56 -- pragma Import (C, Sin, "sin");
57
58 -- or for the C type "long double":
59 -- function Sin (X : Long_Long_Float) return Long_Long_Float
60 -- pragma Import (C, Sin, "sinl");
61
62 generic
63 type Float_Type is digits <>;
64
65 with function C_Sqrt (X : Float_Type) return Float_Type is <>;
66 with function C_Log (X : Float_Type) return Float_Type is <>;
67 with function C_Exp (X : Float_Type) return Float_Type is <>;
68 with function C_Pow (X, Y : Float_Type) return Float_Type is <>;
69
70 with function C_Sin (X : Float_Type) return Float_Type is <>;
71 with function C_Cos (X : Float_Type) return Float_Type is <>;
72 with function C_Tan (X : Float_Type) return Float_Type is <>;
73
74 with function C_Asin (X : Float_Type) return Float_Type is <>;
75 with function C_Acos (X : Float_Type) return Float_Type is <>;
76 with function C_Atan2 (Y, X : Float_Type) return Float_Type is <>;
77
78 package System.Generic_C_Math_Interface is
79 pragma Pure (Generic_C_Math_Interface);
80
81 pragma Assert (Float_Type'Machine_Radix = 2);
82
83 function Sqrt (X : Float_Type'Base) return Float_Type'Base;
84 function Log (X : Float_Type'Base) return Float_Type'Base;
85 function Log (X, Base : Float_Type'Base) return Float_Type'Base;
86 function Exp (X : Float_Type'Base) return Float_Type'Base;
87 function "**" (Left, Right : Float_Type'Base) return Float_Type'Base;
88
89 function Sin (X : Float_Type'Base) return Float_Type'Base;
90 function Sin (X, Cycle : Float_Type'Base) return Float_Type'Base;
91 function Cos (X : Float_Type'Base) return Float_Type'Base;
92 function Cos (X, Cycle : Float_Type'Base) return Float_Type'Base;
93 function Tan (X : Float_Type'Base) return Float_Type'Base;
94 function Tan (X, Cycle : Float_Type'Base) return Float_Type'Base;
95 function Cot (X : Float_Type'Base) return Float_Type'Base;
96 function Cot (X, Cycle : Float_Type'Base) return Float_Type'Base;
97
98 function Arcsin (X : Float_Type'Base) return Float_Type'Base;
99 function Arcsin (X, Cycle : Float_Type'Base) return Float_Type'Base;
100 function Arccos (X : Float_Type'Base) return Float_Type'Base;
101 function Arccos (X, Cycle : Float_Type'Base) return Float_Type'Base;
102
103 function Arctan
104 (Y : Float_Type'Base;
105 X : Float_Type'Base := 1.0) return Float_Type'Base;
106
107 function Arctan
108 (Y : Float_Type'Base;
109 X : Float_Type'Base := 1.0;
110 Cycle : Float_Type'Base) return Float_Type'Base;
111
112 function Arccot
113 (X : Float_Type'Base;
114 Y : Float_Type'Base := 1.0) return Float_Type'Base;
115
116 function Arccot
117 (X : Float_Type'Base;
118 Y : Float_Type'Base := 1.0;
119 Cycle : Float_Type'Base) return Float_Type'Base;
120
121 end System.Generic_C_Math_Interface;