Add stubs and heap region definitions (#13521) (#13523)

* Add stubs and heap region definitions

* nudge

(cherry picked from commit e390c8cb7f)

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-11-11 06:48:02 +00:00
committed by GitHub
parent 053ce10ce5
commit 70c87d1a23

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) {
@ -615,6 +629,10 @@ void sol_log_(const char *s, uint64_t len) {
void sol_log_64(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) {
printf("sol_log_64: %llu, %llu, %llu, %llu, %llu\n", arg1, arg2, arg3, arg4, arg5);
}
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