From 0c86faece3b5a4014a2561cbef9b8197d45dcebc Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Fri, 25 Jul 2008 14:59:31 +0000 Subject: [PATCH] Use isfinite/isnan as macros, like C99 prescribes. Needed for long double support in OS X --- src/c/number.d | 14 +++++--------- src/c/print.d | 5 +---- src/configure.in | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/c/number.d b/src/c/number.d index 54d63a241..24ed60928 100644 --- a/src/c/number.d +++ b/src/c/number.d @@ -24,10 +24,6 @@ #include #include -#ifndef HAVE_ISNANF -#define isnanf(x) isnan(x) -#endif - #ifndef M_PI # ifdef PI # define M_PI PI @@ -161,10 +157,10 @@ ecl_make_singlefloat(float f) ecl_detect_fpe(); if (f == (float)0.0) return(cl_core.singlefloat_zero); - if (isnanf(f)) { + if (isnan(f)) { cl_error(1, @'division-by-zero'); } - if (!finite(f)) { + if (!isfinite(f)) { cl_error(1, @'floating-point-overflow'); } x = cl_alloc_object(t_singlefloat); @@ -183,7 +179,7 @@ ecl_make_doublefloat(double f) if (isnan(f)) { cl_error(1, @'division-by-zero'); } - if (!finite(f)) { + if (!isfinite(f)) { cl_error(1, @'floating-point-overflow'); } x = cl_alloc_object(t_doublefloat); @@ -200,10 +196,10 @@ make_longfloat(long double f) ecl_detect_fpe(); if (f == (long double)0.0) return cl_core.longfloat_zero; - if (isnanl(f)) { + if (isnan(f)) { cl_error(1, @'division-by-zero'); } - if (!finite(f)) { + if (!isfinite(f)) { cl_error(1, @'floating-point-overflow'); } x = cl_alloc_object(t_longfloat); diff --git a/src/c/print.d b/src/c/print.d index d0a9f48e6..263300a31 100644 --- a/src/c/print.d +++ b/src/c/print.d @@ -493,8 +493,6 @@ write_base(int base, cl_object stream) #define G_EXP_STRING "Lg" #define DBL_TYPE long double #define strtod strtold -#define isnan isnanl -#define finite finitel extern long double strtold(const char *nptr, char **endptr); #else #define EXP_STRING "e" @@ -510,8 +508,7 @@ int edit_double(int n, DBL_TYPE d, int *sp, char *s, int *ep) fenv_t env; feholdexcept(&env); #endif - - if (isnan(d) || !finite(d)) + if (isnan(d) || !isfinite(d)) FEerror("Can't print a non-number.", 0); if (n < -DBL_MAX_DIGITS) n = DBL_MAX_DIGITS; diff --git a/src/configure.in b/src/configure.in index 1c2b662b9..d1b363a97 100644 --- a/src/configure.in +++ b/src/configure.in @@ -464,7 +464,7 @@ AC_CHECK_FUNCS( [floor getcwd gethostbyaddr gethostbyname getpagesize] \ [strcasecmp strchr strerror strtol] ) dnl !!! end autoscan -AC_CHECK_FUNCS( [nanosleep alarm times isnanf select setenv putenv] \ +AC_CHECK_FUNCS( [nanosleep alarm times select setenv putenv] \ [lstat mkstemp sigprocmask isatty feenableexcept tzset] \ [gettimeofday getrusage] )