Add stubs and heap region definitions (#13521)

* Add stubs and heap region definitions

* nudge
This commit is contained in:
Jack May 2020-11-10 21:50:16 -08:00 committed by GitHub
parent 2660b44d91
commit e390c8cb7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 1 deletions

View File

@ -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 <stdio.h>
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