Created
January 23, 2010 21:41
-
-
Save nall/284814 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
BOOL GET_BIT(uint32_t value, uint32_t bit) | |
{ | |
assert(bit < (sizeof(value) * 8)); | |
return ((value >> bit) & 1); | |
} | |
uint32_t SET_BIT(uint32_t value, uint32_t bit, BOOL bitValue) | |
{ | |
assert(bit < (sizeof(value) * 8)); | |
assert(bitValue == 1 || bitValue == 0); | |
const uint32_t mask = (bitValue << bit); | |
return ((value & ~mask) | mask); | |
} | |
#else // DEBUG | |
#define GET_BIT(value, bit) (((value) >> (bit)) & 1) | |
#define SET_BIT(value, bit, bitValue) ((value & ~(bitValue << bit)) | (bitValue << bit)) | |
#endif // DEBUG | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment