Dead
[official-gcc.git] / gomp-20050608-branch / libstdc++-v3 / libmath / stubs.c
blob72c4f75a9d18dfb762ba0480a65e3821f3e1034e
1 /* Stub definitions for libmath subpart of libstdc++. */
3 /* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
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.
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.
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.
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. */
30 #include <math.h>
31 #include "config.h"
33 /* For targets which do not have support for long double versions,
34 we use the crude approximation. We'll do better later. */
37 #ifndef HAVE_FABSF
38 float
39 fabsf(float x)
41 return (float) fabs(x);
43 #endif
45 #ifndef HAVE_FABSL
46 long double
47 fabsl(long double x)
49 return fabs((double) x);
51 #endif
54 #ifndef HAVE_ACOSF
55 float
56 acosf(float x)
58 return (float) acos(x);
60 #endif
62 #ifndef HAVE_ACOSL
63 long double
64 acosl(long double x)
66 return acos((double) x);
68 #endif
71 #ifndef HAVE_ASINF
72 float
73 asinf(float x)
75 return (float) asin(x);
77 #endif
79 #ifndef HAVE_ASINL
80 long double
81 asinl(long double x)
83 return asin((double) x);
85 #endif
88 #ifndef HAVE_ATANF
89 float
90 atanf(float x)
92 return (float) atan(x);
94 #endif
96 #ifndef HAVE_ATANL
97 long double
98 atanl(long double x)
100 return atan ((double) x);
102 #endif
105 #ifndef HAVE_ATAN2F
106 float
107 atan2f(float x, float y)
109 return (float) atan2(x, y);
111 #endif
113 #ifndef HAVE_ATAN2L
114 long double
115 atan2l(long double x, long double y)
117 return atan2((double) x, (double) y);
119 #endif
122 #ifndef HAVE_CEILF
123 float
124 ceilf(float x)
126 return (float) ceil(x);
128 #endif
130 #ifndef HAVE_CEILL
131 long double
132 ceill(long double x)
134 return ceil((double) x);
136 #endif
139 #ifndef HAVE_COSF
140 float
141 cosf(float x)
143 return (float) cos(x);
145 #endif
147 #ifndef HAVE_COSL
148 long double
149 cosl(long double x)
151 return cos((double) x);
153 #endif
156 #ifndef HAVE_COSHF
157 float
158 coshf(float x)
160 return (float) cosh(x);
162 #endif
164 #ifndef HAVE_COSHL
165 long double
166 coshl(long double x)
168 return cosh((double) x);
170 #endif
173 #ifndef HAVE_EXPF
174 float
175 expf(float x)
177 return (float) exp(x);
179 #endif
181 #ifndef HAVE_EXPL
182 long double
183 expl(long double x)
185 return exp((double) x);
187 #endif
190 #ifndef HAVE_FLOORF
191 float
192 floorf(float x)
194 return (float) floor(x);
196 #endif
198 #ifndef HAVE_FLOORL
199 long double
200 floorl(long double x)
202 return floor((double) x);
204 #endif
207 #ifndef HAVE_FMODF
208 float
209 fmodf(float x, float y)
211 return (float) fmod(x, y);
213 #endif
215 #ifndef HAVE_FMODL
216 long double
217 fmodl(long double x, long double y)
219 return fmod((double) x, (double) y);
221 #endif
224 #ifndef HAVE_FREXPF
225 float
226 frexpf(float x, int *exp)
228 return (float) frexp(x, exp);
230 #endif
232 #ifndef HAVE_FREXPL
233 long double
234 frexpl(long double x, int *exp)
236 return frexp((double) x, exp);
238 #endif
241 #ifndef HAVE_SQRTF
242 float
243 sqrtf(float x)
245 return (float) sqrt(x);
247 #endif
249 #ifndef HAVE_SQRTL
250 long double
251 sqrtl(long double x)
253 return sqrt((double) x);
255 #endif
258 /* Compute the hypothenuse of a right triangle with side x and y. */
259 #ifndef HAVE_HYPOTF
260 float
261 hypotf(float x, float y)
263 float s = fabsf(x) + fabsf(y);
264 if (s == 0.0F)
265 return s;
266 x /= s; y /= s;
267 return s * sqrtf(x * x + y * y);
269 #endif
271 #ifndef HAVE_HYPOT
272 double
273 hypot(double x, double y)
275 double s = fabs(x) + fabs(y);
276 if (s == 0.0)
277 return s;
278 x /= s; y /= s;
279 return s * sqrt(x * x + y * y);
281 #endif
283 #ifndef HAVE_HYPOTL
284 long double
285 hypotl(long double x, long double y)
287 long double s = fabsl(x) + fabsl(y);
288 if (s == 0.0L)
289 return s;
290 x /= s; y /= s;
291 return s * sqrtl(x * x + y * y);
293 #endif
297 #ifndef HAVE_LDEXPF
298 float
299 ldexpf(float x, int exp)
301 return (float) ldexp(x, exp);
303 #endif
305 #ifndef HAVE_LDEXPL
306 long double
307 ldexpl(long double x, int exp)
309 return ldexp((double) x, exp);
311 #endif
314 #ifndef HAVE_LOGF
315 float
316 logf(float x)
318 return (float) log(x);
320 #endif
322 #ifndef HAVE_LOGL
323 long double
324 logl(long double x)
326 return log((double) x);
328 #endif
331 #ifndef HAVE_LOG10F
332 float
333 log10f(float x)
335 return (float) log10(x);
337 #endif
339 #ifndef HAVE_LOG10L
340 long double
341 log10l(long double x)
343 return log10((double) x);
345 #endif
348 #ifndef HAVE_MODFF
349 float
350 modff(float x, float *iptr)
352 double result, temp;
354 result = modf(x, &temp);
355 *iptr = (float) temp;
356 return (float) result;
358 #endif
360 #ifndef HAVE_MODFL
361 long double
362 modfl(long double x, long double *iptr)
364 double result, temp;
366 result = modf((double) x, &temp);
367 *iptr = temp;
368 return result;
370 #endif
373 #ifndef HAVE_POWF
374 float
375 powf(float x, float y)
377 return (float) pow(x, y);
379 #endif
381 #ifndef HAVE_POWL
382 long double
383 powl(long double x, long double y)
385 return pow((double) x, (double) y);
387 #endif
390 #ifndef HAVE_SINF
391 float
392 sinf(float x)
394 return (float) sin(x);
396 #endif
398 #ifndef HAVE_SINL
399 long double
400 sinl(long double x)
402 return sin((double) x);
404 #endif
407 #ifndef HAVE_SINHF
408 float
409 sinhf(float x)
411 return (float) sinh(x);
413 #endif
415 #ifndef HAVE_SINHL
416 long double
417 sinhl(long double x)
419 return sinh((double) x);
421 #endif
424 #ifndef HAVE_TANF
425 float
426 tanf(float x)
428 return (float) tan(x);
430 #endif
432 #ifndef HAVE_TANL
433 long double
434 tanl(long double x)
436 return tan((double) x);
438 #endif
441 #ifndef HAVE_TANHF
442 float
443 tanhf(float x)
445 return (float) tanh(x);
447 #endif
449 #ifndef HAVE_TANHL
450 long double
451 tanhl(long double x)
453 return tanh((double) x);
455 #endif