1 |
use std::{mem::MaybeUninit, ptr::NonNull};
|
2 |
|
3 |
struct RuntimePointer(NonNull<()>);
|
4 |
|
5 |
unsafe impl Send for RuntimePointer {}
|
6 |
unsafe impl Sync for RuntimePointer {}
|
7 |
|
8 |
static mut GITERATED_RUNTIME: MaybeUninit<RuntimePointer> = MaybeUninit::zeroed();
|
9 |
|
10 |
pub unsafe fn initialize_runtime(runtime_pointer: *mut ()) {
|
11 |
GITERATED_RUNTIME.write(RuntimePointer(NonNull::new(runtime_pointer).unwrap()));
|
12 |
}
|
13 |
|
14 |
pub unsafe fn get_runtime_reference() -> NonNull<()> {
|
15 |
GITERATED_RUNTIME.assume_init_read().0
|
16 |
}
|
17 |
|