Upgrade libm.
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies
the set of functions we support on ARM, MIPS, and x86, fixes "long double",
adds ISO C99 support, and adds basic unit tests.
It turns out that our "long double" functions have always been broken
for non-normal numbers. This patch fixes that by not using the upstream
implementations and just forwarding to the regular "double" implementation
instead (since "long double" on Android is just "double" anyway, which is
what BSD doesn't support).
All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64.
Bug: 3169850
Bug: 8012787
Bug: https://code.google.com/p/android/issues/detail?id=6697
Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
2013-01-31 04:06:37 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-05-09 00:07:43 +02:00
|
|
|
#define _GNU_SOURCE
|
Upgrade libm.
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies
the set of functions we support on ARM, MIPS, and x86, fixes "long double",
adds ISO C99 support, and adds basic unit tests.
It turns out that our "long double" functions have always been broken
for non-normal numbers. This patch fixes that by not using the upstream
implementations and just forwarding to the regular "double" implementation
instead (since "long double" on Android is just "double" anyway, which is
what BSD doesn't support).
All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64.
Bug: 3169850
Bug: 8012787
Bug: https://code.google.com/p/android/issues/detail?id=6697
Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
2013-01-31 04:06:37 +01:00
|
|
|
#include <float.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2017-07-14 02:30:06 +02:00
|
|
|
#if !defined(__LP64__)
|
|
|
|
|
|
|
|
// The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
|
|
|
|
// Android works around those cases by replacing the broken functions with our own trivial stubs
|
|
|
|
// that call the regular "double" function.
|
Upgrade libm.
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies
the set of functions we support on ARM, MIPS, and x86, fixes "long double",
adds ISO C99 support, and adds basic unit tests.
It turns out that our "long double" functions have always been broken
for non-normal numbers. This patch fixes that by not using the upstream
implementations and just forwarding to the regular "double" implementation
instead (since "long double" on Android is just "double" anyway, which is
what BSD doesn't support).
All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64.
Bug: 3169850
Bug: 8012787
Bug: https://code.google.com/p/android/issues/detail?id=6697
Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
2013-01-31 04:06:37 +01:00
|
|
|
|
|
|
|
long double fmaxl(long double a1, long double a2) { return fmax(a1, a2); }
|
|
|
|
long double fmodl(long double a1, long double a2) { return fmod(a1, a2); }
|
|
|
|
long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
|
|
|
|
int ilogbl(long double a1) { return ilogb(a1); }
|
|
|
|
long long llrintl(long double a1) { return llrint(a1); }
|
2015-06-12 18:15:02 +02:00
|
|
|
#if !defined(__i386__) // x86 has an assembler lrint/lrintl.
|
Upgrade libm.
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies
the set of functions we support on ARM, MIPS, and x86, fixes "long double",
adds ISO C99 support, and adds basic unit tests.
It turns out that our "long double" functions have always been broken
for non-normal numbers. This patch fixes that by not using the upstream
implementations and just forwarding to the regular "double" implementation
instead (since "long double" on Android is just "double" anyway, which is
what BSD doesn't support).
All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64.
Bug: 3169850
Bug: 8012787
Bug: https://code.google.com/p/android/issues/detail?id=6697
Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
2013-01-31 04:06:37 +01:00
|
|
|
long lrintl(long double a1) { return lrint(a1); }
|
2015-06-12 18:15:02 +02:00
|
|
|
#endif
|
Upgrade libm.
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies
the set of functions we support on ARM, MIPS, and x86, fixes "long double",
adds ISO C99 support, and adds basic unit tests.
It turns out that our "long double" functions have always been broken
for non-normal numbers. This patch fixes that by not using the upstream
implementations and just forwarding to the regular "double" implementation
instead (since "long double" on Android is just "double" anyway, which is
what BSD doesn't support).
All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64.
Bug: 3169850
Bug: 8012787
Bug: https://code.google.com/p/android/issues/detail?id=6697
Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
2013-01-31 04:06:37 +01:00
|
|
|
long long llroundl(long double a1) { return llround(a1); }
|
|
|
|
long lroundl(long double a1) { return lround(a1); }
|
2014-03-14 18:56:46 +01:00
|
|
|
long double modfl(long double a1, long double* a2) { double i; double f = modf(a1, &i); *a2 = i; return f; }
|
2014-04-17 19:17:32 +02:00
|
|
|
float nexttowardf(float a1, long double a2) { return nextafterf(a1, (float) a2); }
|
Upgrade libm.
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies
the set of functions we support on ARM, MIPS, and x86, fixes "long double",
adds ISO C99 support, and adds basic unit tests.
It turns out that our "long double" functions have always been broken
for non-normal numbers. This patch fixes that by not using the upstream
implementations and just forwarding to the regular "double" implementation
instead (since "long double" on Android is just "double" anyway, which is
what BSD doesn't support).
All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64.
Bug: 3169850
Bug: 8012787
Bug: https://code.google.com/p/android/issues/detail?id=6697
Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
2013-01-31 04:06:37 +01:00
|
|
|
long double roundl(long double a1) { return round(a1); }
|
2018-07-24 02:01:52 +02:00
|
|
|
void sincosl(long double x, long double* s, long double* c) { sincos(x, (double*) s, (double*) c); }
|
2014-03-14 18:56:46 +01:00
|
|
|
|
|
|
|
#endif // __LP64__
|
2017-07-14 02:30:06 +02:00
|
|
|
|
2019-09-17 22:08:02 +02:00
|
|
|
// FreeBSD doesn't have an ld128 implementation of tgammal, so both LP32 and LP64 need this.
|
2017-07-14 02:30:06 +02:00
|
|
|
long double tgammal(long double x) { return tgamma(x); }
|