diff options
Diffstat (limited to 'newlib/libm/common/sl_finite.c')
-rw-r--r-- | newlib/libm/common/sl_finite.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/newlib/libm/common/sl_finite.c b/newlib/libm/common/sl_finite.c new file mode 100644 index 000000000..0c27b4fae --- /dev/null +++ b/newlib/libm/common/sl_finite.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2015 by Red Hat, Incorporated. All rights reserved. + * + * Permission to use, copy, modify, and distribute this software + * is freely granted, provided that this notice is preserved. + */ + +/* finitel(x) returns 1 is x is finite, else 0; */ + +#include <math.h> + +int +finitel (long double x) +{ +#ifdef _LDBL_EQ_DBL + return finite (x); +#else + /* Let the compiler do this for us. + Note - we do not know how many bits there are in a long double. + Some architectures for example have an 80-bit long double whereas + others use 128-bits. We use macros and comiler builtin functions + to avoid specific knowledge of the long double format. */ + return __builtin_isinf_sign (x) == 0; +#endif +} + |