Skip to content

Commit

Permalink
#200: changed macro name to avoid redefinition error, and added if el…
Browse files Browse the repository at this point in the history
…se clause for bit overflow
  • Loading branch information
DimitryP6 committed Dec 1, 2024
1 parent 6799607 commit 39abc7e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions middleware/include/c_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
/*
* Gets a bit of a binary number at desired location
*/
#define GET_BIT(num, bit) ((num >> bit) & 1)
#define NER_GET_BIT(num, bit) ((num >> bit) & 1)

/*
* Sets a bit of a binary number at desired location
*/
#define SET_BIT(num, bit) (num |= (1UL << bit))
#define NER_SET_BIT(num, bit) \
bit < (sizeof(num) * 8) ? (num |= (1UL << bit)) : num

#endif /* C_UTILS */

Expand Down

0 comments on commit 39abc7e

Please sign in to comment.