Makefile.am (sources): Add math_stubs_float.cc.
[gcc.git] / libstdc++-v3 / src / math_stubs_float.cc
1 // Stub definitions for float math.
2
3 // Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 #include <cmath>
31
32 // For targets which do not have support for float versions,
33 // we use the following crude approximations. We keep saying that we'll do
34 // better later, but never do.
35
36 extern "C"
37 {
38 #ifndef _GLIBCXX_HAVE_FABSF
39 float
40 fabsf(float x)
41 {
42 return (float) fabs(x);
43 }
44 #endif
45
46 #ifndef _GLIBCXX_HAVE_ACOSF
47 float
48 acosf(float x)
49 {
50 return (float) acos(x);
51 }
52 #endif
53
54 #ifndef _GLIBCXX_HAVE_ASINF
55 float
56 asinf(float x)
57 {
58 return (float) asin(x);
59 }
60 #endif
61
62 #ifndef _GLIBCXX_HAVE_ATANF
63 float
64 atanf(float x)
65 {
66 return (float) atan(x);
67 }
68 #endif
69
70 #ifndef _GLIBCXX_HAVE_ATAN2F
71 float
72 atan2f(float x, float y)
73 {
74 return (float) atan2(x, y);
75 }
76 #endif
77
78 #ifndef _GLIBCXX_HAVE_CEILF
79 float
80 ceilf(float x)
81 {
82 return (float) ceil(x);
83 }
84 #endif
85
86 #ifndef _GLIBCXX_HAVE_COSF
87 float
88 cosf(float x)
89 {
90 return (float) cos(x);
91 }
92 #endif
93
94 #ifndef _GLIBCXX_HAVE_COSHF
95 float
96 coshf(float x)
97 {
98 return (float) cosh(x);
99 }
100 #endif
101
102 #ifndef _GLIBCXX_HAVE_EXPF
103 float
104 expf(float x)
105 {
106 return (float) exp(x);
107 }
108 #endif
109
110 #ifndef _GLIBCXX_HAVE_FLOORF
111 float
112 floorf(float x)
113 {
114 return (float) floor(x);
115 }
116 #endif
117
118 #ifndef _GLIBCXX_HAVE_FMODF
119 float
120 fmodf(float x, float y)
121 {
122 return (float) fmod(x, y);
123 }
124 #endif
125
126 #ifndef _GLIBCXX_HAVE_FREXPF
127 float
128 frexpf(float x, int *exp)
129 {
130 return (float) frexp(x, exp);
131 }
132 #endif
133
134 #ifndef _GLIBCXX_HAVE_SQRTF
135 float
136 sqrtf(float x)
137 {
138 return (float) sqrt(x);
139 }
140 #endif
141
142 #ifndef _GLIBCXX_HAVE_HYPOTF
143 float
144 hypotf(float x, float y)
145 {
146 float s = fabsf(x) + fabsf(y);
147 if (s == 0.0F)
148 return s;
149 x /= s; y /= s;
150 return s * sqrtf(x * x + y * y);
151 }
152 #endif
153
154 #ifndef _GLIBCXX_HAVE_LDEXPF
155 float
156 ldexpf(float x, int exp)
157 {
158 return (float) ldexp(x, exp);
159 }
160 #endif
161
162 #ifndef _GLIBCXX_HAVE_LOGF
163 float
164 logf(float x)
165 {
166 return (float) log(x);
167 }
168 #endif
169
170 #ifndef _GLIBCXX_HAVE_LOG10F
171 float
172 log10f(float x)
173 {
174 return (float) log10(x);
175 }
176 #endif
177
178 #ifndef _GLIBCXX_HAVE_MODFF
179 float
180 modff(float x, float *iptr)
181 {
182 double result, temp;
183
184 result = modf(x, &temp);
185 *iptr = (float) temp;
186 return (float) result;
187 }
188 #endif
189
190 #ifndef _GLIBCXX_HAVE_POWF
191 float
192 powf(float x, float y)
193 {
194 return (float) pow(x, y);
195 }
196 #endif
197
198 #ifndef _GLIBCXX_HAVE_SINF
199 float
200 sinf(float x)
201 {
202 return (float) sin(x);
203 }
204 #endif
205
206 #ifndef _GLIBCXX_HAVE_SINHF
207 float
208 sinhf(float x)
209 {
210 return (float) sinh(x);
211 }
212 #endif
213
214 #ifndef _GLIBCXX_HAVE_TANF
215 float
216 tanf(float x)
217 {
218 return (float) tan(x);
219 }
220 #endif
221
222 #ifndef _GLIBCXX_HAVE_TANHF
223 float
224 tanhf(float x)
225 {
226 return (float) tanh(x);
227 }
228 #endif
229 } // extern "C"