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

fix alignment on SPARC #2195

Closed
wants to merge 3 commits into from
Closed

fix alignment on SPARC #2195

wants to merge 3 commits into from

Conversation

dimpase
Copy link
Member

@dimpase dimpase commented Feb 19, 2018

this fixes #2191

@@ -310,7 +310,13 @@ static inline uint64_t rotl64 ( uint64_t x, int8_t r )

FORCE_INLINE uint64_t getblock8 ( const uint64_t * p, int i )
{
#ifdef HAVE_ALIGNED_ACCESS_REQUIRED
Copy link
Member

Choose a reason for hiding this comment

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

We already perform an alignment check for long (which I reckon is only a 32bit int on most supported systems(, which sets C_STACK_ALIGN to the required alignment. That in turn is used in gasman.

That said, both the AX_CHECK_ALIGNED_ACCESS_REQUIRED macro added here, and also the existing GP_C_LONG_ALIGN M4 macro which sets C_STACK_ALIGN, strike me as incorrect for this PR: You need to know the required alignment for an uint64_t, but the former macro checks that for an int, and the latter for a long (actually, the latter hard codes a result for some platforms and falls back to a test for others, e.g. ARM).

Arguably GP_C_LONG_ALIGN is also incorrect for what we use it in GASMAN, as we need it for pointers there resp. UInt (which is uint64_t on a 64bit arch).

Finally, one may wonder what the actual expected alignment for the p argument to getblock8 is. Inspecting the code, I think it always points to an even address, though strictly speaking nothing in the API guarantees this. So I think if using C_STACK_ALIGN, one would have to test #if C_STACK_ALIGN != 1 and that would mean memcpy gets used even on x86 (as for some reason, we hardcode an alignment of 2 there).

In summary, I think we need to fix GP_C_LONG_ALIGN (independent of this PR). And for this PR, it might be best to always use memcpy in here... I wonder if gcc and clang might even be clever enough to optimize it away when used here. on x86...?

@dimpase
Copy link
Member Author

dimpase commented Feb 19, 2018

Thanks. I've created #2196 to replace this one.

@dimpase dimpase closed this Feb 19, 2018
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.

hashkeybag.tst gives Bus Error on SPARC Solaris 11
2 participants