forked from model-checking/verify-rust-std
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pal/hermit):
deny(unsafe_op_in_unsafe_fn)
Signed-off-by: Martin Kröning <[email protected]>
- Loading branch information
Showing
5 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,21 +1,28 @@ | ||
use super::hermit_abi; | ||
use crate::alloc::{GlobalAlloc, Layout, System}; | ||
use crate::ptr; | ||
|
||
#[stable(feature = "alloc_system_type", since = "1.28.0")] | ||
unsafe impl GlobalAlloc for System { | ||
#[inline] | ||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { | ||
hermit_abi::malloc(layout.size(), layout.align()) | ||
let size = layout.size(); | ||
let align = layout.align(); | ||
unsafe { hermit_abi::malloc(size, align) } | ||
} | ||
|
||
#[inline] | ||
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { | ||
hermit_abi::free(ptr, layout.size(), layout.align()) | ||
let size = layout.size(); | ||
let align = layout.align(); | ||
unsafe { | ||
hermit_abi::free(ptr, size, align); | ||
} | ||
} | ||
|
||
#[inline] | ||
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { | ||
hermit_abi::realloc(ptr, layout.size(), layout.align(), new_size) | ||
let size = layout.size(); | ||
let align = layout.align(); | ||
unsafe { hermit_abi::realloc(ptr, size, align, new_size) } | ||
} | ||
} |
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