Re: [bootwrapper PATCH v2 02/13] Add bit-field macros

Mark Rutland
2022-01-17T13:29:19Z

On Mon, Jan 17, 2022 at 12:11:36PM +0000, Steven Price wrote:
> On 14/01/2022 10:56, Mark Rutland wrote:
> > +/*
> > + * Insert the least significant bits of `val` into the bit-field described by
> > + * the contiguous set of bits in `mask`.
> > + *
> > + * For example:
> > + * - BITS_INSERT(BITS(3, 0), 0xA) is 0x000A
> > + * - BITS_INSERT(BITS(15, 12), 0xA) is 0xA000
> > + * - BITS_INSERT(BIT(15), 0xF) is 0x1000
>
> * - BITS_INSERT(BIT(35), 0x1) is 0x0
>
> ... which might be surprising!
>
> of course BITS_INSERT(BIT(35), ULL(0x1)) works, but I feel either the
> description above needs to signpost this gotcha, or a cast is needed below.
>
> AFAICT this macro isn't actually used in your series.

Good point; I'll either add the cast or drop that for now.

Thanks,
Mark.