com php-src: Also try __has_builtin() where built ins are used: Zend/zend_alloc.c Zend/zend_hash .c Zend/zend_portability.h

From: Date: Mon, 22 Jun 2015 11:24:39 +0000
Subject: com php-src: Also try __has_builtin() where built ins are used: Zend/zend_alloc.c Zend/zend_hash .c Zend/zend_portability.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87439@lists.php.net to get a copy of this message
Commit: 70e86b876691e4bf1377f9bf1e25a7158d33805d Author: Bob Weinand <bobwei9@hotmail.com> Mon, 22 Jun 2015 13:24:39 +0200 Parents: 29aad0ef45618a25d5f87031a3e4e74ba1f6ac58 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=70e86b876691e4bf1377f9bf1e25a7158d33805d Log: Also try __has_builtin() where builtins are used Changed paths: M Zend/zend_alloc.c M Zend/zend_hash.c M Zend/zend_portability.h Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 2d47b64..f788737 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -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; diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 960a8a9..0ff506a 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -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; diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 65455ee..57080ca 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -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

« previous php.cvs (#87439) next »