qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 05/23] hw: add register access utility functions


From: Richard Henderson
Subject: Re: [RFC PATCH 05/23] hw: add register access utility functions
Date: Tue, 13 Aug 2024 08:35:53 +1000
User-agent: Mozilla Thunderbird

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~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]