Skip to content

Commit c446452

Browse files
committed
Remove x86 bit test optimization
This is undefined behavior and we cannot rely on it. Additionally it breaks builds using undefined behavior sanitizers.
1 parent 00cfa1a commit c446452

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Zend/zend_portability.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,8 @@ char *alloca();
440440
#define MAX(a, b) (((a)>(b))?(a):(b))
441441
#define MIN(a, b) (((a)<(b))?(a):(b))
442442

443-
/* x86 instructions BT, SHL, SHR don't require masking */
444-
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) || defined(ZEND_WIN32)
445-
# define ZEND_BIT_TEST(bits, bit) (((bits)[(bit) / (sizeof((bits)[0])*8)] >> (bit)) & 1)
446-
#else
447-
# define ZEND_BIT_TEST(bits, bit) (((bits)[(bit) / (sizeof((bits)[0])*8)] >> ((bit) & (sizeof((bits)[0])*8-1))) & 1)
448-
#endif
443+
#define ZEND_BIT_TEST(bits, bit) \
444+
(((bits)[(bit) / (sizeof((bits)[0])*8)] >> ((bit) & (sizeof((bits)[0])*8-1))) & 1)
449445

450446
/* We always define a function, even if there's a macro or expression we could
451447
* alias, so that using it in contexts where we can't make function calls

0 commit comments

Comments
 (0)