Fix heap
All checks were successful
Build / build (push) Successful in 9m19s

This commit is contained in:
Mathieu Strypsteen 2024-12-26 10:01:52 +01:00
parent 2107b9edb3
commit 90958a96ee
2 changed files with 3 additions and 6 deletions

View file

@ -2,7 +2,7 @@ use crate::spec::{Target, TargetMetadata, base};
pub(crate) fn target() -> Target {
let mut base = base::os::opts();
base.cpu = "x86-64".into();
base.cpu = "x86-64-v2".into();
Target {
llvm_target: "x86_64-unknown-none".into(),
metadata: TargetMetadata {

View file

@ -19,11 +19,8 @@ unsafe impl GlobalAlloc for System {
}
let num_blocks =
if layout.size() % 16 == 0 { layout.size() / 16 } else { (layout.size() / 16) + 1 };
HEAP_USED.fetch_add(num_blocks, Ordering::Relaxed);
let ptr = unsafe {
ptr::addr_of_mut!(HEAP_DATA.0[HEAP_USED.load(Ordering::Relaxed) - num_blocks])
as *mut u8
};
let heap_used = HEAP_USED.fetch_add(num_blocks, Ordering::SeqCst);
let ptr = unsafe { ptr::addr_of_mut!(HEAP_DATA.0[heap_used * 16]) as *mut u8 };
ptr
}