shell: move position of last_nl in struct shell_backend_ctx_flags#103597
Merged
aescolar merged 1 commit intozephyrproject-rtos:mainfrom Feb 25, 2026
Merged
Conversation
`last_nl` is 8 bits long, put it at the beginning of the packed struct, so it can be read and written with one intruction, as it is now aligned. Signed-off-by: Fin Maaß <[email protected]>
|
Contributor
|
Thanks for the suggestion! Just a quick note: this is a bitfield within a uint32_t, not a packed struct, so the compiler will likely handle it as a single word access regardless of the order. Do you happen to have any benchmarks or assembly output showing that this specific alignment improves efficiency? I suspect the impact might be negligible here. |
jakub-uC
approved these changes
Feb 13, 2026
Member
Author
|
for RISCV: before: after: build cmd: As far as I know a compiler would never change the order of the members of a struct itself. |
pdgendt
approved these changes
Feb 25, 2026
aescolar
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



last_nlis 8 bits long, put it at the beginning of the packed struct, so it can be read and written with one intruction, as it is now aligned.