The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * ==================================================== |
| 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
| 4 | * |
| 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
| 6 | * Permission to use, copy, modify, and distribute this |
| 7 | * software is freely granted, provided that this notice |
| 8 | * is preserved. |
| 9 | * ==================================================== |
| 10 | */ |
| 11 | |
| 12 | /* |
Elliott Hughes | fee514e | 2020-09-17 11:57:50 -0700 | [diff] [blame] | 13 | * Originally based on fdlibm.h 5.1 via FreeBSD. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 14 | */ |
| 15 | |
Elliott Hughes | fee514e | 2020-09-17 11:57:50 -0700 | [diff] [blame] | 16 | #pragma once |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 17 | |
| 18 | #include <sys/cdefs.h> |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 19 | #include <limits.h> |
| 20 | |
Elliott Hughes | de9ac71 | 2014-05-19 16:58:52 -0700 | [diff] [blame] | 21 | __BEGIN_DECLS |
Elliott Hughes | de9ac71 | 2014-05-19 16:58:52 -0700 | [diff] [blame] | 22 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 23 | /* C11. */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 24 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 25 | typedef double __double_t; |
| 26 | typedef __double_t double_t; |
| 27 | typedef float __float_t; |
| 28 | typedef __float_t float_t; |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 29 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 30 | #define HUGE_VAL __builtin_huge_val() |
| 31 | #define HUGE_VALF __builtin_huge_valf() |
| 32 | #define HUGE_VALL __builtin_huge_vall() |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 33 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 34 | #define INFINITY __builtin_inff() |
| 35 | |
| 36 | #define NAN __builtin_nanf("") |
| 37 | |
| 38 | #define FP_INFINITE 0x01 |
| 39 | #define FP_NAN 0x02 |
| 40 | #define FP_NORMAL 0x04 |
| 41 | #define FP_SUBNORMAL 0x08 |
| 42 | #define FP_ZERO 0x10 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 43 | |
Elliott Hughes | b662280 | 2015-08-14 14:04:30 -0700 | [diff] [blame] | 44 | #if defined(__FP_FAST_FMA) |
| 45 | #define FP_FAST_FMA 1 |
| 46 | #endif |
| 47 | #if defined(__FP_FAST_FMAF) |
| 48 | #define FP_FAST_FMAF 1 |
| 49 | #endif |
| 50 | #if defined(__FP_FAST_FMAL) |
| 51 | #define FP_FAST_FMAL 1 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 52 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 53 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 54 | #define FP_ILOGB0 (-INT_MAX) |
| 55 | #define FP_ILOGBNAN INT_MAX |
| 56 | |
| 57 | #define MATH_ERRNO 1 |
| 58 | #define MATH_ERREXCEPT 2 |
| 59 | #define math_errhandling MATH_ERREXCEPT |
| 60 | |
| 61 | #define fpclassify(x) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 62 | |
Elliott Hughes | b662280 | 2015-08-14 14:04:30 -0700 | [diff] [blame] | 63 | #define isfinite(x) __builtin_isfinite(x) |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 64 | |
Elliott Hughes | b662280 | 2015-08-14 14:04:30 -0700 | [diff] [blame] | 65 | #define isinf(x) __builtin_isinf(x) |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 66 | |
Elliott Hughes | b662280 | 2015-08-14 14:04:30 -0700 | [diff] [blame] | 67 | #define isnan(x) __builtin_isnan(x) |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 68 | |
Elliott Hughes | b662280 | 2015-08-14 14:04:30 -0700 | [diff] [blame] | 69 | #define isnormal(x) __builtin_isnormal(x) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 70 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 71 | #define signbit(x) \ |
| 72 | ((sizeof(x) == sizeof(float)) ? __builtin_signbitf(x) \ |
| 73 | : (sizeof(x) == sizeof(double)) ? __builtin_signbit(x) \ |
| 74 | : __builtin_signbitl(x)) |
| 75 | |
| 76 | double acos(double __x); |
| 77 | float acosf(float __x); |
| 78 | long double acosl(long double __x) __RENAME_LDBL(acos, 3, 21); |
| 79 | |
| 80 | double asin(double __x); |
| 81 | float asinf(float __x); |
| 82 | long double asinl(long double __x) __RENAME_LDBL(asin, 3, 21); |
| 83 | |
| 84 | double atan(double __x); |
| 85 | float atanf(float __x); |
| 86 | long double atanl(long double __x) __RENAME_LDBL(atan, 3, 21); |
| 87 | |
| 88 | double atan2(double __y, double __x); |
| 89 | float atan2f(float __y, float __x); |
| 90 | long double atan2l(long double __y, long double __x) __RENAME_LDBL(atan2, 3, 21); |
| 91 | |
| 92 | double cos(double __x); |
| 93 | float cosf(float __x); |
| 94 | long double cosl(long double __x) __RENAME_LDBL(cos, 3, 21); |
| 95 | |
| 96 | double sin(double __x); |
| 97 | float sinf(float __x); |
| 98 | long double sinl(long double __x) __RENAME_LDBL(sin, 3, 21); |
| 99 | |
| 100 | double tan(double __x); |
| 101 | float tanf(float __x); |
| 102 | long double tanl(long double __x) __RENAME_LDBL(tan, 3, 21); |
| 103 | |
| 104 | double acosh(double __x); |
| 105 | float acoshf(float __x); |
| 106 | long double acoshl(long double __x) __RENAME_LDBL(acosh, 3, 21); |
| 107 | |
| 108 | double asinh(double __x); |
| 109 | float asinhf(float __x); |
| 110 | long double asinhl(long double __x) __RENAME_LDBL(asinh, 3, 21); |
| 111 | |
| 112 | double atanh(double __x); |
| 113 | float atanhf(float __x); |
| 114 | long double atanhl(long double __x) __RENAME_LDBL(atanh, 3, 21); |
| 115 | |
| 116 | double cosh(double __x); |
| 117 | float coshf(float __x); |
| 118 | long double coshl(long double __x) __RENAME_LDBL(cosh, 3, 21); |
| 119 | |
| 120 | double sinh(double __x); |
| 121 | float sinhf(float __x); |
| 122 | long double sinhl(long double __x) __RENAME_LDBL(sinh, 3, 21); |
| 123 | |
| 124 | double tanh(double __x); |
| 125 | float tanhf(float __x); |
| 126 | long double tanhl(long double __x) __RENAME_LDBL(tanh, 3, 21); |
| 127 | |
| 128 | double exp(double __x); |
| 129 | float expf(float __x); |
| 130 | long double expl(long double __x) __RENAME_LDBL(exp, 3, 21); |
| 131 | |
| 132 | double exp2(double __x); |
| 133 | float exp2f(float __x); |
| 134 | long double exp2l(long double __x) __RENAME_LDBL(exp2, 3, 21); |
| 135 | |
| 136 | double expm1(double __x); |
| 137 | float expm1f(float __x); |
| 138 | long double expm1l(long double __x) __RENAME_LDBL(expm1, 3, 21); |
| 139 | |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 140 | double frexp(double __x, int* _Nonnull __exponent); |
| 141 | float frexpf(float __x, int* _Nonnull __exponent); |
| 142 | long double frexpl(long double __x, int* _Nonnull __exponent) __RENAME_LDBL(frexp, 3, 21); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 143 | |
| 144 | int ilogb(double __x) __attribute_const__; |
| 145 | int ilogbf(float __x) __attribute_const__; |
Elliott Hughes | d6541c2 | 2017-09-18 16:22:32 -0700 | [diff] [blame] | 146 | int ilogbl(long double __x) __RENAME_LDBL(ilogb, 3, 3) __attribute_const__; |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 147 | |
| 148 | double ldexp(double __x, int __exponent); |
| 149 | float ldexpf(float __x, int __exponent); |
| 150 | long double ldexpl(long double __x, int __exponent) __RENAME_LDBL(ldexp, 3, 3); |
| 151 | |
| 152 | double log(double __x); |
| 153 | float logf(float __x); |
| 154 | long double logl(long double __x) __RENAME_LDBL(log, 3, 21); |
| 155 | |
| 156 | double log10(double __x); |
| 157 | float log10f(float __x); |
| 158 | long double log10l(long double __x) __RENAME_LDBL(log10, 3, 21); |
| 159 | |
| 160 | double log1p(double __x); |
| 161 | float log1pf(float __x); |
| 162 | long double log1pl(long double __x) __RENAME_LDBL(log1p, 3, 21); |
| 163 | |
| 164 | double log2(double __x) __INTRODUCED_IN(18); |
| 165 | float log2f(float __x) __INTRODUCED_IN(18); |
| 166 | long double log2l(long double __x) __RENAME_LDBL(log2, 18, 18); |
| 167 | |
| 168 | double logb(double __x); |
| 169 | float logbf(float __x); |
| 170 | long double logbl(long double __x) __RENAME_LDBL(logb, 3, 18); |
| 171 | |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 172 | double modf(double __x, double* _Nonnull __integral_part); |
| 173 | float modff(float __x, float* _Nonnull __integral_part); |
| 174 | long double modfl(long double __x, long double* _Nonnull __integral_part) __RENAME_LDBL(modf, 3, 21); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 175 | |
| 176 | double scalbn(double __x, int __exponent); |
| 177 | float scalbnf(float __x, int __exponent); |
| 178 | long double scalbnl(long double __x, int __exponent) __RENAME_LDBL(scalbn, 3, 3); |
| 179 | |
Elliott Hughes | e17ebfd | 2023-05-26 13:00:51 -0700 | [diff] [blame] | 180 | double scalbln(double __x, long __exponent); |
| 181 | float scalblnf(float __x, long __exponent); |
| 182 | long double scalblnl(long double __x, long __exponent) __RENAME_LDBL(scalbln, 9, 18); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 183 | |
| 184 | double cbrt(double __x); |
| 185 | float cbrtf(float __x); |
| 186 | long double cbrtl(long double __x) __RENAME_LDBL(cbrt, 3, 21); |
| 187 | |
| 188 | double fabs(double __x) __attribute_const__; |
| 189 | float fabsf(float __x) __attribute_const__; |
Elliott Hughes | d6541c2 | 2017-09-18 16:22:32 -0700 | [diff] [blame] | 190 | long double fabsl(long double __x) __RENAME_LDBL(fabs, 3, 3) __attribute_const__; |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 191 | |
| 192 | double hypot(double __x, double __y); |
| 193 | float hypotf(float __x, float __y); |
| 194 | long double hypotl(long double __x, long double __y) __RENAME_LDBL(hypot, 3, 21); |
| 195 | |
| 196 | double pow(double __x, double __y); |
| 197 | float powf(float __x, float __y); |
| 198 | long double powl(long double __x, long double __y) __RENAME_LDBL(pow, 3, 21); |
| 199 | |
| 200 | double sqrt(double __x); |
| 201 | float sqrtf(float __x); |
| 202 | long double sqrtl(long double __x) __RENAME_LDBL(sqrt, 3, 21); |
| 203 | |
| 204 | double erf(double __x); |
| 205 | float erff(float __x); |
| 206 | long double erfl(long double __x) __RENAME_LDBL(erf, 3, 21); |
| 207 | |
| 208 | double erfc(double __x); |
| 209 | float erfcf(float __x); |
| 210 | long double erfcl(long double __x) __RENAME_LDBL(erfc, 3, 21); |
| 211 | |
| 212 | double lgamma(double __x); |
| 213 | float lgammaf(float __x); |
| 214 | long double lgammal(long double __x) __RENAME_LDBL(lgamma, 3, 21); |
| 215 | |
| 216 | double tgamma(double __x); |
Elliott Hughes | f106a39 | 2019-10-03 16:09:04 -0700 | [diff] [blame] | 217 | float tgammaf(float __x); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 218 | long double tgammal(long double __x) __RENAME_LDBL(tgamma, 3, 21); |
| 219 | |
| 220 | double ceil(double __x); |
| 221 | float ceilf(float __x); |
| 222 | long double ceill(long double __x) __RENAME_LDBL(ceil, 3, 3); |
| 223 | |
| 224 | double floor(double __x); |
| 225 | float floorf(float __x); |
| 226 | long double floorl(long double __x) __RENAME_LDBL(floor, 3, 3); |
| 227 | |
| 228 | double nearbyint(double __x); |
| 229 | float nearbyintf(float __x); |
| 230 | long double nearbyintl(long double __x) __RENAME_LDBL(nearbyint, 3, 21); |
| 231 | |
| 232 | double rint(double __x); |
| 233 | float rintf(float __x); |
| 234 | long double rintl(long double __x) __RENAME_LDBL(rint, 3, 21); |
| 235 | |
| 236 | long lrint(double __x); |
| 237 | long lrintf(float __x); |
| 238 | long lrintl(long double __x) __RENAME_LDBL(lrint, 3, 21); |
| 239 | |
| 240 | long long llrint(double __x); |
| 241 | long long llrintf(float __x); |
| 242 | long long llrintl(long double __x) __RENAME_LDBL(llrint, 3, 21); |
| 243 | |
| 244 | double round(double __x); |
| 245 | float roundf(float __x); |
| 246 | long double roundl(long double __x) __RENAME_LDBL(roundl, 3, 3); |
| 247 | |
| 248 | long lround(double __x); |
| 249 | long lroundf(float __x); |
| 250 | long lroundl(long double __x) __RENAME_LDBL(lround, 3, 3); |
| 251 | |
| 252 | long long llround(double __x); |
| 253 | long long llroundf(float __x); |
| 254 | long long llroundl(long double __x) __RENAME_LDBL(llround, 3, 3); |
| 255 | |
| 256 | double trunc(double __x); |
| 257 | float truncf(float __x); |
| 258 | long double truncl(long double __x) __RENAME_LDBL(trunc, 3, 3); |
| 259 | |
| 260 | double fmod(double __x, double __y); |
| 261 | float fmodf(float __x, float __y); |
| 262 | long double fmodl(long double __x, long double __y) __RENAME_LDBL(fmod, 3, 21); |
| 263 | |
| 264 | double remainder(double __x, double __y); |
| 265 | float remainderf(float __x, float __y); |
| 266 | long double remainderl(long double __x, long double __y) __RENAME_LDBL(remainder, 3, 21); |
| 267 | |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 268 | double remquo(double __x, double __y, int* _Nonnull __quotient_bits); |
| 269 | float remquof(float __x, float __y, int* _Nonnull __quotient_bits); |
| 270 | long double remquol(long double __x, long double __y, int* _Nonnull __quotient_bits) __RENAME_LDBL(remquo, 3, 21); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 271 | |
| 272 | double copysign(double __value, double __sign) __attribute_const__; |
| 273 | float copysignf(float __value, float __sign) __attribute_const__; |
Elliott Hughes | d6541c2 | 2017-09-18 16:22:32 -0700 | [diff] [blame] | 274 | long double copysignl(long double __value, long double __sign) __RENAME_LDBL(copysign, 3, 3) __attribute_const__; |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 275 | |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 276 | double nan(const char* _Nonnull __kind) __attribute_const__; |
| 277 | float nanf(const char* _Nonnull __kind) __attribute_const__; |
| 278 | long double nanl(const char* _Nonnull __kind) __RENAME_LDBL(nan, 13, 13) __attribute_const__; |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 279 | |
| 280 | double nextafter(double __x, double __y); |
| 281 | float nextafterf(float __x, float __y); |
Dan Albert | eae41f8 | 2021-01-29 16:24:06 -0800 | [diff] [blame] | 282 | long double nextafterl(long double __x, long double __y) __RENAME_LDBL_NO_GUARD_FOR_NDK(nextafter, 3, 21); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 283 | |
Elliott Hughes | e17ebfd | 2023-05-26 13:00:51 -0700 | [diff] [blame] | 284 | double nexttoward(double __x, long double __y); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 285 | float nexttowardf(float __x, long double __y); |
Dan Albert | eae41f8 | 2021-01-29 16:24:06 -0800 | [diff] [blame] | 286 | long double nexttowardl(long double __x, long double __y) __RENAME_LDBL_NO_GUARD_FOR_NDK(nexttoward, 18, 18); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 287 | |
| 288 | double fdim(double __x, double __y); |
| 289 | float fdimf(float __x, float __y); |
| 290 | long double fdiml(long double __x, long double __y) __RENAME_LDBL(fdim, 3, 3); |
| 291 | |
| 292 | double fmax(double __x, double __y) __attribute_const__; |
| 293 | float fmaxf(float __x, float __y) __attribute_const__; |
Elliott Hughes | d6541c2 | 2017-09-18 16:22:32 -0700 | [diff] [blame] | 294 | long double fmaxl(long double __x, long double __y) __RENAME_LDBL(fmax, 3, 3) __attribute_const__; |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 295 | |
| 296 | double fmin(double __x, double __y) __attribute_const__; |
| 297 | float fminf(float __x, float __y) __attribute_const__; |
Elliott Hughes | d6541c2 | 2017-09-18 16:22:32 -0700 | [diff] [blame] | 298 | long double fminl(long double __x, long double __y) __RENAME_LDBL(fmin, 3, 3) __attribute_const__; |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 299 | |
| 300 | double fma(double __x, double __y, double __z); |
| 301 | float fmaf(float __x, float __y, float __z); |
Dan Albert | eae41f8 | 2021-01-29 16:24:06 -0800 | [diff] [blame] | 302 | long double fmal(long double __x, long double __y, long double __z) __RENAME_LDBL_NO_GUARD_FOR_NDK(fma, 3, 21); |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 303 | |
Elliott Hughes | b662280 | 2015-08-14 14:04:30 -0700 | [diff] [blame] | 304 | #define isgreater(x, y) __builtin_isgreater((x), (y)) |
| 305 | #define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y)) |
| 306 | #define isless(x, y) __builtin_isless((x), (y)) |
| 307 | #define islessequal(x, y) __builtin_islessequal((x), (y)) |
| 308 | #define islessgreater(x, y) __builtin_islessgreater((x), (y)) |
| 309 | #define isunordered(x, y) __builtin_isunordered((x), (y)) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 310 | |
Dan Albert | 284c8f1 | 2017-03-30 16:34:27 -0700 | [diff] [blame] | 311 | /* |
| 312 | * https://code.google.com/p/android/issues/detail?id=271629 |
| 313 | * To be fully compliant with C++, we need to not define these (C doesn't |
| 314 | * specify them either). Exposing these means that isinf and isnan will have a |
| 315 | * return type of int in C++ rather than bool like they're supposed to be. |
| 316 | * |
| 317 | * GNU libstdc++ 4.9 isn't able to handle a standard compliant C library. Its |
| 318 | * <cmath> will `#undef isnan` from math.h and only adds the function overloads |
| 319 | * to the std namespace, making it impossible to use both <cmath> (which gets |
| 320 | * included by a lot of other standard headers) and ::isnan. |
| 321 | */ |
Elliott Hughes | 684c31a | 2017-08-18 15:07:41 -0700 | [diff] [blame] | 322 | int (isinf)(double __x) __attribute_const__ __INTRODUCED_IN(21); |
| 323 | int (isnan)(double __x) __attribute_const__; |
Dan Albert | 284c8f1 | 2017-03-30 16:34:27 -0700 | [diff] [blame] | 324 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 325 | /* POSIX extensions. */ |
Josh Gao | 46b4416 | 2016-05-27 11:14:16 -0700 | [diff] [blame] | 326 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 327 | extern int signgam; |
Elliott Hughes | b4f2f28 | 2014-05-08 21:19:12 -0700 | [diff] [blame] | 328 | |
Elliott Hughes | 684c31a | 2017-08-18 15:07:41 -0700 | [diff] [blame] | 329 | double j0(double __x); |
| 330 | double j1(double __x); |
| 331 | double jn(int __n, double __x); |
| 332 | double y0(double __x); |
| 333 | double y1(double __x); |
| 334 | double yn(int __n, double __x); |
Elliott Hughes | c1929e4 | 2016-08-12 16:18:03 -0700 | [diff] [blame] | 335 | |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 336 | #define M_E 2.7182818284590452354 /* e */ |
| 337 | #define M_LOG2E 1.4426950408889634074 /* log 2e */ |
| 338 | #define M_LOG10E 0.43429448190325182765 /* log 10e */ |
| 339 | #define M_LN2 0.69314718055994530942 /* log e2 */ |
| 340 | #define M_LN10 2.30258509299404568402 /* log e10 */ |
| 341 | #define M_PI 3.14159265358979323846 /* pi */ |
| 342 | #define M_PI_2 1.57079632679489661923 /* pi/2 */ |
| 343 | #define M_PI_4 0.78539816339744830962 /* pi/4 */ |
| 344 | #define M_1_PI 0.31830988618379067154 /* 1/pi */ |
| 345 | #define M_2_PI 0.63661977236758134308 /* 2/pi */ |
| 346 | #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ |
| 347 | #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ |
| 348 | #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ |
Elliott Hughes | 9c8d711 | 2016-06-13 13:23:42 -0700 | [diff] [blame] | 349 | |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 350 | #define MAXFLOAT ((float)3.40282346638528860e+38) |
Elliott Hughes | 9c8d711 | 2016-06-13 13:23:42 -0700 | [diff] [blame] | 351 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 352 | /* BSD extensions. */ |
| 353 | |
| 354 | #if defined(__USE_BSD) |
| 355 | #define HUGE MAXFLOAT |
| 356 | #endif |
| 357 | |
| 358 | /* Extensions in both BSD and GNU. */ |
| 359 | |
Elliott Hughes | 9c8d711 | 2016-06-13 13:23:42 -0700 | [diff] [blame] | 360 | #if defined(__USE_BSD) || defined(__USE_GNU) |
Elliott Hughes | 684c31a | 2017-08-18 15:07:41 -0700 | [diff] [blame] | 361 | double gamma(double __x); |
| 362 | double scalb(double __x, double __exponent); |
| 363 | double drem(double __x, double __y); |
| 364 | int finite(double __x) __attribute_const__; |
| 365 | int isnanf(float __x) __attribute_const__; |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 366 | double gamma_r(double __x, int* _Nonnull __sign); |
| 367 | double lgamma_r(double __x, int* _Nonnull __sign); |
Elliott Hughes | 684c31a | 2017-08-18 15:07:41 -0700 | [diff] [blame] | 368 | double significand(double __x); |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 369 | long double lgammal_r(long double __x, int* _Nonnull __sign) __INTRODUCED_IN(23); |
Elliott Hughes | 684c31a | 2017-08-18 15:07:41 -0700 | [diff] [blame] | 370 | long double significandl(long double __x) __INTRODUCED_IN(21); |
| 371 | float dremf(float __x, float __y); |
| 372 | int finitef(float __x) __attribute_const__; |
| 373 | float gammaf(float __x); |
| 374 | float j0f(float __x); |
| 375 | float j1f(float __x); |
| 376 | float jnf(int __n, float __x); |
| 377 | float scalbf(float __x, float __exponent); |
| 378 | float y0f(float __x); |
| 379 | float y1f(float __x); |
| 380 | float ynf(int __n, float __x); |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 381 | float gammaf_r(float __x, int* _Nonnull __sign); |
| 382 | float lgammaf_r(float __x, int* _Nonnull __sign); |
Elliott Hughes | 684c31a | 2017-08-18 15:07:41 -0700 | [diff] [blame] | 383 | float significandf(float __x); |
zijunzhao | 195b90b | 2023-02-08 02:00:09 +0000 | [diff] [blame] | 384 | void sincos(double __x, double* _Nonnull __sin, double* _Nonnull __cos); |
| 385 | void sincosf(float __x, float* _Nonnull __sin, float* _Nonnull __cos); |
| 386 | void sincosl(long double __x, long double* _Nonnull __sin, long double* _Nonnull __cos); |
Elliott Hughes | 7553185 | 2014-09-18 11:23:58 -0700 | [diff] [blame] | 387 | #endif |
| 388 | |
Elliott Hughes | 50cda38 | 2017-09-14 15:30:08 -0700 | [diff] [blame] | 389 | /* GNU extensions. */ |
| 390 | |
Elliott Hughes | 5f5cc45 | 2014-08-18 16:04:03 -0700 | [diff] [blame] | 391 | #if defined(__USE_GNU) |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 392 | #define M_El 2.718281828459045235360287471352662498L /* e */ |
| 393 | #define M_LOG2El 1.442695040888963407359924681001892137L /* log 2e */ |
| 394 | #define M_LOG10El 0.434294481903251827651128918916605082L /* log 10e */ |
| 395 | #define M_LN2l 0.693147180559945309417232121458176568L /* log e2 */ |
| 396 | #define M_LN10l 2.302585092994045684017991454684364208L /* log e10 */ |
| 397 | #define M_PIl 3.141592653589793238462643383279502884L /* pi */ |
| 398 | #define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */ |
| 399 | #define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */ |
| 400 | #define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */ |
| 401 | #define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */ |
| 402 | #define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */ |
| 403 | #define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */ |
| 404 | #define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */ |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 405 | #endif |
Elliott Hughes | b4f2f28 | 2014-05-08 21:19:12 -0700 | [diff] [blame] | 406 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 407 | __END_DECLS |