Ejemplo n.º 1
0
Archivo: misc.c Proyecto: B-Rich/qemu
/*
 * Find address in stack.
 */
d4stacknode *
d4_find (d4cache *c, int stacknum, d4addr blockaddr)
{
	d4stacknode *ptr;

	if (c->stack[stacknum].n > D4HASH_THRESH) {
		int buck = D4HASH (blockaddr, stacknum, c->cacheid);
		for (ptr = d4stackhash.table[buck];
		     ptr!=NULL && (ptr->blockaddr!=blockaddr || ptr->cachep!=c || ptr->onstack != stacknum);
		     ptr = ptr->bucket)
			assert (ptr->valid != 0);
		return ptr;
	}

	/*
	 * Don't hash, search the stack linearly.
	 * The search will terminate,
	 * because the last node is guaranteed to have valid==0.
	 */
	for (ptr = c->stack[stacknum].top;
	     ptr->blockaddr != blockaddr && ptr->valid != 0;
	     ptr = ptr->down)
		continue;

	if (ptr->valid != 0)
		return ptr;

	return NULL;	/* not found */
}
Ejemplo n.º 2
0
Archivo: misc.c Proyecto: B-Rich/qemu
/* Insert the indicated node into the hash table */
void
d4hash (d4cache *c, int stacknum, d4stacknode *s)
{
	int buck = D4HASH (s->blockaddr, stacknum, s->cachep->cacheid);

	assert (c->stack[stacknum].n > D4HASH_THRESH);
	s->bucket = d4stackhash.table[buck];
	d4stackhash.table[buck] = s;
}
Ejemplo n.º 3
0
/* Insert the indicated node into the hash table */
void
d4hash (d4cache *c, int stacknum, d4stacknode *s)
{
	//printf("d4hash called for address %d\n", s->blockaddr);
	
	int buck = D4HASH (s->blockaddr, stacknum, s->cachep->cacheid);

	assert (c->stack[stacknum].n > D4HASH_THRESH);
	s->bucket = d4stackhash.table[buck];
	d4stackhash.table[buck] = s;
}
Ejemplo n.º 4
0
Archivo: misc.c Proyecto: B-Rich/qemu
/* Remove the indicated node from the hash table */
void
d4_unhash (d4cache *c, int stacknum, d4stacknode *s)
{
	int buck = D4HASH (s->blockaddr, stacknum, c->cacheid);
	d4stacknode *p = d4stackhash.table[buck];

	assert (c->stack[stacknum].n > D4HASH_THRESH);
	if (p == s)
		d4stackhash.table[buck] = s->bucket;
	else {
		while (p->bucket != s) {
			assert (p->bucket != NULL);
			p = p->bucket;
		}
		p->bucket = s->bucket;
	}
}