This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH 1/2] math.h: declare isinfl, isnanl for Cygwin
- From: Gregory Pietsch <gpietsch at comcast dot net>
- To: Yaakov Selkowitz <yselkowi at redhat dot com>, newlib at sourceware dot org
- Date: Fri, 1 Apr 2016 21:26:49 -0400
- Subject: Re: [PATCH 1/2] math.h: declare isinfl, isnanl for Cygwin
- Authentication-results: sourceware.org; auth=none
- References: <1459550970-3424-1-git-send-email-yselkowi at redhat dot com>
isnan and isinf are macros, not functions, so they should work on long
doubles.
Something like:
#define isnan(_X) (fpclassify(_X)==FP_NAN)
#define isinf(_X) (fpclassify(_X)==FP_INFINITE)
I know Stroustrup hates macros, but we have not expanded into C99
territory, right?
Anyway, given the macros, implementations for these two functions are
trivial:
#include <math.h>
int (isnanl)(long double x)
{
return isnan(x);
}
#include <math.h>
int (isinfl)(long double x)
{
return isinf(x);
}
While we're at it, could we add isfinitel and isnormall too?
Gregory
On 4/1/2016 6:49 PM, Yaakov Selkowitz wrote:
libstdc++ requires these to be declared in order to be enabled.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
---
newlib/libc/include/math.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index e5d6123..a69abe9 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -460,6 +460,8 @@ extern long double fmodl _PARAMS((long double, long double));
extern long double hypotl _PARAMS((long double, long double));
#endif /* ! defined (__math_68881) */
#endif /* ! defined (_REENT_ONLY) */
+extern int isnanl _PARAMS((long double));
+extern int isinfl _PARAMS((long double));
extern long double copysignl _PARAMS((long double, long double));
extern long double nanl _PARAMS((const char *));
extern int ilogbl _PARAMS((long double));