-
Notifications
You must be signed in to change notification settings - Fork 189
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
Fix bitsize of cmsgHdrLen and msgCtrlLen on Posix #535
Conversation
Good catch. I think that We need to find a good way both for Linux and macOS. |
Never mind. I was looking at |
I made a mistake. On macOS,
So, its return type is I'm puzzled why tests fail with this PR. |
Looking at |
The network stack of macOS is a bit strange. Could you put |
Should be possible I guess. Although it's plausible that it's actually Linux that is the special case. macOS is ostensibly based on BSD, which is the source of the |
Yes, POSIX.1-2008 supports the macOS definition of the structs, so I guess Linux unilaterally changed the API to fix security issues. Thus, Linux is the special case. |
Actually, rather than hardcoding special cases, I think the best solution would be to just use |
These fields are size_t on Linux, so using CInt on LP64 only accesses 32 bits of the total 64. This is especially noticable on big endian, where the lower 32 bits of the number are written to the upper 32 bits of the field. Also use #type socklen_t instead of CUInt/CInt where applicable, since POSIX does not specify the size of this type.
There, now the tests pass both on macOS (arm64) and Linux (ppc64) for me. The second force-push was just updating the commit message to be more accurate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks admirable to me!
Merged. Thanks you for your awesome contribution! |
These fields are size_t, so using CInt on LP64 only accesses 32 bits
of the total 64. This is especially noticable on big endian, where
the lower 32 bits of the number are written to the upper 32 bits of
the field.