[PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64

Joe Komlodi posted 2 patches 4 years, 6 months ago
Maintainers: Alistair Francis <alistair@alistair23.me>
[PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64
Posted by Joe Komlodi 4 years, 6 months ago
If we have a field that's wider than 32-bits, we need a data type wide enough to
be able to create the bitfield used to deposit the value.

Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>
---
 include/hw/registerfields.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
index 9a03ac5..f7bfa1f 100644
--- a/include/hw/registerfields.h
+++ b/include/hw/registerfields.h
@@ -95,7 +95,7 @@
     _d; })
 #define FIELD_DP64(storage, reg, field, val) ({                           \
     struct {                                                              \
-        unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
+        unsigned long v:R_ ## reg ## _ ## field ## _LENGTH;                \
     } _v = { .v = val };                                                  \
     uint64_t _d;                                                          \
     _d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT,          \
-- 
2.7.4


Re: [PATCH 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64
Posted by Richard Henderson 4 years, 6 months ago
On 7/19/21 10:16 AM, Joe Komlodi wrote:
>   #define FIELD_DP64(storage, reg, field, val) ({                           \
>       struct {                                                              \
> -        unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
> +        unsigned long v:R_ ## reg ## _ ## field ## _LENGTH;                \

Won't work for a 32-bit host.  Use uint64_t.


r~