blob: 611512ad14d61c25f9baf08cdff01303771ad19e [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
Calin Juravlef723b702014-04-01 17:38:59 +010020/*
21 * On LP64 sizeof(long double) > sizeof(double) so functions which fall back
22 * to their double variants lose precision. Emit a warning whenever something
23 * links against such functions.
24 * On LP32 sizeof(long double) == sizeof(double) so we don't need to warn.
25 */
26#ifdef __LP64__
27#define WARN_IMPRECISE(x) \
28 __warn_references(x, # x " has lower than advertised precision");
29#else
30#define WARN_IMPRECISE(x)
31#endif //__LP64__
32
33#define DECLARE_IMPRECISE(f) \
34 long double f ## l(long double v) { return f(v); } \
35 WARN_IMPRECISE(x)
36
37DECLARE_IMPRECISE(cosh);
38DECLARE_IMPRECISE(erfc);
39DECLARE_IMPRECISE(erf);
40DECLARE_IMPRECISE(lgamma);
41DECLARE_IMPRECISE(sinh);
42DECLARE_IMPRECISE(tanh);
43DECLARE_IMPRECISE(tgamma);
44DECLARE_IMPRECISE(significand);
45
Calin Juravle4d77c112014-03-14 17:56:46 +000046long double powl(long double a1, long double a2) { return pow(a1, a2); }
Calin Juravlef723b702014-04-01 17:38:59 +010047WARN_IMPRECISE(powl)
Calin Juravle4d77c112014-03-14 17:56:46 +000048
49#ifndef __LP64__
Elliott Hughesa0ee0782013-01-30 19:06:37 -080050/*
51 * The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
52 * Android works around those cases by replacing the broken functions with our own trivial stubs
53 * that call the regular "double" function.
54 */
55
Elliott Hughesa0ee0782013-01-30 19:06:37 -080056int __isfinitel(long double a1) { return __isfinite(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080057int __isnormall(long double a1) { return __isnormal(a1); }
58int __signbitl(long double a1) { return __signbit(a1); }
59
60long double acoshl(long double a1) { return acosh(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080061long double acosl(long double a1) { return acos(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080062long double asinhl(long double a1) { return asinh(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080063long double asinl(long double a1) { return asin(a1); }
64long double atan2l(long double a1, long double a2) { return atan2(a1, a2); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080065long double atanhl(long double a1) { return atanh(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080066long double atanl(long double a1) { return atan(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080067long double cbrtl(long double a1) { return cbrt(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080068long double ceill(long double a1) { return ceil(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080069long double copysignl(long double a1, long double a2) { return copysign(a1, a2); }
Calin Juravle4d77c112014-03-14 17:56:46 +000070
Elliott Hughes170dbe22013-02-07 17:45:11 -080071long double cosl(long double a1) { return cos(a1); }
Calin Juravle4d77c112014-03-14 17:56:46 +000072
Elliott Hughes241608e2013-12-18 16:06:52 -080073long double exp2l(long double a1) { return exp2(a1); }
74long double expl(long double a1) { return exp(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080075long double expm1l(long double a1) { return expm1(a1); }
76long double fabsl(long double a1) { return fabs(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080077long double floorl(long double a1) { return floor(a1); }
78long double fmal(long double a1, long double a2, long double a3) { return fma(a1, a2, a3); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080079long double fmaxl(long double a1, long double a2) { return fmax(a1, a2); }
80long double fmodl(long double a1, long double a2) { return fmod(a1, a2); }
81long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
Elliott Hughes241608e2013-12-18 16:06:52 -080082long double frexpl(long double a1, int* a2) { return frexp(a1, a2); }
83long double hypotl(long double a1, long double a2) { return hypot(a1, a2); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080084int ilogbl(long double a1) { return ilogb(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -080085long double ldexpl(long double a1, int a2) { return ldexp(a1, a2); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080086long long llrintl(long double a1) { return llrint(a1); }
87long double log10l(long double a1) { return log10(a1); }
88long double log1pl(long double a1) { return log1p(a1); }
89long double log2l(long double a1) { return log2(a1); }
Elliott Hughes926a3072013-02-06 16:07:54 -080090long double logbl(long double a1) { return logb(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -080091long double logl(long double a1) { return log(a1); }
92long lrintl(long double a1) { return lrint(a1); }
93long long llroundl(long double a1) { return llround(a1); }
94long lroundl(long double a1) { return lround(a1); }
Calin Juravle4d77c112014-03-14 17:56:46 +000095long 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 -080096long double nanl(const char* a1) { return nan(a1); }
97long double nextafterl(long double a1, long double a2) { return nextafter(a1, a2); }
Elliott Hughes241608e2013-12-18 16:06:52 -080098long double remainderl(long double a1, long double a2) { return remainder(a1, a2); }
99long double remquol(long double a1, long double a2, int* a3) { return remquo(a1, a2, a3); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -0800100long double rintl(long double a1) { return rint(a1); }
101long double roundl(long double a1) { return round(a1); }
102long double scalbnl(long double a1, int a2) { return scalbn(a1, a2); }
Elliott Hughes170dbe22013-02-07 17:45:11 -0800103long double sinl(long double a1) { return sin(a1); }
Elliott Hughesa0ee0782013-01-30 19:06:37 -0800104long double sqrtl(long double a1) { return sqrt(a1); }
Elliott Hughes170dbe22013-02-07 17:45:11 -0800105long double tanl(long double a1) { return tan(a1); }
Elliott Hughes241608e2013-12-18 16:06:52 -0800106long double truncl(long double a1) { return trunc(a1); }
Calin Juravle4d77c112014-03-14 17:56:46 +0000107
108#endif // __LP64__