JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

no clue what this is

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨7889bf6

⁨giterated-runtime/giterated-static-runtime/src/lib.rs⁩ - ⁨1214⁩ bytes
Raw
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
18 static mut GITERATED_RUNTIME_HANDLE: MaybeUninit<RuntimePointer> = MaybeUninit::zeroed();
19
20 pub unsafe fn initialize_runtime_handle(runtime_handle: *mut ()) {
21 GITERATED_RUNTIME_HANDLE.write(RuntimePointer(NonNull::new(runtime_handle).unwrap()));
22 }
23
24 pub unsafe fn get_runtime_handle() -> NonNull<()> {
25 GITERATED_RUNTIME_HANDLE.assume_init_read().0
26 }
27
28 static mut GITERATED_TYPE_METADATA: MaybeUninit<RuntimePointer> = MaybeUninit::zeroed();
29
30 pub unsafe fn initialize_type_metadata(runtime_pointer: *mut ()) {
31 GITERATED_TYPE_METADATA.write(RuntimePointer(NonNull::new(runtime_pointer).unwrap()));
32 }
33
34 pub unsafe fn get_type_metadata_reference() -> NonNull<()> {
35 GITERATED_TYPE_METADATA.assume_init_read().0
36 }
37