File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -416,6 +416,26 @@ definitions instead of typedefs in headers and function prototypes; this
416
416
avoids problems with duplicated typedefs and reduces the need to include
417
417
headers from other headers.
418
418
419
+ Bitfields
420
+ ---------
421
+
422
+ C bitfields can be a cause of non-portability issues, especially under windows
423
+ where `MSVC has a different way to lay them out than GCC
424
+ <https://gcc.gnu.org/onlinedocs/gcc/x86-Type-Attributes.html> `_, or where
425
+ endianness matters.
426
+
427
+ For this reason, we disallow usage of bitfields in packed structures and in any
428
+ structures which are supposed to exactly match a specific layout in guest
429
+ memory. Some existing code may use it, and we carefully ensured the layout was
430
+ the one expected.
431
+
432
+ We also suggest avoiding bitfields even in structures where the exact
433
+ layout does not matter, unless you can show that they provide a significant
434
+ usability benefit.
435
+
436
+ We encourage the usage of ``include/hw/registerfields.h `` as a safe replacement
437
+ for bitfields.
438
+
419
439
Reserved namespaces in C and POSIX
420
440
----------------------------------
421
441
You can’t perform that action at this time.
0 commit comments