solana_nostd_entrypoint/
lib.rs

1#![no_std]
2#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
3
4pub use solana_program;
5
6pub mod entrypoint_nostd;
7pub use entrypoint_nostd::*;
8
9#[macro_export]
10macro_rules! noalloc_allocator {
11    () => {
12        pub mod allocator {
13            pub struct NoAlloc;
14            extern crate alloc;
15            unsafe impl alloc::alloc::GlobalAlloc for NoAlloc {
16                #[inline]
17                unsafe fn alloc(
18                    &self,
19                    _: core::alloc::Layout,
20                ) -> *mut u8 {
21                    panic!("no_alloc :)");
22                }
23                #[inline]
24                unsafe fn dealloc(
25                    &self,
26                    _: *mut u8,
27                    _: core::alloc::Layout,
28                ) {
29                }
30            }
31
32            #[cfg(target_os = "solana")]
33            #[global_allocator]
34            static A: NoAlloc = NoAlloc;
35        }
36    };
37}
38
39#[macro_export]
40macro_rules! basic_panic_impl {
41    () => {
42        #[cfg(target_os = "solana")]
43        #[no_mangle]
44        fn custom_panic(_info: &core::panic::PanicInfo<'_>) {
45            $crate::solana_program::log::sol_log("panicked!");
46        }
47    };
48}