mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Use zend_ polyfilled nan/finite, check finite
This commit is contained in:
parent
59f6cec3dd
commit
676ed04d0d
1 changed files with 3 additions and 9 deletions
|
@ -71,16 +71,10 @@ ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, c
|
||||||
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC);
|
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC);
|
||||||
END_EXTERN_C()
|
END_EXTERN_C()
|
||||||
|
|
||||||
/* isnan() might not be available (<C99), so we'll define it if so */
|
|
||||||
#ifndef isnan
|
|
||||||
/* NaN is never equal to itself */
|
|
||||||
# define isnan(n) ((n) != (n))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ZEND_DVAL_TO_LVAL_CAST_OK
|
#if ZEND_DVAL_TO_LVAL_CAST_OK
|
||||||
static zend_always_inline long zend_dval_to_lval(double d)
|
static zend_always_inline long zend_dval_to_lval(double d)
|
||||||
{
|
{
|
||||||
if (EXPECTED(!isnan(d))) {
|
if (EXPECTED(zend_finite(d)) && EXPECTED(!zend_isnan(d))) {
|
||||||
return (long)d;
|
return (long)d;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -100,7 +94,7 @@ static zend_always_inline long zend_dval_to_lval(double d)
|
||||||
dmod = ceil(dmod) + two_pow_32;
|
dmod = ceil(dmod) + two_pow_32;
|
||||||
}
|
}
|
||||||
return (long)(unsigned long)dmod;
|
return (long)(unsigned long)dmod;
|
||||||
} else if (UNEXPECTED(isnan(d))) {
|
} else if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (long)d;
|
return (long)d;
|
||||||
|
@ -120,7 +114,7 @@ static zend_always_inline long zend_dval_to_lval(double d)
|
||||||
dmod += two_pow_64;
|
dmod += two_pow_64;
|
||||||
}
|
}
|
||||||
return (long)(unsigned long)dmod;
|
return (long)(unsigned long)dmod;
|
||||||
} else if (UNEXPECTED(isnan(d))) {
|
} else if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (long)d;
|
return (long)d;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue