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