summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorGustavo Lopes <glopes@nebm.ist.utl.pt>2013-04-30 19:00:31 +0200
committerGustavo Lopes <glopes@nebm.ist.utl.pt>2013-04-30 19:28:24 +0200
commit514afd67b651bea834bdb84b7685b48e9e56ac21 (patch)
treed8b6c9669f26733a4718bcff487a5180d0408fce /Zend
parent4a92ae34011ad2246500f27469f378b66d832976 (diff)
downloadphp-git-514afd67b651bea834bdb84b7685b48e9e56ac21.tar.gz
Fix bug #64729: compilation failure on x32
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_alloc.c18
-rw-r--r--Zend/zend_multiply.h4
2 files changed, 16 insertions, 6 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 605e396463..0bbd59a357 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -672,7 +672,7 @@ static inline unsigned int zend_mm_high_bit(size_t _size)
#elif defined(__GNUC__) && defined(__x86_64__)
unsigned long n;
- __asm__("bsrq %1,%0\n\t" : "=r" (n) : "rm" (_size));
+ __asm__("bsr %1,%0\n\t" : "=r" (n) : "rm" (_size));
return (unsigned int)n;
#elif defined(_MSC_VER) && defined(_M_IX86)
__asm {
@@ -698,12 +698,12 @@ static inline unsigned int zend_mm_low_bit(size_t _size)
#elif defined(__GNUC__) && defined(__x86_64__)
unsigned long n;
- __asm__("bsfq %1,%0\n\t" : "=r" (n) : "rm" (_size));
+ __asm__("bsf %1,%0\n\t" : "=r" (n) : "rm" (_size));
return (unsigned int)n;
#elif defined(_MSC_VER) && defined(_M_IX86)
__asm {
bsf eax, _size
- }
+ }
#else
static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
unsigned int n;
@@ -2481,12 +2481,22 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
size_t res = nmemb;
unsigned long overflow = 0;
- __asm__ ("mulq %3\n\taddq %4,%0\n\tadcq %1,%1"
+#ifdef __ILP32__ /* x32 */
+# define LP_SUFF "l"
+#else /* amd64 */
+# define LP_SUFF "q"
+#endif
+
+ __asm__ ("mul" LP_SUFF " %3\n\t"
+ "add %4,%0\n\t"
+ "adc %1,%1"
: "=&a"(res), "=&d" (overflow)
: "%0"(res),
"rm"(size),
"rm"(offset));
+#undef LP_SUFF
+
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
return 0;
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
index c3c9657f3b..092d3cd0b2 100644
--- a/Zend/zend_multiply.h
+++ b/Zend/zend_multiply.h
@@ -35,8 +35,8 @@
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
long __tmpvar; \
- __asm__ ("imulq %3,%0\n" \
- "adcq $0,%1" \
+ __asm__ ("imul %3,%0\n" \
+ "adc $0,%1" \
: "=r"(__tmpvar),"=r"(usedval) \
: "0"(a), "r"(b), "1"(0)); \
if (usedval) (dval) = (double) (a) * (double) (b); \