Liste des Groupes | Revenir à c arch |
Robert Finch <robfi680@gmail.com> writes:Which brings to mind a slight different but related bit-field issue.On 2024-09-15 12:09 p.m., David Brown wrote:>>What about bit-fields in a struct? I believe they are usually packed. InIn addition, some padding-related things can be defined by Standard>
itself. Not in this particular case, but, for example, it could be
defined that when field of one integer type is immediately followed by
another field of integer type with the same or narrower width then
there should be no padding in-between.
>
case its for something like an I/O device.
That's a bit more complicated as it depends on the target byte-order.
>
e.g.
>
struct GIC_ECC_INT_STATUSR_s {
#if __BYTE_ORDER == __BIG_ENDIAN
uint64_t reserved_41_63 : 23;
uint64_t dbe : 9; /**< R/W1C/H - RAM
ECC DBE detected. */
uint64_t reserved_9_31 : 23;
uint64_t sbe : 9; /**< R/W1C/H - RAM
ECC SBE detected. */
#else
uint64_t sbe : 9;
uint64_t reserved_9_31 : 23;
uint64_t dbe : 9;
uint64_t reserved_41_63 : 23;
#endif
} s;
Les messages affichés proviennent d'usenet.