void pypy_check_stack_count(void) { # ifdef PYPY_USE_ASMGCC void *anchor = (void*)&pypy_g_ASM_FRAMEDATA_HEAD; void *fd = ((void* *) (((char *)anchor) + sizeof(void*)))[0]; long got = 0; long stacks_counter = pypy_g_rpython_rtyper_lltypesystem_rffi_StackCounter.sc_inst_stacks_counter; while (fd != anchor) { got += 1; fd = ((void* *) (((char *)fd) + sizeof(void*)))[0]; } RPyAssert(rpy_fastgil == 1, "pypy_check_stack_count doesn't have the GIL"); RPyAssert(got == stacks_counter - 1, "bad stacks_counter or non-closed stacks around"); # endif }
void pypy_debug_alloc_start(void *addr, const char *funcname) { struct pypy_debug_alloc_s *p = malloc(sizeof(struct pypy_debug_alloc_s)); RPyAssert(p, "out of memory"); p->next = pypy_debug_alloc_list; p->addr = addr; p->funcname = funcname; pypy_debug_alloc_list = p; }
void pypy_debug_alloc_stop(void *addr) { struct pypy_debug_alloc_s **p; for (p = &pypy_debug_alloc_list; *p; p = &((*p)->next)) if ((*p)->addr == addr) { struct pypy_debug_alloc_s *dying; dying = *p; *p = dying->next; free(dying); return; } RPyAssert(0, "free() of a never-malloc()ed object"); }