Skip to content
Snippets Groups Projects
main.c 588 B
Newer Older
  • Learn to ignore specific revisions
  • rahix's avatar
    rahix committed
    #include "py/runtime.h"
    #include "py/gc.h"
    #include "lib/utils/pyexec.h"
    
    
    rahix's avatar
    rahix committed
    static char* stack_top;
    
    rahix's avatar
    rahix committed
    static char heap[4096];
    
    int main(void)
    {
    	/* TODO: Replace this with a proper heap implementation */
    	int stack_dummy;
    	stack_top = (char*)&stack_dummy;
    
    	gc_init(heap, heap + sizeof(heap));
    
    	mp_init();
    	pyexec_friendly_repl();
    
    	while (1) {
    		;
    	}
    }
    
    void gc_collect(void)
    {
    	/* TODO: Replace this with a proper heap implementation */
    
    rahix's avatar
    rahix committed
    	void* dummy;
    
    rahix's avatar
    rahix committed
    
    	gc_collect_start();
    
    rahix's avatar
    rahix committed
    	gc_collect_root(
    		&dummy,
    		((mp_uint_t)stack_top - (mp_uint_t)&dummy) / sizeof(mp_uint_t));
    
    rahix's avatar
    rahix committed
    	gc_collect_end();
    }