Skip to content

Wrap CRUBIT_THREAD_SAFE types in UnsafeCell#746

Merged
copybara-service[bot] merged 1 commit intomainfrom
test_886895197
May 6, 2026
Merged

Wrap CRUBIT_THREAD_SAFE types in UnsafeCell#746
copybara-service[bot] merged 1 commit intomainfrom
test_886895197

Conversation

@copybara-service
Copy link
Copy Markdown

@copybara-service copybara-service Bot commented Mar 24, 2026

Wrap CRUBIT_THREAD_SAFE types in UnsafeCell

For types annotated with CRUBIT_THREAD_SAFE, replace the normal Rust struct
fields with a single opaque UnsafeCell<[MaybeUninit; SIZE]> body.
This enables interior mutability, allowing non-const C++ methods to be
called through shared references.

This also prevents standard Rust #[derive(Copy, Clone)] generation,
and forces an explicit alignment override since the opaque byte array body
has alignment 1.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Mar 24, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@copybara-service copybara-service Bot force-pushed the test_886895197 branch 4 times, most recently from b705a4f to c69a9d5 Compare April 6, 2026 17:21
@copybara-service copybara-service Bot force-pushed the test_886895197 branch 10 times, most recently from 6519904 to 849aa21 Compare May 6, 2026 22:20
For types annotated with CRUBIT_THREAD_SAFE, replace the normal Rust struct
fields with a single opaque UnsafeCell<[MaybeUninit<u8>; SIZE]> body.
This enables interior mutability, allowing non-const C++ methods to be
called through shared references.

This also prevents standard Rust `#[derive(Copy, Clone)]` generation,
and forces an explicit alignment override since the opaque byte array body
has alignment 1.

PiperOrigin-RevId: 911579009
@copybara-service copybara-service Bot merged commit e4c008a into main May 6, 2026
@copybara-service copybara-service Bot deleted the test_886895197 branch May 6, 2026 22:24
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.

0 participants