diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-05-08 11:58:17 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-05-08 11:58:17 +0300 |
commit | 4ad9cf460595efd1151faec0780b6ae5a4e0bc57 (patch) | |
tree | 21ce3f1d510267c812e54470a5addcb689de300f /Zend/zend_portability.h | |
parent | dc796b04c1193e0ca5def1239c5bd2bd93d5af09 (diff) | |
download | php-git-4ad9cf460595efd1151faec0780b6ae5a4e0bc57.tar.gz |
Bit test optimization
Diffstat (limited to 'Zend/zend_portability.h')
-rw-r--r-- | Zend/zend_portability.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 4bbe023bdf..0bef8dd374 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -442,6 +442,13 @@ 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__)) +# 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 + /* 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 * won't fail to compile on some machines and not others. |