blob: e24c00117615608813f805a51919b27cbd55af10 [file] [log] [blame]
Andrew Hsieh0df3e702013-10-15 15:55:12 +08001/*
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/*
13 * from: @(#)fdlibm.h 5.1 93/09/24
14 * $FreeBSD: src/lib/msun/src/math.h,v 1.61 2005/04/16 21:12:47 das Exp $
15 */
16
17#ifndef _MATH_H_
18#define _MATH_H_
19
20#include <sys/cdefs.h>
21#include <sys/types.h>
22#include <limits.h>
23
24#define __pure2
25
26/*
27 * ANSI/POSIX
28 */
29extern const union __infinity_un {
30 unsigned char __uc[8];
31 double __ud;
32} __infinity;
33
34extern const union __nan_un {
35 unsigned char __uc[sizeof(float)];
36 float __uf;
37} __nan;
38
39/* #if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) */
40#if 1
41#define __MATH_BUILTIN_CONSTANTS
42#endif
43
44/* #if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER) */
45#if 1
46#define __MATH_BUILTIN_RELOPS
47#endif
48
49/* #ifdef __MATH_BUILTIN_CONSTANTS */
50#if 1
51#define HUGE_VAL __builtin_huge_val()
52#else
53#define HUGE_VAL (__infinity.__ud)
54#endif
55
56/* #if __ISO_C_VISIBLE >= 1999 */
57#if 0
58#define FP_ILOGB0 (-__INT_MAX)
59#define FP_ILOGBNAN __INT_MAX
60#else
61#define FP_ILOGB0 (-INT_MAX)
62#define FP_ILOGBNAN INT_MAX
63#endif
64
65#ifdef __MATH_BUILTIN_CONSTANTS
66#define HUGE_VALF __builtin_huge_valf()
67#define HUGE_VALL __builtin_huge_vall()
68#define INFINITY __builtin_inf()
69#define NAN __builtin_nan("")
70#else
71#define HUGE_VALF (float)HUGE_VAL
72#define HUGE_VALL (long double)HUGE_VAL
73#define INFINITY HUGE_VALF
74#define NAN (__nan.__uf)
75#endif /* __MATH_BUILTIN_CONSTANTS */
76
77#define MATH_ERRNO 1
78#define MATH_ERREXCEPT 2
79#define math_errhandling MATH_ERREXCEPT
80
81/* XXX We need a <machine/math.h>. */
82#if defined(__ia64__) || defined(__sparc64__)
83#define FP_FAST_FMA
84#endif
85#ifdef __ia64__
86#define FP_FAST_FMAL
87#endif
88#define FP_FAST_FMAF
89
90/* Symbolic constants to classify floating point numbers. */
91#define FP_INFINITE 0x01
92#define FP_NAN 0x02
93#define FP_NORMAL 0x04
94#define FP_SUBNORMAL 0x08
95#define FP_ZERO 0x10
96#define fpclassify(x) \
97 ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
98 : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
99 : __fpclassifyl(x))
100
101#define isfinite(x) \
102 ((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
103 : (sizeof (x) == sizeof (double)) ? __isfinite(x) \
104 : __isfinitel(x))
105#define isinf(x) \
106 ((sizeof (x) == sizeof (float)) ? __isinff(x) \
107 : (sizeof (x) == sizeof (double)) ? __isinf(x) \
108 : __isinfl(x))
109#define isnan(x) \
110 ((sizeof (x) == sizeof (float)) ? isnanf(x) \
111 : (sizeof (x) == sizeof (double)) ? isnan(x) \
112 : __isnanl(x))
113#define isnormal(x) \
114 ((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
115 : (sizeof (x) == sizeof (double)) ? __isnormal(x) \
116 : __isnormall(x))
117
118#ifdef __MATH_BUILTIN_RELOPS
119#define isgreater(x, y) __builtin_isgreater((x), (y))
120#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
121#define isless(x, y) __builtin_isless((x), (y))
122#define islessequal(x, y) __builtin_islessequal((x), (y))
123#define islessgreater(x, y) __builtin_islessgreater((x), (y))
124#define isunordered(x, y) __builtin_isunordered((x), (y))
125#else
126#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
127#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
128#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
129#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
130#define islessgreater(x, y) (!isunordered((x), (y)) && \
131 ((x) > (y) || (y) > (x)))
132#define isunordered(x, y) (isnan(x) || isnan(y))
133#endif /* __MATH_BUILTIN_RELOPS */
134
135#define signbit(x) \
136 ((sizeof (x) == sizeof (float)) ? __signbitf(x) \
137 : (sizeof (x) == sizeof (double)) ? __signbit(x) \
138 : __signbitl(x))
139
140#if 0
141typedef __double_t double_t;
142typedef __float_t float_t;
143#endif
144/* #endif */ /* __ISO_C_VISIBLE >= 1999 */
145
146/*
147 * XOPEN/SVID
148 */
149/* #if __BSD_VISIBLE || __XSI_VISIBLE */
150#define M_E 2.7182818284590452354 /* e */
151#define M_LOG2E 1.4426950408889634074 /* log 2e */
152#define M_LOG10E 0.43429448190325182765 /* log 10e */
153#define M_LN2 0.69314718055994530942 /* log e2 */
154#define M_LN10 2.30258509299404568402 /* log e10 */
155#define M_PI 3.14159265358979323846 /* pi */
156#define M_PI_2 1.57079632679489661923 /* pi/2 */
157#define M_PI_4 0.78539816339744830962 /* pi/4 */
158#define M_1_PI 0.31830988618379067154 /* 1/pi */
159#define M_2_PI 0.63661977236758134308 /* 2/pi */
160#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
161#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
162#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
163
164#define MAXFLOAT ((float)3.40282346638528860e+38)
165extern int signgam;
166/* #endif */ /* __BSD_VISIBLE || __XSI_VISIBLE */
167
168#if __BSD_VISIBLE
169#if 0
170/* Old value from 4.4BSD-Lite math.h; this is probably better. */
171#define HUGE HUGE_VAL
172#else
173#define HUGE MAXFLOAT
174#endif
175#endif /* __BSD_VISIBLE */
176
177/*
178 * Most of these functions depend on the rounding mode and have the side
179 * effect of raising floating-point exceptions, so they are not declared
180 * as __pure2. In C99, FENV_ACCESS affects the purity of these functions.
181 */
182__BEGIN_DECLS
183/*
184 * ANSI/POSIX
185 */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800186int __fpclassifyd(double) __NDK_FPABI_MATH__ __pure2;
187int __fpclassifyf(float) __NDK_FPABI_MATH__ __pure2;
188int __fpclassifyl(long double) __NDK_FPABI_MATH__ __pure2;
189int __isfinitef(float) __NDK_FPABI_MATH__ __pure2;
190int __isfinite(double) __NDK_FPABI_MATH__ __pure2;
191int __isfinitel(long double) __NDK_FPABI_MATH__ __pure2;
192int __isinff(float) __NDK_FPABI_MATH__ __pure2;
193int __isinf(double) __NDK_FPABI_MATH__ __pure2;
194int __isinfl(long double) __NDK_FPABI_MATH__ __pure2;
195int __isnanl(long double) __NDK_FPABI_MATH__ __pure2;
196int __isnormalf(float) __NDK_FPABI_MATH__ __pure2;
197int __isnormal(double) __NDK_FPABI_MATH__ __pure2;
198int __isnormall(long double) __NDK_FPABI_MATH__ __pure2;
199int __signbit(double) __NDK_FPABI_MATH__ __pure2;
200int __signbitf(float) __NDK_FPABI_MATH__ __pure2;
201int __signbitl(long double) __NDK_FPABI_MATH__ __pure2;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800202
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800203double acos(double) __NDK_FPABI_MATH__;
204double asin(double) __NDK_FPABI_MATH__;
205double atan(double) __NDK_FPABI_MATH__;
206double atan2(double, double) __NDK_FPABI_MATH__;
207double cos(double) __NDK_FPABI_MATH__;
208double sin(double) __NDK_FPABI_MATH__;
209double tan(double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800210
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800211double cosh(double) __NDK_FPABI_MATH__;
212double sinh(double) __NDK_FPABI_MATH__;
213double tanh(double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800214
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800215double exp(double) __NDK_FPABI_MATH__;
216double frexp(double, int *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
217double ldexp(double, int) __NDK_FPABI_MATH__;
218double log(double) __NDK_FPABI_MATH__;
219double log10(double) __NDK_FPABI_MATH__;
220double modf(double, double *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800221
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800222double pow(double, double) __NDK_FPABI_MATH__;
223double sqrt(double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800224
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800225double ceil(double) __NDK_FPABI_MATH__;
226double fabs(double) __NDK_FPABI_MATH__ __pure2;
227double floor(double) __NDK_FPABI_MATH__;
228double fmod(double, double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800229
230/*
231 * These functions are not in C90.
232 */
233/* #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800234double acosh(double) __NDK_FPABI_MATH__;
235double asinh(double) __NDK_FPABI_MATH__;
236double atanh(double) __NDK_FPABI_MATH__;
237double cbrt(double) __NDK_FPABI_MATH__;
238double erf(double) __NDK_FPABI_MATH__;
239double erfc(double) __NDK_FPABI_MATH__;
240double exp2(double) __NDK_FPABI_MATH__;
241double expm1(double) __NDK_FPABI_MATH__;
242double fma(double, double, double) __NDK_FPABI_MATH__;
243double hypot(double, double) __NDK_FPABI_MATH__;
244int ilogb(double) __NDK_FPABI_MATH__ __pure2;
245/* int (isinf)(double) __NDK_FPABI_MATH__ __pure2; */
246int (isnan)(double) __NDK_FPABI_MATH__ __pure2;
247double lgamma(double) __NDK_FPABI_MATH__;
248long long llrint(double) __NDK_FPABI_MATH__;
249long long llround(double) __NDK_FPABI_MATH__;
250double log1p(double) __NDK_FPABI_MATH__;
251double log2(double) __NDK_FPABI_MATH__;
252double logb(double) __NDK_FPABI_MATH__;
253long lrint(double) __NDK_FPABI_MATH__;
254long lround(double) __NDK_FPABI_MATH__;
255double nan(const char *) __NDK_FPABI_MATH__ __pure2;
256double nextafter(double, double) __NDK_FPABI_MATH__;
257double remainder(double, double) __NDK_FPABI_MATH__;
258double remquo(double, double, int *) __NDK_FPABI_MATH__;
259double rint(double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800260/* #endif */ /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
261
262/* #if __BSD_VISIBLE || __XSI_VISIBLE */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800263double j0(double) __NDK_FPABI_MATH__;
264double j1(double) __NDK_FPABI_MATH__;
265double jn(int, double) __NDK_FPABI_MATH__;
266double scalb(double, double) __NDK_FPABI_MATH__;
267double y0(double) __NDK_FPABI_MATH__;
268double y1(double) __NDK_FPABI_MATH__;
269double yn(int, double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800270
271/* #if __XSI_VISIBLE <= 500 || __BSD_VISIBLE */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800272double gamma(double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800273/* #endif */
274/* #endif */ /* __BSD_VISIBLE || __XSI_VISIBLE */
275
276/* #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800277double copysign(double, double) __NDK_FPABI_MATH__ __pure2;
278double fdim(double, double) __NDK_FPABI_MATH__;
279double fmax(double, double) __NDK_FPABI_MATH__ __pure2;
280double fmin(double, double) __NDK_FPABI_MATH__ __pure2;
281double nearbyint(double) __NDK_FPABI_MATH__;
282double round(double) __NDK_FPABI_MATH__;
283double scalbln(double, long) __NDK_FPABI_MATH__;
284double scalbn(double, int) __NDK_FPABI_MATH__;
285double tgamma(double) __NDK_FPABI_MATH__;
286double trunc(double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800287/* #endif */
288
289/*
290 * BSD math library entry points
291 */
292/* #if __BSD_VISIBLE */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800293double drem(double, double) __NDK_FPABI_MATH__;
294int finite(double) __NDK_FPABI_MATH__ __pure2;
295int isnanf(float) __NDK_FPABI_MATH__ __pure2;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800296
297/*
298 * Reentrant version of gamma & lgamma; passes signgam back by reference
299 * as the second argument; user must allocate space for signgam.
300 */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800301double gamma_r(double, int *) __NDK_FPABI_MATH__;
302double lgamma_r(double, int *) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800303
304/*
305 * IEEE Test Vector
306 */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800307double significand(double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800308/* #endif */ /* __BSD_VISIBLE */
309
310/* float versions of ANSI/POSIX functions */
311/*#if __ISO_C_VISIBLE >= 1999 */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800312float acosf(float) __NDK_FPABI_MATH__;
313float asinf(float) __NDK_FPABI_MATH__;
314float atanf(float) __NDK_FPABI_MATH__;
315float atan2f(float, float) __NDK_FPABI_MATH__;
316float cosf(float) __NDK_FPABI_MATH__;
317float sinf(float) __NDK_FPABI_MATH__;
318float tanf(float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800319
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800320float coshf(float) __NDK_FPABI_MATH__;
321float sinhf(float) __NDK_FPABI_MATH__;
322float tanhf(float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800323
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800324float exp2f(float) __NDK_FPABI_MATH__;
325float expf(float) __NDK_FPABI_MATH__;
326float expm1f(float) __NDK_FPABI_MATH__;
327float frexpf(float, int *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
328int ilogbf(float) __NDK_FPABI_MATH__ __pure2;
329float ldexpf(float, int) __NDK_FPABI_MATH__;
330float log10f(float) __NDK_FPABI_MATH__;
331float log1pf(float) __NDK_FPABI_MATH__;
332float log2f(float) __NDK_FPABI_MATH__;
333float logf(float) __NDK_FPABI_MATH__;
334float modff(float, float *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800335
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800336float powf(float, float) __NDK_FPABI_MATH__;
337float sqrtf(float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800338
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800339float ceilf(float) __NDK_FPABI_MATH__;
340float fabsf(float) __NDK_FPABI_MATH__ __pure2;
341float floorf(float) __NDK_FPABI_MATH__;
342float fmodf(float, float) __NDK_FPABI_MATH__;
343float roundf(float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800344
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800345float erff(float) __NDK_FPABI_MATH__;
346float erfcf(float) __NDK_FPABI_MATH__;
347float hypotf(float, float) __NDK_FPABI_MATH__;
348float lgammaf(float) __NDK_FPABI_MATH__;
349float tgammaf(float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800350
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800351float acoshf(float) __NDK_FPABI_MATH__;
352float asinhf(float) __NDK_FPABI_MATH__;
353float atanhf(float) __NDK_FPABI_MATH__;
354float cbrtf(float) __NDK_FPABI_MATH__;
355float logbf(float) __NDK_FPABI_MATH__;
356float copysignf(float, float) __NDK_FPABI_MATH__ __pure2;
357long long llrintf(float) __NDK_FPABI_MATH__;
358long long llroundf(float) __NDK_FPABI_MATH__;
359long lrintf(float) __NDK_FPABI_MATH__;
360long lroundf(float) __NDK_FPABI_MATH__;
361float nanf(const char *) __NDK_FPABI_MATH__ __pure2;
362float nearbyintf(float) __NDK_FPABI_MATH__;
363float nextafterf(float, float) __NDK_FPABI_MATH__;
364float remainderf(float, float) __NDK_FPABI_MATH__;
365float remquof(float, float, int *) __NDK_FPABI_MATH__;
366float rintf(float) __NDK_FPABI_MATH__;
367float scalblnf(float, long) __NDK_FPABI_MATH__;
368float scalbnf(float, int) __NDK_FPABI_MATH__;
369float truncf(float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800370
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800371float fdimf(float, float) __NDK_FPABI_MATH__;
372float fmaf(float, float, float) __NDK_FPABI_MATH__;
373float fmaxf(float, float) __NDK_FPABI_MATH__ __pure2;
374float fminf(float, float) __NDK_FPABI_MATH__ __pure2;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800375/* #endif */
376
377/*
378 * float versions of BSD math library entry points
379 */
380/* #if __BSD_VISIBLE */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800381float dremf(float, float) __NDK_FPABI_MATH__;
382int finitef(float) __NDK_FPABI_MATH__ __pure2;
383float gammaf(float) __NDK_FPABI_MATH__;
384float j0f(float) __NDK_FPABI_MATH__;
385float j1f(float) __NDK_FPABI_MATH__;
386float jnf(int, float) __NDK_FPABI_MATH__;
387float scalbf(float, float) __NDK_FPABI_MATH__;
388float y0f(float) __NDK_FPABI_MATH__;
389float y1f(float) __NDK_FPABI_MATH__;
390float ynf(int, float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800391
392/*
393 * Float versions of reentrant version of gamma & lgamma; passes
394 * signgam back by reference as the second argument; user must
395 * allocate space for signgam.
396 */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800397float gammaf_r(float, int *) __NDK_FPABI_MATH__;
398float lgammaf_r(float, int *) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800399
400/*
401 * float version of IEEE Test Vector
402 */
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800403float significandf(float) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800404/* #endif */ /* __BSD_VISIBLE */
405
406/*
407 * long double versions of ISO/POSIX math functions
408 */
409/* #if __ISO_C_VISIBLE >= 1999 */
410#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800411long double acoshl(long double) __NDK_FPABI_MATH__;
412long double acosl(long double) __NDK_FPABI_MATH__;
413long double asinhl(long double) __NDK_FPABI_MATH__;
414long double asinl(long double) __NDK_FPABI_MATH__;
415long double atan2l(long double, long double) __NDK_FPABI_MATH__;
416long double atanhl(long double) __NDK_FPABI_MATH__;
417long double atanl(long double) __NDK_FPABI_MATH__;
418long double cbrtl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800419#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800420long double ceill(long double) __NDK_FPABI_MATH__;
421long double copysignl(long double, long double) __NDK_FPABI_MATH__ __pure2;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800422#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800423long double coshl(long double) __NDK_FPABI_MATH__;
424long double cosl(long double) __NDK_FPABI_MATH__;
425long double erfcl(long double) __NDK_FPABI_MATH__;
426long double erfl(long double) __NDK_FPABI_MATH__;
427long double exp2l(long double) __NDK_FPABI_MATH__;
428long double expl(long double) __NDK_FPABI_MATH__;
429long double expm1l(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800430#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800431long double fabsl(long double) __NDK_FPABI_MATH__ __pure2;
432long double fdiml(long double, long double) __NDK_FPABI_MATH__;
433long double floorl(long double) __NDK_FPABI_MATH__;
434long double fmal(long double, long double, long double) __NDK_FPABI_MATH__;
435long double fmaxl(long double, long double) __NDK_FPABI_MATH__ __pure2;
436long double fminl(long double, long double) __NDK_FPABI_MATH__ __pure2;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800437#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800438long double fmodl(long double, long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800439#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800440long double frexpl(long double value, int *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800441#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800442long double hypotl(long double, long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800443#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800444int ilogbl(long double) __NDK_FPABI_MATH__ __pure2;
445long double ldexpl(long double, int) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800446#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800447long double lgammal(long double) __NDK_FPABI_MATH__;
448long long llrintl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800449#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800450long long llroundl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800451#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800452long double log10l(long double) __NDK_FPABI_MATH__;
453long double log1pl(long double) __NDK_FPABI_MATH__;
454long double log2l(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800455#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800456long double logbl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800457#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800458long lrintl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800459#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800460long lroundl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800461#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800462long double modfl(long double, long double *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800463#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800464long double nanl(const char *) __NDK_FPABI_MATH__ __pure2;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800465#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800466long double nearbyintl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800467#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800468long double nextafterl(long double, long double) __NDK_FPABI_MATH__;
469double nexttoward(double, long double) __NDK_FPABI_MATH__;
470float nexttowardf(float, long double) __NDK_FPABI_MATH__;
471long double nexttowardl(long double, long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800472#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800473long double powl(long double, long double) __NDK_FPABI_MATH__;
474long double remainderl(long double, long double) __NDK_FPABI_MATH__;
475long double remquol(long double, long double, int *) __NDK_FPABI_MATH__;
476long double rintl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800477#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800478long double roundl(long double) __NDK_FPABI_MATH__;
479long double scalblnl(long double, long) __NDK_FPABI_MATH__;
480long double scalbnl(long double, int) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800481#if 0
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800482long double sinhl(long double) __NDK_FPABI_MATH__;
483long double sinl(long double) __NDK_FPABI_MATH__;
484long double sqrtl(long double) __NDK_FPABI_MATH__;
485long double tanhl(long double) __NDK_FPABI_MATH__;
486long double tanl(long double) __NDK_FPABI_MATH__;
487long double tgammal(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800488#endif
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800489long double truncl(long double) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800490
491/* BIONIC: GLibc compatibility - required by the ARM toolchain */
492#ifdef _GNU_SOURCE
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800493void sincos(double x, double *sin, double *cos) __NDK_FPABI_MATH__;
494void sincosf(float x, float *sin, float *cos) __NDK_FPABI_MATH__;
495void sincosl(long double x, long double *sin, long double *cos) __NDK_FPABI_MATH__;
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800496#endif
497
Andrew Hsieh5881b5c2013-10-16 16:26:26 +0800498long double log2l(long double) __NDK_FPABI_MATH__;
Andrew Hsieh2a571fd2013-11-21 15:31:39 +0800499
500/* builtin version of all the above math functions are annotated too */
501
502double __builtin_acos(double) __NDK_FPABI_MATH__;
503double __builtin_asin(double) __NDK_FPABI_MATH__;
504double __builtin_atan(double) __NDK_FPABI_MATH__;
505double __builtin_atan2(double, double) __NDK_FPABI_MATH__;
506double __builtin_cos(double) __NDK_FPABI_MATH__;
507double __builtin_sin(double) __NDK_FPABI_MATH__;
508double __builtin_tan(double) __NDK_FPABI_MATH__;
509double __builtin_cosh(double) __NDK_FPABI_MATH__;
510double __builtin_sinh(double) __NDK_FPABI_MATH__;
511double __builtin_tanh(double) __NDK_FPABI_MATH__;
512double __builtin_exp(double) __NDK_FPABI_MATH__;
513double __builtin_frexp(double, int *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
514double __builtin_ldexp(double, int) __NDK_FPABI_MATH__;
515double __builtin_log(double) __NDK_FPABI_MATH__;
516double __builtin_log10(double) __NDK_FPABI_MATH__;
517double __builtin_modf(double, double *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
518double __builtin_pow(double, double) __NDK_FPABI_MATH__;
519double __builtin_sqrt(double) __NDK_FPABI_MATH__;
520double __builtin_ceil(double) __NDK_FPABI_MATH__;
521double __builtin_fabs(double) __NDK_FPABI_MATH__ __pure2;
522double __builtin_floor(double) __NDK_FPABI_MATH__;
523double __builtin_fmod(double, double) __NDK_FPABI_MATH__;
524double __builtin_acosh(double) __NDK_FPABI_MATH__;
525double __builtin_asinh(double) __NDK_FPABI_MATH__;
526double __builtin_atanh(double) __NDK_FPABI_MATH__;
527double __builtin_cbrt(double) __NDK_FPABI_MATH__;
528double __builtin_erf(double) __NDK_FPABI_MATH__;
529double __builtin_erfc(double) __NDK_FPABI_MATH__;
530double __builtin_exp2(double) __NDK_FPABI_MATH__;
531double __builtin_expm1(double) __NDK_FPABI_MATH__;
532double __builtin_fma(double, double, double) __NDK_FPABI_MATH__;
533double __builtin_hypot(double, double) __NDK_FPABI_MATH__;
534int __builtin_ilogb(double) __NDK_FPABI_MATH__ __pure2;
535/* int __builtin_isinf(double) __NDK_FPABI_MATH__ __pure2; */
Logan Chienad40d952013-12-25 08:21:38 +0800536#if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5)
Andrew Hsieh2a571fd2013-11-21 15:31:39 +0800537int __builtin_isnan(double) __NDK_FPABI_MATH__ __pure2;
538#else
Andrew Hsiehf2427232013-12-30 14:13:10 +0800539/* clang < 3.5 has faulty prototype for __builtin_isnan */
Andrew Hsieh2a571fd2013-11-21 15:31:39 +0800540#endif
541double __builtin_lgamma(double) __NDK_FPABI_MATH__;
542long long __builtin_llrint(double) __NDK_FPABI_MATH__;
543long long __builtin_llround(double) __NDK_FPABI_MATH__;
544double __builtin_log1p(double) __NDK_FPABI_MATH__;
545double __builtin_log2(double) __NDK_FPABI_MATH__;
546double __builtin_logb(double) __NDK_FPABI_MATH__;
547long __builtin_lrint(double) __NDK_FPABI_MATH__;
548long __builtin_lround(double) __NDK_FPABI_MATH__;
549double __builtin_nan(const char *) __NDK_FPABI_MATH__ __pure2;
550double __builtin_nextafter(double, double) __NDK_FPABI_MATH__;
551double __builtin_remainder(double, double) __NDK_FPABI_MATH__;
552double __builtin_remquo(double, double, int *) __NDK_FPABI_MATH__;
553double __builtin_rint(double) __NDK_FPABI_MATH__;
554double __builtin_j0(double) __NDK_FPABI_MATH__;
555double __builtin_j1(double) __NDK_FPABI_MATH__;
556double __builtin_jn(int, double) __NDK_FPABI_MATH__;
557double __builtin_scalb(double, double) __NDK_FPABI_MATH__;
558double __builtin_y0(double) __NDK_FPABI_MATH__;
559double __builtin_y1(double) __NDK_FPABI_MATH__;
560double __builtin_yn(int, double) __NDK_FPABI_MATH__;
561double __builtin_gamma(double) __NDK_FPABI_MATH__;
562double __builtin_copysign(double, double) __NDK_FPABI_MATH__ __pure2;
563double __builtin_fdim(double, double) __NDK_FPABI_MATH__;
564double __builtin_fmax(double, double) __NDK_FPABI_MATH__ __pure2;
565double __builtin_fmin(double, double) __NDK_FPABI_MATH__ __pure2;
566double __builtin_nearbyint(double) __NDK_FPABI_MATH__;
567double __builtin_round(double) __NDK_FPABI_MATH__;
568double __builtin_scalbln(double, long) __NDK_FPABI_MATH__;
569double __builtin_scalbn(double, int) __NDK_FPABI_MATH__;
570double __builtin_tgamma(double) __NDK_FPABI_MATH__;
571double __builtin_trunc(double) __NDK_FPABI_MATH__;
572double __builtin_drem(double, double) __NDK_FPABI_MATH__;
573int __builtin_finite(double) __NDK_FPABI_MATH__ __pure2;
574int __builtin_isnanf(float) __NDK_FPABI_MATH__ __pure2;
575double __builtin_gamma_r(double, int *) __NDK_FPABI_MATH__;
576double __builtin_lgamma_r(double, int *) __NDK_FPABI_MATH__;
577double __builtin_significand(double) __NDK_FPABI_MATH__;
578float __builtin_acosf(float) __NDK_FPABI_MATH__;
579float __builtin_asinf(float) __NDK_FPABI_MATH__;
580float __builtin_atanf(float) __NDK_FPABI_MATH__;
581float __builtin_atan2f(float, float) __NDK_FPABI_MATH__;
582float __builtin_cosf(float) __NDK_FPABI_MATH__;
583float __builtin_sinf(float) __NDK_FPABI_MATH__;
584float __builtin_tanf(float) __NDK_FPABI_MATH__;
585float __builtin_coshf(float) __NDK_FPABI_MATH__;
586float __builtin_sinhf(float) __NDK_FPABI_MATH__;
587float __builtin_tanhf(float) __NDK_FPABI_MATH__;
588float __builtin_exp2f(float) __NDK_FPABI_MATH__;
589float __builtin_expf(float) __NDK_FPABI_MATH__;
590float __builtin_expm1f(float) __NDK_FPABI_MATH__;
591float __builtin_frexpf(float, int *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
592int __builtin_ilogbf(float) __NDK_FPABI_MATH__ __pure2;
593float __builtin_ldexpf(float, int) __NDK_FPABI_MATH__;
594float __builtin_log10f(float) __NDK_FPABI_MATH__;
595float __builtin_log1pf(float) __NDK_FPABI_MATH__;
596float __builtin_log2f(float) __NDK_FPABI_MATH__;
597float __builtin_logf(float) __NDK_FPABI_MATH__;
598float __builtin_modff(float, float *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
599float __builtin_powf(float, float) __NDK_FPABI_MATH__;
600float __builtin_sqrtf(float) __NDK_FPABI_MATH__;
601float __builtin_ceilf(float) __NDK_FPABI_MATH__;
602float __builtin_fabsf(float) __NDK_FPABI_MATH__ __pure2;
603float __builtin_floorf(float) __NDK_FPABI_MATH__;
604float __builtin_fmodf(float, float) __NDK_FPABI_MATH__;
605float __builtin_roundf(float) __NDK_FPABI_MATH__;
606float __builtin_erff(float) __NDK_FPABI_MATH__;
607float __builtin_erfcf(float) __NDK_FPABI_MATH__;
608float __builtin_hypotf(float, float) __NDK_FPABI_MATH__;
609float __builtin_lgammaf(float) __NDK_FPABI_MATH__;
610float __builtin_tgammaf(float) __NDK_FPABI_MATH__;
611float __builtin_acoshf(float) __NDK_FPABI_MATH__;
612float __builtin_asinhf(float) __NDK_FPABI_MATH__;
613float __builtin_atanhf(float) __NDK_FPABI_MATH__;
614float __builtin_cbrtf(float) __NDK_FPABI_MATH__;
615float __builtin_logbf(float) __NDK_FPABI_MATH__;
616float __builtin_copysignf(float, float) __NDK_FPABI_MATH__ __pure2;
617long long __builtin_llrintf(float) __NDK_FPABI_MATH__;
618long long __builtin_llroundf(float) __NDK_FPABI_MATH__;
619long __builtin_lrintf(float) __NDK_FPABI_MATH__;
620long __builtin_lroundf(float) __NDK_FPABI_MATH__;
621float __builtin_nanf(const char *) __NDK_FPABI_MATH__ __pure2;
622float __builtin_nearbyintf(float) __NDK_FPABI_MATH__;
623float __builtin_nextafterf(float, float) __NDK_FPABI_MATH__;
624float __builtin_remainderf(float, float) __NDK_FPABI_MATH__;
625float __builtin_remquof(float, float, int *) __NDK_FPABI_MATH__;
626float __builtin_rintf(float) __NDK_FPABI_MATH__;
627float __builtin_scalblnf(float, long) __NDK_FPABI_MATH__;
628float __builtin_scalbnf(float, int) __NDK_FPABI_MATH__;
629float __builtin_truncf(float) __NDK_FPABI_MATH__;
630float __builtin_fdimf(float, float) __NDK_FPABI_MATH__;
631float __builtin_fmaf(float, float, float) __NDK_FPABI_MATH__;
632float __builtin_fmaxf(float, float) __NDK_FPABI_MATH__ __pure2;
633float __builtin_fminf(float, float) __NDK_FPABI_MATH__ __pure2;
634float __builtin_dremf(float, float) __NDK_FPABI_MATH__;
635int __builtin_finitef(float) __NDK_FPABI_MATH__ __pure2;
636float __builtin_gammaf(float) __NDK_FPABI_MATH__;
637float __builtin_j0f(float) __NDK_FPABI_MATH__;
638float __builtin_j1f(float) __NDK_FPABI_MATH__;
639float __builtin_jnf(int, float) __NDK_FPABI_MATH__;
640float __builtin_scalbf(float, float) __NDK_FPABI_MATH__;
641float __builtin_y0f(float) __NDK_FPABI_MATH__;
642float __builtin_y1f(float) __NDK_FPABI_MATH__;
643float __builtin_ynf(int, float) __NDK_FPABI_MATH__;
644float __builtin_gammaf_r(float, int *) __NDK_FPABI_MATH__;
645float __builtin_lgammaf_r(float, int *) __NDK_FPABI_MATH__;
646float __builtin_significandf(float) __NDK_FPABI_MATH__;
647long double __builtin_acoshl(long double) __NDK_FPABI_MATH__;
648long double __builtin_acosl(long double) __NDK_FPABI_MATH__;
649long double __builtin_asinhl(long double) __NDK_FPABI_MATH__;
650long double __builtin_asinl(long double) __NDK_FPABI_MATH__;
651long double __builtin_atan2l(long double, long double) __NDK_FPABI_MATH__;
652long double __builtin_atanhl(long double) __NDK_FPABI_MATH__;
653long double __builtin_atanl(long double) __NDK_FPABI_MATH__;
654long double __builtin_cbrtl(long double) __NDK_FPABI_MATH__;
655long double __builtin_ceill(long double) __NDK_FPABI_MATH__;
656long double __builtin_copysignl(long double, long double) __NDK_FPABI_MATH__ __pure2;
657long double __builtin_coshl(long double) __NDK_FPABI_MATH__;
658long double __builtin_cosl(long double) __NDK_FPABI_MATH__;
659long double __builtin_erfcl(long double) __NDK_FPABI_MATH__;
660long double __builtin_erfl(long double) __NDK_FPABI_MATH__;
661long double __builtin_exp2l(long double) __NDK_FPABI_MATH__;
662long double __builtin_expl(long double) __NDK_FPABI_MATH__;
663long double __builtin_expm1l(long double) __NDK_FPABI_MATH__;
664long double __builtin_fabsl(long double) __NDK_FPABI_MATH__ __pure2;
665long double __builtin_fdiml(long double, long double) __NDK_FPABI_MATH__;
666long double __builtin_floorl(long double) __NDK_FPABI_MATH__;
667long double __builtin_fmal(long double, long double, long double) __NDK_FPABI_MATH__;
668long double __builtin_fmaxl(long double, long double) __NDK_FPABI_MATH__ __pure2;
669long double __builtin_fminl(long double, long double) __NDK_FPABI_MATH__ __pure2;
670long double __builtin_fmodl(long double, long double) __NDK_FPABI_MATH__;
671long double __builtin_frexpl(long double value, int *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
672long double __builtin_hypotl(long double, long double) __NDK_FPABI_MATH__;
673int __builtin_ilogbl(long double) __NDK_FPABI_MATH__ __pure2;
674long double __builtin_ldexpl(long double, int) __NDK_FPABI_MATH__;
675long double __builtin_lgammal(long double) __NDK_FPABI_MATH__;
676long long __builtin_llrintl(long double) __NDK_FPABI_MATH__;
677long long __builtin_llroundl(long double) __NDK_FPABI_MATH__;
678long double __builtin_log10l(long double) __NDK_FPABI_MATH__;
679long double __builtin_log1pl(long double) __NDK_FPABI_MATH__;
680long double __builtin_log2l(long double) __NDK_FPABI_MATH__;
681long double __builtin_logbl(long double) __NDK_FPABI_MATH__;
682long double __builtin_logl(long double) __NDK_FPABI_MATH__;
683long __builtin_lrintl(long double) __NDK_FPABI_MATH__;
684long __builtin_lroundl(long double) __NDK_FPABI_MATH__;
685long double __builtin_modfl(long double, long double *) __NDK_FPABI_MATH__; /* fundamentally !__pure2 */
686long double __builtin_nanl(const char *) __NDK_FPABI_MATH__ __pure2;
687long double __builtin_nearbyintl(long double) __NDK_FPABI_MATH__;
688long double __builtin_nextafterl(long double, long double) __NDK_FPABI_MATH__;
Andrew Hsiehf2427232013-12-30 14:13:10 +0800689#if !defined(__clang__) || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)
Andrew Hsieh2a571fd2013-11-21 15:31:39 +0800690double __builtin_nexttoward(double, long double) __NDK_FPABI_MATH__;
691float __builtin_nexttowardf(float, long double) __NDK_FPABI_MATH__;
692#else
693/* clang < 3.4 */
694double __builtin_nexttoward(double, double) __NDK_FPABI_MATH__;
695float __builtin_nexttowardf(float, float) __NDK_FPABI_MATH__;
696#endif
697long double __builtin_nexttowardl(long double, long double) __NDK_FPABI_MATH__;
698long double __builtin_powl(long double, long double) __NDK_FPABI_MATH__;
699long double __builtin_remainderl(long double, long double) __NDK_FPABI_MATH__;
700long double __builtin_remquol(long double, long double, int *) __NDK_FPABI_MATH__;
701long double __builtin_rintl(long double) __NDK_FPABI_MATH__;
702long double __builtin_roundl(long double) __NDK_FPABI_MATH__;
703long double __builtin_scalblnl(long double, long) __NDK_FPABI_MATH__;
704long double __builtin_scalbnl(long double, int) __NDK_FPABI_MATH__;
705long double __builtin_sinhl(long double) __NDK_FPABI_MATH__;
706long double __builtin_sinl(long double) __NDK_FPABI_MATH__;
707long double __builtin_sqrtl(long double) __NDK_FPABI_MATH__;
708long double __builtin_tanhl(long double) __NDK_FPABI_MATH__;
709long double __builtin_tanl(long double) __NDK_FPABI_MATH__;
710long double __builtin_tgammal(long double) __NDK_FPABI_MATH__;
711long double __builtin_truncl(long double) __NDK_FPABI_MATH__;
712void __builtin_sincos(double x, double *sin, double *cos) __NDK_FPABI_MATH__;
713void __builtin_sincosf(float x, float *sin, float *cos) __NDK_FPABI_MATH__;
714void __builtin_sincosl(long double x, long double *sin, long double *cos) __NDK_FPABI_MATH__;
715long double __builtin_log2l(long double) __NDK_FPABI_MATH__;
716
717/* #endif */ /* __ISO_C_VISIBLE >= 1999 */
Andrew Hsieh0df3e702013-10-15 15:55:12 +0800718__END_DECLS
719
720#endif /* !_MATH_H_ */