| OLD | NEW |
| 1 /* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */ | 1 /* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */ |
| 2 /* | 2 /* |
| 3 * ==================================================== | 3 * ==================================================== |
| 4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | 4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Developed at SunPro, a Sun Microsystems, Inc. business. | 6 * Developed at SunPro, a Sun Microsystems, Inc. business. |
| 7 * Permission to use, copy, modify, and distribute this | 7 * Permission to use, copy, modify, and distribute this |
| 8 * software is freely granted, provided that this notice | 8 * software is freely granted, provided that this notice |
| 9 * is preserved. | 9 * is preserved. |
| 10 * ==================================================== | 10 * ==================================================== |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * unlikely to be coming soon, but for reference the clang/llvm bug | 23 * unlikely to be coming soon, but for reference the clang/llvm bug |
| 24 * tracking this fact may be found at: | 24 * tracking this fact may be found at: |
| 25 * https://llvm.org/bugs/show_bug.cgi?id=8100 */ | 25 * https://llvm.org/bugs/show_bug.cgi?id=8100 */ |
| 26 #ifdef __clang__ | 26 #ifdef __clang__ |
| 27 #define PRAGMA_STDC_FENV_ACCESS_ON | 27 #define PRAGMA_STDC_FENV_ACCESS_ON |
| 28 #else | 28 #else |
| 29 #define PRAGMA_STDC_FENV_ACCESS_ON _Pragma("STDC FENV_ACCESS ON") | 29 #define PRAGMA_STDC_FENV_ACCESS_ON _Pragma("STDC FENV_ACCESS ON") |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 | 32 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 |
| 33 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_E
NDIAN | 33 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && \ |
| 34 __BYTE_ORDER == __LITTLE_ENDIAN |
| 34 union ldshape { | 35 union ldshape { |
| 35 » long double f; | 36 long double f; |
| 36 » struct { | 37 struct { |
| 37 » » uint64_t m; | 38 uint64_t m; |
| 38 » » uint16_t se; | 39 uint16_t se; |
| 39 » } i; | 40 } i; |
| 40 }; | 41 }; |
| 41 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_
ENDIAN | 42 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && \ |
| 43 __BYTE_ORDER == __LITTLE_ENDIAN |
| 42 union ldshape { | 44 union ldshape { |
| 43 » long double f; | 45 long double f; |
| 44 » struct { | 46 struct { |
| 45 » » uint64_t lo; | 47 uint64_t lo; |
| 46 » » uint32_t mid; | 48 uint32_t mid; |
| 47 » » uint16_t top; | 49 uint16_t top; |
| 48 » » uint16_t se; | 50 uint16_t se; |
| 49 » } i; | 51 } i; |
| 50 » struct { | 52 struct { |
| 51 » » uint64_t lo; | 53 uint64_t lo; |
| 52 » » uint64_t hi; | 54 uint64_t hi; |
| 53 » } i2; | 55 } i2; |
| 54 }; | 56 }; |
| 55 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __BIG_END
IAN | 57 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && \ |
| 58 __BYTE_ORDER == __BIG_ENDIAN |
| 56 union ldshape { | 59 union ldshape { |
| 57 » long double f; | 60 long double f; |
| 58 » struct { | 61 struct { |
| 59 » » uint16_t se; | 62 uint16_t se; |
| 60 » » uint16_t top; | 63 uint16_t top; |
| 61 » » uint32_t mid; | 64 uint32_t mid; |
| 62 » » uint64_t lo; | 65 uint64_t lo; |
| 63 » } i; | 66 } i; |
| 64 » struct { | 67 struct { |
| 65 » » uint64_t hi; | 68 uint64_t hi; |
| 66 » » uint64_t lo; | 69 uint64_t lo; |
| 67 » } i2; | 70 } i2; |
| 68 }; | 71 }; |
| 69 #else | 72 #else |
| 70 #error Unsupported long double representation | 73 #error Unsupported long double representation |
| 71 #endif | 74 #endif |
| 72 | 75 |
| 73 #define FORCE_EVAL(x) do { \ | 76 #define FORCE_EVAL(x) \ |
| 74 » if (sizeof(x) == sizeof(float)) { \ | 77 do { \ |
| 75 » » volatile float __x; \ | 78 if (sizeof(x) == sizeof(float)) { \ |
| 76 » » __x = (x); \ | 79 volatile float __x; \ |
| 77 » } else if (sizeof(x) == sizeof(double)) { \ | 80 __x = (x); \ |
| 78 » » volatile double __x; \ | 81 } else if (sizeof(x) == sizeof(double)) { \ |
| 79 » » __x = (x); \ | 82 volatile double __x; \ |
| 80 » } else { \ | 83 __x = (x); \ |
| 81 » » volatile long double __x; \ | 84 } else { \ |
| 82 » » __x = (x); \ | 85 volatile long double __x; \ |
| 83 » } \ | 86 __x = (x); \ |
| 84 } while(0) | 87 } \ |
| 88 } while (0) |
| 85 | 89 |
| 86 /* Get two 32 bit ints from a double. */ | 90 /* Get two 32 bit ints from a double. */ |
| 87 #define EXTRACT_WORDS(hi,lo,d) \ | 91 #define EXTRACT_WORDS(hi, lo, d) \ |
| 88 do { \ | 92 do { \ |
| 89 union {double f; uint64_t i;} __u; \ | 93 union { \ |
| 90 __u.f = (d); \ | 94 double f; \ |
| 91 (hi) = __u.i >> 32; \ | 95 uint64_t i; \ |
| 92 (lo) = (uint32_t)__u.i; \ | 96 } __u; \ |
| 93 } while (0) | 97 __u.f = (d); \ |
| 98 (hi) = __u.i >> 32; \ |
| 99 (lo) = (uint32_t)__u.i; \ |
| 100 } while (0) |
| 94 | 101 |
| 95 /* Get the more significant 32 bit int from a double. */ | 102 /* Get the more significant 32 bit int from a double. */ |
| 96 #define GET_HIGH_WORD(hi,d) \ | 103 #define GET_HIGH_WORD(hi, d) \ |
| 97 do { \ | 104 do { \ |
| 98 union {double f; uint64_t i;} __u; \ | 105 union { \ |
| 99 __u.f = (d); \ | 106 double f; \ |
| 100 (hi) = __u.i >> 32; \ | 107 uint64_t i; \ |
| 101 } while (0) | 108 } __u; \ |
| 109 __u.f = (d); \ |
| 110 (hi) = __u.i >> 32; \ |
| 111 } while (0) |
| 102 | 112 |
| 103 /* Get the less significant 32 bit int from a double. */ | 113 /* Get the less significant 32 bit int from a double. */ |
| 104 #define GET_LOW_WORD(lo,d) \ | 114 #define GET_LOW_WORD(lo, d) \ |
| 105 do { \ | 115 do { \ |
| 106 union {double f; uint64_t i;} __u; \ | 116 union { \ |
| 107 __u.f = (d); \ | 117 double f; \ |
| 108 (lo) = (uint32_t)__u.i; \ | 118 uint64_t i; \ |
| 109 } while (0) | 119 } __u; \ |
| 120 __u.f = (d); \ |
| 121 (lo) = (uint32_t)__u.i; \ |
| 122 } while (0) |
| 110 | 123 |
| 111 /* Set a double from two 32 bit ints. */ | 124 /* Set a double from two 32 bit ints. */ |
| 112 #define INSERT_WORDS(d,hi,lo) \ | 125 #define INSERT_WORDS(d, hi, lo) \ |
| 113 do { \ | 126 do { \ |
| 114 union {double f; uint64_t i;} __u; \ | 127 union { \ |
| 115 __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \ | 128 double f; \ |
| 116 (d) = __u.f; \ | 129 uint64_t i; \ |
| 117 } while (0) | 130 } __u; \ |
| 131 __u.i = ((uint64_t)(hi) << 32) | (uint32_t)(lo); \ |
| 132 (d) = __u.f; \ |
| 133 } while (0) |
| 118 | 134 |
| 119 /* Set the more significant 32 bits of a double from an int. */ | 135 /* Set the more significant 32 bits of a double from an int. */ |
| 120 #define SET_HIGH_WORD(d,hi) \ | 136 #define SET_HIGH_WORD(d, hi) \ |
| 121 do { \ | 137 do { \ |
| 122 union {double f; uint64_t i;} __u; \ | 138 union { \ |
| 123 __u.f = (d); \ | 139 double f; \ |
| 124 __u.i &= 0xffffffff; \ | 140 uint64_t i; \ |
| 125 __u.i |= (uint64_t)(hi) << 32; \ | 141 } __u; \ |
| 126 (d) = __u.f; \ | 142 __u.f = (d); \ |
| 127 } while (0) | 143 __u.i &= 0xffffffff; \ |
| 144 __u.i |= (uint64_t)(hi) << 32; \ |
| 145 (d) = __u.f; \ |
| 146 } while (0) |
| 128 | 147 |
| 129 /* Set the less significant 32 bits of a double from an int. */ | 148 /* Set the less significant 32 bits of a double from an int. */ |
| 130 #define SET_LOW_WORD(d,lo) \ | 149 #define SET_LOW_WORD(d, lo) \ |
| 131 do { \ | 150 do { \ |
| 132 union {double f; uint64_t i;} __u; \ | 151 union { \ |
| 133 __u.f = (d); \ | 152 double f; \ |
| 134 __u.i &= 0xffffffff00000000ull; \ | 153 uint64_t i; \ |
| 135 __u.i |= (uint32_t)(lo); \ | 154 } __u; \ |
| 136 (d) = __u.f; \ | 155 __u.f = (d); \ |
| 137 } while (0) | 156 __u.i &= 0xffffffff00000000ull; \ |
| 157 __u.i |= (uint32_t)(lo); \ |
| 158 (d) = __u.f; \ |
| 159 } while (0) |
| 138 | 160 |
| 139 /* Get a 32 bit int from a float. */ | 161 /* Get a 32 bit int from a float. */ |
| 140 #define GET_FLOAT_WORD(w,d) \ | 162 #define GET_FLOAT_WORD(w, d) \ |
| 141 do { \ | 163 do { \ |
| 142 union {float f; uint32_t i;} __u; \ | 164 union { \ |
| 143 __u.f = (d); \ | 165 float f; \ |
| 144 (w) = __u.i; \ | 166 uint32_t i; \ |
| 145 } while (0) | 167 } __u; \ |
| 168 __u.f = (d); \ |
| 169 (w) = __u.i; \ |
| 170 } while (0) |
| 146 | 171 |
| 147 /* Set a float from a 32 bit int. */ | 172 /* Set a float from a 32 bit int. */ |
| 148 #define SET_FLOAT_WORD(d,w) \ | 173 #define SET_FLOAT_WORD(d, w) \ |
| 149 do { \ | 174 do { \ |
| 150 union {float f; uint32_t i;} __u; \ | 175 union { \ |
| 151 __u.i = (w); \ | 176 float f; \ |
| 152 (d) = __u.f; \ | 177 uint32_t i; \ |
| 153 } while (0) | 178 } __u; \ |
| 179 __u.i = (w); \ |
| 180 (d) = __u.f; \ |
| 181 } while (0) |
| 154 | 182 |
| 155 #undef __CMPLX | 183 #undef __CMPLX |
| 156 #undef CMPLX | 184 #undef CMPLX |
| 157 #undef CMPLXF | 185 #undef CMPLXF |
| 158 #undef CMPLXL | 186 #undef CMPLXL |
| 159 | 187 |
| 160 #define __CMPLX(x, y, t) \ | 188 #define __CMPLX(x, y, t) \ |
| 161 » ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z) | 189 ((union { \ |
| 190 _Complex t __z; \ |
| 191 t __xy[2]; \ |
| 192 }){.__xy = {(x), (y)}} \ |
| 193 .__z) |
| 162 | 194 |
| 163 #define CMPLX(x, y) __CMPLX(x, y, double) | 195 #define CMPLX(x, y) __CMPLX(x, y, double) |
| 164 #define CMPLXF(x, y) __CMPLX(x, y, float) | 196 #define CMPLXF(x, y) __CMPLX(x, y, float) |
| 165 #define CMPLXL(x, y) __CMPLX(x, y, long double) | 197 #define CMPLXL(x, y) __CMPLX(x, y, long double) |
| 166 | 198 |
| 167 /* fdlibm kernel functions */ | 199 /* fdlibm kernel functions */ |
| 168 | 200 |
| 169 int __rem_pio2_large(double*,double*,int,int,int); | 201 int __rem_pio2_large(double*, double*, int, int, int); |
| 170 | 202 |
| 171 int __rem_pio2(double,double*); | 203 int __rem_pio2(double, double*); |
| 172 double __sin(double,double,int); | 204 double __sin(double, double, int); |
| 173 double __cos(double,double); | 205 double __cos(double, double); |
| 174 double __tan(double,double,int); | 206 double __tan(double, double, int); |
| 175 double __expo2(double); | 207 double __expo2(double); |
| 176 double complex __ldexp_cexp(double complex,int); | 208 double complex __ldexp_cexp(double complex, int); |
| 177 | 209 |
| 178 int __rem_pio2f(float,double*); | 210 int __rem_pio2f(float, double*); |
| 179 float __sindf(double); | 211 float __sindf(double); |
| 180 float __cosdf(double); | 212 float __cosdf(double); |
| 181 float __tandf(double,int); | 213 float __tandf(double, int); |
| 182 float __expo2f(float); | 214 float __expo2f(float); |
| 183 float complex __ldexp_cexpf(float complex,int); | 215 float complex __ldexp_cexpf(float complex, int); |
| 184 | 216 |
| 185 int __rem_pio2l(long double, long double *); | 217 int __rem_pio2l(long double, long double*); |
| 186 long double __sinl(long double, long double, int); | 218 long double __sinl(long double, long double, int); |
| 187 long double __cosl(long double, long double); | 219 long double __cosl(long double, long double); |
| 188 long double __tanl(long double, long double, int); | 220 long double __tanl(long double, long double, int); |
| 189 | 221 |
| 190 /* polynomial evaluation */ | 222 /* polynomial evaluation */ |
| 191 long double __polevll(long double, const long double *, int); | 223 long double __polevll(long double, const long double*, int); |
| 192 long double __p1evll(long double, const long double *, int); | 224 long double __p1evll(long double, const long double*, int); |
| 193 | 225 |
| 194 #endif | 226 #endif |
| OLD | NEW |