Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust reserved bitfields to make SDCC happy #1893

Merged
merged 2 commits into from
Feb 13, 2023

Conversation

jefftrull
Copy link
Contributor

The open-source SDCC compiler has many limitations, but I have managed, after considerable hacking, to compile TinyUSB with it. This is one issue that I think is legitimately universal: compiler-specific assumptions about bitfield alignment which are implementation-defined per the Standard. Please see the discussion with the SDCC maintainers.

Describe the PR
This PR tweaks some reserved bitfields so the assumptions made elsewhere in the code (particularly in an assert) are more portable, and so they hew to implementation-defined limits on size. In particular:

  • keep each field at or under 16b
  • For optimal packing, segment bitfields to 8b boundaries

Additional context
N/A

If merged this will resolve #1892

- keep each field at or under 16b
- For optimal packing, segment fields to 8b boundaries
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only a typo in arithmetic

uint32_t TU_RESERVED : 26;
uint32_t TU_RESERVED0 : 2;
uint32_t TU_RESERVED1 : 16;
uint32_t TU_RESERVED2 : 4;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2+16+4 = 22, last one should be 8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How embarrassing! I changed it at the last minute and got it wrong :(

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look good now thank you

@hathach hathach merged commit d87f4da into hathach:master Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bit field arrangement is not guaranteed by the C standard (cdc.h)
2 participants