On Thu, Dec 05, 2024 at 05:51:42PM -0600, Richard Henderson wrote: > Date: Thu, 5 Dec 2024 17:51:42 -0600 > From: Richard Henderson <richard.hender...@linaro.org> > Subject: Re: [RFC 06/13] rust: add bindings for memattrs > > On 12/5/24 12:30, Paolo Bonzini wrote: > > On 12/5/24 19:15, Richard Henderson wrote: > > > On 12/5/24 00:07, Zhao Liu wrote: > > > > The MemTxAttrs structure is composed of bitfield members, and bindgen is > > > > unable to generate an equivalent macro definition for > > > > MEMTXATTRS_UNSPECIFIED. > > > > > > I'm happy to move away from bit fields to uint32_t or suchlike to > > > enable MEMTXATTRS_UNSPECIFIED be a compile-time constant. > > > > Yeah, if we go from > > > > typedef struct MemTxAttrs { > > unsigned int unspecified:1; > > unsigned int secure:1; > > unsigned int space:2; > > unsigned int user:1; > > unsigned int memory:1; > > unsigned int requester_id:16; > > unsigned int pid:8; > > } MemTxAttrs; > > > > to > > > > typedef struct MemTxAttrs { > > uint8_t unspecified; > > uint8_t secure; > > uint8_t space; > > uint8_t user; > > uint8_t memory; > > uint8_t pid; > > uint16_t requester_id; > > } MemTxAttrs; > > > > is still decently packed and simplifies things a lot. Zhao, can you > > submit that as an independent patch? > Hmm. I'd been thinking of uint32_t and hw/registerfields.h, but I have not > scoped the size of that conversion. > > But short of that, please use 'bool' not 'uint8_t' for those single-bit flags. >
Sure! Thank u both! BTW, may I ask why you favor bool over uint8_t, and is it because they are indeed just 0/1 as well? :) Thanks, Zhao