]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/c_std/std_cmath.h
* boehm.cc (_Jv_BuildGCDescr): Use `1ULL'.
[thirdparty/gcc.git] / libstdc++-v3 / include / c_std / std_cmath.h
CommitLineData
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
3d7c150e
BK
44#ifndef _CMATH
45#define _CMATH 1
34ff0b99
BK
46
47#pragma GCC system_header
22aef514 48
98e6e789 49#include <bits/c++config.h>
cdc958d8 50#include <bits/cpp_type_traits.h>
4e588ec9 51
c0dae541 52#include <math.h>
22aef514 53
8089616e
BK
54// Get rid of those macros defined in <math.h> in lieu of real functions.
55#undef abs
56#undef div
57#undef acos
58#undef asin
59#undef atan
60#undef atan2
61#undef ceil
62#undef cos
63#undef cosh
64#undef exp
65#undef fabs
66#undef floor
67#undef fmod
68#undef frexp
69#undef ldexp
70#undef log
71#undef log10
72#undef modf
73#undef pow
74#undef sin
75#undef sinh
4200d6fe 76#undef sqrt
8089616e
BK
77#undef tan
78#undef tanh
79
b39d0359
LR
80// ...and in the darkness bind them...
81namespace __gnu_cxx
82{
83 namespace __c99_binding
84 {
3d7c150e
BK
85#if _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_CHECK || \
86 _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
b39d0359
LR
87 extern "C" float (acosf)(float);
88 extern "C" float (asinf)(float);
89 extern "C" float (atanf)(float);
90 extern "C" float (atan2f)(float, float);
91 extern "C" float (ceilf)(float);
92 extern "C" float (coshf)(float);
93 extern "C" float (expf)(float);
94 extern "C" float (floorf)(float);
95 extern "C" float (fmodf)(float, float);
96 extern "C" float (frexpf)(float, int*);
97 extern "C" float (ldexpf)(float, int);
98 extern "C" float (logf)(float);
99 extern "C" float (log10f)(float);
100 extern "C" float (modff)(float, float*);
101 extern "C" float (powf)(float, float);
102 extern "C" float (sinhf)(float);
103 extern "C" float (tanf)(float);
104 extern "C" float (tanhf)(float);
105#endif
3d7c150e
BK
106#if !_GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
107#if _GLIBCXX_HAVE_ACOSF
b39d0359
LR
108 using ::acosf;
109#endif
3d7c150e 110#if _GLIBCXX_HAVE_ASINF
b39d0359
LR
111 using ::asinf;
112#endif
3d7c150e 113#if _GLIBCXX_HAVE_ATANF
b39d0359
LR
114 using ::atanf;
115#endif
3d7c150e 116#if _GLIBCXX_HAVE_ATAN2F
b39d0359
LR
117 using ::atan2f;
118#endif
3d7c150e 119#if _GLIBCXX_HAVE_CEILF
b39d0359
LR
120 using ::ceilf;
121#endif
3d7c150e 122#if _GLIBCXX_HAVE_COSHF
b39d0359
LR
123 using ::coshf;
124#endif
3d7c150e 125#if _GLIBCXX_HAVE_EXPF
b39d0359
LR
126 using ::expf;
127#endif
3d7c150e 128#if _GLIBCXX_HAVE_FLOORF
b39d0359
LR
129 using ::floorf;
130#endif
3d7c150e 131#if _GLIBCXX_HAVE_FMODF
b39d0359
LR
132 using ::fmodf;
133#endif
3d7c150e 134#if _GLIBCXX_HAVE_FREXPF
b39d0359
LR
135 using ::frexpf;
136#endif
3d7c150e 137#if _GLIBCXX_HAVE_LDEXPF
b39d0359
LR
138 using ::ldexpf;
139#endif
3d7c150e 140#if _GLIBCXX_HAVE_LOGF
b39d0359
LR
141 using ::logf;
142#endif
3d7c150e 143#if _GLIBCXX_HAVE_LOG10F
b39d0359
LR
144 using ::log10f;
145#endif
3d7c150e 146#if _GLIBCXX_HAVE_MODFF
b39d0359
LR
147 using ::modff;
148#endif
3d7c150e 149#if _GLIBCXX_HAVE_POWF
b39d0359
LR
150 using ::powf;
151#endif
3d7c150e 152#if _GLIBCXX_HAVE_SINHF
b39d0359
LR
153 using ::sinhf;
154#endif
3d7c150e 155#if _GLIBCXX_HAVE_TANF
b39d0359
LR
156 using ::tanf;
157#endif
3d7c150e 158#if _GLIBCXX_HAVE_TANHF
b39d0359
LR
159 using ::tanhf;
160#endif
3d7c150e 161#endif /* _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC */
b39d0359
LR
162 }
163}
164
98e6e789
BK
165namespace std
166{
167 // Forward declaration of a helper function. This really should be
168 // an `exported' forward declaration.
169 template<typename _Tp> _Tp __cmath_power(_Tp, unsigned int);
170
4e588ec9
GDR
171 inline double
172 abs(double __x)
173 { return __builtin_fabs(__x); }
174
d52e4867
RS
175 inline float
176 abs(float __x)
177 { return __builtin_fabsf(__x); }
178
4e588ec9
GDR
179 inline long double
180 abs(long double __x)
181 { return __builtin_fabsl(__x); }
182
3d7c150e 183#if _GLIBCXX_HAVE_ACOSF
22aef514 184 inline float
b39d0359 185 acos(float __x) { return __gnu_cxx::__c99_binding::acosf(__x); }
22aef514
BK
186#else
187 inline float
98e6e789 188 acos(float __x) { return ::acos(static_cast<double>(__x)); }
22aef514
BK
189#endif
190
de96ac46 191 using ::acos;
4e588ec9 192
3d7c150e 193#if _GLIBCXX_HAVE_ACOSL
4e588ec9
GDR
194 inline long double
195 acos(long double __x) { return ::acosl(__x); }
196#else
197 inline long double
198 acos(long double __x) { return ::acos(static_cast<double>(__x)); }
199#endif
200
cdc958d8
GDR
201 template<typename _Tp>
202 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
203 acos(_Tp __x)
204 {
205 return ::acos(static_cast<double>(__x));
206 }
207
d52e4867
RS
208 using ::asin;
209
3d7c150e 210#if _GLIBCXX_HAVE_ASINF
22aef514 211 inline float
b39d0359 212 asin(float __x) { return __gnu_cxx::__c99_binding::asinf(__x); }
22aef514
BK
213#else
214 inline float
98e6e789 215 asin(float __x) { return ::asin(static_cast<double>(__x)); }
22aef514
BK
216#endif
217
3d7c150e 218#if _GLIBCXX_HAVE_ASINL
4e588ec9
GDR
219 inline long double
220 asin(long double __x) { return ::asinl(__x); }
221#else
222 inline long double
223 asin(long double __x) { return ::asin(static_cast<double>(__x)); }
224#endif
225
cdc958d8
GDR
226 template<typename _Tp>
227 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
228 asin(_Tp __x)
229 { return ::asin(static_cast<double>(__x)); }
230
d52e4867
RS
231 using ::atan;
232
3d7c150e 233#if _GLIBCXX_HAVE_ATANF
22aef514 234 inline float
b39d0359 235 atan(float __x) { return __gnu_cxx::__c99_binding::atanf(__x); }
22aef514
BK
236#else
237 inline float
98e6e789 238 atan(float __x) { return ::atan(static_cast<double>(__x)); }
22aef514
BK
239#endif
240
3d7c150e 241#if _GLIBCXX_HAVE_ATANL
4e588ec9
GDR
242 inline long double
243 atan(long double __x) { return ::atanl(__x); }
244#else
245 inline long double
246 atan(long double __x) { return ::atan(static_cast<double>(__x)); }
247#endif
248
cdc958d8
GDR
249 template<typename _Tp>
250 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
251 atan(_Tp __x)
252 { return ::atan(static_cast<double>(__x)); }
253
d52e4867
RS
254 using ::atan2;
255
3d7c150e 256#if _GLIBCXX_HAVE_ATAN2F
22aef514 257 inline float
b39d0359 258 atan2(float __y, float __x) { return __gnu_cxx::__c99_binding::atan2f(__y, __x); }
22aef514
BK
259#else
260 inline float
98e6e789
BK
261 atan2(float __y, float __x)
262 { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
22aef514
BK
263#endif
264
3d7c150e 265#if _GLIBCXX_HAVE_ATAN2L
4e588ec9
GDR
266 inline long double
267 atan2(long double __y, long double __x) { return ::atan2l(__y, __x); }
268#else
269 inline long double
270 atan2(long double __y, long double __x)
271 { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
272#endif
273
cdc958d8
GDR
274 template<typename _Tp, typename _Up>
275 inline typename __enable_if<double, __is_integer<_Tp>::_M_type
276 && __is_integer<_Up>::_M_type>::_M_type
277 atan2(_Tp __x, _Up __y)
278 { return ::atan2(static_cast<double>(__x), static_cast<double>(__y)); }
279
d52e4867
RS
280 using ::ceil;
281
3d7c150e 282#if _GLIBCXX_HAVE_CEILF
22aef514 283 inline float
b39d0359 284 ceil(float __x) { return __gnu_cxx::__c99_binding::ceilf(__x); }
22aef514
BK
285#else
286 inline float
98e6e789 287 ceil(float __x) { return ::ceil(static_cast<double>(__x)); }
22aef514
BK
288#endif
289
3d7c150e 290#if _GLIBCXX_HAVE_CEILL
4e588ec9
GDR
291 inline long double
292 ceil(long double __x) { return ::ceill(__x); }
22aef514 293#else
4e588ec9
GDR
294 inline long double
295 ceil(long double __x) { return ::ceil(static_cast<double>(__x)); }
22aef514
BK
296#endif
297
cdc958d8
GDR
298 template<typename _Tp>
299 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
300 ceil(_Tp __x)
301 { return ::ceil(static_cast<double>(__x)); }
302
d52e4867
RS
303 using ::cos;
304
4e588ec9
GDR
305 inline float
306 cos(float __x)
307 { return __builtin_cosf(__x); }
308
4e588ec9
GDR
309 inline long double
310 cos(long double __x)
311 { return __builtin_cosl(__x); }
312
cdc958d8
GDR
313 template<typename _Tp>
314 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
315 cos(_Tp __x)
316 { return __builtin_cos(__x); }
317
d52e4867
RS
318 using ::cosh;
319
3d7c150e 320#if _GLIBCXX_HAVE_COSHF
22aef514 321 inline float
b39d0359 322 cosh(float __x) { return __gnu_cxx::__c99_binding::coshf(__x); }
22aef514
BK
323#else
324 inline float
98e6e789 325 cosh(float __x) { return ::cosh(static_cast<double>(__x)); }
22aef514
BK
326#endif
327
3d7c150e 328#if _GLIBCXX_HAVE_COSHL
4e588ec9
GDR
329 inline long double
330 cosh(long double __x) { return ::coshl(__x); }
331#else
332 inline long double
333 cosh(long double __x) { return ::cosh(static_cast<double>(__x)); }
334#endif
335
cdc958d8
GDR
336 template<typename _Tp>
337 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
338 cosh(_Tp __x)
339 { return ::cosh(static_cast<double>(__x)); }
340
d52e4867
RS
341 using ::exp;
342
3d7c150e 343#if _GLIBCXX_HAVE_EXPF
22aef514 344 inline float
b39d0359 345 exp(float __x) { return __gnu_cxx::__c99_binding::expf(__x); }
22aef514
BK
346#else
347 inline float
98e6e789 348 exp(float __x) { return ::exp(static_cast<double>(__x)); }
22aef514
BK
349#endif
350
3d7c150e 351#if _GLIBCXX_HAVE_EXPL
4e588ec9
GDR
352 inline long double
353 exp(long double __x) { return ::expl(__x); }
22aef514 354#else
4e588ec9
GDR
355 inline long double
356 exp(long double __x) { return ::exp(static_cast<double>(__x)); }
22aef514
BK
357#endif
358
cdc958d8
GDR
359 template<typename _Tp>
360 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
361 exp(_Tp __x)
362 { return ::exp(static_cast<double>(__x)); }
363
d52e4867
RS
364 using ::fabs;
365
4e588ec9
GDR
366 inline float
367 fabs(float __x)
368 { return __builtin_fabsf(__x); }
369
4e588ec9
GDR
370 inline long double
371 fabs(long double __x)
372 { return __builtin_fabsl(__x); }
373
cdc958d8
GDR
374 template<typename _Tp>
375 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
376 fabs(_Tp __x)
377 { return __builtin_fabs(__x); }
378
d52e4867
RS
379 using ::floor;
380
3d7c150e 381#if _GLIBCXX_HAVE_FLOORF
22aef514 382 inline float
b39d0359 383 floor(float __x) { return __gnu_cxx::__c99_binding::floorf(__x); }
22aef514
BK
384#else
385 inline float
98e6e789 386 floor(float __x) { return ::floor(static_cast<double>(__x)); }
22aef514
BK
387#endif
388
3d7c150e 389#if _GLIBCXX_HAVE_FLOORL
4e588ec9
GDR
390 inline long double
391 floor(long double __x) { return ::floorl(__x); }
392#else
393 inline long double
394 floor(long double __x) { return ::floor(static_cast<double>(__x)); }
395#endif
396
cdc958d8
GDR
397 template<typename _Tp>
398 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
399 floor(_Tp __x)
400 { return ::floor(static_cast<double>(__x)); }
401
d52e4867
RS
402 using ::fmod;
403
3d7c150e 404#if _GLIBCXX_HAVE_FMODF
22aef514 405 inline float
b39d0359 406 fmod(float __x, float __y) { return __gnu_cxx::__c99_binding::fmodf(__x, __y); }
22aef514
BK
407#else
408 inline float
98e6e789
BK
409 fmod(float __x, float __y)
410 { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
22aef514
BK
411#endif
412
3d7c150e 413#if _GLIBCXX_HAVE_FMODL
4e588ec9
GDR
414 inline long double
415 fmod(long double __x, long double __y) { return ::fmodl(__x, __y); }
416#else
417 inline long double
418 fmod(long double __x, long double __y)
419 { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
420#endif
421
d52e4867
RS
422 using ::frexp;
423
3d7c150e 424#if _GLIBCXX_HAVE_FREXPF
22aef514 425 inline float
b39d0359 426 frexp(float __x, int* __exp) { return __gnu_cxx::__c99_binding::frexpf(__x, __exp); }
22aef514
BK
427#else
428 inline float
98e6e789 429 frexp(float __x, int* __exp) { return ::frexp(__x, __exp); }
22aef514
BK
430#endif
431
3d7c150e 432#if _GLIBCXX_HAVE_FREXPL
4e588ec9
GDR
433 inline long double
434 frexp(long double __x, int* __exp) { return ::frexpl(__x, __exp); }
435#else
436 inline long double
437 frexp(long double __x, int* __exp)
438 { return ::frexp(static_cast<double>(__x), __exp); }
439#endif
440
cdc958d8
GDR
441 template<typename _Tp>
442 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
443 frexp(_Tp __x, int* __exp)
444 { return ::frexp(static_cast<double>(__x), __exp); }
445
d52e4867
RS
446 using ::ldexp;
447
3d7c150e 448#if _GLIBCXX_HAVE_LDEXPF
22aef514 449 inline float
b39d0359 450 ldexp(float __x, int __exp) { return __gnu_cxx::__c99_binding::ldexpf(__x, __exp); }
22aef514
BK
451#else
452 inline float
98e6e789
BK
453 ldexp(float __x, int __exp)
454 { return ::ldexp(static_cast<double>(__x), __exp); }
22aef514
BK
455#endif
456
3d7c150e 457#if _GLIBCXX_HAVE_LDEXPL
4e588ec9
GDR
458 inline long double
459 ldexp(long double __x, int __exp) { return ::ldexpl(__x, __exp); }
460#else
461 inline long double
462 ldexp(long double __x, int __exp)
463 { return ::ldexp(static_cast<double>(__x), __exp); }
464#endif
465
cdc958d8
GDR
466 template<typename _Tp>
467 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
468 ldexp(_Tp __x, int __exp)
469 { return ::ldexp(static_cast<double>(__x), __exp); }
470
d52e4867
RS
471 using ::log;
472
3d7c150e 473#if _GLIBCXX_HAVE_LOGF
22aef514 474 inline float
b39d0359 475 log(float __x) { return __gnu_cxx::__c99_binding::logf(__x); }
22aef514 476#else
98e6e789
BK
477 inline float log(float __x)
478 { return ::log(static_cast<double>(__x)); }
22aef514
BK
479#endif
480
3d7c150e 481#if _GLIBCXX_HAVE_LOGL
4e588ec9
GDR
482 inline long double
483 log(long double __x) { return ::logl(__x); }
484#else
485 inline long double
486 log(long double __x) { return ::log(static_cast<double>(__x)); }
487#endif
488
cdc958d8
GDR
489 template<typename _Tp>
490 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
491 log(_Tp __x)
492 { return ::log(static_cast<double>(__x)); }
493
d52e4867
RS
494 using ::log10;
495
3d7c150e 496#if _GLIBCXX_HAVE_LOG10F
22aef514 497 inline float
b39d0359 498 log10(float __x) { return __gnu_cxx::__c99_binding::log10f(__x); }
22aef514
BK
499#else
500 inline float
98e6e789 501 log10(float __x) { return ::log10(static_cast<double>(__x)); }
22aef514
BK
502#endif
503
3d7c150e 504#if _GLIBCXX_HAVE_LOG10L
4e588ec9
GDR
505 inline long double
506 log10(long double __x) { return ::log10l(__x); }
507#else
508 inline long double
509 log10(long double __x) { return ::log10(static_cast<double>(__x)); }
510#endif
511
cdc958d8
GDR
512 template<typename _Tp>
513 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
514 log10(_Tp __x)
515 { return ::log10(static_cast<double>(__x)); }
516
d52e4867
RS
517 using ::modf;
518
3d7c150e 519#if _GLIBCXX_HAVE_MODFF
22aef514 520 inline float
b39d0359 521 modf(float __x, float* __iptr) { return __gnu_cxx::__c99_binding::modff(__x, __iptr); }
22aef514
BK
522#else
523 inline float
98e6e789 524 modf(float __x, float* __iptr)
22aef514
BK
525 {
526 double __tmp;
98e6e789
BK
527 double __res = ::modf(static_cast<double>(__x), &__tmp);
528 *__iptr = static_cast<float>(__tmp);
22aef514
BK
529 return __res;
530 }
531#endif
98e6e789 532
3d7c150e 533#if _GLIBCXX_HAVE_MODFL
4e588ec9
GDR
534 inline long double
535 modf(long double __x, long double* __iptr) { return ::modfl(__x, __iptr); }
536#else
537 inline long double
538 modf(long double __x, long double* __iptr)
539 {
540 double __tmp;
541 double __res = ::modf(static_cast<double>(__x), &__tmp);
542 * __iptr = static_cast<long double>(__tmp);
543 return __res;
544 }
545#endif
546
98e6e789
BK
547 template<typename _Tp>
548 inline _Tp
549 __pow_helper(_Tp __x, int __n)
550 {
551 return __n < 0
552 ? _Tp(1)/__cmath_power(__x, -__n)
553 : __cmath_power(__x, __n);
554 }
d52e4867
RS
555
556 using ::pow;
557
3d7c150e 558#if _GLIBCXX_HAVE_POWF
22aef514 559 inline float
b39d0359 560 pow(float __x, float __y) { return __gnu_cxx::__c99_binding::powf(__x, __y); }
22aef514
BK
561#else
562 inline float
98e6e789
BK
563 pow(float __x, float __y)
564 { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
22aef514
BK
565#endif
566
3d7c150e 567#if _GLIBCXX_HAVE_POWL
4e588ec9
GDR
568 inline long double
569 pow(long double __x, long double __y) { return ::powl(__x, __y); }
22aef514 570#else
4e588ec9
GDR
571 inline long double
572 pow(long double __x, long double __y)
573 { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
22aef514
BK
574#endif
575
22aef514 576 inline double
98e6e789 577 pow(double __x, int __i)
de96ac46 578 { return __pow_helper(__x, __i); }
22aef514 579
d52e4867
RS
580 inline float
581 pow(float __x, int __n)
582 { return __pow_helper(__x, __n); }
583
22aef514 584 inline long double
4e588ec9 585 pow(long double __x, int __n)
de96ac46 586 { return __pow_helper(__x, __n); }
22aef514 587
d52e4867
RS
588 using ::sin;
589
4e588ec9
GDR
590 inline float
591 sin(float __x)
592 { return __builtin_sinf(__x); }
22aef514 593
4e588ec9
GDR
594 inline long double
595 sin(long double __x)
596 { return __builtin_sinl(__x); }
22aef514 597
cdc958d8
GDR
598 template<typename _Tp>
599 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
600 sin(_Tp __x)
601 { return __builtin_sin(__x); }
602
d52e4867
RS
603 using ::sinh;
604
3d7c150e 605#if _GLIBCXX_HAVE_SINHF
4e588ec9 606 inline float
b39d0359 607 sinh(float __x) { return __gnu_cxx::__c99_binding::sinhf(__x); }
22aef514 608#else
4e588ec9
GDR
609 inline float
610 sinh(float __x) { return ::sinh(static_cast<double>(__x)); }
22aef514
BK
611#endif
612
3d7c150e 613#if _GLIBCXX_HAVE_SINHL
22aef514 614 inline long double
4e588ec9 615 sinh(long double __x) { return ::sinhl(__x); }
22aef514
BK
616#else
617 inline long double
4e588ec9 618 sinh(long double __x) { return ::sinh(static_cast<double>(__x)); }
22aef514
BK
619#endif
620
cdc958d8
GDR
621 template<typename _Tp>
622 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
623 sinh(_Tp __x)
624 { return ::sinh(static_cast<_Tp>(__x)); }
625
d52e4867
RS
626 using ::sqrt;
627
4e588ec9
GDR
628 inline float
629 sqrt(float __x)
630 { return __builtin_sqrtf(__x); }
22aef514 631
4e588ec9
GDR
632 inline long double
633 sqrt(long double __x)
634 { return __builtin_sqrtl(__x); }
22aef514 635
cdc958d8
GDR
636 template<typename _Tp>
637 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
638 sqrt(_Tp __x)
639 { return __builtin_sqrt(__x); }
640
d52e4867
RS
641 using ::tan;
642
3d7c150e 643#if _GLIBCXX_HAVE_TANF
4e588ec9 644 inline float
b39d0359 645 tan(float __x) { return __gnu_cxx::__c99_binding::tanf(__x); }
22aef514 646#else
4e588ec9
GDR
647 inline float
648 tan(float __x) { return ::tan(static_cast<double>(__x)); }
22aef514
BK
649#endif
650
3d7c150e 651#if _GLIBCXX_HAVE_TANL
22aef514 652 inline long double
4e588ec9 653 tan(long double __x) { return ::tanl(__x); }
22aef514
BK
654#else
655 inline long double
4e588ec9 656 tan(long double __x) { return ::tan(static_cast<double>(__x)); }
22aef514
BK
657#endif
658
cdc958d8
GDR
659 template<typename _Tp>
660 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
661 tan(_Tp __x)
662 { return ::tan(static_cast<double>(__x)); }
663
d52e4867
RS
664 using ::tanh;
665
3d7c150e 666#if _GLIBCXX_HAVE_TANHF
4e588ec9 667 inline float
b39d0359 668 tanh(float __x) { return __gnu_cxx::__c99_binding::tanhf(__x); }
22aef514 669#else
4e588ec9
GDR
670 inline float
671 tanh(float __x) { return ::tanh(static_cast<double>(__x)); }
22aef514
BK
672#endif
673
3d7c150e 674#if _GLIBCXX_HAVE_TANHL
22aef514 675 inline long double
98e6e789 676 tanh(long double __x) { return ::tanhl(__x); }
22aef514
BK
677#else
678 inline long double
98e6e789 679 tanh(long double __x) { return ::tanh(static_cast<double>(__x)); }
22aef514 680#endif
cdc958d8
GDR
681
682 template<typename _Tp>
683 inline typename __enable_if<double, __is_integer<_Tp>::_M_type>::_M_type
684 tanh(_Tp __x)
685 { return ::tanh(static_cast<double>(__x)); }
61c71946 686}
22aef514 687
7cda84dc 688
3d7c150e
BK
689#if _GLIBCXX_USE_C99
690#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
7cda84dc 691// These are possible macros imported from C99-land. For strict
3702c634
GDR
692// conformance, remove possible C99-injected names from the global
693// namespace, and sequester them in the __gnu_cxx extension namespace.
694namespace __gnu_cxx
7cda84dc
BK
695{
696 template<typename _Tp>
697 int
698 __capture_fpclassify(_Tp __f) { return fpclassify(__f); }
699
700 template<typename _Tp>
701 int
702 __capture_isfinite(_Tp __f) { return isfinite(__f); }
703
704 template<typename _Tp>
705 int
706 __capture_isinf(_Tp __f) { return isinf(__f); }
707
708 template<typename _Tp>
709 int
710 __capture_isnan(_Tp __f) { return isnan(__f); }
711
712 template<typename _Tp>
713 int
714 __capture_isnormal(_Tp __f) { return isnormal(__f); }
715
716 template<typename _Tp>
717 int
718 __capture_signbit(_Tp __f) { return signbit(__f); }
719
720 template<typename _Tp>
721 int
3702c634
GDR
722 __capture_isgreater(_Tp __f1, _Tp __f2)
723 { return isgreater(__f1, __f2); }
7cda84dc 724
3702c634
GDR
725 template<typename _Tp>
726 int
727 __capture_isgreaterequal(_Tp __f1, _Tp __f2)
728 { return isgreaterequal(__f1, __f2); }
7cda84dc 729
3702c634
GDR
730 template<typename _Tp>
731 int
732 __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); }
7cda84dc 733
3702c634
GDR
734 template<typename _Tp>
735 int
736 __capture_islessequal(_Tp __f1, _Tp __f2)
737 { return islessequal(__f1, __f2); }
7cda84dc 738
3702c634
GDR
739 template<typename _Tp>
740 int
741 __capture_islessgreater(_Tp __f1, _Tp __f2)
742 { return islessgreater(__f1, __f2); }
7cda84dc 743
3702c634
GDR
744 template<typename _Tp>
745 int
746 __capture_isunordered(_Tp __f1, _Tp __f2)
747 { return isunordered(__f1, __f2); }
c04ec67e 748}
7cda84dc 749
c04ec67e 750// Only undefine the C99 FP macros, if actually captured for namespace movement
7cda84dc
BK
751#undef fpclassify
752#undef isfinite
753#undef isinf
754#undef isnan
755#undef isnormal
756#undef signbit
757#undef isgreater
758#undef isgreaterequal
759#undef isless
760#undef islessequal
761#undef islessgreater
762#undef isunordered
3d7c150e 763#endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
c04ec67e 764#endif
7cda84dc 765
3d7c150e
BK
766#if _GLIBCXX_USE_C99
767#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
3702c634 768namespace __gnu_cxx
7cda84dc
BK
769{
770 template<typename _Tp>
771 int
772 fpclassify(_Tp __f) { return __capture_fpclassify(__f); }
773
774 template<typename _Tp>
775 int
776 isfinite(_Tp __f) { return __capture_isfinite(__f); }
777
778 template<typename _Tp>
779 int
780 isinf(_Tp __f) { return __capture_isinf(__f); }
781
782 template<typename _Tp>
783 int
784 isnan(_Tp __f) { return __capture_isnan(__f); }
785
786 template<typename _Tp>
787 int
788 isnormal(_Tp __f) { return __capture_isnormal(__f); }
789
790 template<typename _Tp>
791 int
792 signbit(_Tp __f) { return __capture_signbit(__f); }
793
794 template<typename _Tp>
795 int
796 isgreater(_Tp __f1, _Tp __f2) { return __capture_isgreater(__f1, __f2); }
797
798 template<typename _Tp>
799 int
800 isgreaterequal(_Tp __f1, _Tp __f2)
801 { return __capture_isgreaterequal(__f1, __f2); }
802
803 template<typename _Tp>
804 int
805 isless(_Tp __f1, _Tp __f2) { return __capture_isless(__f1, __f2); }
806
807 template<typename _Tp>
808 int
809 islessequal(_Tp __f1, _Tp __f2)
810 { return __capture_islessequal(__f1, __f2); }
811
812 template<typename _Tp>
813 int
5db6f3de
BK
814 islessgreater(_Tp __f1, _Tp __f2)
815 { return __capture_islessgreater(__f1, __f2); }
7cda84dc
BK
816
817 template<typename _Tp>
818 int
819 isunordered(_Tp __f1, _Tp __f2)
820 { return __capture_isunordered(__f1, __f2); }
821}
5db6f3de
BK
822
823namespace std
824{
3702c634
GDR
825 using __gnu_cxx::fpclassify;
826 using __gnu_cxx::isfinite;
827 using __gnu_cxx::isinf;
828 using __gnu_cxx::isnan;
829 using __gnu_cxx::isnormal;
830 using __gnu_cxx::signbit;
831 using __gnu_cxx::isgreater;
832 using __gnu_cxx::isgreaterequal;
833 using __gnu_cxx::isless;
834 using __gnu_cxx::islessequal;
835 using __gnu_cxx::islessgreater;
836 using __gnu_cxx::isunordered;
5db6f3de 837}
3d7c150e 838#endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
7cda84dc
BK
839#endif
840
3d7c150e 841#ifdef _GLIBCXX_NO_TEMPLATE_EXPORT
98e6e789 842# define export
34ff0b99 843# include <bits/cmath.tcc>
607642b6 844#endif
22aef514 845
98e6e789 846#endif