Skip to content

Commit 22d3173

Browse files
duda-patrykkartben
authored andcommitted
include: zephyr: sys: Introduce IS_BIT_SET() macro
This macro is defined in a few places which leads to macro redefinition error e.g. when compiling prometheus network sample for NPCX boards. Provide one definition of IS_BIT_SET() in util_macro.h to fix the problem. Signed-off-by: Patryk Duda <[email protected]>
1 parent 132a24d commit 22d3173

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

drivers/mm/mm_drv_intel_adsp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
#define MAX_EBB_BANKS_IN_SEGMENT 32
5656
#define SRAM_BANK_SIZE (128 * 1024)
5757
#define L2_SRAM_BANK_NUM (L2_SRAM_SIZE / SRAM_BANK_SIZE)
58-
#define IS_BIT_SET(value, idx) ((value) & (1 << (idx)))
5958

6059
/**
6160
* Calculate TLB entry based on physical address.

include/zephyr/sys/util_macro.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ extern "C" {
9393
*/
9494
#define IS_BIT_MASK(m) IS_SHIFTED_BIT_MASK(m, 0)
9595

96+
/**
97+
* @brief Check if bit is set in a value
98+
*
99+
* @param value Value that contain checked bit
100+
* @param bit Bit number
101+
*/
102+
#define IS_BIT_SET(value, bit) ((((value) >> (bit)) & (0x1)) != 0)
103+
96104
/** @brief Extract the Least Significant Bit from @p value. */
97105
#define LSB_GET(value) ((value) & -(value))
98106

soc/nuvoton/npcx/common/reg/reg_access.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
/*
1111
* NPCX register bit/field access operations
1212
*/
13-
#define IS_BIT_SET(reg, bit) (((reg >> bit) & (0x1)) != 0)
1413

1514
#define GET_POS_FIELD(pos, size) pos
1615
#define GET_SIZE_FIELD(pos, size) size

subsys/net/lib/shell/http.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ LOG_MODULE_DECLARE(net_shell);
1212
#include <zephyr/net/http/server.h>
1313
#include <zephyr/net/http/method.h>
1414
#include <zephyr/net/http/parser.h>
15-
16-
#define IS_BIT_SET(val, bit) (((val >> bit) & (0x1)) != 0)
15+
#include <zephyr/sys/util.h>
1716

1817
static int cmd_net_http(const struct shell *sh, size_t argc, char *argv[])
1918
{

0 commit comments

Comments
 (0)