Add alternate bitfield padding option

Adds configuration option CFG_TUSB_ALT_BIT_PACKING_ALIGNMENT, which
substitutes bitfield variable " : 0" padding syntax with an unused
variable of size equal to the remaining number of bits.

This change resolves aligned access issues for some platforms.

Default behavior is original if the option is not explicitly enabled.
This commit is contained in:
Jeremiah McCarthy
2021-02-16 10:40:06 -05:00
parent 09868434cd
commit f8fbc0930b
6 changed files with 56 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
@@ -163,7 +163,11 @@ typedef struct {
uint16_t high_speed : 1;
uint16_t port_test_mode : 1;
uint16_t port_indicator_control : 1;
uint16_t : 0;
#if CFG_TUSB_ALT_BIT_PACKING_ALIGNMENT
uint16_t unused : 3;
#else
uint16_t : 0;
#endif /* CFG_TUSB_ALT_BIT_PACKING_ALIGNMENT */
};
uint16_t value;