diff options
| author | David Grimes <dgrimes@navisite.com> | 2019-11-22 13:47:13 -0500 |
|---|---|---|
| committer | David Grimes <dgrimes@navisite.com> | 2019-11-22 13:47:13 -0500 |
| commit | f13ba7e8d9048802e960b45264f7d85cc16a1a4d (patch) | |
| tree | f6f7686528e60c6de291d3c9ef0160c88369644e /py/gc.h | |
| parent | c000567d880b054ca9ed0e9f96ee474451e92e3c (diff) | |
* only make objects long lived if they are on the GC heap
Diffstat (limited to 'py/gc.h')
| -rw-r--r-- | py/gc.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -29,8 +29,19 @@ #include <stdint.h> #include "py/mpconfig.h" +#include "py/mpstate.h" #include "py/misc.h" +#define WORDS_PER_BLOCK ((MICROPY_BYTES_PER_GC_BLOCK) / BYTES_PER_WORD) +#define BYTES_PER_BLOCK (MICROPY_BYTES_PER_GC_BLOCK) + +// ptr should be of type void* +#define VERIFY_PTR(ptr) ( \ + ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0 /* must be aligned on a block */ \ + && ptr >= (void*)MP_STATE_MEM(gc_pool_start) /* must be above start of pool */ \ + && ptr < (void*)MP_STATE_MEM(gc_pool_end) /* must be below end of pool */ \ + ) + void gc_init(void *start, void *end); void gc_deinit(void); |
