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

Update word size detection #87

Closed
wants to merge 1 commit into from

Conversation

mayeut
Copy link
Contributor

@mayeut mayeut commented Jun 5, 2022

The detection for word size was dependent on __LONG_WIDTH__ for at least gcc Alpine Linux (probably other musl distros too).
This is not working with clang which does not define __LONG_WIDTH__.
Replace __LONG_WIDTH__ by __SIZE_WIDTH__.
As this will not work as expected for x32 ABI, add a robust x32 detection first.

The detection for word size was dependent on `__LONG_WIDTH__` for at least gcc Alpine Linux (probably other musl distros too).
This is not working with clang which does not define `__LONG_WIDTH__`.
Replace `__LONG_WIDTH__` by `__SIZE_WIDTH__`.
As this will not work as expected for x32 ABI, add a robust x32 detection first.
Comment on lines +46 to +48
#if defined(__x86_64__) && defined(__ILP32__)
// this is the way to detect x32 ABI per https://wiki.debian.org/X32Port
# define BASE64_WORDSIZE 64
Copy link
Contributor Author

@mayeut mayeut Jun 5, 2022

Choose a reason for hiding this comment

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

I wanted to keep the old behavior for platforms other than x32 ABI but this check could be simplified in this specific instance to just:

#if defined(__x86_64__)
  // force word size on __x86_64__ 
  // on x32 ABI which defines __x86_64__ and uses 64-bit words but 32-bit pointers, __SIZE_WIDTH__ == 32
  #  define BASE64_WORDSIZE 64

Copy link
Owner

Choose a reason for hiding this comment

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

Indeed, I'll fix it in the rebase.

aklomp pushed a commit that referenced this pull request Jun 5, 2022
The detection for word size was dependent on `__LONG_WIDTH__` for at
least gcc Alpine Linux (probably other musl distros too).

This is not working with clang which does not define `__LONG_WIDTH__`.
Replace `__LONG_WIDTH__` by `__SIZE_WIDTH__`.

As this will not work as expected for x32 ABI, add robust x32 detection
first.

Closes #87.
@aklomp aklomp closed this in ddc8183 Jun 5, 2022
@mayeut mayeut deleted the rework-bit-width-detection branch June 5, 2022 17:07
@aklomp aklomp mentioned this pull request Jun 6, 2022
7 tasks
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