macros.h
changeset 2493 f6b4300cc2b0
parent 2398 912f16512ce2
child 2663 e5a3df7f225a
equal deleted inserted replaced
2492:b4785c8f3700 2493:f6b4300cc2b0
   143 		return ((const byte*)b)[0] + (((const byte*)b)[1] << 8);
   143 		return ((const byte*)b)[0] + (((const byte*)b)[1] << 8);
   144 	}
   144 	}
   145 #endif
   145 #endif
   146 
   146 
   147 /// Fetch n bits starting at bit s from x
   147 /// Fetch n bits starting at bit s from x
   148 #define GB(x, s, n) (((x) >> (s)) & ((1 << (n)) - 1))
   148 #define GB(x, s, n) (((x) >> (s)) & ((1U << (n)) - 1))
   149 /// Set n bits starting at bit s in x to d
   149 /// Set n bits starting at bit s in x to d
   150 #define SB(x, s, n, d) ((x) = ((x) & ~(((1 << (n)) - 1) << (s))) | ((d) << (s)))
   150 #define SB(x, s, n, d) ((x) = ((x) & ~(((1U << (n)) - 1) << (s))) | ((d) << (s)))
   151 /// Add i to the n bits starting at bit s in x
   151 /// Add i to the n bits starting at bit s in x
   152 #define AB(x, s, n, i) ((x) = ((x) & ~(((1 << (n)) - 1) << (s))) | (((x) + ((i) << (s))) & (((1 << (n)) - 1) << (s))))
   152 #define AB(x, s, n, i) ((x) = ((x) & ~(((1U << (n)) - 1) << (s))) | (((x) + ((i) << (s))) & (((1U << (n)) - 1) << (s))))
   153 
   153 
   154 /**
   154 /**
   155  * ROtate x Left/Right by n (must be >= 0)
   155  * ROtate x Left/Right by n (must be >= 0)
   156  * @note Assumes a byte has 8 bits
   156  * @note Assumes a byte has 8 bits
   157  */
   157  */