Skip to content

Commit f49e14f

Browse files
authored
Rollup merge of #108022 - CraftSpider:align-bytes, r=oli-obk
Support allocations with non-Box<[u8]> bytes This is prep work for allowing miri to support passing pointers to C code, which will require `Allocation`s to be correctly aligned. Currently, it just makes `Allocation` generic and plumbs the necessary changes through the right places. The follow-up to this will be adding a type in the miri interpreter which correctly aligns the bytes, using that for the Miri engine, then allowing Miri to pass pointers into these allocations to C calls. Based off of #100467, credit to ```@emarteca``` for the code
2 parents 3a38500 + 862386f commit f49e14f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/machine.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,10 +777,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
777777

778778
type Provenance = Provenance;
779779
type ProvenanceExtra = ProvenanceExtra;
780+
type Bytes = Box<[u8]>;
780781

781782
type MemoryMap = MonoHashMap<
782783
AllocId,
783-
(MemoryKind<MiriMemoryKind>, Allocation<Provenance, Self::AllocExtra>),
784+
(MemoryKind<MiriMemoryKind>, Allocation<Provenance, Self::AllocExtra, Self::Bytes>),
784785
>;
785786

786787
const GLOBAL_KIND: Option<MiriMemoryKind> = Some(MiriMemoryKind::Global);

0 commit comments

Comments
 (0)