]> granicus.if.org Git - php/commitdiff
Remove x86 bit test optimization
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 18 Mar 2019 09:12:15 +0000 (10:12 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 18 Mar 2019 09:12:15 +0000 (10:12 +0100)
This is undefined behavior and we cannot rely on it. Additionally it
breaks builds using undefined behavior sanitizers.

Zend/zend_portability.h

index 12e99b74d8b185f63794b45a61474eddd5af769b..301032d8c315d6e91be7a05ec2c13c29a3664687 100644 (file)
@@ -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