diff options
| author | Anatol Belski <ab@php.net> | 2014-09-22 10:26:17 +0200 |
|---|---|---|
| committer | Anatol Belski <ab@php.net> | 2014-09-22 10:26:17 +0200 |
| commit | 6bb530d1eba583143efda0b4f49e43cb6d6fb203 (patch) | |
| tree | 75f5432eac05df91defaf2f530efd08eb4796605 /Zend/zend_operators.h | |
| parent | 403709aaf46f2fe563df4d9f238528428287eb92 (diff) | |
| parent | 065edced71c7f15f32fc2fb483a9048328b8108e (diff) | |
| download | php-git-6bb530d1eba583143efda0b4f49e43cb6d6fb203.tar.gz | |
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: (24 commits)
added a comment
fix the REPARSE_DATA_BUFFER struct def
simplify the condition
Fix two memory errors by interning earlier
Add smart_str_append for appending zend_strings
Rename smart_str_append to smart_str_append_smart_str
Use smart_str for exception stack traces
Use smart_str in get_function_declaration
Move smart_str implementation into Zend/
UPGRADING for Integer Semantics
Fixed bug #66242 (don't assume char is signed)
Fixed bug #67633
Fixed if/else if ordering
Use SIZEOF_ZEND_LONG instead of SIZEOF_LONG
Use zend_ polyfilled nan/finite, check finite
Updated 32-bit << test
Updated << 64-bit tests
Prevent bit shift count wrapping quirkiness on some CPUs for left shift
Cast NaN and Infinity to zero
Updated >> 64-bit tests
...
Diffstat (limited to 'Zend/zend_operators.h')
| -rw-r--r-- | Zend/zend_operators.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index ddec162174..adb30f603f 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -72,11 +72,20 @@ ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, cons END_EXTERN_C() #if ZEND_DVAL_TO_LVAL_CAST_OK -# define zend_dval_to_lval(d) ((zend_long) (d)) +static zend_always_inline zend_long zend_dval_to_lval(double d) +{ + if (EXPECTED(zend_finite(d)) && EXPECTED(!zend_isnan(d))) { + return (zend_long)d; + } else { + return 0; + } +} #elif SIZEOF_ZEND_LONG == 4 static zend_always_inline zend_long zend_dval_to_lval(double d) { - if (d > ZEND_LONG_MAX || d < ZEND_LONG_MIN) { + if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) { + return 0; + } else if (d > ZEND_LONG_MAX || d < ZEND_LONG_MIN) { double two_pow_32 = pow(2., 32.), dmod; @@ -93,8 +102,10 @@ static zend_always_inline zend_long zend_dval_to_lval(double d) #else static zend_always_inline zend_long zend_dval_to_lval(double d) { + if (UNEXPECTED(!zend_finite(d)) || UNEXPECTED(zend_isnan(d))) { + return 0; /* >= as (double)ZEND_LONG_MAX is outside signed range */ - if (d >= ZEND_LONG_MAX || d < ZEND_LONG_MIN) { + } else if (d >= ZEND_LONG_MAX || d < ZEND_LONG_MIN) { double two_pow_64 = pow(2., 64.), dmod; |
