00001 /* 00002 # This file is Copyright 2003, 2006, 2007, 2009, 2010 Dean Hall. 00003 # 00004 # This file is part of the PyMite VM. 00005 # The PyMite VM is free software: you can redistribute it and/or modify 00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2. 00007 # 00008 # The PyMite VM is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2 00012 # is seen in the file COPYING in this directory. 00013 */ 00014 00015 00016 #ifndef __HEAP_H__ 00017 #define __HEAP_H__ 00018 00019 00032 #define HEAP_GC_NF_THRESHOLD (512) 00033 00034 00035 #ifdef __DEBUG__ 00036 #define DEBUG_PRINT_HEAP_AVAIL(s) \ 00037 do { uint16_t n; heap_getAvail(&n); printf(s "heap avail = %d\n", n); } \ 00038 while (0) 00039 #else 00040 #define DEBUG_PRINT_HEAP_AVAIL(s) 00041 #endif 00042 00043 00049 PmReturn_t heap_init(void); 00050 00061 PmReturn_t heap_getChunk(uint16_t requestedsize, uint8_t **r_pchunk); 00062 00068 PmReturn_t heap_freeChunk(pPmObj_t ptr); 00069 00071 #if PM_HEAP_SIZE > 65535 00072 uint32_t 00073 #else 00074 uint16_t 00075 #endif 00076 heap_getAvail(void); 00077 00078 #ifdef HAVE_GC 00079 00084 PmReturn_t heap_gcRun(void); 00085 00092 PmReturn_t heap_gcSetAuto(uint8_t auto_gc); 00093 00094 #endif /* HAVE_GC */ 00095 00103 void heap_gcPushTempRoot(pPmObj_t pobj, uint8_t *r_objid); 00104 00111 void heap_gcPopTempRoot(uint8_t objid); 00112 00113 #endif /* __HEAP_H__ */