GCC 6 does not like this: #define VMW_BIT_MASK(shift) (((1 << (shift - 1)) << 1) - 1) it produces errors: /builddir/build/BUILD/open-vm-tools-10.0.0-3000743/lib/include/x86cpuid.h:912:51: error: result of '-2147483648 << 1' requires 33 bits to represent, but 'int' only has 32 bits [-Werror=shift-overflow=] #define VMW_BIT_MASK(shift) (((1 << (shift - 1)) << 1) - 1)
#define VMW_BIT_MASK(shift) (int)~((~0u << (shift - 1)) << 1) Both shifts are shifts of an 'unsigned int', not anything wider. Depending on the compiler, this may save time and/or a register when 'shift' is not a compile-time constant. The final cast to (int) is only for the purpose of matching the type of the original expression. Of course 'shift' must be positive [especially not zero] and not more than the bit width of an 'int'. -- devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxxx http://lists.fedoraproject.org/admin/lists/devel@xxxxxxxxxxxxxxxxxxxxxxx