Skip to content

Guarantee 8 bytes of alignment in Thread::into_raw #143859

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

orlp
Copy link
Contributor

@orlp orlp commented Jul 12, 2025

When using AtomicPtr for synchronization it's incredibly useful when you've got a couple bits you can stuff metadata in. By guaranteeing that Thread's Inner struct is aligned to 8 bytes everyone can use the bottom 3 bits to signal other things, such as a critical section, etc.

This guarantee is thus very useful and costs us nothing.

@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2025

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 12, 2025
@ibraheemdev
Copy link
Member

r? libs-api, this adds an alignment guarantee to the unstable Thread::into_raw API (#97523).

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jul 12, 2025
@rustbot rustbot assigned BurntSushi and unassigned jhpratt Jul 12, 2025
@rust-log-analyzer

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants