Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unsafe AtomicRefCell<PersistentLayoutData> transmute due to memor…
…y alignment differences
- Loading branch information
1 parent
48fdda3
commit 593e890
Showing
6 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use atomic_refcell::AtomicRefCell; | ||
use layout::PersistentLayoutData; | ||
use script_layout_interface::PartialPersistentLayoutData; | ||
use std::mem::align_of; | ||
|
||
fn check_layout_alignment(expected: usize, current: usize) { | ||
if current != expected { | ||
panic!("Your changes have altered the mem alignment of the PartialPersistentLayoutData \ | ||
struct to {}, but it must match the {}-alignment of PersistentLayoutData struct. \ | ||
Please fix alignment in components/script_layout_interface/lib.rs", | ||
current, expected); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_persistent_layout_data_alignment() { | ||
check_layout_alignment(align_of::<PersistentLayoutData>(), | ||
align_of::<PartialPersistentLayoutData>()); | ||
|
||
check_layout_alignment(align_of::<AtomicRefCell<PersistentLayoutData>>(), | ||
align_of::<AtomicRefCell<PartialPersistentLayoutData>>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters