src/core/bitmath_func.hpp
changeset 8609 8c0c3e9dd6a0
parent 8551 a7c546f4cf86
child 8628 4e316518420a
equal deleted inserted replaced
8608:45d77f05d3a3 8609:8c0c3e9dd6a0
   274 template<typename T> static inline T ROR(const T x, const uint8 n)
   274 template<typename T> static inline T ROR(const T x, const uint8 n)
   275 {
   275 {
   276 	return (T)(x >> n | x << (sizeof(x) * 8 - n));
   276 	return (T)(x >> n | x << (sizeof(x) * 8 - n));
   277 }
   277 }
   278 
   278 
       
   279 /**
       
   280  * Do an operation for each set set bit in a value.
       
   281  *
       
   282  * This macros is used to do an operation for each set
       
   283  * bit in a variable. The first variable can be reused
       
   284  * in the operation due to it's the bit position counter.
       
   285  * The second variable will be cleared during the usage
       
   286  *
       
   287  * @param i The position counter
       
   288  * @param b The value which we check for set bits
       
   289  */
       
   290 #define FOR_EACH_SET_BIT(i, b)      \
       
   291 	for (i = 0; b != 0; i++, b >>= 1) \
       
   292 		if (b & 1)
       
   293 
   279 #endif /* BITMATH_FUNC_HPP */
   294 #endif /* BITMATH_FUNC_HPP */