* config/mcore/mcore.c: Convert to ISO C90 function declarations and definitions.
[official-gcc.git] / libstdc++-v3 / libmath / stubs.c
blob1968bffe7f9a110670b561aa3e13e4ed766372ca
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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_ATAN2F
38 float
39 atan2f(float x, float y)
41 return (float) atan2(x, y);
43 #endif
45 #ifndef HAVE_ATAN2L
46 long double
47 atan2l(long double x, long double y)
49 return atan2((double) x, (double) y);
51 #endif
54 #ifndef HAVE_COSF
55 float
56 cosf(float x)
58 return (float) cos(x);
60 #endif
62 #ifndef HAVE_COSL
63 long double
64 cosl(long double x)
66 return cos((double) x);
68 #endif
71 #ifndef HAVE_COSHF
72 float
73 coshf(float x)
75 return (float) cosh(x);
77 #endif
79 #ifndef HAVE_COSHL
80 long double
81 coshl(long double x)
83 return cosh((double) x);
85 #endif
88 #ifndef HAVE_EXPF
89 float
90 expf(float x)
92 return (float) exp(x);
94 #endif
96 #ifndef HAVE_EXPL
97 long double
98 expl(long double x)
100 return exp((double) x);
102 #endif
105 /* Compute the hypothenuse of a right triangle with side x and y. */
106 #ifndef HAVE_HYPOTF
107 float
108 hypotf(float x, float y)
110 float s = fabsf(x) + fabsf(y);
111 if (s == 0.0F)
112 return s;
113 x /= s; y /= s;
114 return s * sqrtf(x * x + y * y);
116 #endif
118 #ifndef HAVE_HYPOT
119 double
120 hypot(double x, double y)
122 double s = fabs(x) + fabs(y);
123 if (s == 0.0)
124 return s;
125 x /= s; y /= s;
126 return s * sqrt(x * x + y * y);
128 #endif
130 #ifndef HAVE_HYPOTL
131 long double
132 hypotl(long double x, long double y)
134 long double s = fabsl(x) + fabsl(y);
135 if (s == 0.0L)
136 return s;
137 x /= s; y /= s;
138 return s * sqrtl(x * x + y * y);
140 #endif
144 #ifndef HAVE_LOGF
145 float
146 logf(float x)
148 return (float) log(x);
150 #endif
152 #ifndef HAVE_LOGL
153 long double
154 logl(long double x)
156 return log((double) x);
158 #endif
161 #ifndef HAVE_LOG10F
162 float
163 log10f(float x)
165 return (float) log10(x);
167 #endif
169 #ifndef HAVE_LOG10L
170 long double
171 log10l(long double x)
173 return log10((double) x);
175 #endif
178 #ifndef HAVE_POWF
179 float
180 powf(float x, float y)
182 return (float) pow(x, y);
184 #endif
186 #ifndef HAVE_POWL
187 long double
188 powl(long double x, long double y)
190 return pow((double) x, (double) y);
192 #endif
195 #ifndef HAVE_SINF
196 float
197 sinf(float x)
199 return (float) sin(x);
201 #endif
203 #ifndef HAVE_SINL
204 long double
205 sinl(long double x)
207 return sin((double) x);
209 #endif
212 #ifndef HAVE_SINHF
213 float
214 sinhf(float x)
216 return (float) sinh(x);
218 #endif
220 #ifndef HAVE_SINHL
221 long double
222 sinhl(long double x)
224 return sinh((double) x);
226 #endif
229 #ifndef HAVE_SQRTF
230 float
231 sqrtf(float x)
233 return (float) sqrt(x);
235 #endif
237 #ifndef HAVE_SQRTL
238 long double
239 sqrtl(long double x)
241 return sqrt((double) x);
243 #endif
246 #ifndef HAVE_TANF
247 float
248 tanf(float x)
250 return (float) tan(x);
252 #endif
254 #ifndef HAVE_TANL
255 long double
256 tanl(long double x)
258 return tan((double) x);
260 #endif
263 #ifndef HAVE_TANHF
264 float
265 tanhf(float x)
267 return (float) tanh(x);
269 #endif
271 #ifndef HAVE_TANHL
272 long double
273 tanhl(long double x)
275 return tanh((double) x);
277 #endif