|
56 | 56 | #define FP_ILOGB0 (-0x7fffffff - _C2) |
57 | 57 | #define FP_ILOGBNAN 0x7fffffff |
58 | 58 |
|
59 | | - static_assert(__SIZEOF_LONG_DOUBLE__ >= __SIZEOF_DOUBLE__, |
| 59 | + static_assert((__SIZEOF_LONG_DOUBLE__ > 0) && (__SIZEOF_LONG_DOUBLE__ >= __SIZEOF_DOUBLE__), |
60 | 60 | "Error: Configuration error regarding 64-bit double/long-double for AVR"); |
61 | 61 |
|
62 | 62 | #if(__SIZEOF_DOUBLE__ == 4) |
|
221 | 221 | #error Error: sizeof(double) is unknown or not standard for AVR. |
222 | 222 | #endif |
223 | 223 |
|
| 224 | + #if defined(__cplusplus) |
224 | 225 | extern "C" |
225 | 226 | { |
| 227 | + #endif |
226 | 228 | float asinhf(float x); |
227 | 229 | double asinh (double x); |
228 | 230 | long double asinhl(long double x); |
229 | | - |
230 | 231 | float acoshf(float x); |
231 | 232 | double acosh (double x); |
232 | 233 | long double acoshl(long double x); |
233 | | - |
234 | 234 | float atanhf(float x); |
235 | 235 | double atanh (double x); |
236 | 236 | long double atanhl(long double x); |
237 | | - |
238 | | - int ilogbf(float x); |
239 | | - int ilogb (double x); |
240 | | - int ilogbl(long double x); |
241 | | - |
| 237 | + int ilogbf(float x); |
| 238 | + int ilogb (double x); |
| 239 | + int ilogbl(long double x); |
242 | 240 | float tgammaf(float x); |
243 | 241 | double tgamma (double x); |
244 | 242 | long double tgammal(long double x); |
245 | | - |
246 | 243 | float lgammaf(float x); |
247 | 244 | double lgamma (double x); |
248 | 245 | long double lgammal(long double x); |
| 246 | + #if defined(__cplusplus) |
249 | 247 | } |
| 248 | + #endif |
250 | 249 |
|
251 | 250 | namespace std |
252 | 251 | { |
253 | 252 | inline bool isnan (float x) { return (__BUILTIN_ISNANF(x) == 1); } |
254 | 253 | inline bool isnan (double x) { return (__BUILTIN_ISNAN (x) == 1); } |
255 | 254 | inline bool isnan (long double x) { return (__BUILTIN_ISNANL(x) == 1); } |
| 255 | + inline float abs (float x) { return __BUILTIN_FABSF (x); } |
| 256 | + inline double abs (double x) { return __BUILTIN_FABS (x); } |
| 257 | + inline long double abs (long double x) { return __BUILTIN_FABSL (x); } |
256 | 258 | inline float fabs (float x) { return __BUILTIN_FABSF (x); } |
257 | 259 | inline double fabs (double x) { return __BUILTIN_FABS (x); } |
258 | 260 | inline long double fabs (long double x) { return __BUILTIN_FABSL (x); } |
|
269 | 271 | inline bool isinf(double x) { return ::std::cmath_detail::isinf_impl(x); } |
270 | 272 | inline bool isinf(long double x) { return ::std::cmath_detail::isinf_impl(x); } |
271 | 273 |
|
272 | | - inline bool isfinite(float x) { return ((!(::std::isinf)(x)) && (!(::std::isnan)(x))); } |
273 | | - inline bool isfinite(double x) { return ((!(::std::isinf)(x)) && (!(::std::isnan)(x))); } |
274 | | - inline bool isfinite(long double x) { return ((!(::std::isinf)(x)) && (!(::std::isnan)(x))); } |
275 | | - |
276 | 274 | namespace cmath_detail { |
277 | 275 |
|
278 | 276 | template<typename FloatType> |
|
318 | 316 |
|
319 | 317 | } // namespace cmath_detail |
320 | 318 |
|
| 319 | + inline bool isfinite(float x) { return ((!(::std::isinf)(x)) && (!(::std::isnan)(x))); } |
| 320 | + inline bool isfinite(double x) { return ((!(::std::isinf)(x)) && (!(::std::isnan)(x))); } |
| 321 | + inline bool isfinite(long double x) { return ((!(::std::isinf)(x)) && (!(::std::isnan)(x))); } |
| 322 | + |
321 | 323 | inline int fpclassify(float x) { return ::std::cmath_detail::fpclassify_impl(x); } |
322 | 324 | inline int fpclassify(double x) { return ::std::cmath_detail::fpclassify_impl(x); } |
323 | 325 | inline int fpclassify(long double x) { return ::std::cmath_detail::fpclassify_impl(x); } |
|
418 | 420 | { |
419 | 421 | #endif |
420 | 422 | // These are (most of) the functions from <math.h> having C-linkage. |
| 423 | + int isinff (float); |
| 424 | + int isinfl (long double); |
| 425 | + int isnanf (float); |
| 426 | + int isnanl (long double); |
421 | 427 | int isfinitef (float); |
422 | 428 | int isfinitel (long double); |
423 | 429 | int ilogbf (float); |
|
490 | 496 | extern "C++" |
491 | 497 | { |
492 | 498 | #endif |
493 | | - inline bool isfinite (float x) { return (::isfinitef(x) == 1); } |
494 | | - inline bool isfinite (double x) { return (::isfinite (x) == 1); } |
495 | | - inline bool isfinite (long double x) { return (::isfinitel(x) == 1); } |
496 | 499 | inline int ilogb (float x) { return ::ilogbf(x); } |
497 | 500 | inline int ilogb (double x) { return ::ilogb (x); } |
498 | 501 | inline int ilogb (long double x) { return ::ilogbl(x); } |
|
576 | 579 | inline double tanh (double x) { return __builtin_tanh (x); } |
577 | 580 | inline long double tanh (long double x) { return __builtin_tanhl (x); } |
578 | 581 | #else |
579 | | - inline bool isnan (float x) { return ::isnanf(x); } |
| 582 | + inline bool isnan (float x) { return (::isnanf)(x); } |
580 | 583 | bool isnan (double x); |
581 | | - inline bool isnan (long double x) { return ::isnanl(x); } |
582 | | - inline float abs (float x) { return ::fabsf (x); } |
| 584 | + inline bool isnan (long double x) { return (::isnanl)(x); } |
| 585 | + inline bool isinf (float x) { return (::isnanf)(x); } |
| 586 | + bool isinf (double x); |
| 587 | + inline bool isinf (long double x) { return (::isnanl)(x); } |
| 588 | + inline float abs (float x) { return ::fabsf(x); } |
583 | 589 | extern "C" double abs (double x); |
584 | | - inline long double abs (long double x) { return ::fabsl (x); } |
585 | | - inline float fabs (float x) { return ::fabsf (x); } |
| 590 | + inline long double abs (long double x) { return ::fabsl(x); } |
| 591 | + inline float fabs (float x) { return ::fabsf(x); } |
586 | 592 | extern "C" double fabs (double x); |
587 | | - inline long double fabs (long double x) { return ::fabsl (x); } |
| 593 | + inline long double fabs (long double x) { return ::fabsl(x); } |
588 | 594 | inline float fmod (float x, float y) { return ::fmodf(x, y); } |
589 | 595 | extern "C" double fmod (double x, double y); |
590 | 596 | inline long double fmod (long double x, long double y) { return ::fmodl(x, y); } |
591 | | - inline float modf (float x, float* p) { return ::modff (x, p); } |
| 597 | + inline float modf (float x, float* p) { return ::modff(x, p); } |
592 | 598 | extern "C" double modf (double x, double* p); |
593 | | - inline long double modf (long double x, long double* p) { return ::modfl (x, p); } |
| 599 | + inline long double modf (long double x, long double* p) { return ::modfl(x, p); } |
594 | 600 | inline float floor (float x) { return ::floorf(x); } |
595 | 601 | extern "C" double floor (double x); |
596 | 602 | inline long double floor (long double x) { return ::floorl(x); } |
597 | | - inline float ceil (float x) { return ::ceilf (x); } |
| 603 | + inline float ceil (float x) { return ::ceilf(x); } |
598 | 604 | extern "C" double ceil (double x); |
599 | | - inline long double ceil (long double x) { return ::ceill (x); } |
| 605 | + inline long double ceil (long double x) { return ::ceill(x); } |
600 | 606 | inline float frexp (float x, int* p) { return ::frexpf(x, p); } |
601 | 607 | extern "C" double frexp (double x, int* p); |
602 | 608 | inline long double frexp (long double x, int* p) { return ::frexpl(x, p); } |
603 | 609 | inline float ldexp (float x, int p) { return ::ldexpf(x, p); } |
604 | 610 | extern "C" double ldexp (double x, int p); |
605 | | - inline long double ldexp (long double x, int p) { return ::ldexpl (x, p); } |
| 611 | + inline long double ldexp (long double x, int p) { return ::ldexpl(x, p); } |
606 | 612 | inline long lround (float x) { return ::lroundf(x); } |
607 | 613 | extern "C" long lround (double x); |
608 | 614 | inline long lround (long double x) { return ::lroundl(x); } |
609 | | - inline float sqrt (float x) { return ::sqrtf (x); } |
| 615 | + inline float sqrt (float x) { return ::sqrtf(x); } |
610 | 616 | extern "C" double sqrt (double x); |
611 | | - inline long double sqrt (long double x) { return ::sqrtl (x); } |
612 | | - inline float cbrt (float x) { return ::cbrtf (x); } |
| 617 | + inline long double sqrt (long double x) { return ::sqrtl(x); } |
| 618 | + inline float cbrt (float x) { return ::cbrtf(x); } |
613 | 619 | extern "C" double cbrt (double x); |
614 | | - inline long double cbrt (long double x) { return ::cbrtl (x); } |
615 | | - inline float sin (float x) { return ::sinf (x); } |
| 620 | + inline long double cbrt (long double x) { return ::cbrtl(x); } |
| 621 | + inline float sin (float x) { return ::sinf(x); } |
616 | 622 | extern "C" double sin (double x); |
617 | | - inline long double sin (long double x) { return ::sinl (x); } |
618 | | - inline float cos (float x) { return ::cosf (x); } |
| 623 | + inline long double sin (long double x) { return ::sinl(x); } |
| 624 | + inline float cos (float x) { return ::cosf(x); } |
619 | 625 | extern "C" double cos (double x); |
620 | | - inline long double cos (long double x) { return ::cosl (x); } |
621 | | - inline float tan (float x) { return ::tanf (x); } |
| 626 | + inline long double cos (long double x) { return ::cosl(x); } |
| 627 | + inline float tan (float x) { return ::tanf(x); } |
622 | 628 | extern "C" double tan (double x); |
623 | | - inline long double tan (long double x) { return ::tanl (x); } |
624 | | - inline float asin (float x) { return ::asinf (x); } |
| 629 | + inline long double tan (long double x) { return ::tanl(x); } |
| 630 | + inline float asin (float x) { return ::asinf(x); } |
625 | 631 | extern "C" double asin (double x); |
626 | | - inline long double asin (long double x) { return ::asinl (x); } |
627 | | - inline float acos (float x) { return ::acosf (x); } |
| 632 | + inline long double asin (long double x) { return ::asinl(x); } |
| 633 | + inline float acos (float x) { return ::acosf(x); } |
628 | 634 | extern "C" double acos (double x); |
629 | | - inline long double acos (long double x) { return ::acosl (x); } |
630 | | - inline float atan (float x) { return ::atanf (x); } |
| 635 | + inline long double acos (long double x) { return ::acosl(x); } |
| 636 | + inline float atan (float x) { return ::atanf(x); } |
631 | 637 | extern "C" double atan (double x); |
632 | | - inline long double atan (long double x) { return ::atanl (x); } |
| 638 | + inline long double atan (long double x) { return ::atanl(x); } |
633 | 639 | inline float atan2 (float y, float x) { return ::atan2f(y, x); } |
634 | 640 | extern "C" double atan2 (double y, double x); |
635 | 641 | inline long double atan2 (long double y, long double x) { return ::atan2l(y, x); } |
636 | | - inline float exp (float x) { return ::expf (x); } |
| 642 | + inline float exp (float x) { return ::expf(x); } |
637 | 643 | extern "C" double exp (double x); |
638 | | - inline long double exp (long double x) { return ::expl (x); } |
639 | | - inline float pow (float x, float a) { return ::powf (x, a); } |
| 644 | + inline long double exp (long double x) { return ::expl(x); } |
| 645 | + inline float pow (float x, float a) { return ::powf(x, a); } |
640 | 646 | extern "C" double pow (double x, double a); |
641 | | - inline long double pow (long double x, long double a) { return ::powl (x, a); } |
642 | | - inline float log (float x) { return ::logf (x); } |
| 647 | + inline long double pow (long double x, long double a) { return ::powl(x, a); } |
| 648 | + inline float log (float x) { return ::logf(x); } |
643 | 649 | extern "C" double log (double x); |
644 | | - inline long double log (long double x) { return ::logl (x); } |
| 650 | + inline long double log (long double x) { return ::logl(x); } |
645 | 651 | inline float log10 (float x) { return ::log10f(x); } |
646 | 652 | extern "C" double log10 (double x); |
647 | 653 | inline long double log10 (long double x) { return ::log10l(x); } |
648 | | - inline float sinh (float x) { return ::sinhf (x); } |
| 654 | + inline float sinh (float x) { return ::sinhf(x); } |
649 | 655 | extern "C" double sinh (double x); |
650 | | - inline long double sinh (long double x) { return ::sinhl (x); } |
651 | | - inline float cosh (float x) { return ::coshf (x); } |
| 656 | + inline long double sinh (long double x) { return ::sinhl(x); } |
| 657 | + inline float cosh (float x) { return ::coshf(x); } |
652 | 658 | extern "C" double cosh (double x); |
653 | | - inline long double cosh (long double x) { return ::coshl (x); } |
654 | | - inline float tanh (float x) { return ::tanhf (x); } |
| 659 | + inline long double cosh (long double x) { return ::coshl(x); } |
| 660 | + inline float tanh (float x) { return ::tanhf(x); } |
655 | 661 | extern "C" double tanh (double x); |
656 | | - inline long double tanh (long double x) { return ::tanhl (x); } |
| 662 | + inline long double tanh (long double x) { return ::tanhl(x); } |
657 | 663 | #endif |
| 664 | + inline bool isfinite (float x) { return ((!(::isinff)(x)) && (!(::isnanf)(x))); } |
| 665 | + extern "C" bool isfinite (double x); |
| 666 | + inline bool isfinite (long double x) { return ((!(::isinfl)(x)) && (!(::isnanl)(x))); } |
658 | 667 | inline float asinh (float x) { return ::asinhf(x); } |
659 | 668 | extern "C" double asinh (double x); |
660 | 669 | inline long double asinh (long double x) { return ::asinhl(x); } |
|
671 | 680 | extern "C" double lgamma (double x); |
672 | 681 | inline long double lgamma (long double x) { return ::lgammal(x); } |
673 | 682 | #if (defined(__cplusplus) && (__cplusplus > 201703L)) |
674 | | - inline float lerp (float a, float b, float t) { return a + (t * (b - a)); } |
675 | | - inline double lerp (double a, double b, double t) { return a + (t * (b - a)); } |
676 | | - inline long double lerp (long double a, long double b, long double t) |
677 | | - { return a + (t * (b - a)); } |
| 683 | + inline float lerp (float a, float b, float t) { return a + (t * (b - a)); } |
| 684 | + inline double lerp (double a, double b, double t) { return a + (t * (b - a)); } |
| 685 | + inline long double lerp (long double a, long double b, long double t) { return a + (t * (b - a)); } |
678 | 686 | #endif |
679 | 687 | #if defined(__cplusplus) |
680 | 688 | } |
|
0 commit comments