mirror of
https://github.com/php/php-src.git
synced 2026-04-27 10:16:41 +02:00
Also try __has_builtin() where builtins are used
This commit is contained in:
+5
-9
@@ -478,12 +478,10 @@ static void zend_mm_munmap(void *addr, size_t size)
|
||||
/* number of trailing set (1) bits */
|
||||
static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
# if SIZEOF_ZEND_LONG == SIZEOF_LONG
|
||||
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) && SIZEOF_ZEND_LONG == SIZEOF_LONG
|
||||
return __builtin_ctzl(~bitset);
|
||||
# else
|
||||
#elif defined(__GNUC__) || __has_builtin(__builtin_ctzll)
|
||||
return __builtin_ctzll(~bitset);
|
||||
# endif
|
||||
#elif defined(_WIN32)
|
||||
unsigned long index;
|
||||
|
||||
@@ -519,12 +517,10 @@ static zend_always_inline int zend_mm_bitset_nts(zend_mm_bitset bitset)
|
||||
/* number of trailing zero bits (0x01 -> 1; 0x40 -> 6; 0x00 -> LEN) */
|
||||
static zend_always_inline int zend_mm_bitset_ntz(zend_mm_bitset bitset)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
# if SIZEOF_ZEND_LONG == SIZEOF_LONG
|
||||
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) && SIZEOF_ZEND_LONG == SIZEOF_LONG
|
||||
return __builtin_ctzl(bitset);
|
||||
# else
|
||||
#elif defined(__GNUC__) || __has_builtin(__builtin_ctzll)
|
||||
return __builtin_ctzll(bitset);
|
||||
# endif
|
||||
#elif defined(_WIN32)
|
||||
unsigned long index;
|
||||
|
||||
@@ -1120,7 +1116,7 @@ static zend_always_inline void zend_mm_free_large(zend_mm_heap *heap, zend_mm_ch
|
||||
/* higher set bit number (0->N/A, 1->1, 2->2, 4->3, 8->4, 127->7, 128->8 etc) */
|
||||
static zend_always_inline int zend_mm_small_size_to_bit(int size)
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__GNUC__) || __has_builtin(__builtin_clz)
|
||||
return (__builtin_clz(size) ^ 0x1f) + 1;
|
||||
#elif defined(_WIN32)
|
||||
unsigned long index;
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ static uint32_t zend_always_inline zend_hash_check_size(uint32_t nSize)
|
||||
rather than using an undefined bis scan result. */
|
||||
return nSize;
|
||||
}
|
||||
#elif defined(__GNUC__)
|
||||
#elif defined(__GNUC__) || __has_builtin(__builtin_clz)
|
||||
return 0x2 << (__builtin_clz(nSize - 1) ^ 0x1f);
|
||||
#else
|
||||
nSize -= 1;
|
||||
|
||||
@@ -85,9 +85,17 @@
|
||||
# define ZEND_GCC_VERSION 0
|
||||
#endif
|
||||
|
||||
/* Compatibility with non-clang compilers */
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#ifndef __has_builtin
|
||||
# define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
#if defined(ZEND_WIN32)
|
||||
# define ZEND_ASSUME(c) __assume(c)
|
||||
#elif defined(__GNUC__) && PHP_HAVE_BUILTIN_EXPECT && ZEND_GCC_VERSION >= 4005
|
||||
#elif ((defined(__GNUC__) && ZEND_GCC_VERSION >= 4005) || __has_builtin(__builtin_unreachable)) && PHP_HAVE_BUILTIN_EXPECT
|
||||
# define ZEND_ASSUME(c) do { \
|
||||
if (__builtin_expect(!(c), 0)) __builtin_unreachable(); \
|
||||
} while (0)
|
||||
@@ -161,11 +169,6 @@ char *alloca();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Compatibility with non-clang compilers */
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if ZEND_GCC_VERSION >= 2096
|
||||
# define ZEND_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user