From 39abc7e16d9ccbf7440bc5ab0d08d0ff6917fa05 Mon Sep 17 00:00:00 2001 From: DimitryP6 Date: Sun, 1 Dec 2024 18:18:44 -0500 Subject: [PATCH] #200: changed macro name to avoid redefinition error, and added if else clause for bit overflow --- middleware/include/c_utils.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/middleware/include/c_utils.h b/middleware/include/c_utils.h index e28b01e..4b127f0 100644 --- a/middleware/include/c_utils.h +++ b/middleware/include/c_utils.h @@ -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 */