diff options
| author | Felipe Pena <felipe@php.net> | 2009-01-05 20:31:54 +0000 |
|---|---|---|
| committer | Felipe Pena <felipe@php.net> | 2009-01-05 20:31:54 +0000 |
| commit | f8689552a4c7b210bbfef59a4a74dfb34bf809c4 (patch) | |
| tree | 6cad23dc4fdcc339bf38d6b7793cf915fe0108e5 /Zend/zend_operators.h | |
| parent | f0240a0382c7ac38144543965f7c45e57af54665 (diff) | |
| download | php-git-f8689552a4c7b210bbfef59a4a74dfb34bf809c4.tar.gz | |
MFH:
- Fixed bug #46701 (Creating associative array with long values in the key fails on 32bit linux)
Patch by Shire
Diffstat (limited to 'Zend/zend_operators.h')
| -rw-r--r-- | Zend/zend_operators.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 523f04deb9..19f3a32461 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -75,6 +75,40 @@ 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); END_EXTERN_C() +#define MAX_UNSIGNED_INT ((double) LONG_MAX * 2) + 1 +#ifdef _WIN64 +# define DVAL_TO_LVAL(d, l) \ + if ((d) > LONG_MAX) { \ + (l) = (long)(unsigned long)(__int64) (d); \ + } else { \ + (l) = (long) (d); \ + } +#elif !defined(_WIN64) && __WORDSIZE == 64 +# define DVAL_TO_LVAL(d, l) \ + if ((d) >= LONG_MAX) { \ + (l) = LONG_MAX; \ + } else if ((d) <= LONG_MIN) { \ + (l) = LONG_MIN; \ + } else {\ + (l) = (long) (d); \ + } +#else +# define DVAL_TO_LVAL(d, l) \ + if ((d) > LONG_MAX) { \ + if ((d) > MAX_UNSIGNED_INT) { \ + (l) = LONG_MAX; \ + } else { \ + (l) = (unsigned long) (d); \ + } \ + } else { \ + if((d) < LONG_MIN) { \ + (l) = LONG_MIN; \ + } else { \ + (l) = (long) (d); \ + } \ + } +#endif + #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9') #define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) |
