OSDN Git Service

797b2017fb0627608ce8c4395d56b43c07d2a787
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / libmath / stubs.c
1 /* Stub definitions for libmath subpart of libstdc++. */
2
3 /* Copyright (C) 2001, 2002, 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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 <math.h>
31 #include "config.h"
32
33 /* For targets which do not have support for long double versions,
34    we use the crude approximation.  We'll do better later.  */
35
36
37 #ifndef HAVE_ACOSF
38 float
39 acosf(float x)
40 {
41   return (float) acos(x);
42 }
43 #endif
44
45 #ifndef HAVE_ACOSL
46 long double
47 acosl(long double x)
48 {
49   return acos((double) x);
50 }
51 #endif
52
53
54 #ifndef HAVE_ASINF
55 float
56 asinf(float x)
57 {
58   return (float) asin(x);
59 }
60 #endif
61
62 #ifndef HAVE_ASINL
63 long double
64 asinl(long double x)
65 {
66   return asin((double) x);
67 }
68 #endif
69
70
71 #ifndef HAVE_ATANF
72 float
73 atanf(float x)
74 {
75   return (float) atan(x);
76 }
77 #endif
78
79 #ifndef HAVE_ATANL
80 long double
81 atanl(long double x)
82 {
83   return atan ((double) x);
84 }
85 #endif
86
87
88 #ifndef HAVE_ATAN2F
89 float
90 atan2f(float x, float y)
91 {
92   return (float) atan2(x, y);
93 }
94 #endif
95
96 #ifndef HAVE_ATAN2L
97 long double
98 atan2l(long double x, long double y)
99 {
100   return atan2((double) x, (double) y);
101 }
102 #endif
103
104
105 #ifndef HAVE_CEILF
106 float
107 ceilf(float x)
108 {
109   return (float) ceil(x);
110 }
111 #endif
112
113 #ifndef HAVE_CEILL
114 long double
115 ceill(long double x)
116 {
117   return ceil((double) x);
118 }
119 #endif
120
121
122 #ifndef HAVE_COSF
123 float
124 cosf(float x)
125 {
126   return (float) cos(x);
127 }
128 #endif
129
130 #ifndef HAVE_COSL
131 long double
132 cosl(long double x)
133 {
134   return cos((double) x);
135 }
136 #endif
137
138
139 #ifndef HAVE_COSHF
140 float
141 coshf(float x)
142 {
143   return (float) cosh(x);
144 }
145 #endif
146
147 #ifndef HAVE_COSHL
148 long double
149 coshl(long double x)
150 {
151   return cosh((double) x);
152 }
153 #endif
154
155
156 #ifndef HAVE_EXPF
157 float
158 expf(float x)
159 {
160   return (float) exp(x);
161 }
162 #endif
163
164 #ifndef HAVE_EXPL
165 long double
166 expl(long double x)
167 {
168   return exp((double) x);
169 }
170 #endif
171
172
173 #ifndef HAVE_FLOORF
174 float
175 floorf(float x)
176 {
177   return (float) floor(x);
178 }
179 #endif
180
181 #ifndef HAVE_FLOORL
182 long double
183 floorl(long double x)
184 {
185   return floor((double) x);
186 }
187 #endif
188
189
190 #ifndef HAVE_FMODF
191 float
192 fmodf(float x, float y)
193 {
194   return (float) fmod(x, y);
195 }
196 #endif
197
198 #ifndef HAVE_FMODL
199 long double
200 fmodl(long double x, long double y)
201 {
202   return fmod((double) x, (double) y);
203 }
204 #endif
205
206
207 #ifndef HAVE_FREXPF
208 float
209 frexpf(float x, int *exp)
210 {
211   return (float) frexp(x, exp);
212 }
213 #endif
214
215 #ifndef HAVE_FREXPL
216 long double
217 frexpl(long double x, int *exp)
218 {
219   return frexp((double) x, exp);
220 }
221 #endif
222
223
224 #ifndef HAVE_SQRTF
225 float
226 sqrtf(float x)
227 {
228   return (float) sqrt(x);
229 }
230 #endif
231
232 #ifndef HAVE_SQRTL
233 long double
234 sqrtl(long double x)
235 {
236   return  sqrt((double) x);
237 }
238 #endif
239
240
241 /* Compute the hypothenuse of a right triangle with side x and y.  */
242 #ifndef HAVE_HYPOTF
243 float
244 hypotf(float x, float y)
245 {
246   float s = fabsf(x) + fabsf(y);
247   if (s == 0.0F)
248     return s;
249   x /= s; y /= s;
250   return s * sqrtf(x * x + y * y);
251 }
252 #endif
253
254 #ifndef HAVE_HYPOT
255 double
256 hypot(double x, double y)
257 {
258   double s = fabs(x) + fabs(y);
259   if (s == 0.0)
260     return s;
261   x /= s; y /= s;
262   return s * sqrt(x * x + y * y);
263 }
264 #endif
265
266 #ifndef HAVE_HYPOTL
267 long double
268 hypotl(long double x, long double y)
269 {
270   long double s = fabsl(x) + fabsl(y);
271   if (s == 0.0L)
272     return s;
273   x /= s; y /= s;
274   return s * sqrtl(x * x + y * y);
275 }
276 #endif
277
278
279
280 #ifndef HAVE_LDEXPF
281 float
282 ldexpf(float x, int exp)
283 {
284   return (float) ldexp(x, exp);
285 }
286 #endif
287
288 #ifndef HAVE_LDEXPL
289 long double
290 ldexpl(long double x, int exp)
291 {
292   return ldexp((double) x, exp);
293 }
294 #endif
295
296
297 #ifndef HAVE_LOGF
298 float
299 logf(float x)
300 {
301   return (float) log(x);
302 }
303 #endif
304
305 #ifndef HAVE_LOGL
306 long double
307 logl(long double x)
308 {
309   return log((double) x);
310 }
311 #endif
312
313
314 #ifndef HAVE_LOG10F
315 float
316 log10f(float x)
317 {
318   return (float) log10(x);
319 }
320 #endif
321
322 #ifndef HAVE_LOG10L
323 long double
324 log10l(long double x)
325 {
326   return log10((double) x);
327 }
328 #endif
329
330
331 #ifndef HAVE_MODFF
332 float
333 modff(float x, float *iptr)
334 {
335   double result, temp;
336
337   result = modf(x, &temp);
338   *iptr = (float) temp;
339   return (float) result;
340 }
341 #endif
342
343 #ifndef HAVE_MODFL
344 long double
345 modfl(long double x, long double *iptr)
346 {
347   double result, temp;
348
349   result = modf((double) x, &temp);
350   *iptr = temp;
351   return result;
352 }
353 #endif
354
355
356 #ifndef HAVE_POWF
357 float
358 powf(float x, float y)
359 {
360   return (float) pow(x, y);
361 }
362 #endif
363
364 #ifndef HAVE_POWL
365 long double
366 powl(long double x, long double y)
367 {
368   return pow((double) x, (double) y);
369 }
370 #endif
371
372
373 #ifndef HAVE_SINF
374 float
375 sinf(float x)
376 {
377   return (float) sin(x);
378 }
379 #endif
380
381 #ifndef HAVE_SINL
382 long double
383 sinl(long double x)
384 {
385   return sin((double) x);
386 }
387 #endif
388
389
390 #ifndef HAVE_SINHF
391 float
392 sinhf(float x)
393 {
394   return (float) sinh(x);
395 }
396 #endif
397
398 #ifndef HAVE_SINHL
399 long double
400 sinhl(long double x)
401 {
402   return sinh((double) x);
403 }
404 #endif
405
406
407 #ifndef HAVE_TANF
408 float
409 tanf(float x)
410 {
411   return (float) tan(x);
412 }
413 #endif
414
415 #ifndef HAVE_TANL
416 long double
417 tanl(long double x)
418 {
419   return tan((double) x);
420 }
421 #endif
422
423
424 #ifndef HAVE_TANHF
425 float
426 tanhf(float x)
427 {
428   return (float) tanh(x);
429 }
430 #endif
431
432 #ifndef HAVE_TANHL
433 long double
434 tanhl(long double x)
435 {
436   return tanh((double) x);
437 }
438 #endif