am 6816d8cc: Merge "Use __builtin_* in <math.h>."
* commit '6816d8cc69dc1d142d722686d006f25df94afcd3': Use __builtin_* in <math.h>.
This commit is contained in:
commit
3034028d7a
@ -65,6 +65,50 @@ void BM_math_logb::Run(int iters) {
|
|||||||
StopBenchmarkTiming();
|
StopBenchmarkTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_isfinite_macro, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_isfinite_macro::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += isfinite(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__BIONIC__)
|
||||||
|
#define test_isfinite __isfinite
|
||||||
|
#else
|
||||||
|
#define test_isfinite __finite
|
||||||
|
#endif
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_isfinite, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_isfinite::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += test_isfinite(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_isinf_macro, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_isinf_macro::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += isinf(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
|
||||||
BENCHMARK_WITH_ARG(BM_math_isinf, double)->AT_COMMON_VALS;
|
BENCHMARK_WITH_ARG(BM_math_isinf, double)->AT_COMMON_VALS;
|
||||||
void BM_math_isinf::Run(int iters, double value) {
|
void BM_math_isinf::Run(int iters, double value) {
|
||||||
StartBenchmarkTiming();
|
StartBenchmarkTiming();
|
||||||
@ -78,6 +122,60 @@ void BM_math_isinf::Run(int iters, double value) {
|
|||||||
StopBenchmarkTiming();
|
StopBenchmarkTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_isnan_macro, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_isnan_macro::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += isnan(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_isnan, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_isnan::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += (isnan)(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_isnormal_macro, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_isnormal_macro::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += isnormal(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__BIONIC__)
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_isnormal, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_isnormal::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += (__isnormal)(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BENCHMARK_NO_ARG(BM_math_sin_fast);
|
BENCHMARK_NO_ARG(BM_math_sin_fast);
|
||||||
void BM_math_sin_fast::Run(int iters) {
|
void BM_math_sin_fast::Run(int iters) {
|
||||||
StartBenchmarkTiming();
|
StartBenchmarkTiming();
|
||||||
@ -134,3 +232,29 @@ void BM_math_fpclassify::Run(int iters, double value) {
|
|||||||
|
|
||||||
StopBenchmarkTiming();
|
StopBenchmarkTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_signbit_macro, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_signbit_macro::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += signbit(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK_WITH_ARG(BM_math_signbit, double)->AT_COMMON_VALS;
|
||||||
|
void BM_math_signbit::Run(int iters, double value) {
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
d = 0.0;
|
||||||
|
v = value;
|
||||||
|
for (int i = 0; i < iters; ++i) {
|
||||||
|
d += (__signbit)(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MATH_H_
|
#ifndef _MATH_H_
|
||||||
#define _MATH_H_
|
#define _MATH_H_
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -23,108 +23,56 @@
|
|||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
#pragma GCC visibility push(default)
|
#pragma GCC visibility push(default)
|
||||||
|
|
||||||
/*
|
#define HUGE_VAL __builtin_huge_val()
|
||||||
* ANSI/POSIX
|
|
||||||
*/
|
|
||||||
extern const union __infinity_un {
|
|
||||||
unsigned char __uc[8];
|
|
||||||
double __ud;
|
|
||||||
} __infinity;
|
|
||||||
|
|
||||||
extern const union __nan_un {
|
|
||||||
unsigned char __uc[sizeof(float)];
|
|
||||||
float __uf;
|
|
||||||
} __nan;
|
|
||||||
|
|
||||||
#if __GNUC_PREREQ(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
|
|
||||||
#define __MATH_BUILTIN_CONSTANTS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __GNUC_PREREQ(3, 0) && !defined(__INTEL_COMPILER)
|
|
||||||
#define __MATH_BUILTIN_RELOPS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MATH_BUILTIN_CONSTANTS
|
|
||||||
#define HUGE_VAL __builtin_huge_val()
|
|
||||||
#else
|
|
||||||
#define HUGE_VAL (__infinity.__ud)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __ISO_C_VISIBLE >= 1999
|
#if __ISO_C_VISIBLE >= 1999
|
||||||
#define FP_ILOGB0 (-INT_MAX) /* Android-changed */
|
#define FP_ILOGB0 (-INT_MAX)
|
||||||
#define FP_ILOGBNAN INT_MAX /* Android-changed */
|
#define FP_ILOGBNAN INT_MAX
|
||||||
|
|
||||||
#ifdef __MATH_BUILTIN_CONSTANTS
|
#define HUGE_VALF __builtin_huge_valf()
|
||||||
#define HUGE_VALF __builtin_huge_valf()
|
#define HUGE_VALL __builtin_huge_vall()
|
||||||
#define HUGE_VALL __builtin_huge_vall()
|
#define INFINITY __builtin_inff()
|
||||||
#define INFINITY __builtin_inff()
|
#define NAN __builtin_nanf("")
|
||||||
#define NAN __builtin_nanf("")
|
|
||||||
#else
|
|
||||||
#define HUGE_VALF (float)HUGE_VAL
|
|
||||||
#define HUGE_VALL (long double)HUGE_VAL
|
|
||||||
#define INFINITY HUGE_VALF
|
|
||||||
#define NAN (__nan.__uf)
|
|
||||||
#endif /* __MATH_BUILTIN_CONSTANTS */
|
|
||||||
|
|
||||||
#define MATH_ERRNO 1
|
#define MATH_ERRNO 1
|
||||||
#define MATH_ERREXCEPT 2
|
#define MATH_ERREXCEPT 2
|
||||||
#define math_errhandling MATH_ERREXCEPT
|
#define math_errhandling MATH_ERREXCEPT
|
||||||
|
|
||||||
#define FP_FAST_FMAF 1
|
#if defined(__FP_FAST_FMA)
|
||||||
#ifdef __ia64__
|
#define FP_FAST_FMA 1
|
||||||
#define FP_FAST_FMA 1
|
#endif
|
||||||
#define FP_FAST_FMAL 1
|
#if defined(__FP_FAST_FMAF)
|
||||||
|
#define FP_FAST_FMAF 1
|
||||||
|
#endif
|
||||||
|
#if defined(__FP_FAST_FMAL)
|
||||||
|
#define FP_FAST_FMAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Symbolic constants to classify floating point numbers. */
|
/* Symbolic constants to classify floating point numbers. */
|
||||||
#define FP_INFINITE 0x01
|
#define FP_INFINITE 0x01
|
||||||
#define FP_NAN 0x02
|
#define FP_NAN 0x02
|
||||||
#define FP_NORMAL 0x04
|
#define FP_NORMAL 0x04
|
||||||
#define FP_SUBNORMAL 0x08
|
#define FP_SUBNORMAL 0x08
|
||||||
#define FP_ZERO 0x10
|
#define FP_ZERO 0x10
|
||||||
#define fpclassify(x) \
|
#define fpclassify(x) \
|
||||||
((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
|
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
|
||||||
: (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
|
|
||||||
: __fpclassifyl(x))
|
|
||||||
|
|
||||||
#define isfinite(x) \
|
#define isfinite(x) __builtin_isfinite(x)
|
||||||
((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
|
#define isinf(x) __builtin_isinf(x)
|
||||||
: (sizeof (x) == sizeof (double)) ? __isfinite(x) \
|
#define isnan(x) __builtin_isnan(x)
|
||||||
: __isfinitel(x))
|
#define isnormal(x) __builtin_isnormal(x)
|
||||||
#define isinf(x) \
|
|
||||||
((sizeof (x) == sizeof (float)) ? __isinff(x) \
|
|
||||||
: (sizeof (x) == sizeof (double)) ? isinf(x) \
|
|
||||||
: __isinfl(x))
|
|
||||||
#define isnan(x) \
|
|
||||||
((sizeof (x) == sizeof (float)) ? __isnanf(x) \
|
|
||||||
: (sizeof (x) == sizeof (double)) ? isnan(x) \
|
|
||||||
: __isnanl(x))
|
|
||||||
#define isnormal(x) \
|
|
||||||
((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
|
|
||||||
: (sizeof (x) == sizeof (double)) ? __isnormal(x) \
|
|
||||||
: __isnormall(x))
|
|
||||||
|
|
||||||
#ifdef __MATH_BUILTIN_RELOPS
|
#define isgreater(x, y) __builtin_isgreater((x), (y))
|
||||||
#define isgreater(x, y) __builtin_isgreater((x), (y))
|
#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
|
||||||
#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
|
#define isless(x, y) __builtin_isless((x), (y))
|
||||||
#define isless(x, y) __builtin_isless((x), (y))
|
#define islessequal(x, y) __builtin_islessequal((x), (y))
|
||||||
#define islessequal(x, y) __builtin_islessequal((x), (y))
|
#define islessgreater(x, y) __builtin_islessgreater((x), (y))
|
||||||
#define islessgreater(x, y) __builtin_islessgreater((x), (y))
|
#define isunordered(x, y) __builtin_isunordered((x), (y))
|
||||||
#define isunordered(x, y) __builtin_isunordered((x), (y))
|
|
||||||
#else
|
|
||||||
#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
|
|
||||||
#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
|
|
||||||
#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
|
|
||||||
#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
|
|
||||||
#define islessgreater(x, y) (!isunordered((x), (y)) && \
|
|
||||||
((x) > (y) || (y) > (x)))
|
|
||||||
#define isunordered(x, y) (isnan(x) || isnan(y))
|
|
||||||
#endif /* __MATH_BUILTIN_RELOPS */
|
|
||||||
|
|
||||||
#define signbit(x) \
|
#define signbit(x) \
|
||||||
((sizeof (x) == sizeof (float)) ? __signbitf(x) \
|
((sizeof(x) == sizeof(float)) ? __builtin_signbitf(x) \
|
||||||
: (sizeof (x) == sizeof (double)) ? __signbit(x) \
|
: (sizeof(x) == sizeof(double)) ? __builtin_signbit(x) \
|
||||||
: __signbitl(x))
|
: __builtin_signbitl(x))
|
||||||
|
|
||||||
typedef double __double_t;
|
typedef double __double_t;
|
||||||
typedef __double_t double_t;
|
typedef __double_t double_t;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user