7 extern char __iheap_start;
9 #define IWRAM_POOL_SZ 32768
10 #define __iheap_start iwram[0]
11 static char iwram[IWRAM_POOL_SZ];
13 static char *top = &__iheap_start;
15 int iwram_brk(void *addr)
17 if((char*)addr < &__iheap_start) {
18 addr = &__iheap_start;
20 emuprint("iwram brk: %p (sp: %p)", addr, get_sp());
23 panic(get_pc(), "iwram_brk (%p) >= sp", addr);
29 void *iwram_sbrk(intptr_t delta)
32 iwram_brk(top + delta);
36 int ispow2(unsigned int x)
48 void *malloc_nf_impl(size_t sz, const char *file, int line)
51 if(!(p = malloc(sz))) {
52 panic(get_pc(), "%s:%d malloc %lu\n", file, line, (unsigned long)sz);
57 void *calloc_nf_impl(size_t num, size_t sz, const char *file, int line)
60 if(!(p = calloc(num, sz))) {
61 panic(get_pc(), "%s:%d calloc %lu\n", file, line, (unsigned long)(num * sz));
66 void *realloc_nf_impl(void *p, size_t sz, const char *file, int line)
68 if(!(p = realloc(p, sz))) {
69 panic(get_pc(), "%s:%d realloc %lu\n", file, line, (unsigned long)sz);
74 char *strdup_nf_impl(const char *s, const char *file, int line)
80 if(!(res = malloc(len + 1))) {
81 panic(get_pc(), "%s:%d strdup\n", file, line);
83 memcpy(res, s, len + 1);
88 /* utility functions which are implemented in assembly on GBA builds */
90 void fillblock_16byte(void *dest, uint32_t val, int count)
95 for(i=0; i<count; i++) {
106 return 0; /* not useful on PC builds */
111 return (void*)-1; /* not useful on PC builds */