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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@
#endif

// Detect word size:
#if defined(_INTEGRAL_MAX_BITS)
#if defined(__x86_64__) && defined(__ILP32__)
// this is the way to detect x32 ABI per https://wiki.debian.org/X32Port
# define BASE64_WORDSIZE 64
Comment on lines +46 to +48
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.

#elif defined(_INTEGRAL_MAX_BITS)
# define BASE64_WORDSIZE _INTEGRAL_MAX_BITS
#elif defined(__WORDSIZE)
# define BASE64_WORDSIZE __WORDSIZE
#elif defined (__LONG_WIDTH__)
# define BASE64_WORDSIZE __LONG_WIDTH__
#elif defined (__SIZE_WIDTH__)
# define BASE64_WORDSIZE __SIZE_WIDTH__
#else
# error BASE64_WORDSIZE_NOT_DEFINED
#endif
Expand Down