From 53a8584123f359c2c32f1869d98e4dd9e0a7a6ab Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 16 Oct 2014 12:38:44 +0200 Subject: [PATCH] Fix allocator for 64bit zend_long with 32bit long --- Zend/zend_alloc.c | 8 ++++++++ Zend/zend_multiply.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index f5ffb6491b..bae723f278 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -482,7 +482,11 @@ static void zend_mm_munmap(void *addr, size_t size) static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset) { #if defined(__GNUC__) +# if SIZEOF_ZEND_LONG == SIZEOF_LONG return __builtin_ctzl(~bitset); +# else + return __builtin_ctzll(~bitset); +# endif #elif defined(_WIN32) unsigned long index; @@ -519,7 +523,11 @@ static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset) static zend_always_inline int zend_mm_bitset_ntz(zend_mm_bitset bitset) { #if defined(__GNUC__) +# if SIZEOF_ZEND_LONG == SIZEOF_LONG return __builtin_ctzl(bitset); +# else + return __builtin_ctzll(bitset); +# endif #elif defined(_WIN32) unsigned long index; diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index ad874ba039..6dce8fb6ac 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -117,7 +117,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) { size_t res = nmemb; - zend_ulong m_overflow = 0; + size_t m_overflow = 0; __asm__ ("mull %3\n\taddl %4,%0\n\tadcl $0,%1" : "=&a"(res), "=&d" (m_overflow) -- 2.40.0