Code Snippet
  1. //a=targe variable, b=bit number to act upon 0-n
  2. #define BIT_SET(a,b) ((a) |= (1<<(b)))
  3. #define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
  4. #define BIT_TOGGLE(a,b) ((a) ^= (1<<(b)))
  5. #define BIT_CHECK(a,b) ((a) & (1<<(b)))
  6.  
  7. //x=targe varible, y=mask
  8. #define BITMASK_SET(x,y) ((x) |= (y))
  9. #define BITMASK_CLEAR(x,y) ((x) &= (~(y)))
  10. #define BITMASK_TOGGLE(x,y) ((x) ^= (y))
  11. #define BITMASK_CHECK(x,y) ((x) & (y))