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
Bitfield fixes #270
Bitfield fixes #270
Conversation
|
Space vs tabs fixes incoming... |
| @@ -99,6 +101,7 @@ | |||
| * printf("Value: %d", (s32)some_register.some_signed_fields); | |||
| * | |||
| */ | |||
| #pragma pack(1) | |||
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Other than this, LGTM. |
| @@ -158,3 +161,4 @@ struct BitField | |||
| static_assert(bits <= 8 * sizeof(T), "Invalid number of bits"); | |||
| static_assert(bits > 0, "Invalid number of bits"); | |||
| }; | |||
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
At least one platform (ARM with NEON instructions enabled) generates SIGBUSes if BitField objects aren't aligned properly.
|
No static_asserts, because alignof(storage) always returns 0, and while |
|
Added static_assert within the BitFieldTest. |
The BitField class added in b4337a2 turned out to have some critical issues: Generated assembly code would be bloated and slow, and also the code had alignment issues when compiling on ARM. This branch contains two tiny patches which fix those issues by inlining all class methods and by ensuring proper structure packing. An additional third patch adds unit tests for the alignment fixes.