1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the 13 * distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <math.h> 30#include <assert.h> 31 32/* Any 64-bit Android math library should provide these functions, 33 * so these wrappers are only needed for 32-bit systems. 34 */ 35#ifndef __LP64__ 36 37/* 38 * On 32-bit Android, long double and double are identical, hence 39 * nexttoward is the same as nextafter. 40 */ 41 42__attribute__((weak)) double nexttoward(double d, long double td) { 43 return nextafter(d, (double)td); 44} 45 46__attribute__((weak)) float nexttowardf(float f, long double td) { 47 return nextafterf(f, (float)td); 48} 49 50__attribute__((weak)) long double nexttowardl(long double ld, long double td) { 51 return nextafter((double)ld, (double)td); 52} 53 54__attribute__((weak)) long double acosl(long double x) { return acos((double)x); } 55__attribute__((weak)) long double asinl(long double x) { return asin((double)x); } 56__attribute__((weak)) long double atanl(long double x) { return atan((double)x); } 57__attribute__((weak)) long double atan2l(long double x, long double y) { return atan2((double)x, (double)y); } 58__attribute__((weak)) long double cosl(long double x) { return cos((double)x); } 59__attribute__((weak)) long double coshl(long double x) { return cosh((double)x); } 60__attribute__((weak)) long double expl(long double x) { return exp((double)x); } 61__attribute__((weak)) long double fmodl(long double x, long double y) { return fmod((double)x, (double)y); } 62__attribute__((weak)) long double powl(long double x, long double y) { return pow((double)x, (double)y); } 63__attribute__((weak)) long double sinl(long double x) { return sin((double)x); } 64__attribute__((weak)) long double sinhl(long double x) { return sinh((double)x); } 65__attribute__((weak)) long double sqrtl(long double x) { return sqrt((double)x); } 66__attribute__((weak)) long double tanl(long double x) { return tan((double)x); } 67__attribute__((weak)) long double tanhl(long double x) { return tanh((double)x); } 68__attribute__((weak)) long double acoshl(long double x) { return acosh((double)x); } 69__attribute__((weak)) long double asinhl(long double x) { return asinh((double)x); } 70__attribute__((weak)) long double atanhl(long double x) { return atanh((double)x); } 71__attribute__((weak)) long double cbrtl(long double x) { return cbrt((double)x); } 72__attribute__((weak)) long double erfl(long double x) { return erf((double)x); } 73__attribute__((weak)) long double erfcl(long double x) { return erfc((double)x); } 74__attribute__((weak)) long double expm1l(long double x) { return expm1((double)x); } 75__attribute__((weak)) long double hypotl(long double x, long double y) { return hypot((double)x, (double)y); } 76__attribute__((weak)) long double lgammal(long double x) { return lgamma((double)x); } 77__attribute__((weak)) long long int llrintl(long double x) { return llrint((double)x); } 78__attribute__((weak)) long double logl(long double x) { return log((double)x); } 79__attribute__((weak)) long double log1pl(long double x) { return log1p((double)x); } 80__attribute__((weak)) long double log2l(long double x) { return log2((double)x); } 81__attribute__((weak)) long double logbl(long double x) { return logb((double)x); } 82__attribute__((weak)) long double log10l(long double x) { return log10((double)x); } 83__attribute__((weak)) long double nanl(const char* s) { return nan(s); } 84__attribute__((weak)) long double nearbyintl(long double x) { return nearbyint((double)x); } 85__attribute__((weak)) long double remainderl(long double x, long double y) { return remainder((double)x, (double)y); } 86__attribute__((weak)) long double remquol(long double x, long double y, int* i) { return remquo((double)x, (double)y, i); } 87__attribute__((weak)) long double rintl(long double x) { return rint((double)x); } 88__attribute__((weak)) long int lrintl(long double x) { return lrint((double)x); } 89__attribute__((weak)) long double tgammal(long double x) { return tgamma((double)x); } 90__attribute__((weak)) long double modfl(long double x, long double* y) { return modf((double)x, (double *)y); } 91__attribute__((weak)) long double exp2l(long double x) { return exp2((double)x); } 92 93#endif // !__LP64__ 94