1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276
|
/* Configuration for math routines.
Copyright (c) 2017-2018 Arm Ltd. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the company may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
#ifndef _MATH_CONFIG_H
#define _MATH_CONFIG_H
#include <math.h>
#include <stdint.h>
#include <errno.h>
#include <fenv.h>
#ifndef WANT_ROUNDING
/* Correct special case results in non-nearest rounding modes. */
# define WANT_ROUNDING 1
#endif
#ifdef _IEEE_LIBM
# define WANT_ERRNO 0
# define _LIB_VERSION _IEEE_
#else
/* Set errno according to ISO C with (math_errhandling & MATH_ERRNO) != 0. */
# define WANT_ERRNO 1
# define _LIB_VERSION _POSIX_
#endif
#ifndef WANT_ERRNO_UFLOW
/* Set errno to ERANGE if result underflows to 0 (in all rounding modes). */
# define WANT_ERRNO_UFLOW (WANT_ROUNDING && WANT_ERRNO)
#endif
#define _IEEE_ -1
#define _POSIX_ 0
#ifdef _HAVE_ATTRIBUTE_ALWAYS_INLINE
#define ALWAYS_INLINE __inline__ __attribute__((__always_inline__))
#else
#define ALWAYS_INLINE __inline__
#endif
#ifdef _HAVE_ATTRIBUTE_NOINLINE
# define NOINLINE __attribute__ ((__noinline__))
#else
# define NOINLINE
#endif
#ifdef _HAVE_BUILTIN_EXPECT
# define likely(x) __builtin_expect (!!(x), 1)
# define unlikely(x) __builtin_expect (x, 0)
#else
# define likely(x) (x)
# define unlikely(x) (x)
#endif
/* Compiler can inline round as a single instruction. */
#ifndef HAVE_FAST_ROUND
# if __aarch64__
# define HAVE_FAST_ROUND 1
# else
# define HAVE_FAST_ROUND 0
# endif
#endif
/* Compiler can inline lround, but not (long)round(x). */
#ifndef HAVE_FAST_LROUND
# if __aarch64__ && (100*__GNUC__ + __GNUC_MINOR__) >= 408 && __NO_MATH_ERRNO__
# define HAVE_FAST_LROUND 1
# else
# define HAVE_FAST_LROUND 0
# endif
#endif
#if HAVE_FAST_ROUND
/* When set, the roundtoint and converttoint functions are provided with
the semantics documented below. */
# define TOINT_INTRINSICS 1
/* Round x to nearest int in all rounding modes, ties have to be rounded
consistently with converttoint so the results match. If the result
would be outside of [-2^31, 2^31-1] then the semantics is unspecified. */
static ALWAYS_INLINE double_t
roundtoint (double_t x)
{
return round (x);
}
/* Convert x to nearest int in all rounding modes, ties have to be rounded
consistently with roundtoint. If the result is not representible in an
int32_t then the semantics is unspecified. */
static ALWAYS_INLINE int32_t
converttoint (double_t x)
{
# if HAVE_FAST_LROUND
return lround (x);
# else
return (long) round (x);
# endif
}
#endif
#ifndef TOINT_INTRINSICS
# define TOINT_INTRINSICS 0
#endif
static ALWAYS_INLINE uint32_t
asuint (float f)
{
#if defined(__riscv_flen) && __riscv_flen >= 32
uint32_t result;
__asm__("fmv.x.w\t%0, %1" : "=r" (result) : "f" (f));
return result;
#else
union
{
float f;
uint32_t i;
} u = {f};
return u.i;
#endif
}
static ALWAYS_INLINE float
asfloat (uint32_t i)
{
#if defined(__riscv_flen) && __riscv_flen >= 32
float result;
__asm__("fmv.w.x\t%0, %1" : "=f" (result) : "r" (i));
return result;
#else
union
{
uint32_t i;
float f;
} u = {i};
return u.f;
#endif
}
static ALWAYS_INLINE int32_t
_asint32 (float f)
{
return (int32_t) asuint(f);
}
static ALWAYS_INLINE int
_sign32(int32_t ix)
{
return ((uint32_t) ix) >> 31;
}
static ALWAYS_INLINE int
_exponent32(int32_t ix)
{
return (ix >> 23) & 0xff;
}
static ALWAYS_INLINE int32_t
_significand32(int32_t ix)
{
return ix & 0x7fffff;
}
static ALWAYS_INLINE float
_asfloat(int32_t i)
{
return asfloat((uint32_t) i);
}
static ALWAYS_INLINE uint64_t
asuint64 (double f)
{
#if defined(__riscv_flen) && __riscv_flen >= 64 && __riscv_xlen >= 64
uint64_t result;
__asm__("fmv.x.d\t%0, %1" : "=r" (result) : "f" (f));
return result;
#else
union
{
double f;
uint64_t i;
} u = {f};
return u.i;
#endif
}
static ALWAYS_INLINE double
asdouble (uint64_t i)
{
#if defined(__riscv_flen) && __riscv_flen >= 64 && __riscv_xlen >= 64
double result;
__asm__("fmv.d.x\t%0, %1" : "=f" (result) : "r" (i));
return result;
#else
union
{
uint64_t i;
double f;
} u = {i};
return u.f;
#endif
}
static ALWAYS_INLINE int64_t
_asint64(double f)
{
return (int64_t) asuint64(f);
}
static ALWAYS_INLINE int
_sign64(int64_t ix)
{
return ((uint64_t) ix) >> 63;
}
static ALWAYS_INLINE int
_exponent64(int64_t ix)
{
return (ix >> 52) & 0x7ff;
}
static ALWAYS_INLINE int64_t
_significand64(int64_t ix)
{
return ix & 0xfffffffffffffLL;
}
static ALWAYS_INLINE double
_asdouble(int64_t i)
{
return asdouble((uint64_t) i);
}
#ifndef IEEE_754_2008_SNAN
# define IEEE_754_2008_SNAN 1
#endif
static ALWAYS_INLINE int
issignalingf_inline (float x)
{
uint32_t ix = asuint (x);
if (!IEEE_754_2008_SNAN)
return (ix & 0x7fc00000) == 0x7fc00000;
return 2 * (ix ^ 0x00400000) > 0xFF800000u;
}
static ALWAYS_INLINE int
issignaling_inline (double x)
{
uint64_t ix = asuint64 (x);
if (!IEEE_754_2008_SNAN)
return (ix & 0x7ff8000000000000) == 0x7ff8000000000000;
return 2 * (ix ^ 0x0008000000000000) > 2 * 0x7ff8000000000000ULL;
}
#ifdef PICOLIBC_FLOAT_NOEXCEPT
#define FORCE_FLOAT float
#define pick_float_except(expr,val) (val)
#else
#define FORCE_FLOAT volatile float
#define pick_float_except(expr,val) (expr)
#endif
#ifdef PICOLIBC_DOUBLE_NOEXCEPT
#define FORCE_DOUBLE double
#define pick_double_except(expr,val) (val)
#else
#define FORCE_DOUBLE volatile double
#define pick_double_except(expr,val) (expr)
#endif
#ifdef PICOLIBC_LONG_DOUBLE_NOEXCEPT
#define FORCE_LONG_DOUBLE long double
#define pick_long_double_except(expr,val) (val)
#else
#define FORCE_LONG_DOUBLE volatile long double
#define pick_long_double_except(expr,val) (expr)
#endif
static ALWAYS_INLINE float
opt_barrier_float (float x)
{
FORCE_FLOAT y = x;
return y;
}
static ALWAYS_INLINE double
opt_barrier_double (double x)
{
FORCE_DOUBLE y = x;
return y;
}
static ALWAYS_INLINE void
force_eval_float (float x)
{
FORCE_FLOAT y = x;
(void) y;
}
static ALWAYS_INLINE void
force_eval_double (double x)
{
FORCE_DOUBLE y = x;
(void) y;
}
#ifdef _HAVE_LONG_DOUBLE
static ALWAYS_INLINE void
force_eval_long_double (long double x)
{
FORCE_LONG_DOUBLE y = x;
(void) y;
}
#endif
/* Clang doesn't appear to suppor precise exceptions on
* many targets. We introduce barriers for that compiler
* to force evaluation order where needed
*/
#ifdef __clang__
#define clang_barrier_double(x) opt_barrier_double(x)
#define clang_barrier_float(x) opt_barrier_float(x)
#define clang_force_double(x) force_eval_double(x)
#define clang_force_float(x) force_eval_float(x)
#else
#define clang_barrier_double(x) (x)
#define clang_barrier_float(x) (x)
#define clang_force_double(x) (x)
#define clang_force_float(x) (x)
#endif
#ifdef _ADD_UNDER_R_TO_FUNCS
#define __FLOAT_NAME(x) x ## f_r
#define _FLOAT_NAME(x) __FLOAT_NAME(x)
#define _FLOAT_ALIAS(x) # x "f_r"
#define __LD_NAME(x) x ## l_r
#define _LD_NAME(x) __LD_NAME(x)
#define _LD_ALIAS(x) # x "l_r"
#else
#define __FLOAT_NAME(x) x ## f
#define _FLOAT_NAME(x) __FLOAT_NAME(x)
#define _FLOAT_ALIAS(x) # x "f"
#define __LD_NAME(x) x ## l
#define _LD_NAME(x) __LD_NAME(x)
#define _LD_ALIAS(x) # x "l"
#endif
#define __FLOAT_NAME_REG(x) x ## f
#define _FLOAT_NAME_REG(x) __FLOAT_NAME_REG(x)
#define __LD_NAME_REG(x) x ## l
#define _LD_NAME_REG(x) __LD_NAME_REG(x)
#ifdef _ADD_D_TO_DOUBLE_FUNCS
#define __D_NAME(x) x ## d
#define _D_NAME(x) __D_NAME(x)
#define _D_ALIAS(x) # x "d"
#elif defined(_ADD_UNDER_R_TO_FUNCS)
#define __D_NAME(x) x ## _r
#define _D_NAME(x) __D_NAME(x)
#define _D_ALIAS(x) # x "_r"
#else
#define __D_NAME(x) x
#define _D_NAME(x) __D_NAME(x)
#define _D_ALIAS(x) # x
#endif
#define __D_NAME_REG(x) x
#define _D_NAME_REG(x) __D_NAME_REG(x)
/*
* Figure out how to map the 32- and 64- bit functions to
* the three C float types (float, double, long double).
*
* 'float' is assumed to be a 32-bit IEEE value.
*
* Internal names for 64-bit funcs are unqualified,
* Internal names for 32-bit funcs have a trailing 'f'
* Internal names for longer funcs have a trailing 'l'
*
* When types are the same size, they are assumed to have the same
* representation. Aliases are generated in this case to eliminate
* overhead.
*
* 32-bit functions are always 'float'
* 64-bit functions may either be 'double' or 'long double',
* if at least one of those is 64 bits in size
*
* There is limited support for long double greater than 64 bits
*/
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wattribute-alias="
#pragma GCC diagnostic ignored "-Wmissing-attributes"
#endif
#ifdef _DOUBLE_IS_32BITS
# ifdef _HAVE_ALIAS_ATTRIBUTE
# define _MATH_ALIAS_d_to_f(name) extern double _D_NAME(name)(void) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_d_to_f(name) extern double _D_NAME(name)(double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_D_to_f(name) extern double _D_NAME(name)(const double *x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_s_to_f(name) extern double _D_NAME(name)(const char *x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_dd_to_f(name) extern double _D_NAME(name)(double x, double y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_dl_to_f(name) extern double _D_NAME(name)(double x, long double y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_dD_to_f(name) extern double _D_NAME(name)(double x, double *y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_ddd_to_f(name) extern double _D_NAME(name)(double x, double y, double z) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_dI_to_f(name) extern double _D_NAME(name)(double x, int *y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_ddI_to_f(name) extern double _D_NAME(name)(double x, double y, int *z) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_id_to_f(name) extern double _D_NAME(name)(int n, double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_di_to_f(name) extern double _D_NAME(name)(double x, int n) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_d_dj_to_f(name) extern double _D_NAME(name)(double x, long n) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_i_d_to_f(name) extern int name(double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_j_d_to_f(name) extern long name(double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_k_d_to_f(name) extern long long name(double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_i_dd_to_f(name) extern int name(double x, double y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_v_dDD_to_f(name) extern void name(double x, double *y, double *z) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# else
# define _MATH_ALIAS_d_to_f(name) double _D_NAME(name)(void) { return (double) __FLOAT_NAME(name)(); }
# define _MATH_ALIAS_d_d_to_f(name) double _D_NAME(name)(double x) { return (double) __FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_d_D_to_f(name) double _D_NAME(name)(const double *x) { return (double) __FLOAT_NAME(name)((float *) x); }
# define _MATH_ALIAS_d_s_to_f(name) double _D_NAME(name)(const char *x) { return (double) __FLOAT_NAME(name)(x); }
# define _MATH_ALIAS_d_dd_to_f(name) double _D_NAME(name)(double x, double y) { return (double) __FLOAT_NAME(name)((float) x, (float) y); }
# define _MATH_ALIAS_d_dl_to_f(name) double _D_NAME(name)(double x, long double y) { return (double) __FLOAT_NAME(name)((float) x, y); }
# define _MATH_ALIAS_d_dD_to_f(name) double _D_NAME(name)(double x, double *y) { return (double) __FLOAT_NAME(name)((float) x, (float *) y); }
# define _MATH_ALIAS_d_ddd_to_f(name) double _D_NAME(name)(double x, double y, double z) { return (double) __FLOAT_NAME(name)((float) x, (float) y, (float) z); }
# define _MATH_ALIAS_d_dI_to_f(name) double _D_NAME(name)(double x, int *y) { return (double) __FLOAT_NAME(name)((float) x, y); }
# define _MATH_ALIAS_d_ddI_to_f(name) double _D_NAME(name)(double x, double y, int *z) { return (double) __FLOAT_NAME(name)((float) x, (float) y, z); }
# define _MATH_ALIAS_d_id_to_f(name) double _D_NAME(name)(int n, double x) { return (double) __FLOAT_NAME(name)(n, (float) x); }
# define _MATH_ALIAS_d_di_to_f(name) double _D_NAME(name)(double x, int n) { return (double) __FLOAT_NAME(name)((float) x, n); }
# define _MATH_ALIAS_d_dj_to_f(name) double _D_NAME(name)(double x, long n) { return (double) __FLOAT_NAME(name)((float) x, n); }
# define _MATH_ALIAS_i_d_to_f(name) int _D_NAME(name)(double x) { return __FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_j_d_to_f(name) long _D_NAME(name)(double x) { return __FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_k_d_to_f(name) long long _D_NAME(name)(double x) { return __FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_i_dd_to_f(name) int _D_NAME(name)(double x, double y) { return __FLOAT_NAME(name)((float) x, (float) y); }
# define _MATH_ALIAS_v_dDD_to_f(name) void _D_NAME(name)(double x, double *y, double *z) { return __FLOAT_NAME(name)((float) x, (float *) y, (float *) z); }
# endif
#else
# define _MATH_ALIAS_d_to_f(name)
# define _MATH_ALIAS_d_d_to_f(name)
# define _MATH_ALIAS_d_D_to_f(name)
# define _MATH_ALIAS_d_s_to_f(name)
# define _MATH_ALIAS_d_dd_to_f(name)
# define _MATH_ALIAS_d_dl_to_f(name)
# define _MATH_ALIAS_d_dD_to_f(name)
# define _MATH_ALIAS_d_ddd_to_f(name)
# define _MATH_ALIAS_d_dI_to_f(name)
# define _MATH_ALIAS_d_ddI_to_f(name)
# define _MATH_ALIAS_d_id_to_f(name)
# define _MATH_ALIAS_d_di_to_f(name)
# define _MATH_ALIAS_d_dj_to_f(name)
# define _MATH_ALIAS_i_d_to_f(name)
# define _MATH_ALIAS_j_d_to_f(name)
# define _MATH_ALIAS_k_d_to_f(name)
# define _MATH_ALIAS_i_dd_to_f(name)
# define _MATH_ALIAS_v_dDD_to_f(name)
# define _NEED_FLOAT64
#endif
#ifdef _LDBL_EQ_DBL
# ifdef _DOUBLE_IS_32BITS
# ifdef _HAVE_ALIAS_ATTRIBUTE
# define _MATH_ALIAS_l_to_f(name) extern long double _LD_NAME(name)(void) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_l_to_f(name) extern long double _LD_NAME(name)(long double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_L_to_f(name) extern long double _LD_NAME(name)(const long double *x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_s_to_f(name) extern long double _LD_NAME(name)(const char *x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_ll_to_f(name) extern long double _LD_NAME(name)(long double x, long double y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_lL_to_f(name) extern long double _LD_NAME(name)(long double x, long double *y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_lll_to_f(name) extern long double _LD_NAME(name)(long double x, long double y, long double z) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_lI_to_f(name) extern long double _LD_NAME(name)(long double x, int *y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_llI_to_f(name) extern long double _LD_NAME(name)(long double x, long double y, int *z) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_il_to_f(name) extern long double _LD_NAME(name)(int n, long double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_li_to_f(name) extern long double _LD_NAME(name)(long double x, int n) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_l_lj_to_f(name) extern long double _LD_NAME(name)(long double x, long n) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_i_l_to_f(name) extern int _LD_NAME(name)(long double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_j_l_to_f(name) extern long _LD_NAME(name)(long double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_k_l_to_f(name) extern long long _LD_NAME(name)(long double x) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_i_ll_to_f(name) extern int _LD_NAME(name)(long double x, long double y) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# define _MATH_ALIAS_v_lLL_to_f(name) extern void _LD_NAME(name)(long double x, long double *y, long double *z) __attribute__((__alias__(_FLOAT_ALIAS(name))));
# else
# define _MATH_ALIAS_l_to_f(name) long double _LD_NAME(name)(void) { return (long double) _FLOAT_NAME(name)(); }
# define _MATH_ALIAS_l_l_to_f(name) long double _LD_NAME(name)(long double x) { return (long double) _FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_l_L_to_f(name) long double _LD_NAME(name)(const long double *x) { return (long double) _FLOAT_NAME(name)((float *) x); }
# define _MATH_ALIAS_l_s_to_f(name) long double _LD_NAME(name)(const char *x) { return (long double) _FLOAT_NAME(name)(x); }
# define _MATH_ALIAS_l_ll_to_f(name) long double _LD_NAME(name)(long double x, long double y) { return (long double) _FLOAT_NAME(name)((float) x, (float) y); }
# define _MATH_ALIAS_l_lL_to_f(name) long double _LD_NAME(name)(long double x, long double *y) { return (long double) _FLOAT_NAME(name)((float) x, (float *) y); }
# define _MATH_ALIAS_l_lll_to_f(name) long double _LD_NAME(name)(long double x, long double y, long double z) { return (long double) _FLOAT_NAME(name)((float) x, (float) y, (float) z); }
# define _MATH_ALIAS_l_lI_to_f(name) long double _LD_NAME(name)(long double x, int *y) { return (long double) _FLOAT_NAME(name)((float) x, y); }
# define _MATH_ALIAS_l_llI_to_f(name) long double _LD_NAME(name)(long double x, long double y, int *z) { return (long double) _FLOAT_NAME(name)((float) x, (float) y, z); }
# define _MATH_ALIAS_l_il_to_f(name) long double _LD_NAME(name)(int n, long double x) { return (long double) _FLOAT_NAME(name)(n, (float) x); }
# define _MATH_ALIAS_l_li_to_f(name) long double _LD_NAME(name)(long double x, int n) { return (long double) _FLOAT_NAME(name)((float) x, n); }
# define _MATH_ALIAS_l_lj_to_f(name) long double _LD_NAME(name)(long double x, long n) { return (long double) _FLOAT_NAME(name)((float) x, n); }
# define _MATH_ALIAS_i_l_to_f(name) int _LD_NAME(name)(long double x) { return _FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_j_l_to_f(name) long _LD_NAME(name)(long double x) { return _FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_k_l_to_f(name) long long _LD_NAME(name)(long double x) { return _FLOAT_NAME(name)((float) x); }
# define _MATH_ALIAS_i_ll_to_f(name) int _LD_NAME(name)(long double x, long double y) { return _FLOAT_NAME(name)((float) x, (float) y); }
# define _MATH_ALIAS_v_lLL_to_f(name) void _LD_NAME(name)(long double x, long double *y, long double *z) { return _FLOAT_NAME(name)((float) x, (float *) y, (float *) z); }
# endif
# define _MATH_ALIAS_l_to_d(name)
# define _MATH_ALIAS_l_l_to_d(name)
# define _MATH_ALIAS_l_L_to_d(name)
# define _MATH_ALIAS_l_s_to_d(name)
# define _MATH_ALIAS_l_ll_to_d(name)
# define _MATH_ALIAS_l_lL_to_d(name)
# define _MATH_ALIAS_l_lll_to_d(name)
# define _MATH_ALIAS_l_lI_to_d(name)
# define _MATH_ALIAS_l_llI_to_d(name)
# define _MATH_ALIAS_l_il_to_d(name)
# define _MATH_ALIAS_l_li_to_d(name)
# define _MATH_ALIAS_l_lj_to_d(name)
# define _MATH_ALIAS_i_l_to_d(name)
# define _MATH_ALIAS_j_l_to_d(name)
# define _MATH_ALIAS_k_l_to_d(name)
# define _MATH_ALIAS_i_ll_to_d(name)
# else
# define _MATH_ALIAS_l_to_f(name)
# define _MATH_ALIAS_l_l_to_f(name)
# define _MATH_ALIAS_l_L_to_f(name)
# define _MATH_ALIAS_l_s_to_f(name)
# define _MATH_ALIAS_l_ll_to_f(name)
# define _MATH_ALIAS_l_lL_to_f(name)
# define _MATH_ALIAS_l_lll_to_f(name)
# define _MATH_ALIAS_l_lI_to_f(name)
# define _MATH_ALIAS_l_llI_to_f(name)
# define _MATH_ALIAS_l_il_to_f(name)
# define _MATH_ALIAS_l_li_to_f(name)
# define _MATH_ALIAS_l_lj_to_f(name)
# define _MATH_ALIAS_i_l_to_f(name)
# define _MATH_ALIAS_j_l_to_f(name)
# define _MATH_ALIAS_k_l_to_f(name)
# define _MATH_ALIAS_i_ll_to_f(name)
# define _MATH_ALIAS_v_lLL_to_f(name)
# ifdef _HAVE_ALIAS_ATTRIBUTE
# define _MATH_ALIAS_l_to_d(name) extern long double _LD_NAME(name)(void) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_l_to_d(name) extern long double _LD_NAME(name)(long double x) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_L_to_d(name) extern long double _LD_NAME(name)(const long double *x) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_s_to_d(name) extern long double _LD_NAME(name)(const char *x) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_ll_to_d(name) extern long double _LD_NAME(name)(long double x, long double y) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_lL_to_d(name) extern long double _LD_NAME(name)(long double x, long double *y) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_lll_to_d(name) extern long double _LD_NAME(name)(long double x, long double y, long double z) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_lI_to_d(name) extern long double _LD_NAME(name)(long double x, int *y) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_llI_to_d(name) extern long double _LD_NAME(name)(long double x, long double y, int *z) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_il_to_d(name) extern long double _LD_NAME(name)(int n, long double x) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_li_to_d(name) extern long double _LD_NAME(name)(long double x, int n) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_l_lj_to_d(name) extern long double _LD_NAME(name)(long double x, long n) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_i_l_to_d(name) extern int _LD_NAME(name)(long double x) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_j_l_to_d(name) extern long _LD_NAME(name)(long double x) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_k_l_to_d(name) extern long long _LD_NAME(name)(long double x) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_i_ll_to_d(name) extern int _LD_NAME(name)(long double x, long double y) __attribute__((__alias__(_D_ALIAS(name))));
# define _MATH_ALIAS_v_lLL_to_d(name) extern void _LD_NAME(name)(long double x, long double *y, long double *z) __attribute__((__alias__(_D_ALIAS(name))));
# else
# define _MATH_ALIAS_l_to_d(name) long double _LD_NAME(name)(void) { return (long double) _D_NAME(name)(); }
# define _MATH_ALIAS_l_l_to_d(name) long double _LD_NAME(name)(long double x) { return (long double) _D_NAME(name)((double) x); }
# define _MATH_ALIAS_l_L_to_d(name) long double _LD_NAME(name)(const long double *x) { return (long double) _D_NAME(name)((double *) x); }
# define _MATH_ALIAS_l_s_to_d(name) long double _LD_NAME(name)(const char *x) { return (long double) _D_NAME(name)(x); }
# define _MATH_ALIAS_l_ll_to_d(name) long double _LD_NAME(name)(long double x, long double y) { return (long double) _D_NAME(name)((double) x, (double) y); }
# define _MATH_ALIAS_l_lL_to_d(name) long double _LD_NAME(name)(long double x, long double *y) { return (long double) _D_NAME(name)((double) x, (double *) y); }
# define _MATH_ALIAS_l_lll_to_d(name) long double _LD_NAME(name)(long double x, long double y, long double z) { return (long double) _D_NAME(name)((double) x, (double) y, (double) z); }
# define _MATH_ALIAS_l_lI_to_d(name) long double _LD_NAME(name)(long double x, int *y) { return (long double) _D_NAME(name)((double) x, y); }
# define _MATH_ALIAS_l_llI_to_d(name) long double _LD_NAME(name)(long double x, long double y, int *z) { return (long double) _D_NAME(name)((double) x, (double) y, z); }
# define _MATH_ALIAS_l_il_to_d(name) long double _LD_NAME(name)(int n, long double x) { return (long double) _D_NAME(name)(n, (double) x); }
# define _MATH_ALIAS_l_li_to_d(name) long double _LD_NAME(name)(long double x, int n) { return (long double) _D_NAME(name)((double) x, n); }
# define _MATH_ALIAS_l_lj_to_d(name) long double _LD_NAME(name)(long double x, long j) { return (long double) _D_NAME(name)((double) x, n); }
# define _MATH_ALIAS_i_l_to_d(name) int _LD_NAME(name)(long double x) { return _D_NAME(name)((double) x); }
# define _MATH_ALIAS_j_l_to_d(name) long _LD_NAME(name)(long double x) { return _D_NAME(name)((double) x); }
# define _MATH_ALIAS_k_l_to_d(name) long long _LD_NAME(name)(long double x) { return _D_NAME(name)((double) x); }
# define _MATH_ALIAS_i_ll_to_d(name) int _LD_NAME(name)(long double x, long double y) { return _D_NAME(name)((double) x, (double) y); }
# define _MATH_ALIAS_v_lLL_to_d(name) void _LD_NAME(name)(long double x, long double *y, long double *z) { return _D_NAME(name)((double) x, (double *) y, (double *) z); }
# endif
# endif
#else
# if __SIZEOF_LONG_DOUBLE__ == 8
# define _NAME_64(x) _LD_NAME_REG(x)
# define _NAME_64_SPECIAL(d,l) l
typedef long double __float64;
# define FORCE_FLOAT64 FORCE_LONG_DOUBLE
# define pick_float64_except(a,b) pick_long_double_except(a,b)
# define _NEED_FLOAT64
# define __F_64(x) x ## L
# define _F_64(x) __F_64(x)
# define _FLOAT64_MIN LDBL_MIN
# define _FLOAT64_MAX LDBL_MAX
# define force_eval_float64 force_eval_long_double
# endif
# define _MATH_ALIAS_l_to_f(name)
# define _MATH_ALIAS_l_l_to_f(name)
# define _MATH_ALIAS_l_L_to_f(name)
# define _MATH_ALIAS_l_s_to_f(name)
# define _MATH_ALIAS_l_ll_to_f(name)
# define _MATH_ALIAS_l_lL_to_f(name)
# define _MATH_ALIAS_l_lll_to_f(name)
# define _MATH_ALIAS_l_lI_to_f(name)
# define _MATH_ALIAS_l_llI_to_f(name)
# define _MATH_ALIAS_l_il_to_f(name)
# define _MATH_ALIAS_l_li_to_f(name)
# define _MATH_ALIAS_l_lj_to_f(name)
# define _MATH_ALIAS_i_l_to_f(name)
# define _MATH_ALIAS_j_l_to_f(name)
# define _MATH_ALIAS_k_l_to_f(name)
# define _MATH_ALIAS_i_ll_to_f(name)
# define _MATH_ALIAS_v_lLL_to_f(name)
# define _MATH_ALIAS_l_to_d(name)
# define _MATH_ALIAS_l_l_to_d(name)
# define _MATH_ALIAS_l_L_to_d(name)
# define _MATH_ALIAS_l_s_to_d(name)
# define _MATH_ALIAS_l_ll_to_d(name)
# define _MATH_ALIAS_l_lL_to_d(name)
# define _MATH_ALIAS_l_lll_to_d(name)
# define _MATH_ALIAS_l_lI_to_d(name)
# define _MATH_ALIAS_l_llI_to_d(name)
# define _MATH_ALIAS_l_il_to_d(name)
# define _MATH_ALIAS_l_li_to_d(name)
# define _MATH_ALIAS_l_lj_to_d(name)
# define _MATH_ALIAS_i_l_to_d(name)
# define _MATH_ALIAS_j_l_to_d(name)
# define _MATH_ALIAS_k_l_to_d(name)
# define _MATH_ALIAS_i_ll_to_d(name)
# define _MATH_ALIAS_v_lLL_to_d(name)
#endif
#ifndef _NAME_64
# define _NAME_64(x) _D_NAME_REG(x)
# define _NAME_64_SPECIAL(d,l) d
# define _F_64(x) x
# define _FLOAT64_MIN DBL_MIN
# define _FLOAT64_MAX DBL_MAX
typedef double __float64;
# define FORCE_FLOAT64 FORCE_DOUBLE
# define pick_float64_except(a,b) pick_double_except(a,b)
# define force_eval_float64 force_eval_double
#endif
#if __SIZEOF_LONG_DOUBLE__ > 8
# define _NEED_FLOAT_HUGE
/* Guess long double layout based on compiler defines */
#if __LDBL_MANT_DIG__ == 64 && 16383 <= __LDBL_MAX_EXP__ && __LDBL_MAX_EXP__ <= 16384
#define _INTEL80_FLOAT
#ifdef __LP64__
#define _INTEL80_FLOAT_PAD
#endif
#endif
#if __LDBL_MANT_DIG__ == 113 && 16383 <= __LDBL_MAX_EXP__ && __LDBL_MAX_EXP__ <= 16384
#define _IEEE128_FLOAT
#endif
#if __LDBL_MANT_DIG__ == 106 && __LDBL_MAX_EXP__ == 1024
#define _DOUBLE_DOUBLE_FLOAT
#endif
#ifndef __FLOAT_WORD_ORDER__
#define __FLOAT_WORD_ORDER__ __BYTE_ORDER__
#endif
#endif
#define _MATH_ALIAS_f(name) \
_MATH_ALIAS_d_to_f(name) \
_MATH_ALIAS_l_to_f(name)
#define _MATH_ALIAS_f_f(name) \
_MATH_ALIAS_d_d_to_f(name) \
_MATH_ALIAS_l_l_to_f(name)
#define _MATH_ALIAS_f_F(name) \
_MATH_ALIAS_d_D_to_f(name) \
_MATH_ALIAS_l_L_to_f(name)
#define _MATH_ALIAS_f_s(name) \
_MATH_ALIAS_d_s_to_f(name) \
_MATH_ALIAS_l_s_to_f(name)
#define _MATH_ALIAS_f_ff(name) \
_MATH_ALIAS_d_dd_to_f(name) \
_MATH_ALIAS_l_ll_to_f(name)
#define _MATH_ALIAS_f_fl(name) \
_MATH_ALIAS_d_dl_to_f(name) \
_MATH_ALIAS_l_ll_to_f(name)
#define _MATH_ALIAS_f_fF(name) \
_MATH_ALIAS_d_dD_to_f(name) \
_MATH_ALIAS_l_lL_to_f(name)
#define _MATH_ALIAS_f_fff(name) \
_MATH_ALIAS_d_ddd_to_f(name) \
_MATH_ALIAS_l_lll_to_f(name)
#define _MATH_ALIAS_f_fI(name) \
_MATH_ALIAS_d_dI_to_f(name) \
_MATH_ALIAS_l_lI_to_f(name)
#define _MATH_ALIAS_f_ffI(name) \
_MATH_ALIAS_d_ddI_to_f(name) \
_MATH_ALIAS_l_llI_to_f(name)
#define _MATH_ALIAS_f_if(name) \
_MATH_ALIAS_d_id_to_f(name) \
_MATH_ALIAS_l_il_to_f(name)
#define _MATH_ALIAS_f_fi(name) \
_MATH_ALIAS_d_di_to_f(name) \
_MATH_ALIAS_l_li_to_f(name)
#define _MATH_ALIAS_f_fj(name) \
_MATH_ALIAS_d_dj_to_f(name) \
_MATH_ALIAS_l_lj_to_f(name)
#define _MATH_ALIAS_i_f(name) \
_MATH_ALIAS_i_d_to_f(name) \
_MATH_ALIAS_i_l_to_f(name)
#define _MATH_ALIAS_j_f(name) \
_MATH_ALIAS_j_d_to_f(name) \
_MATH_ALIAS_j_l_to_f(name)
#define _MATH_ALIAS_k_f(name) \
_MATH_ALIAS_k_d_to_f(name) \
_MATH_ALIAS_k_l_to_f(name)
#define _MATH_ALIAS_i_ff(name) \
_MATH_ALIAS_i_dd_to_f(name) \
_MATH_ALIAS_i_ll_to_f(name)
#define _MATH_ALIAS_v_fFF(name) \
_MATH_ALIAS_v_dDD_to_f(name) \
_MATH_ALIAS_v_lLL_to_f(name)
#define _MATH_ALIAS_d(name) \
_MATH_ALIAS_l_to_d(name)
#define _MATH_ALIAS_d_d(name) \
_MATH_ALIAS_l_l_to_d(name)
#define _MATH_ALIAS_d_D(name) \
_MATH_ALIAS_l_L_to_d(name)
#define _MATH_ALIAS_d_s(name) \
_MATH_ALIAS_l_s_to_d(name)
#define _MATH_ALIAS_d_dd(name) \
_MATH_ALIAS_l_ll_to_d(name)
#define _MATH_ALIAS_d_dl(name) \
_MATH_ALIAS_l_ll_to_d(name)
#define _MATH_ALIAS_d_dD(name) \
_MATH_ALIAS_l_lL_to_d(name)
#define _MATH_ALIAS_d_ddd(name) \
_MATH_ALIAS_l_lll_to_d(name)
#define _MATH_ALIAS_d_dI(name) \
_MATH_ALIAS_l_lI_to_d(name)
#define _MATH_ALIAS_d_ddI(name) \
_MATH_ALIAS_l_llI_to_d(name)
#define _MATH_ALIAS_d_id(name) \
_MATH_ALIAS_l_il_to_d(name)
#define _MATH_ALIAS_d_di(name) \
_MATH_ALIAS_l_li_to_d(name)
#define _MATH_ALIAS_d_dj(name) \
_MATH_ALIAS_l_lj_to_d(name)
#define _MATH_ALIAS_i_d(name) \
_MATH_ALIAS_i_l_to_d(name)
#define _MATH_ALIAS_j_d(name) \
_MATH_ALIAS_j_l_to_d(name)
#define _MATH_ALIAS_k_d(name) \
_MATH_ALIAS_k_l_to_d(name)
#define _MATH_ALIAS_i_dd(name) \
_MATH_ALIAS_i_ll_to_d(name)
#define _MATH_ALIAS_v_dDD(name) \
_MATH_ALIAS_v_lLL_to_d(name)
/* Evaluate an expression as the specified type, normally a type
cast should be enough, but compilers implement non-standard
excess-precision handling, so when FLT_EVAL_METHOD != 0 then
these functions may need to be customized. */
static ALWAYS_INLINE float
eval_as_float (float x)
{
return x;
}
static ALWAYS_INLINE double
eval_as_double (double x)
{
return x;
}
/* gcc emitting PE/COFF doesn't support visibility */
#if defined (__GNUC__) && !defined (__CYGWIN__)
# define HIDDEN __attribute__ ((__visibility__ ("hidden")))
#else
# define HIDDEN
#endif
/* Error handling tail calls for special cases, with a sign argument.
The sign of the return value is set if the argument is non-zero. */
/* The result overflows. */
HIDDEN float __math_oflowf (uint32_t);
/* The result underflows to 0 in nearest rounding mode. */
HIDDEN float __math_uflowf (uint32_t);
/* The result underflows to 0 in some directed rounding mode only. */
HIDDEN float __math_may_uflowf (uint32_t);
/* Division by zero. */
HIDDEN float __math_divzerof (uint32_t);
/* The result overflows. */
HIDDEN __float64 __math_oflow (uint32_t);
/* The result underflows to 0 in nearest rounding mode. */
HIDDEN __float64 __math_uflow (uint32_t);
/* The result underflows to 0 in some directed rounding mode only. */
HIDDEN __float64 __math_may_uflow (uint32_t);
/* Division by zero. */
HIDDEN __float64 __math_divzero (uint32_t);
/* Error handling using input checking. */
/* Invalid input unless it is a quiet NaN. */
HIDDEN float __math_invalidf (float);
/* set invalid exception */
#if defined(FE_INVALID) && !defined(PICOLIBC_FLOAT_NOEXECPT)
HIDDEN void __math_set_invalidf(void);
#else
#define __math_set_invalidf() ((void) 0)
#endif
/* Invalid input unless it is a quiet NaN. */
HIDDEN __float64 __math_invalid (__float64);
/* set invalid exception */
#if defined(FE_INVALID) && !defined(PICOLIBC_DOUBLE_NOEXECPT)
HIDDEN void __math_set_invalid(void);
#else
#define __math_set_invalid() ((void) 0)
#endif
#ifdef _HAVE_LONG_DOUBLE
HIDDEN long double __math_oflowl (uint32_t);
/* The result underflows to 0 in nearest rounding mode. */
HIDDEN long double __math_uflowl (uint32_t);
/* The result underflows to 0 in some directed rounding mode only. */
HIDDEN long double __math_may_uflowl (uint32_t);
/* Division by zero. */
HIDDEN long double __math_divzerol (uint32_t);
/* Invalid input unless it is a quiet NaN. */
HIDDEN long double __math_invalidl (long double);
/* set invalid exception */
#if defined(FE_INVALID) && !defined(PICOLIBC_LONG_DOUBLE_NOEXECPT)
HIDDEN void __math_set_invalidl(void);
#else
#define __math_set_invalidl() ((void) 0)
#endif
#endif
/* Error handling using output checking, only for errno setting. */
/* Check if the result overflowed to infinity. */
HIDDEN float __math_check_oflowf (float);
/* Check if the result overflowed to infinity. */
HIDDEN __float64 __math_check_oflow (__float64);
#ifdef _NEED_FLOAT_HUGE
HIDDEN long double __math_check_oflowl(long double);
#endif
/* Check if the result underflowed to 0. */
HIDDEN float __math_check_uflowf (float);
HIDDEN __float64 __math_check_uflow (__float64);
#ifdef _NEED_FLOAT_HUGE
HIDDEN long double __math_check_uflowl(long double);
#endif
/* Check if the result overflowed to infinity. */
static inline __float64
check_oflow (__float64 x)
{
return WANT_ERRNO ? __math_check_oflow (x) : x;
}
/* Check if the result overflowed to infinity. */
static inline float
check_oflowf (float x)
{
return WANT_ERRNO ? __math_check_oflowf (x) : x;
}
#ifdef _NEED_FLOAT_HUGE
static inline long double
check_oflowl (long double x)
{
return WANT_ERRNO ? __math_check_oflowl (x) : x;
}
#endif
/* Check if the result underflowed to 0. */
static inline __float64
check_uflow (__float64 x)
{
return WANT_ERRNO ? __math_check_uflow (x) : x;
}
/* Check if the result underflowed to 0. */
static inline float
check_uflowf (float x)
{
return WANT_ERRNO ? __math_check_uflowf (x) : x;
}
#ifdef _NEED_FLOAT_HUGE
static inline long double
check_uflowl (long double x)
{
return WANT_ERRNO ? __math_check_uflowl (x) : x;
}
#endif
/* Set inexact exception */
#if defined(FE_INEXACT) && !defined(PICOLIBC_DOUBLE_NOEXECPT)
__float64 __math_inexact(__float64);
void __math_set_inexact(void);
#else
#define __math_inexact(val) (val)
#define __math_set_inexact() ((void) 0)
#endif
#if defined(FE_INEXACT) && !defined(PICOLIBC_FLOAT_NOEXECPT)
float __math_inexactf(float val);
void __math_set_inexactf(void);
#else
#define __math_inexactf(val) (val)
#define __math_set_inexactf() ((void) 0)
#endif
#if defined(FE_INEXACT) && !defined(PICOLIBC_LONG_DOUBLE_NOEXECPT) && defined(_NEED_FLOAT_HUGE)
long double __math_inexactl(long double val);
void __math_set_inexactl(void);
#else
#define __math_inexactl(val) (val)
#define __math_set_inexactl() ((void) 0)
#endif
/* Shared between expf, exp2f and powf. */
#define EXP2F_TABLE_BITS 5
#define EXP2F_POLY_ORDER 3
extern const struct exp2f_data
{
uint64_t tab[1 << EXP2F_TABLE_BITS];
double shift_scaled;
double poly[EXP2F_POLY_ORDER];
double shift;
double invln2_scaled;
double poly_scaled[EXP2F_POLY_ORDER];
} __exp2f_data HIDDEN;
#define LOGF_TABLE_BITS 4
#define LOGF_POLY_ORDER 4
extern const struct logf_data
{
struct
{
double invc, logc;
} tab[1 << LOGF_TABLE_BITS];
double ln2;
double poly[LOGF_POLY_ORDER - 1]; /* First order coefficient is 1. */
} __logf_data HIDDEN;
#define LOG2F_TABLE_BITS 4
#define LOG2F_POLY_ORDER 4
extern const struct log2f_data
{
struct
{
double invc, logc;
} tab[1 << LOG2F_TABLE_BITS];
double poly[LOG2F_POLY_ORDER];
} __log2f_data HIDDEN;
#define POWF_LOG2_TABLE_BITS 4
#define POWF_LOG2_POLY_ORDER 5
#if TOINT_INTRINSICS
# define POWF_SCALE_BITS EXP2F_TABLE_BITS
#else
# define POWF_SCALE_BITS 0
#endif
#define POWF_SCALE ((double) (1 << POWF_SCALE_BITS))
extern const struct powf_log2_data
{
struct
{
double invc, logc;
} tab[1 << POWF_LOG2_TABLE_BITS];
double poly[POWF_LOG2_POLY_ORDER];
} __powf_log2_data HIDDEN;
#define EXP_TABLE_BITS 7
#define EXP_POLY_ORDER 5
/* Use polynomial that is optimized for a wider input range. This may be
needed for good precision in non-nearest rounding and !TOINT_INTRINSICS. */
#define EXP_POLY_WIDE 0
/* Use close to nearest rounding toint when !TOINT_INTRINSICS. This may be
needed for good precision in non-nearest rouning and !EXP_POLY_WIDE. */
#define EXP_USE_TOINT_NARROW 0
#define EXP2_POLY_ORDER 5
#define EXP2_POLY_WIDE 0
extern const struct exp_data
{
double invln2N;
double shift;
double negln2hiN;
double negln2loN;
double poly[4]; /* Last four coefficients. */
double exp2_shift;
double exp2_poly[EXP2_POLY_ORDER];
uint64_t tab[2*(1 << EXP_TABLE_BITS)];
} __exp_data HIDDEN;
#define LOG_TABLE_BITS 7
#define LOG_POLY_ORDER 6
#define LOG_POLY1_ORDER 12
extern const struct log_data
{
double ln2hi;
double ln2lo;
double poly[LOG_POLY_ORDER - 1]; /* First coefficient is 1. */
double poly1[LOG_POLY1_ORDER - 1];
struct {double invc, logc;} tab[1 << LOG_TABLE_BITS];
#if !_HAVE_FAST_FMA
struct {double chi, clo;} tab2[1 << LOG_TABLE_BITS];
#endif
} __log_data HIDDEN;
#define LOG2_TABLE_BITS 6
#define LOG2_POLY_ORDER 7
#define LOG2_POLY1_ORDER 11
extern const struct log2_data
{
double invln2hi;
double invln2lo;
double poly[LOG2_POLY_ORDER - 1];
double poly1[LOG2_POLY1_ORDER - 1];
struct {double invc, logc;} tab[1 << LOG2_TABLE_BITS];
#if !_HAVE_FAST_FMA
struct {double chi, clo;} tab2[1 << LOG2_TABLE_BITS];
#endif
} __log2_data HIDDEN;
#define POW_LOG_TABLE_BITS 7
#define POW_LOG_POLY_ORDER 8
extern const struct pow_log_data
{
double ln2hi;
double ln2lo;
double poly[POW_LOG_POLY_ORDER - 1]; /* First coefficient is 1. */
/* Note: the pad field is unused, but allows slightly faster indexing. */
struct {double invc, pad, logc, logctail;} tab[1 << POW_LOG_TABLE_BITS];
} __pow_log_data HIDDEN;
#if WANT_ERRNO
HIDDEN double
__math_with_errno (double y, int e);
HIDDEN float
__math_with_errnof (float y, int e);
#ifdef _HAVE_LONG_DOUBLE
HIDDEN long double
__math_with_errnol (long double y, int e);
#endif
#else
#define __math_with_errno(x, e) (x)
#define __math_with_errnof(x, e) (x)
#define __math_with_errnol(x, e) (x)
#endif
/* Check if the result is a denorm. */
#if (defined(FE_UNDERFLOW) && !defined(PICOLIBC_FLOAT_NOEXCEPT)) || WANT_ERRNO
float __math_denormf (float x);
#else
#define __math_denormf(x) (x)
#endif
#if (defined(FE_UNDERFLOW) && !defined(PICOLIBC_DOUBLE_NOEXCEPT)) || WANT_ERRNO
__float64 __math_denorm (__float64 x);
#else
#define __math_denorm(x) (x)
#endif
#if defined(_NEED_FLOAT_HUGE) && ((defined(FE_UNDERFLOW) && !defined(PICOLIBC_LONG_DOUBLE_NOEXCEPT)) || WANT_ERRNO)
long double __math_denorml(long double x);
#else
#define __math_denorml(x) (x)
#endif
HIDDEN double
__math_xflow (uint32_t sign, double y);
HIDDEN float
__math_xflowf (uint32_t sign, float y);
HIDDEN __float64
__math_lgamma_r (__float64 y, int *signgamp, int *divzero);
HIDDEN float
__math_lgammaf_r (float y, int *signgamp, int *divzero);
#if defined(_HAVE_ALIAS_ATTRIBUTE) && defined(_HAVE_WEAK_ATTRIBUTE)
extern int __signgam;
#else
#define __signgam signgam
#endif
/* Make aliases for 64-bit functions to the correct name */
#define acos64 _NAME_64(acos)
#define acosh64 _NAME_64(acosh)
#define asin64 _NAME_64(asin)
#define asinh64 _NAME_64(asinh)
#define atan64 _NAME_64(atan)
#define atanh64 _NAME_64(atanh)
#define atan264 _NAME_64(atan2)
#define cbrt64 _NAME_64(cbrt)
#define ceil64 _NAME_64(ceil)
#define copysign64 _NAME_64(copysign)
#define cos64 _NAME_64(cos)
#define _cos64 _NAME_64(_cos)
#define cosh64 _NAME_64(cosh)
#define drem64 _NAME_64(drem)
#define erf64 _NAME_64(erf)
#define erfc64 _NAME_64(erfc)
#define exp64 _NAME_64(exp)
#define exp264 _NAME_64(exp2)
#define exp1064 _NAME_64(exp10)
#define expm164 _NAME_64(expm1)
#define fabs64 _NAME_64(fabs)
#define fdim64 _NAME_64(fdim)
#define finite64 _NAME_64(finite)
#define __finite64 _NAME_64(__finite)
#define floor64 _NAME_64(floor)
#define fma64 _NAME_64(fma)
#define fmax64 _NAME_64(fmax)
#define fmin64 _NAME_64(fmin)
#define fmod64 _NAME_64(fmod)
#define __fpclassify64 _NAME_64_SPECIAL(__fpclassifyd, __fpclassifyl)
#define frexp64 _NAME_64(frexp)
#define gamma64 _NAME_64(gamma)
#define getpayload64 _NAME_64(getpayload)
#define hypot64 _NAME_64(hypot)
#define ilogb64 _NAME_64(ilogb)
#define infinity64 _NAME_64(infinity)
#define __iseqsig64 _NAME_64_SPECIAL(__iseqsigd, __iseqsigl)
#define isfinite64 _NAME_64(isfinite)
#define isinf64 _NAME_64(isinf)
#define __isinf64 _NAME_64_SPECIAL(__isinfd, __isinfl)
#define isnan64 _NAME_64(isnan)
#define __isnan64 _NAME_64_SPECIAL(__isnand, __isnanl)
#define ldexp64 _NAME_64(ldexp)
#define j064 _NAME_64(j0)
#define y064 _NAME_64(y0)
#define j164 _NAME_64(j1)
#define y164 _NAME_64(y1)
#define jn64 _NAME_64(jn)
#define yn64 _NAME_64(yn)
#define lgamma64 _NAME_64(lgamma)
#define lgamma64_r _NAME_64_SPECIAL(lgamma_r, lgammal_r)
#define llrint64 _NAME_64(llrint)
#define llround64 _NAME_64(llround)
#define log64 _NAME_64(log)
#define log1064 _NAME_64(log10)
#define log1p64 _NAME_64(log1p)
#define log264 _NAME_64(log2)
#define logb64 _NAME_64(logb)
#define lrint64 _NAME_64(lrint)
#define lround64 _NAME_64(lround)
#define modf64 _NAME_64(modf)
#define nan64 _NAME_64(nan)
#define nearbyint64 _NAME_64(nearbyint)
#define nextafter64 _NAME_64(nextafter)
#define nexttoward64 _NAME_64(nexttoward)
#define pow64 _NAME_64(pow)
#define _pow64 _NAME_64(_pow)
#define pow1064 _NAME_64(pow10)
#define remainder64 _NAME_64(remainder)
#define remquo64 _NAME_64(remquo)
#define rint64 _NAME_64(rint)
#define round64 _NAME_64(round)
#define scalb64 _NAME_64(scalb)
#define scalbn64 _NAME_64(scalbn)
#define scalbln64 _NAME_64(scalbln)
#define significand64 _NAME_64(significand)
#define sin64 _NAME_64(sin)
#define _sin64 _NAME_64(_sin)
#define sincos64 _NAME_64(sincos)
#define sinh64 _NAME_64(sinh)
#define sqrt64 _NAME_64(sqrt)
#define tan64 _NAME_64(tan)
#define tanh64 _NAME_64(tanh)
#define tgamma64 _NAME_64(tgamma)
#define trunc64 _NAME_64(trunc)
#ifdef _HAVE_ALIAS_ATTRIBUTE
float _powf(float, float);
float _sinf(float);
float _cosf(float);
__float64 _pow64(__float64, __float64);
__float64 _sin64(__float64);
__float64 _cos64(__float64);
#ifdef _HAVE_LONG_DOUBLE_MATH
long double _powl(long double, long double);
long double _sinl(long double);
long double _cosl(long double);
#endif
#else
#define _powf(x,y) powf(x,y)
#define _sinf(x) sinf(x)
#define _cosf(x) cosf(x)
#undef _pow64
#undef _sin64
#undef _cos64
#define _pow64(x,y) pow64(x,y)
#define _sin64(x) sin64(x)
#define _cos64(x) cos64(x)
#ifdef _HAVE_LONG_DOUBLE_MATH
#define _powl(x,y) powl(x,y)
#define _sinl(x) sinl(x)
#define _cosl(x) cosl(x)
#endif /* _HAVE_LONG_DOUBLE_MATH */
#endif /* _HAVE_ALIAS_ATTRIBUTE */
#endif
|