about summary refs log tree commit diff
path: root/src/libstd/sys/hermit/alloc.rs
diff options
context:
space:
mode:
authorStefan Lankes <slankes@eonerc.rwth-aachen.de>2019-10-20 07:55:10 +0000
committerStefan Lankes <slankes@eonerc.rwth-aachen.de>2019-10-20 10:46:18 +0200
commit5ebd4d9c27bf8fee4f7d664d76c41832745dff43 (patch)
tree2564a6c2514b8c73d4aed584e9cccb99f138e710 /src/libstd/sys/hermit/alloc.rs
parentdc094bf184bc624149ca6b18abbb14be0d08c3e7 (diff)
downloadrust-5ebd4d9c27bf8fee4f7d664d76c41832745dff43.tar.gz
rust-5ebd4d9c27bf8fee4f7d664d76c41832745dff43.zip
move interface to the unikernel in the crate hermit-abi
=> simplifies the maintenance of the interface
Diffstat (limited to 'src/libstd/sys/hermit/alloc.rs')
-rw-r--r--src/libstd/sys/hermit/alloc.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/libstd/sys/hermit/alloc.rs b/src/libstd/sys/hermit/alloc.rs
index 802a179fb67..86cc4463632 100644
--- a/src/libstd/sys/hermit/alloc.rs
+++ b/src/libstd/sys/hermit/alloc.rs
@@ -1,21 +1,16 @@
 use crate::alloc::{GlobalAlloc, Layout, System};
 use crate::ptr;
-
-extern "C" {
-    fn sys_malloc(size: usize, align: usize) -> *mut u8;
-    fn sys_realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8;
-    fn sys_free(ptr: *mut u8, size: usize, align: usize);
-}
+use crate::sys::hermit::abi;
 
 #[stable(feature = "alloc_system_type", since = "1.28.0")]
 unsafe impl GlobalAlloc for System {
     #[inline]
     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
-        sys_malloc(layout.size(), layout.align())
+        abi::malloc(layout.size(), layout.align())
     }
 
     unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
-        let addr = sys_malloc(layout.size(), layout.align());
+        let addr = abi::malloc(layout.size(), layout.align());
 
         if !addr.is_null() {
             ptr::write_bytes(
@@ -30,11 +25,11 @@ unsafe impl GlobalAlloc for System {
 
     #[inline]
     unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
-        sys_free(ptr, layout.size(), layout.align())
+        abi::free(ptr, layout.size(), layout.align())
     }
 
     #[inline]
     unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
-        sys_realloc(ptr, layout.size(), layout.align(), new_size)
+        abi::realloc(ptr, layout.size(), layout.align(), new_size)
     }
 }