Skip to content

Commit a86ea7a

Browse files
borneoaerhankur
authored andcommitted
helper/bits: add BIT_ULL and GENMASK macros
To support 64 bits bit and masks Replace local definition of BIT in rtos/chromium-ec Change-Id: I1f268d6e8790f1b07bf798680b797878ce81064b Signed-off-by: Antonio Borneo <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/6857 Tested-by: jenkins
1 parent 5dd05fe commit a86ea7a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/helper/bits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
#include <helper/types.h>
2929

3030
#define BIT(nr) (1UL << (nr))
31+
#define BIT_ULL(nr) (1ULL << (nr))
3132
#define BITS_PER_BYTE 8
3233
#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long))
34+
#define BITS_PER_LONG_LONG (BITS_PER_BYTE * sizeof(long long))
35+
#define GENMASK(h, l) (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
36+
#define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
3337
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
3438
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
3539
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)

src/rtos/chromium-ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "config.h"
1212
#endif
1313

14+
#include <helper/bits.h>
1415
#include <rtos/rtos.h>
1516
#include <target/target.h>
1617
#include <target/target_type.h>
@@ -20,7 +21,6 @@
2021
#define CROS_EC_MAX_TASKS 32
2122
#define CROS_EC_MAX_NAME 200
2223
#define CROS_EC_IDLE_STRING "<< idle >>"
23-
#define BIT(x) (1 << (x))
2424

2525
struct chromium_ec_params {
2626
const char *target_name;

0 commit comments

Comments
 (0)