On 8/13/24 07:14, Octavian Purdila wrote:
+#define BITS(hi, lo) (BIT(hi + 1) - BIT(lo))
+#define BIT_IS_SET(v, b) (((v) & BIT(b)) != 0)
To the extent we need these we should be putting them in
bits.h with the other bit-related operations. (But
prefer the existing MAKE_64BIT_MASK over adding a
second macro that evaluates to a mask with a given
run of bits set).
BITS is useful when defining masks from datasheets. Specifically, in
this patch set they are used to define writable bits. While it is
possible to use MAKE_64BIT_MASK, I find it less error prone to use
BITS.
The formulation of BITS is less than perfect: BITS(63, 62) cannot be evaluated because
BIT(64) is undefined.
r~