X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_hashtable.c;h=fa9aba32feb1e98c252dff68f2ea39904f9b3ab9;hp=612ae784780d078360f4d64864c9b5a5539e2dae;hb=362391accc505b29d938e9d0a21bf6a28a8cee34;hpb=24178516ccd9f46718b687d4c630415eb63ff595 diff --git a/palacios/src/palacios/vmm_hashtable.c b/palacios/src/palacios/vmm_hashtable.c index 612ae78..fa9aba3 100644 --- a/palacios/src/palacios/vmm_hashtable.c +++ b/palacios/src/palacios/vmm_hashtable.c @@ -394,6 +394,55 @@ int hashtable_change(struct hashtable * htable, addr_t key, addr_t value, int fr +int hashtable_inc(struct hashtable * htable, addr_t key, addr_t value) { + struct hash_entry * tmp_entry; + uint_t hash_value; + uint_t index; + + hash_value = do_hash(htable, key); + + index = indexFor(htable->table_length, hash_value); + + tmp_entry = htable->table[index]; + + while (tmp_entry != NULL) { + /* Check hash value to short circuit heavier comparison */ + if ((hash_value == tmp_entry->hash) && (htable->eq_fn(key, tmp_entry->key))) { + + tmp_entry->value += value; + return -1; + } + tmp_entry = tmp_entry->next; + } + return 0; +} + + +int hashtable_dec(struct hashtable * htable, addr_t key, addr_t value) { + struct hash_entry * tmp_entry; + uint_t hash_value; + uint_t index; + + hash_value = do_hash(htable, key); + + index = indexFor(htable->table_length, hash_value); + + tmp_entry = htable->table[index]; + + while (tmp_entry != NULL) { + /* Check hash value to short circuit heavier comparison */ + if ((hash_value == tmp_entry->hash) && (htable->eq_fn(key, tmp_entry->key))) { + + tmp_entry->value -= value; + return -1; + } + tmp_entry = tmp_entry->next; + } + return 0; +} + + + /*****************************************************************************/ /* returns value associated with key */