]>
Commit | Line | Data |
---|---|---|
34ff0b99 | 1 | // -*- C++ -*- C forwarding header. |
22aef514 | 2 | |
b39d0359 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 |
34ff0b99 | 4 | // Free Software Foundation, Inc. |
22aef514 BK |
5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
9 | // Free Software Foundation; either version 2, or (at your option) | |
10 | // any later version. | |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
17 | // You should have received a copy of the GNU General Public License along | |
18 | // with this library; see the file COPYING. If not, write to the Free | |
19 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
20 | // USA. | |
21 | ||
22 | // As a special exception, you may use this file as part of a free software | |
23 | // library without restriction. Specifically, if other files instantiate | |
24 | // templates or use macros or inline functions from this file, or you compile | |
25 | // this file and link it with other files to produce an executable, this | |
26 | // file does not by itself cause the resulting executable to be covered by | |
27 | // the GNU General Public License. This exception does not however | |
28 | // invalidate any other reasons why the executable file might be covered by | |
29 | // the GNU General Public License. | |
30 | ||
31 | // | |
32 | // ISO C++ 14882: 26.5 C library | |
33 | // | |
34 | ||
ffe94f83 PE |
35 | /** @file cmath |
36 | * This is a Standard C++ Library file. You should @c #include this file | |
37 | * in your programs, rather than any of the "*.h" implementation files. | |
38 | * | |
39 | * This is the C++ version of the Standard C Library header @c math.h, | |
40 | * and its contents are (mostly) the same as that header, but are all | |
41 | * contained in the namespace @c std. | |
42 | */ | |
43 | ||
3eb35fcf BK |
44 | #ifndef _CPP_CMATH |
45 | #define _CPP_CMATH 1 | |
34ff0b99 BK |
46 | |
47 | #pragma GCC system_header | |
22aef514 | 48 | |
98e6e789 | 49 | #include <bits/c++config.h> |
4e588ec9 | 50 | |
c0dae541 | 51 | #include <math.h> |
22aef514 | 52 | |
8089616e BK |
53 | // Get rid of those macros defined in <math.h> in lieu of real functions. |
54 | #undef abs | |
55 | #undef div | |
56 | #undef acos | |
57 | #undef asin | |
58 | #undef atan | |
59 | #undef atan2 | |
60 | #undef ceil | |
61 | #undef cos | |
62 | #undef cosh | |
63 | #undef exp | |
64 | #undef fabs | |
65 | #undef floor | |
66 | #undef fmod | |
67 | #undef frexp | |
68 | #undef ldexp | |
69 | #undef log | |
70 | #undef log10 | |
71 | #undef modf | |
72 | #undef pow | |
73 | #undef sin | |
74 | #undef sinh | |
4200d6fe | 75 | #undef sqrt |
8089616e BK |
76 | #undef tan |
77 | #undef tanh | |
78 | ||
b39d0359 LR |
79 | // ...and in the darkness bind them... |
80 | namespace __gnu_cxx | |
81 | { | |
82 | namespace __c99_binding | |
83 | { | |
84 | #if _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_CHECK || \ | |
85 | _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC | |
86 | extern "C" float (acosf)(float); | |
87 | extern "C" float (asinf)(float); | |
88 | extern "C" float (atanf)(float); | |
89 | extern "C" float (atan2f)(float, float); | |
90 | extern "C" float (ceilf)(float); | |
91 | extern "C" float (coshf)(float); | |
92 | extern "C" float (expf)(float); | |
93 | extern "C" float (floorf)(float); | |
94 | extern "C" float (fmodf)(float, float); | |
95 | extern "C" float (frexpf)(float, int*); | |
96 | extern "C" float (ldexpf)(float, int); | |
97 | extern "C" float (logf)(float); | |
98 | extern "C" float (log10f)(float); | |
99 | extern "C" float (modff)(float, float*); | |
100 | extern "C" float (powf)(float, float); | |
101 | extern "C" float (sinhf)(float); | |
102 | extern "C" float (tanf)(float); | |
103 | extern "C" float (tanhf)(float); | |
104 | #endif | |
105 | #if !_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC | |
106 | #if _GLIBCPP_HAVE_ACOSF | |
107 | using ::acosf; | |
108 | #endif | |
109 | #if _GLIBCPP_HAVE_ASINF | |
110 | using ::asinf; | |
111 | #endif | |
112 | #if _GLIBCPP_HAVE_ATANF | |
113 | using ::atanf; | |
114 | #endif | |
115 | #if _GLIBCPP_HAVE_ATAN2F | |
116 | using ::atan2f; | |
117 | #endif | |
118 | #if _GLIBCPP_HAVE_CEILF | |
119 | using ::ceilf; | |
120 | #endif | |
121 | #if _GLIBCPP_HAVE_COSHF | |
122 | using ::coshf; | |
123 | #endif | |
124 | #if _GLIBCPP_HAVE_EXPF | |
125 | using ::expf; | |
126 | #endif | |
127 | #if _GLIBCPP_HAVE_FLOORF | |
128 | using ::floorf; | |
129 | #endif | |
130 | #if _GLIBCPP_HAVE_FMODF | |
131 | using ::fmodf; | |
132 | #endif | |
133 | #if _GLIBCPP_HAVE_FREXPF | |
134 | using ::frexpf; | |
135 | #endif | |
136 | #if _GLIBCPP_HAVE_LDEXPF | |
137 | using ::ldexpf; | |
138 | #endif | |
139 | #if _GLIBCPP_HAVE_LOGF | |
140 | using ::logf; | |
141 | #endif | |
142 | #if _GLIBCPP_HAVE_LOG10F | |
143 | using ::log10f; | |
144 | #endif | |
145 | #if _GLIBCPP_HAVE_MODFF | |
146 | using ::modff; | |
147 | #endif | |
148 | #if _GLIBCPP_HAVE_POWF | |
149 | using ::powf; | |
150 | #endif | |
151 | #if _GLIBCPP_HAVE_SINHF | |
152 | using ::sinhf; | |
153 | #endif | |
154 | #if _GLIBCPP_HAVE_TANF | |
155 | using ::tanf; | |
156 | #endif | |
157 | #if _GLIBCPP_HAVE_TANHF | |
158 | using ::tanhf; | |
159 | #endif | |
160 | #endif /* _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC */ | |
161 | } | |
162 | } | |
163 | ||
98e6e789 BK |
164 | namespace std |
165 | { | |
166 | // Forward declaration of a helper function. This really should be | |
167 | // an `exported' forward declaration. | |
168 | template<typename _Tp> _Tp __cmath_power(_Tp, unsigned int); | |
169 | ||
4e588ec9 GDR |
170 | inline double |
171 | abs(double __x) | |
172 | { return __builtin_fabs(__x); } | |
173 | ||
d52e4867 RS |
174 | inline float |
175 | abs(float __x) | |
176 | { return __builtin_fabsf(__x); } | |
177 | ||
4e588ec9 GDR |
178 | inline long double |
179 | abs(long double __x) | |
180 | { return __builtin_fabsl(__x); } | |
181 | ||
22aef514 BK |
182 | #if _GLIBCPP_HAVE_ACOSF |
183 | inline float | |
b39d0359 | 184 | acos(float __x) { return __gnu_cxx::__c99_binding::acosf(__x); } |
22aef514 BK |
185 | #else |
186 | inline float | |
98e6e789 | 187 | acos(float __x) { return ::acos(static_cast<double>(__x)); } |
22aef514 BK |
188 | #endif |
189 | ||
de96ac46 | 190 | using ::acos; |
4e588ec9 GDR |
191 | |
192 | #if _GLIBCPP_HAVE_ACOSL | |
193 | inline long double | |
194 | acos(long double __x) { return ::acosl(__x); } | |
195 | #else | |
196 | inline long double | |
197 | acos(long double __x) { return ::acos(static_cast<double>(__x)); } | |
198 | #endif | |
199 | ||
d52e4867 RS |
200 | using ::asin; |
201 | ||
22aef514 BK |
202 | #if _GLIBCPP_HAVE_ASINF |
203 | inline float | |
b39d0359 | 204 | asin(float __x) { return __gnu_cxx::__c99_binding::asinf(__x); } |
22aef514 BK |
205 | #else |
206 | inline float | |
98e6e789 | 207 | asin(float __x) { return ::asin(static_cast<double>(__x)); } |
22aef514 BK |
208 | #endif |
209 | ||
4e588ec9 GDR |
210 | #if _GLIBCPP_HAVE_ASINL |
211 | inline long double | |
212 | asin(long double __x) { return ::asinl(__x); } | |
213 | #else | |
214 | inline long double | |
215 | asin(long double __x) { return ::asin(static_cast<double>(__x)); } | |
216 | #endif | |
217 | ||
d52e4867 RS |
218 | using ::atan; |
219 | ||
22aef514 BK |
220 | #if _GLIBCPP_HAVE_ATANF |
221 | inline float | |
b39d0359 | 222 | atan(float __x) { return __gnu_cxx::__c99_binding::atanf(__x); } |
22aef514 BK |
223 | #else |
224 | inline float | |
98e6e789 | 225 | atan(float __x) { return ::atan(static_cast<double>(__x)); } |
22aef514 BK |
226 | #endif |
227 | ||
4e588ec9 GDR |
228 | #if _GLIBCPP_HAVE_ATANL |
229 | inline long double | |
230 | atan(long double __x) { return ::atanl(__x); } | |
231 | #else | |
232 | inline long double | |
233 | atan(long double __x) { return ::atan(static_cast<double>(__x)); } | |
234 | #endif | |
235 | ||
d52e4867 RS |
236 | using ::atan2; |
237 | ||
22aef514 BK |
238 | #if _GLIBCPP_HAVE_ATAN2F |
239 | inline float | |
b39d0359 | 240 | atan2(float __y, float __x) { return __gnu_cxx::__c99_binding::atan2f(__y, __x); } |
22aef514 BK |
241 | #else |
242 | inline float | |
98e6e789 BK |
243 | atan2(float __y, float __x) |
244 | { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); } | |
22aef514 BK |
245 | #endif |
246 | ||
4e588ec9 GDR |
247 | #if _GLIBCPP_HAVE_ATAN2L |
248 | inline long double | |
249 | atan2(long double __y, long double __x) { return ::atan2l(__y, __x); } | |
250 | #else | |
251 | inline long double | |
252 | atan2(long double __y, long double __x) | |
253 | { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); } | |
254 | #endif | |
255 | ||
d52e4867 RS |
256 | using ::ceil; |
257 | ||
22aef514 BK |
258 | #if _GLIBCPP_HAVE_CEILF |
259 | inline float | |
b39d0359 | 260 | ceil(float __x) { return __gnu_cxx::__c99_binding::ceilf(__x); } |
22aef514 BK |
261 | #else |
262 | inline float | |
98e6e789 | 263 | ceil(float __x) { return ::ceil(static_cast<double>(__x)); } |
22aef514 BK |
264 | #endif |
265 | ||
4e588ec9 GDR |
266 | #if _GLIBCPP_HAVE_CEILL |
267 | inline long double | |
268 | ceil(long double __x) { return ::ceill(__x); } | |
22aef514 | 269 | #else |
4e588ec9 GDR |
270 | inline long double |
271 | ceil(long double __x) { return ::ceil(static_cast<double>(__x)); } | |
22aef514 BK |
272 | #endif |
273 | ||
d52e4867 RS |
274 | using ::cos; |
275 | ||
4e588ec9 GDR |
276 | inline float |
277 | cos(float __x) | |
278 | { return __builtin_cosf(__x); } | |
279 | ||
4e588ec9 GDR |
280 | inline long double |
281 | cos(long double __x) | |
282 | { return __builtin_cosl(__x); } | |
283 | ||
d52e4867 RS |
284 | using ::cosh; |
285 | ||
22aef514 BK |
286 | #if _GLIBCPP_HAVE_COSHF |
287 | inline float | |
b39d0359 | 288 | cosh(float __x) { return __gnu_cxx::__c99_binding::coshf(__x); } |
22aef514 BK |
289 | #else |
290 | inline float | |
98e6e789 | 291 | cosh(float __x) { return ::cosh(static_cast<double>(__x)); } |
22aef514 BK |
292 | #endif |
293 | ||
4e588ec9 GDR |
294 | #if _GLIBCPP_HAVE_COSHL |
295 | inline long double | |
296 | cosh(long double __x) { return ::coshl(__x); } | |
297 | #else | |
298 | inline long double | |
299 | cosh(long double __x) { return ::cosh(static_cast<double>(__x)); } | |
300 | #endif | |
301 | ||
d52e4867 RS |
302 | using ::exp; |
303 | ||
22aef514 BK |
304 | #if _GLIBCPP_HAVE_EXPF |
305 | inline float | |
b39d0359 | 306 | exp(float __x) { return __gnu_cxx::__c99_binding::expf(__x); } |
22aef514 BK |
307 | #else |
308 | inline float | |
98e6e789 | 309 | exp(float __x) { return ::exp(static_cast<double>(__x)); } |
22aef514 BK |
310 | #endif |
311 | ||
4e588ec9 GDR |
312 | #if _GLIBCPP_HAVE_EXPL |
313 | inline long double | |
314 | exp(long double __x) { return ::expl(__x); } | |
22aef514 | 315 | #else |
4e588ec9 GDR |
316 | inline long double |
317 | exp(long double __x) { return ::exp(static_cast<double>(__x)); } | |
22aef514 BK |
318 | #endif |
319 | ||
d52e4867 RS |
320 | using ::fabs; |
321 | ||
4e588ec9 GDR |
322 | inline float |
323 | fabs(float __x) | |
324 | { return __builtin_fabsf(__x); } | |
325 | ||
4e588ec9 GDR |
326 | inline long double |
327 | fabs(long double __x) | |
328 | { return __builtin_fabsl(__x); } | |
329 | ||
d52e4867 RS |
330 | using ::floor; |
331 | ||
22aef514 BK |
332 | #if _GLIBCPP_HAVE_FLOORF |
333 | inline float | |
b39d0359 | 334 | floor(float __x) { return __gnu_cxx::__c99_binding::floorf(__x); } |
22aef514 BK |
335 | #else |
336 | inline float | |
98e6e789 | 337 | floor(float __x) { return ::floor(static_cast<double>(__x)); } |
22aef514 BK |
338 | #endif |
339 | ||
4e588ec9 GDR |
340 | #if _GLIBCPP_HAVE_FLOORL |
341 | inline long double | |
342 | floor(long double __x) { return ::floorl(__x); } | |
343 | #else | |
344 | inline long double | |
345 | floor(long double __x) { return ::floor(static_cast<double>(__x)); } | |
346 | #endif | |
347 | ||
d52e4867 RS |
348 | using ::fmod; |
349 | ||
98e6e789 | 350 | #if _GLIBCPP_HAVE_FMODF |
22aef514 | 351 | inline float |
b39d0359 | 352 | fmod(float __x, float __y) { return __gnu_cxx::__c99_binding::fmodf(__x, __y); } |
22aef514 BK |
353 | #else |
354 | inline float | |
98e6e789 BK |
355 | fmod(float __x, float __y) |
356 | { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); } | |
22aef514 BK |
357 | #endif |
358 | ||
4e588ec9 GDR |
359 | #if _GLIBCPP_HAVE_FMODL |
360 | inline long double | |
361 | fmod(long double __x, long double __y) { return ::fmodl(__x, __y); } | |
362 | #else | |
363 | inline long double | |
364 | fmod(long double __x, long double __y) | |
365 | { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); } | |
366 | #endif | |
367 | ||
d52e4867 RS |
368 | using ::frexp; |
369 | ||
22aef514 BK |
370 | #if _GLIBCPP_HAVE_FREXPF |
371 | inline float | |
b39d0359 | 372 | frexp(float __x, int* __exp) { return __gnu_cxx::__c99_binding::frexpf(__x, __exp); } |
22aef514 BK |
373 | #else |
374 | inline float | |
98e6e789 | 375 | frexp(float __x, int* __exp) { return ::frexp(__x, __exp); } |
22aef514 BK |
376 | #endif |
377 | ||
4e588ec9 GDR |
378 | #if _GLIBCPP_HAVE_FREXPL |
379 | inline long double | |
380 | frexp(long double __x, int* __exp) { return ::frexpl(__x, __exp); } | |
381 | #else | |
382 | inline long double | |
383 | frexp(long double __x, int* __exp) | |
384 | { return ::frexp(static_cast<double>(__x), __exp); } | |
385 | #endif | |
386 | ||
d52e4867 RS |
387 | using ::ldexp; |
388 | ||
22aef514 BK |
389 | #if _GLIBCPP_HAVE_LDEXPF |
390 | inline float | |
b39d0359 | 391 | ldexp(float __x, int __exp) { return __gnu_cxx::__c99_binding::ldexpf(__x, __exp); } |
22aef514 BK |
392 | #else |
393 | inline float | |
98e6e789 BK |
394 | ldexp(float __x, int __exp) |
395 | { return ::ldexp(static_cast<double>(__x), __exp); } | |
22aef514 BK |
396 | #endif |
397 | ||
4e588ec9 GDR |
398 | #if _GLIBCPP_HAVE_LDEXPL |
399 | inline long double | |
400 | ldexp(long double __x, int __exp) { return ::ldexpl(__x, __exp); } | |
401 | #else | |
402 | inline long double | |
403 | ldexp(long double __x, int __exp) | |
404 | { return ::ldexp(static_cast<double>(__x), __exp); } | |
405 | #endif | |
406 | ||
d52e4867 RS |
407 | using ::log; |
408 | ||
22aef514 BK |
409 | #if _GLIBCPP_HAVE_LOGF |
410 | inline float | |
b39d0359 | 411 | log(float __x) { return __gnu_cxx::__c99_binding::logf(__x); } |
22aef514 | 412 | #else |
98e6e789 BK |
413 | inline float log(float __x) |
414 | { return ::log(static_cast<double>(__x)); } | |
22aef514 BK |
415 | #endif |
416 | ||
4e588ec9 GDR |
417 | #if _GLIBCPP_HAVE_LOGL |
418 | inline long double | |
419 | log(long double __x) { return ::logl(__x); } | |
420 | #else | |
421 | inline long double | |
422 | log(long double __x) { return ::log(static_cast<double>(__x)); } | |
423 | #endif | |
424 | ||
d52e4867 RS |
425 | using ::log10; |
426 | ||
22aef514 BK |
427 | #if _GLIBCPP_HAVE_LOG10F |
428 | inline float | |
b39d0359 | 429 | log10(float __x) { return __gnu_cxx::__c99_binding::log10f(__x); } |
22aef514 BK |
430 | #else |
431 | inline float | |
98e6e789 | 432 | log10(float __x) { return ::log10(static_cast<double>(__x)); } |
22aef514 BK |
433 | #endif |
434 | ||
4e588ec9 GDR |
435 | #if _GLIBCPP_HAVE_LOG10L |
436 | inline long double | |
437 | log10(long double __x) { return ::log10l(__x); } | |
438 | #else | |
439 | inline long double | |
440 | log10(long double __x) { return ::log10(static_cast<double>(__x)); } | |
441 | #endif | |
442 | ||
d52e4867 RS |
443 | using ::modf; |
444 | ||
22aef514 BK |
445 | #if _GLIBCPP_HAVE_MODFF |
446 | inline float | |
b39d0359 | 447 | modf(float __x, float* __iptr) { return __gnu_cxx::__c99_binding::modff(__x, __iptr); } |
22aef514 BK |
448 | #else |
449 | inline float | |
98e6e789 | 450 | modf(float __x, float* __iptr) |
22aef514 BK |
451 | { |
452 | double __tmp; | |
98e6e789 BK |
453 | double __res = ::modf(static_cast<double>(__x), &__tmp); |
454 | *__iptr = static_cast<float>(__tmp); | |
22aef514 BK |
455 | return __res; |
456 | } | |
457 | #endif | |
98e6e789 | 458 | |
4e588ec9 GDR |
459 | #if _GLIBCPP_HAVE_MODFL |
460 | inline long double | |
461 | modf(long double __x, long double* __iptr) { return ::modfl(__x, __iptr); } | |
462 | #else | |
463 | inline long double | |
464 | modf(long double __x, long double* __iptr) | |
465 | { | |
466 | double __tmp; | |
467 | double __res = ::modf(static_cast<double>(__x), &__tmp); | |
468 | * __iptr = static_cast<long double>(__tmp); | |
469 | return __res; | |
470 | } | |
471 | #endif | |
472 | ||
98e6e789 BK |
473 | template<typename _Tp> |
474 | inline _Tp | |
475 | __pow_helper(_Tp __x, int __n) | |
476 | { | |
477 | return __n < 0 | |
478 | ? _Tp(1)/__cmath_power(__x, -__n) | |
479 | : __cmath_power(__x, __n); | |
480 | } | |
d52e4867 RS |
481 | |
482 | using ::pow; | |
483 | ||
22aef514 BK |
484 | #if _GLIBCPP_HAVE_POWF |
485 | inline float | |
b39d0359 | 486 | pow(float __x, float __y) { return __gnu_cxx::__c99_binding::powf(__x, __y); } |
22aef514 BK |
487 | #else |
488 | inline float | |
98e6e789 BK |
489 | pow(float __x, float __y) |
490 | { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); } | |
22aef514 BK |
491 | #endif |
492 | ||
4e588ec9 GDR |
493 | #if _GLIBCPP_HAVE_POWL |
494 | inline long double | |
495 | pow(long double __x, long double __y) { return ::powl(__x, __y); } | |
22aef514 | 496 | #else |
4e588ec9 GDR |
497 | inline long double |
498 | pow(long double __x, long double __y) | |
499 | { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); } | |
22aef514 BK |
500 | #endif |
501 | ||
22aef514 | 502 | inline double |
98e6e789 | 503 | pow(double __x, int __i) |
de96ac46 | 504 | { return __pow_helper(__x, __i); } |
22aef514 | 505 | |
d52e4867 RS |
506 | inline float |
507 | pow(float __x, int __n) | |
508 | { return __pow_helper(__x, __n); } | |
509 | ||
22aef514 | 510 | inline long double |
4e588ec9 | 511 | pow(long double __x, int __n) |
de96ac46 | 512 | { return __pow_helper(__x, __n); } |
22aef514 | 513 | |
d52e4867 RS |
514 | using ::sin; |
515 | ||
4e588ec9 GDR |
516 | inline float |
517 | sin(float __x) | |
518 | { return __builtin_sinf(__x); } | |
22aef514 | 519 | |
4e588ec9 GDR |
520 | inline long double |
521 | sin(long double __x) | |
522 | { return __builtin_sinl(__x); } | |
22aef514 | 523 | |
d52e4867 RS |
524 | using ::sinh; |
525 | ||
4e588ec9 GDR |
526 | #if _GLIBCPP_HAVE_SINHF |
527 | inline float | |
b39d0359 | 528 | sinh(float __x) { return __gnu_cxx::__c99_binding::sinhf(__x); } |
22aef514 | 529 | #else |
4e588ec9 GDR |
530 | inline float |
531 | sinh(float __x) { return ::sinh(static_cast<double>(__x)); } | |
22aef514 BK |
532 | #endif |
533 | ||
4e588ec9 | 534 | #if _GLIBCPP_HAVE_SINHL |
22aef514 | 535 | inline long double |
4e588ec9 | 536 | sinh(long double __x) { return ::sinhl(__x); } |
22aef514 BK |
537 | #else |
538 | inline long double | |
4e588ec9 | 539 | sinh(long double __x) { return ::sinh(static_cast<double>(__x)); } |
22aef514 BK |
540 | #endif |
541 | ||
d52e4867 RS |
542 | using ::sqrt; |
543 | ||
4e588ec9 GDR |
544 | inline float |
545 | sqrt(float __x) | |
546 | { return __builtin_sqrtf(__x); } | |
22aef514 | 547 | |
4e588ec9 GDR |
548 | inline long double |
549 | sqrt(long double __x) | |
550 | { return __builtin_sqrtl(__x); } | |
22aef514 | 551 | |
d52e4867 RS |
552 | using ::tan; |
553 | ||
4e588ec9 GDR |
554 | #if _GLIBCPP_HAVE_TANF |
555 | inline float | |
b39d0359 | 556 | tan(float __x) { return __gnu_cxx::__c99_binding::tanf(__x); } |
22aef514 | 557 | #else |
4e588ec9 GDR |
558 | inline float |
559 | tan(float __x) { return ::tan(static_cast<double>(__x)); } | |
22aef514 BK |
560 | #endif |
561 | ||
4e588ec9 | 562 | #if _GLIBCPP_HAVE_TANL |
22aef514 | 563 | inline long double |
4e588ec9 | 564 | tan(long double __x) { return ::tanl(__x); } |
22aef514 BK |
565 | #else |
566 | inline long double | |
4e588ec9 | 567 | tan(long double __x) { return ::tan(static_cast<double>(__x)); } |
22aef514 BK |
568 | #endif |
569 | ||
d52e4867 RS |
570 | using ::tanh; |
571 | ||
4e588ec9 GDR |
572 | #if _GLIBCPP_HAVE_TANHF |
573 | inline float | |
b39d0359 | 574 | tanh(float __x) { return __gnu_cxx::__c99_binding::tanhf(__x); } |
22aef514 | 575 | #else |
4e588ec9 GDR |
576 | inline float |
577 | tanh(float __x) { return ::tanh(static_cast<double>(__x)); } | |
22aef514 BK |
578 | #endif |
579 | ||
22aef514 BK |
580 | #if _GLIBCPP_HAVE_TANHL |
581 | inline long double | |
98e6e789 | 582 | tanh(long double __x) { return ::tanhl(__x); } |
22aef514 BK |
583 | #else |
584 | inline long double | |
98e6e789 | 585 | tanh(long double __x) { return ::tanh(static_cast<double>(__x)); } |
22aef514 | 586 | #endif |
61c71946 | 587 | } |
22aef514 | 588 | |
7cda84dc BK |
589 | |
590 | #if _GLIBCPP_USE_C99 | |
b39d0359 | 591 | #if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC |
7cda84dc | 592 | // These are possible macros imported from C99-land. For strict |
3702c634 GDR |
593 | // conformance, remove possible C99-injected names from the global |
594 | // namespace, and sequester them in the __gnu_cxx extension namespace. | |
595 | namespace __gnu_cxx | |
7cda84dc BK |
596 | { |
597 | template<typename _Tp> | |
598 | int | |
599 | __capture_fpclassify(_Tp __f) { return fpclassify(__f); } | |
600 | ||
601 | template<typename _Tp> | |
602 | int | |
603 | __capture_isfinite(_Tp __f) { return isfinite(__f); } | |
604 | ||
605 | template<typename _Tp> | |
606 | int | |
607 | __capture_isinf(_Tp __f) { return isinf(__f); } | |
608 | ||
609 | template<typename _Tp> | |
610 | int | |
611 | __capture_isnan(_Tp __f) { return isnan(__f); } | |
612 | ||
613 | template<typename _Tp> | |
614 | int | |
615 | __capture_isnormal(_Tp __f) { return isnormal(__f); } | |
616 | ||
617 | template<typename _Tp> | |
618 | int | |
619 | __capture_signbit(_Tp __f) { return signbit(__f); } | |
620 | ||
621 | template<typename _Tp> | |
622 | int | |
3702c634 GDR |
623 | __capture_isgreater(_Tp __f1, _Tp __f2) |
624 | { return isgreater(__f1, __f2); } | |
7cda84dc | 625 | |
3702c634 GDR |
626 | template<typename _Tp> |
627 | int | |
628 | __capture_isgreaterequal(_Tp __f1, _Tp __f2) | |
629 | { return isgreaterequal(__f1, __f2); } | |
7cda84dc | 630 | |
3702c634 GDR |
631 | template<typename _Tp> |
632 | int | |
633 | __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); } | |
7cda84dc | 634 | |
3702c634 GDR |
635 | template<typename _Tp> |
636 | int | |
637 | __capture_islessequal(_Tp __f1, _Tp __f2) | |
638 | { return islessequal(__f1, __f2); } | |
7cda84dc | 639 | |
3702c634 GDR |
640 | template<typename _Tp> |
641 | int | |
642 | __capture_islessgreater(_Tp __f1, _Tp __f2) | |
643 | { return islessgreater(__f1, __f2); } | |
7cda84dc | 644 | |
3702c634 GDR |
645 | template<typename _Tp> |
646 | int | |
647 | __capture_isunordered(_Tp __f1, _Tp __f2) | |
648 | { return isunordered(__f1, __f2); } | |
c04ec67e | 649 | } |
7cda84dc | 650 | |
c04ec67e | 651 | // Only undefine the C99 FP macros, if actually captured for namespace movement |
7cda84dc BK |
652 | #undef fpclassify |
653 | #undef isfinite | |
654 | #undef isinf | |
655 | #undef isnan | |
656 | #undef isnormal | |
657 | #undef signbit | |
658 | #undef isgreater | |
659 | #undef isgreaterequal | |
660 | #undef isless | |
661 | #undef islessequal | |
662 | #undef islessgreater | |
663 | #undef isunordered | |
c04ec67e LR |
664 | #endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */ |
665 | #endif | |
7cda84dc BK |
666 | |
667 | #if _GLIBCPP_USE_C99 | |
b39d0359 | 668 | #if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC |
3702c634 | 669 | namespace __gnu_cxx |
7cda84dc BK |
670 | { |
671 | template<typename _Tp> | |
672 | int | |
673 | fpclassify(_Tp __f) { return __capture_fpclassify(__f); } | |
674 | ||
675 | template<typename _Tp> | |
676 | int | |
677 | isfinite(_Tp __f) { return __capture_isfinite(__f); } | |
678 | ||
679 | template<typename _Tp> | |
680 | int | |
681 | isinf(_Tp __f) { return __capture_isinf(__f); } | |
682 | ||
683 | template<typename _Tp> | |
684 | int | |
685 | isnan(_Tp __f) { return __capture_isnan(__f); } | |
686 | ||
687 | template<typename _Tp> | |
688 | int | |
689 | isnormal(_Tp __f) { return __capture_isnormal(__f); } | |
690 | ||
691 | template<typename _Tp> | |
692 | int | |
693 | signbit(_Tp __f) { return __capture_signbit(__f); } | |
694 | ||
695 | template<typename _Tp> | |
696 | int | |
697 | isgreater(_Tp __f1, _Tp __f2) { return __capture_isgreater(__f1, __f2); } | |
698 | ||
699 | template<typename _Tp> | |
700 | int | |
701 | isgreaterequal(_Tp __f1, _Tp __f2) | |
702 | { return __capture_isgreaterequal(__f1, __f2); } | |
703 | ||
704 | template<typename _Tp> | |
705 | int | |
706 | isless(_Tp __f1, _Tp __f2) { return __capture_isless(__f1, __f2); } | |
707 | ||
708 | template<typename _Tp> | |
709 | int | |
710 | islessequal(_Tp __f1, _Tp __f2) | |
711 | { return __capture_islessequal(__f1, __f2); } | |
712 | ||
713 | template<typename _Tp> | |
714 | int | |
5db6f3de BK |
715 | islessgreater(_Tp __f1, _Tp __f2) |
716 | { return __capture_islessgreater(__f1, __f2); } | |
7cda84dc BK |
717 | |
718 | template<typename _Tp> | |
719 | int | |
720 | isunordered(_Tp __f1, _Tp __f2) | |
721 | { return __capture_isunordered(__f1, __f2); } | |
722 | } | |
5db6f3de BK |
723 | |
724 | namespace std | |
725 | { | |
3702c634 GDR |
726 | using __gnu_cxx::fpclassify; |
727 | using __gnu_cxx::isfinite; | |
728 | using __gnu_cxx::isinf; | |
729 | using __gnu_cxx::isnan; | |
730 | using __gnu_cxx::isnormal; | |
731 | using __gnu_cxx::signbit; | |
732 | using __gnu_cxx::isgreater; | |
733 | using __gnu_cxx::isgreaterequal; | |
734 | using __gnu_cxx::isless; | |
735 | using __gnu_cxx::islessequal; | |
736 | using __gnu_cxx::islessgreater; | |
737 | using __gnu_cxx::isunordered; | |
5db6f3de | 738 | } |
b39d0359 | 739 | #endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */ |
7cda84dc BK |
740 | #endif |
741 | ||
98e6e789 BK |
742 | #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT |
743 | # define export | |
34ff0b99 | 744 | # include <bits/cmath.tcc> |
607642b6 | 745 | #endif |
22aef514 | 746 | |
98e6e789 | 747 | #endif |