blob: b5b264bf72cbaf4f27d2d0d35d4f16fc83715e08 [file] [log] [blame]
Elliott Hughesa0ee0782013-01-30 19:06:37 -08001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <float.h>
18#include <math.h>
19
20extern int __isinf(double); /* isinf.c */
21int (isinf)(double a1) { return __isinf(a1); }
22
Elliott Hughes241608e2013-12-18 16:06:52 -080023int (isnanf)(float a1) { return __isnanf(a1); }
24
Calin Juravlef723b702014-04-01 17:38:59 +010025/*
26 * On LP64 sizeof(long double) > sizeof(double) so functions which fall back
27 * to their double variants lose precision. Emit a warning whenever something
28 * links against such functions.
29 * On LP32 sizeof(long double) == sizeof(double) so we don't need to warn.
30 */
31#ifdef __LP64__
32#define WARN_IMPRECISE(x) \
33 __warn_references(x, # x " has lower than advertised precision");
34#else
35#define WARN_IMPRECISE(x)
36#endif //__LP64__
37
38#define DECLARE_IMPRECISE(f) \
39 long double f ## l(long double v) { return f(v); } \
40 WARN_IMPRECISE(x)
41
42DECLARE_IMPRECISE(cosh);
43DECLARE_IMPRECISE(erfc);
44DECLARE_IMPRECISE(erf);
45DECLARE_IMPRECISE(lgamma);
46DECLARE_IMPRECISE(sinh);
47DECLARE_IMPRECISE(tanh);
48DECLARE_IMPRECISE(tgamma);
49DECLARE_IMPRECISE(significand);
50
Calin Juravle4d77c112014-03-14 17:56:46 +000051long double powl(long double a1, long double a2) { return pow(a1, a2); }
Calin Juravlef723b702014-04-01 17:38:59 +010052WARN_IMPRECISE(powl)
Calin Juravle4d77c112014-03-14 17:56:46 +000053
54#ifndef __LP64__
Elliott Hughesa0ee0782013-01-30 19:06:37 -080055/*
56 * The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
57 * Android works around those cases by replacing the broken functions with our own trivial stubs
58 * that call the regular "double" function.
59 */
60
61int __fpclassifyl(long double a1) { return __fpclassifyd(a1); }
62int __isfinitel(long double a1) { return __isfinite(a1); }
63int __isinfl(long double a1) { return __isinf(a1); }
Elliott Hughes28ddd912013-12-19 17:13:56 -080064int __isnanl(long double a1) { return (isnan)(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080065int __isnormall(long double a1) { return __isnormal(a1); }
66int __signbitl(long double a1) { return __signbit(a1); }
67
68long double acoshl(long double a1) { return acosh(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080069long double acosl(long double a1) { return acos(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080070long double asinhl(long double a1) { return asinh(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080071long double asinl(long double a1) { return asin(a1); }
72long double atan2l(long double a1, long double a2) { return atan2(a1, a2); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080073long double atanhl(long double a1) { return atanh(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080074long double atanl(long double a1) { return atan(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080075long double cbrtl(long double a1) { return cbrt(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080076long double ceill(long double a1) { return ceil(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080077long double copysignl(long double a1, long double a2) { return copysign(a1, a2); }
Calin Juravle4d77c112014-03-14 17:56:46 +000078
Elliott Hughes170dbe22013-02-07 17:45:11 -080079long double cosl(long double a1) { return cos(a1); }
Calin Juravle4d77c112014-03-14 17:56:46 +000080
Elliott Hughes241608e2013-12-18 16:06:52 -080081long double exp2l(long double a1) { return exp2(a1); }
82long double expl(long double a1) { return exp(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080083long double expm1l(long double a1) { return expm1(a1); }
84long double fabsl(long double a1) { return fabs(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080085long double floorl(long double a1) { return floor(a1); }
86long double fmal(long double a1, long double a2, long double a3) { return fma(a1, a2, a3); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080087long double fmaxl(long double a1, long double a2) { return fmax(a1, a2); }
88long double fmodl(long double a1, long double a2) { return fmod(a1, a2); }
89long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
Elliott Hughes241608e2013-12-18 16:06:52 -080090long double frexpl(long double a1, int* a2) { return frexp(a1, a2); }
91long double hypotl(long double a1, long double a2) { return hypot(a1, a2); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080092int ilogbl(long double a1) { return ilogb(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080093long double ldexpl(long double a1, int a2) { return ldexp(a1, a2); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080094long long llrintl(long double a1) { return llrint(a1); }
95long double log10l(long double a1) { return log10(a1); }
96long double log1pl(long double a1) { return log1p(a1); }
97long double log2l(long double a1) { return log2(a1); }
Elliott Hughes926a3072013-02-06 16:07:54 -080098long double logbl(long double a1) { return logb(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080099long double logl(long double a1) { return log(a1); }
100long lrintl(long double a1) { return lrint(a1); }
101long long llroundl(long double a1) { return llround(a1); }
102long lroundl(long double a1) { return lround(a1); }
Calin Juravle4d77c112014-03-14 17:56:46 +0000103long double modfl(long double a1, long double* a2) { double i; double f = modf(a1, &i); *a2 = i; return f; }
Elliott Hughes241608e2013-12-18 16:06:52 -0800104long double nanl(const char* a1) { return nan(a1); }
105long double nextafterl(long double a1, long double a2) { return nextafter(a1, a2); }
Elliott Hughes241608e2013-12-18 16:06:52 -0800106long double remainderl(long double a1, long double a2) { return remainder(a1, a2); }
107long double remquol(long double a1, long double a2, int* a3) { return remquo(a1, a2, a3); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -0800108long double rintl(long double a1) { return rint(a1); }
109long double roundl(long double a1) { return round(a1); }
110long double scalbnl(long double a1, int a2) { return scalbn(a1, a2); }
Elliott Hughes170dbe22013-02-07 17:45:11 -0800111long double sinl(long double a1) { return sin(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -0800112long double sqrtl(long double a1) { return sqrt(a1); }
Elliott Hughes170dbe22013-02-07 17:45:11 -0800113long double tanl(long double a1) { return tan(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -0800114long double truncl(long double a1) { return trunc(a1); }
Calin Juravle4d77c112014-03-14 17:56:46 +0000115
116#endif // __LP64__