posix/math: Use the GCC built-ins when possible for isnan(), etc.

glibc does the same. Technically, some of these builtins did
not exist / did not work before GCC 4.4, but the source tree
cannot be compiled with a version that old anyway.

x86_64 and _x86 need to keep the old functions for now, of
course; but all other architectures can probably feel free
to drop the s_isnan, etc. functions from their glibc.

This will make upcoming patches easier...

Change-Id: Ifb76ea74076553228c9741a8ee3ecb0e1cf736a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2076
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Augustin Cavalier 2020-01-04 20:09:24 -05:00 committed by Adrien Destugues
parent a1e74397a1
commit dda1013cdb

@ -338,7 +338,15 @@ extern float y1f(float x);
extern float ynf(int x, float y);
extern float lgammaf_r(float x, int *y);
#if __GNUC__ >= 7 || defined(__clang__)
#define fpclassify(value) \
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (value))
#define signbit(value) __builtin_signbit((value))
#define isfinite(value) __builtin_isfinite((value))
#define isnormal(value) __builtin_isnormal((value))
#define isnan(value) __builtin_isnan((value))
#define isinf(value) __builtin_isinf_sign((value))
#else
/* prototypes for functions used in the macros below */
extern int __fpclassifyf(float value);
extern int __signbitf(float value);
@ -391,6 +399,7 @@ extern int __isinf(double value);
(sizeof(value) == sizeof(float) ? __isinff(value) \
: sizeof(value) == sizeof(double) ? __isinf(value) \
: __isinfl(value))
#endif
#if __GNUC__ >= 4
#define isgreater(x, y) __builtin_isgreater((x), (y))