static void add_shmmaps (uae_u32 start, addrbank *what) { shmpiece *x = shm_start; shmpiece *y; uae_u8 *base = what->baseaddr; if (!canbang) return; if (!base) return; x = find_shmpiece (base); if (!x) return; y = xmalloc (sizeof (shmpiece)); *y = *x; base = ((uae_u8 *) NATMEM_OFFSET) + start; y->native_address = shmat (y->id, base, 0); if (y->native_address == (void *) -1) { #ifdef DEBUG_MEMORY dbgf ("NATMEM: Failure to map existing at %08x(%p)\n", start, base); #endif perror ("shmat"); dumplist (); canbang = 0; return; } y->next = shm_start; y->prev = NULL; if (y->next) y->next->prev = y; shm_start = y; }
static shmpiece *find_shmpiece (uae_u8 *base) { shmpiece *x = shm_start; while (x && x->native_address != base) x = x->next; if (!x) { printf ("NATMEM: Failure to find mapping at %p\n", base); dumplist (); canbang = 0; return 0; } return x; }
void racewalk(Node *fn) { Node *nd; Node *nodpc; char s[1024]; if(ispkgin(omit_pkgs, nelem(omit_pkgs)) || isforkfunc(fn)) return; if(!ispkgin(noinst_pkgs, nelem(noinst_pkgs))) { racewalklist(fn->nbody, nil); // nothing interesting for race detector in fn->enter racewalklist(fn->exit, nil); } // nodpc is the PC of the caller as extracted by // getcallerpc. We use -widthptr(FP) for x86. // BUG: this will not work on arm. nodpc = nod(OXXX, nil, nil); *nodpc = *nodfp; nodpc->type = types[TUINTPTR]; nodpc->xoffset = -widthptr; nd = mkcall("racefuncenter", T, nil, nodpc); fn->enter = concat(list1(nd), fn->enter); nd = mkcall("racefuncexit", T, nil); fn->exit = list(fn->exit, nd); if(debug['W']) { snprint(s, sizeof(s), "after racewalk %S", fn->nname->sym); dumplist(s, fn->nbody); snprint(s, sizeof(s), "enter %S", fn->nname->sym); dumplist(s, fn->enter); snprint(s, sizeof(s), "exit %S", fn->nname->sym); dumplist(s, fn->exit); } }
static void delete_shmmaps (uae_u32 start, uae_u32 size) { if (!canbang) return; while (size) { uae_u8 *base = mem_banks[bankindex (start)]->baseaddr; if (base) { shmpiece *x; base = ((uae_u8 *) NATMEM_OFFSET) + start; x = find_shmpiece (base); if (!x) return; if (x->size > size) { #ifdef DEBUG_MEMORY dbgf ("NATMEM: Failure to delete mapping at %08x(size %08x, delsize %08x)\n", start, x->size, size); #endif dumplist (); canbang = 0; return; } shmdt (x->native_address); size -= x->size; start += x->size; if (x->next) x->next->prev = x->prev; /* remove this one from the list */ if (x->prev) x->prev->next = x->next; else shm_start = x->next; free (x); } else { size -= 0x10000; start += 0x10000; } } }