Found a NAN/INF solution that should be portable everywhere(?) (Ard,Marcus)

This commit is contained in:
Marcus Boerger 2004-03-29 18:51:47 +00:00
parent afe794c0d6
commit 8b15b46aa8
2 changed files with 51 additions and 4 deletions

View File

@ -952,12 +952,14 @@ static void basic_globals_dtor(php_basic_globals *basic_globals_p TSRMLS_DC)
PHPAPI double php_get_nan()
{
#if defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
#if HAVE_HUGE_VAL_NAN
return HUGE_VAL + -HUGE_VAL;
#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
double val;
((php_uint32*)&val)[1] = PHP_DOUBLE_QUIET_NAN_HIGH;
((php_uint32*)&val)[0] = 0;
return val;
#elif defined(HAVE_ATOF_ACCEPTS_NAN)
#elif HAVE_ATOF_ACCEPTS_NAN
return atof("NAN");
#else
return 0.0/0.0;
@ -966,12 +968,14 @@ PHPAPI double php_get_nan()
PHPAPI double php_get_inf()
{
#if defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
#if HAVE_HUGE_VAL_NAN
return HUGE_VAL;
#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
double val;
((php_uint32*)&val)[1] = PHP_DOUBLE_INFINITY_HIGH;
((php_uint32*)&val)[0] = 0;
return val;
#elif defined(HAVE_ATOF_ACCEPTS_INF)
#elif HAVE_ATOF_ACCEPTS_INF
return atof("INF");
#else
return 1.0/0.0;

View File

@ -391,6 +391,49 @@ if test "$ac_cv_atof_accept_inf" = "yes"; then
AC_DEFINE([HAVE_ATOF_ACCEPTS_INF], 1, [whether atof() accepts INF])
fi
AC_CACHE_CHECK(whether HUGE_VAL + -HUGEVAL = NAN, ac_cv_huge_val_nan,[
AC_TRY_RUN([
#include <math.h>
#include <stdlib.h>
#ifdef HAVE_ISINF
#define zend_isinf(a) isinf(a)
#elif defined(INFINITY)
/* Might not work, but is required by ISO C99 */
#define zend_isinf(a) (((a)==INFINITY)?1:0)
#elif defined(HAVE_FPCLASS)
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
#else
#define zend_isinf(a) 0
#endif
#ifdef HAVE_ISNAN
#define zend_isnan(a) isnan(a)
#elif defined(NAN)
#define zend_isnan(a) (((a)==NAN)?1:0)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
#else
#define zend_isnan(a) 0
#endif
int main(int argc, char** argv)
{
return zend_isinf(HUGE_VAL) && zend_isnan(HUGE_VAL + -HUGE_VAL) ? 0 : 1;
}
],[
ac_cv_huge_val_nan=yes
],[
ac_cv_huge_val_nan=no
],[
ac_cv_huge_val_nan=yes
])
])
dnl This is the most probable fallback so we assume yes in case of cross compile.
if test "$ac_cv_huge_val_nan" = "yes"; then
AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL = NAN])
fi
PHP_CHECK_I18N_FUNCS
PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \