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

Proper fields alignment in InternalUuidGenerator struct #15

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

vigdail
Copy link

@vigdail vigdail commented Apr 20, 2023

Fixes #14
InternalUuidGenerator struct did not satisfy alignment requirements.

According to atomic package docs:

On ARM, 386, and 32-bit MIPS, it is the caller's responsibility to arrange for 64-bit alignment of 64-bit words accessed atomically via the primitive atomic functions (types Int64 and Uint64 are automatically aligned). The first word in an allocated struct, array, or slice; in a global variable; or in a local variable (because the subject of all atomic operations will escape to the heap) can be relied upon to be 64-bit aligned.

I swapped fields order, now the struct has proper alignment.

Tested on Raspberry Pi 2 Model B

@mayswind
Copy link
Owner

lgtm

@mayswind mayswind merged commit 4b0f7d4 into mayswind:main Apr 20, 2023
@mayswind
Copy link
Owner

thanks

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.

Unaligned 64-bit atomic operation on 32-bit arm machine
2 participants