1 #if !defined( BITOPS_H )
5 * Macros to do bit operations on integer variables.
7 * macro: SET_BIT to set bit at pos of var to 1
8 * macro: CLEAR_BIT to set bit at pos of var to 0
9 * macro: TOGGLE_BIT to toggle bit at pos of var from 1 to 0 and vice versa
10 * macro: CHECK_BIT returns > 0 if bit at pos of var is set to 1
16 * printf("bit 2 is set\n");
17 * printf("value of i is %d\n", i);
21 #define SET_BIT(var, pos) ((var) |= (1<<(pos)))
22 #define CLEAR_BIT(var, pos) ((var) &= (~(1<<(pos))))
23 #define TOGGLE_BIT(var, pos) ((var) ^= (1<<(pos)))
24 #define CHECK_BIT(var, pos) ((var) & (1<<(pos)))
26 #endif // !defined( BITOPS_H )