Skip to content

Commit

Permalink
Fix allocator for 64bit zend_long with 32bit long
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Oct 16, 2014
1 parent 876965d commit 53a8584
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Zend/zend_alloc.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_multiply.h
Expand Up @@ -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)
Expand Down

0 comments on commit 53a8584

Please sign in to comment.