diff --git a/sdk/bpf/c/inc/solana_sdk.h b/sdk/bpf/c/inc/solana_sdk.h index 8041d02e6..4543fe901 100644 --- a/sdk/bpf/c/inc/solana_sdk.h +++ b/sdk/bpf/c/inc/solana_sdk.h @@ -253,6 +253,20 @@ static void sol_free(void *ptr) { (void) sol_alloc_free_(0, ptr); } +/** + * The Solana runtime provides a memory region that is available to programs at + * a fixed virtual address and length. The builtin functions `sol_calloc` and + * `sol_free` call into the Solana runtime to allocate from this memory region + * for heap operations. Because the memory region is directly available to + * programs another option is a program can implement their own heap directly on + * top of that region. If a program chooses to implement their own heap they + * should not call the builtin heap functions because they will conflict. + * `HEAP_START_ADDRESS` and `HEAP_LENGTH` specify the memory region's start + * virtual address and length. + */ +#define HEAP_START_ADDRESS (uint64_t)0x300000000 +#define HEAP_LENGTH (uint64_t)(32 * 1024) + /** * Panics * @@ -606,7 +620,7 @@ uint64_t entrypoint(const uint8_t *input); #ifdef SOL_TEST /** - * Stub log functions when building tests + * Stub functions when building tests */ #include void sol_log_(const char *s, uint64_t len) { @@ -625,6 +639,10 @@ void sol_log_pubkey(const SolPubkey *pubkey) { void sol_log_compute_units_() { printf("Program consumption: __ units remaining\n"); } +void sol_panic_(const char *file, uint64_t len, uint64_t line, uint64_t column) { + printf("Panic in %s at %d:%d\n", file, line, column); + abort(); +} #endif #ifdef __cplusplus