Skip to content

Commit c2bbfea

Browse files
committed
Always align Waiter to 4 bytes
1 parent c11a44a commit c2bbfea

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/libstd/sync/once.rs

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const STATE_MASK: usize = 0x3;
171171
// `wait` would both hand out a mutable reference to its `Waiter` node, and keep
172172
// a shared reference to check `signaled`. Instead we hold shared references and
173173
// use interior mutability.
174+
#[repr(align(4))] // Ensure the two lower bits are free to use as state bits.
174175
struct Waiter {
175176
thread: Cell<Option<Thread>>,
176177
signaled: AtomicBool,

0 commit comments

Comments
 (0)