Skip to content

Commit 53a8584

Browse files
committed
Fix allocator for 64bit zend_long with 32bit long
1 parent 876965d commit 53a8584

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Zend/zend_alloc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,11 @@ static void zend_mm_munmap(void *addr, size_t size)
482482
static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset)
483483
{
484484
#if defined(__GNUC__)
485+
# if SIZEOF_ZEND_LONG == SIZEOF_LONG
485486
return __builtin_ctzl(~bitset);
487+
# else
488+
return __builtin_ctzll(~bitset);
489+
# endif
486490
#elif defined(_WIN32)
487491
unsigned long index;
488492

@@ -519,7 +523,11 @@ static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset)
519523
static zend_always_inline int zend_mm_bitset_ntz(zend_mm_bitset bitset)
520524
{
521525
#if defined(__GNUC__)
526+
# if SIZEOF_ZEND_LONG == SIZEOF_LONG
522527
return __builtin_ctzl(bitset);
528+
# else
529+
return __builtin_ctzll(bitset);
530+
# endif
523531
#elif defined(_WIN32)
524532
unsigned long index;
525533

Zend/zend_multiply.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow)
118118
{
119119
size_t res = nmemb;
120-
zend_ulong m_overflow = 0;
120+
size_t m_overflow = 0;
121121

122122
__asm__ ("mull %3\n\taddl %4,%0\n\tadcl $0,%1"
123123
: "=&a"(res), "=&d" (m_overflow)

0 commit comments

Comments
 (0)