com php-src: Remove x86 bit test optimization: Zend/zend_port ability.h
| From: | Nikita Popov | Date: | Mon, 18 Mar 2019 09:12:15 +0000 |
| Subject: | com php-src: Remove x86 bit test optimization: Zend/zend_port ability.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105194@lists.php.net to get a copy of this message | ||
Commit: c4464526cd8c7ef246ea4be145d798e084460d9d
Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 18 Mar 2019 10:12:15 +0100
Parents: 00cfa1a3672cc433cf1c52a3f8faa205826f76bd
Branches: PHP-7.3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c4464526cd8c7ef246ea4be145d798e084460d9d
Log:
Remove x86 bit test optimization
This is undefined behavior and we cannot rely on it. Additionally it
breaks builds using undefined behavior sanitizers.
Changed paths:
M Zend/zend_portability.h
Diff:
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index 12e99b7..301032d 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -440,12 +440,8 @@ char *alloca();
#define MAX(a, b) (((a)>(b))?(a):(b))
#define MIN(a, b) (((a)<(b))?(a):(b))
-/* x86 instructions BT, SHL, SHR don't require masking */
-#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) || defined(ZEND_WIN32)
-# define ZEND_BIT_TEST(bits, bit) (((bits)[(bit) / (sizeof((bits)[0])*8)] >> (bit)) & 1)
-#else
-# define ZEND_BIT_TEST(bits, bit) (((bits)[(bit) / (sizeof((bits)[0])*8)] >> ((bit) &
(sizeof((bits)[0])*8-1))) & 1)
-#endif
+#define ZEND_BIT_TEST(bits, bit) \
+ (((bits)[(bit) / (sizeof((bits)[0])*8)] >> ((bit) & (sizeof((bits)[0])*8-1))) & 1)
/* We always define a function, even if there's a macro or expression we could
* alias, so that using it in contexts where we can't make function calls