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

Introduce a type for the Fast-Path header #246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

derfian
Copy link
Member

@derfian derfian commented Feb 2, 2018

Allow access to Fast-Path header fields through a dedicated type. This reduces the amount of binary arithmetic with semi-magic constants scattered around the codebase.

This is a follow-up to 08c293b, in which I introduced a FIXME.

Allow fastpath header field access through a dedicated type. This
reduces binary arithmetic with semi-magic constants scattered around
the codebase.
@derfian
Copy link
Member Author

derfian commented Feb 14, 2018

On second thought... After reading more about endianness and bit field structs, I get the impression that this isn't portable to big endian systems. Can anyone with more C experience/knowledge confirm that this is the case?

@uglym8
Copy link
Member

uglym8 commented Feb 14, 2018

@derfian I'll check it.

@uglym8
Copy link
Member

uglym8 commented Feb 19, 2018

I must admit my first impulse was to say that this is OK.

There is no alignment issues and ,come on, it's just byte-based bitfield struct.
It's naturally to think that endianess should be concerned only for multibyte data types.

But after digging deeper I began to believe that C standard doesn't guarantee any particular order for storing bitfields even for bytes, let alone uint16, uint32 etc.
It's governed solely by compiler.

So to be on the safe side we should use shifts instead of bitfields.

Or, we can still use bitfields, but with one additional runtime check:
Whether this particular architecture (compiler actually) we're running rdesktop on is packing bitfields in the way we expect?

References:
https://stackoverflow.com/questions/6043483/why-bit-endianness-is-an-issue-in-bitfields

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.

None yet

2 participants