Skip to content

Commit ccb844e

Browse files
committed
fix xcompile
1 parent 36b58ce commit ccb844e

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed

src/alloc/alloc_bytes.rs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,10 @@ impl Drop for MiriAllocBytes {
5353
unsafe {
5454
match self.params {
5555
MiriAllocParams::Global => alloc::dealloc(self.ptr, alloc_layout),
56-
MiriAllocParams::Isolated(id) => {
57-
#[cfg(target_os = "linux")]
58-
{
59-
IsolatedAlloc::dealloc(self.ptr, alloc_layout, id)
60-
}
61-
#[cfg(not(target_os = "linux"))]
62-
{
63-
unreachable!()
64-
}
65-
}
56+
#[cfg(target_os = "linux")]
57+
MiriAllocParams::Isolated(id) => IsolatedAlloc::dealloc(self.ptr, alloc_layout, id),
58+
#[cfg(not(target_os = "linux"))]
59+
MiriAllocParams::Isolated(_) => unreachable!(),
6660
}
6761
}
6862
}
@@ -127,16 +121,10 @@ impl AllocBytes for MiriAllocBytes {
127121
let alloc_fn = |layout| unsafe {
128122
match params {
129123
MiriAllocParams::Global => alloc::alloc(layout),
130-
MiriAllocParams::Isolated(id) => {
131-
#[cfg(target_os = "linux")]
132-
{
133-
IsolatedAlloc::alloc(layout, id)
134-
}
135-
#[cfg(not(target_os = "linux"))]
136-
{
137-
unreachable!()
138-
}
139-
}
124+
#[cfg(target_os = "linux")]
125+
MiriAllocParams::Isolated(id) => IsolatedAlloc::alloc(layout, id),
126+
#[cfg(not(target_os = "linux"))]
127+
MiriAllocParams::Isolated(_) => unreachable!(),
140128
}
141129
};
142130
let alloc_bytes = MiriAllocBytes::alloc_with(size.to_u64(), align, params, alloc_fn)
@@ -156,16 +144,10 @@ impl AllocBytes for MiriAllocBytes {
156144
let alloc_fn = |layout| unsafe {
157145
match params {
158146
MiriAllocParams::Global => alloc::alloc_zeroed(layout),
159-
MiriAllocParams::Isolated(id) => {
160-
#[cfg(target_os = "linux")]
161-
{
162-
IsolatedAlloc::alloc_zeroed(layout, id)
163-
}
164-
#[cfg(not(target_os = "linux"))]
165-
{
166-
unreachable!()
167-
}
168-
}
147+
#[cfg(target_os = "linux")]
148+
MiriAllocParams::Isolated(id) => IsolatedAlloc::alloc_zeroed(layout, id),
149+
#[cfg(not(target_os = "linux"))]
150+
MiriAllocParams::Isolated(_) => unreachable!(),
169151
}
170152
};
171153
MiriAllocBytes::alloc_with(size, align, params, alloc_fn).ok()

src/machine.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ pub struct MiriMachine<'tcx> {
534534

535535
/// The seed for the RNG, also used as a unique identifier for the machine.
536536
/// If multiple machines exist, this must be different for each.
537+
#[cfg(target_os = "linux")]
537538
pub(crate) seed: u64,
538539

539540
/// The allocation IDs to report when they are being allocated
@@ -720,6 +721,7 @@ impl<'tcx> MiriMachine<'tcx> {
720721
local_crates,
721722
extern_statics: FxHashMap::default(),
722723
rng: RefCell::new(rng),
724+
#[cfg(target_os = "linux")]
723725
seed,
724726
tracked_alloc_ids: config.tracked_alloc_ids.clone(),
725727
track_alloc_accesses: config.track_alloc_accesses,
@@ -923,6 +925,7 @@ impl VisitProvenance for MiriMachine<'_> {
923925
backtrace_style: _,
924926
local_crates: _,
925927
rng: _,
928+
#[cfg(target_os = "linux")]
926929
seed: _,
927930
tracked_alloc_ids: _,
928931
track_alloc_accesses: _,

0 commit comments

Comments
 (0)