-
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.
- Loading branch information
Showing
18 changed files
with
423 additions
and
314 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
//! provide gc for trc | ||
#[derive(Default, Debug)] | ||
pub struct GcMgr {} | ||
pub struct GcMgr { | ||
objs: Vec<*mut ()>, | ||
} | ||
|
||
impl GcMgr { | ||
pub fn new() -> Self { | ||
Self {} | ||
Self { objs: Vec::new() } | ||
} | ||
|
||
pub fn alloc<T>(&mut self, obj: T) -> *mut T { | ||
// unsafe { alloc(Layout::new::<T>()) as *mut T } | ||
// TODO: change it into alloc and change = into write | ||
Box::into_raw(Box::new(obj)) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod ctrc; | ||
pub mod dll; | ||
pub mod utils; |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use libcore::{Module, ModuleStorage}; | ||
|
||
pub type GetLibFuncTy = unsafe fn() -> &'static Module; | ||
pub type GetStorageFuncTy = unsafe fn() -> &'static ModuleStorage; | ||
|
||
pub fn load_module_storage(lib: &libloading::Library) -> (&'static Module, &'static ModuleStorage) { | ||
let get_lib_func: libloading::Symbol<GetLibFuncTy> = | ||
unsafe { lib.get(libcore::GET_LIB_FUNC_NAME.as_bytes()).unwrap() }; | ||
let get_storage_func: libloading::Symbol<GetStorageFuncTy> = | ||
unsafe { lib.get(libcore::GET_STORAGE_FUNC_NAME.as_bytes()).unwrap() }; | ||
unsafe { (get_lib_func(), get_storage_func()) } | ||
} |
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
Oops, something went wrong.