mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-09-30 13:44:58 +02:00
- Fix to rename internally used types from _t to _type, because _t
type names are reserved by POSIX. - iana portlist update git-svn-id: file:///svn/unbound/trunk@3989 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
+31
-31
@@ -44,24 +44,24 @@
|
||||
#include "util/storage/slabhash.h"
|
||||
|
||||
/** use this type for the slabhash test key */
|
||||
typedef struct slabhash_testkey testkey_t;
|
||||
typedef struct slabhash_testkey testkey_type;
|
||||
/** use this type for the slabhash test data */
|
||||
typedef struct slabhash_testdata testdata_t;
|
||||
typedef struct slabhash_testdata testdata_type;
|
||||
|
||||
/** delete key */
|
||||
static void delkey(struct slabhash_testkey* k) {
|
||||
lock_rw_destroy(&k->entry.lock); free(k);}
|
||||
|
||||
/** hash func, very bad to improve collisions, both high and low bits */
|
||||
static hashvalue_t myhash(int id) {
|
||||
hashvalue_t h = (hashvalue_t)id & 0x0f;
|
||||
static hashvalue_type myhash(int id) {
|
||||
hashvalue_type h = (hashvalue_type)id & 0x0f;
|
||||
h |= (h << 28);
|
||||
return h;
|
||||
}
|
||||
|
||||
/** allocate new key, fill in hash */
|
||||
static testkey_t* newkey(int id) {
|
||||
testkey_t* k = (testkey_t*)calloc(1, sizeof(testkey_t));
|
||||
static testkey_type* newkey(int id) {
|
||||
testkey_type* k = (testkey_type*)calloc(1, sizeof(testkey_type));
|
||||
if(!k) fatal_exit("out of memory");
|
||||
k->id = id;
|
||||
k->entry.hash = myhash(id);
|
||||
@@ -70,9 +70,9 @@ static testkey_t* newkey(int id) {
|
||||
return k;
|
||||
}
|
||||
/** new data el */
|
||||
static testdata_t* newdata(int val) {
|
||||
testdata_t* d = (testdata_t*)calloc(1,
|
||||
sizeof(testdata_t));
|
||||
static testdata_type* newdata(int val) {
|
||||
testdata_type* d = (testdata_type*)calloc(1,
|
||||
sizeof(testdata_type));
|
||||
if(!d) fatal_exit("out of memory");
|
||||
d->data = val;
|
||||
return d;
|
||||
@@ -82,10 +82,10 @@ static testdata_t* newdata(int val) {
|
||||
static void
|
||||
test_short_table(struct slabhash* table)
|
||||
{
|
||||
testkey_t* k = newkey(12);
|
||||
testkey_t* k2 = newkey(14);
|
||||
testdata_t* d = newdata(128);
|
||||
testdata_t* d2 = newdata(129);
|
||||
testkey_type* k = newkey(12);
|
||||
testkey_type* k2 = newkey(14);
|
||||
testdata_type* d = newdata(128);
|
||||
testdata_type* d2 = newdata(129);
|
||||
|
||||
k->entry.data = d;
|
||||
k2->entry.data = d2;
|
||||
@@ -106,11 +106,11 @@ test_short_table(struct slabhash* table)
|
||||
|
||||
/** test adding a random element */
|
||||
static void
|
||||
testadd(struct slabhash* table, testdata_t* ref[])
|
||||
testadd(struct slabhash* table, testdata_type* ref[])
|
||||
{
|
||||
int numtoadd = random() % HASHTESTMAX;
|
||||
testdata_t* data = newdata(numtoadd);
|
||||
testkey_t* key = newkey(numtoadd);
|
||||
testdata_type* data = newdata(numtoadd);
|
||||
testkey_type* key = newkey(numtoadd);
|
||||
key->entry.data = data;
|
||||
slabhash_insert(table, myhash(numtoadd), &key->entry, data, NULL);
|
||||
ref[numtoadd] = data;
|
||||
@@ -118,10 +118,10 @@ testadd(struct slabhash* table, testdata_t* ref[])
|
||||
|
||||
/** test adding a random element */
|
||||
static void
|
||||
testremove(struct slabhash* table, testdata_t* ref[])
|
||||
testremove(struct slabhash* table, testdata_type* ref[])
|
||||
{
|
||||
int num = random() % HASHTESTMAX;
|
||||
testkey_t* key = newkey(num);
|
||||
testkey_type* key = newkey(num);
|
||||
slabhash_remove(table, myhash(num), key);
|
||||
ref[num] = NULL;
|
||||
delkey(key);
|
||||
@@ -129,12 +129,12 @@ testremove(struct slabhash* table, testdata_t* ref[])
|
||||
|
||||
/** test adding a random element */
|
||||
static void
|
||||
testlookup(struct slabhash* table, testdata_t* ref[])
|
||||
testlookup(struct slabhash* table, testdata_type* ref[])
|
||||
{
|
||||
int num = random() % HASHTESTMAX;
|
||||
testkey_t* key = newkey(num);
|
||||
testkey_type* key = newkey(num);
|
||||
struct lruhash_entry* en = slabhash_lookup(table, myhash(num), key, 0);
|
||||
testdata_t* data = en? (testdata_t*)en->data : NULL;
|
||||
testdata_type* data = en? (testdata_type*)en->data : NULL;
|
||||
if(en) {
|
||||
unit_assert(en->key);
|
||||
unit_assert(en->data);
|
||||
@@ -193,11 +193,11 @@ check_table(struct slabhash* table)
|
||||
|
||||
/** test adding a random element (unlimited range) */
|
||||
static void
|
||||
testadd_unlim(struct slabhash* table, testdata_t** ref)
|
||||
testadd_unlim(struct slabhash* table, testdata_type** ref)
|
||||
{
|
||||
int numtoadd = random() % (HASHTESTMAX * 10);
|
||||
testdata_t* data = newdata(numtoadd);
|
||||
testkey_t* key = newkey(numtoadd);
|
||||
testdata_type* data = newdata(numtoadd);
|
||||
testkey_type* key = newkey(numtoadd);
|
||||
key->entry.data = data;
|
||||
slabhash_insert(table, myhash(numtoadd), &key->entry, data, NULL);
|
||||
if(ref)
|
||||
@@ -206,10 +206,10 @@ testadd_unlim(struct slabhash* table, testdata_t** ref)
|
||||
|
||||
/** test adding a random element (unlimited range) */
|
||||
static void
|
||||
testremove_unlim(struct slabhash* table, testdata_t** ref)
|
||||
testremove_unlim(struct slabhash* table, testdata_type** ref)
|
||||
{
|
||||
int num = random() % (HASHTESTMAX*10);
|
||||
testkey_t* key = newkey(num);
|
||||
testkey_type* key = newkey(num);
|
||||
slabhash_remove(table, myhash(num), key);
|
||||
if(ref)
|
||||
ref[num] = NULL;
|
||||
@@ -218,12 +218,12 @@ testremove_unlim(struct slabhash* table, testdata_t** ref)
|
||||
|
||||
/** test adding a random element (unlimited range) */
|
||||
static void
|
||||
testlookup_unlim(struct slabhash* table, testdata_t** ref)
|
||||
testlookup_unlim(struct slabhash* table, testdata_type** ref)
|
||||
{
|
||||
int num = random() % (HASHTESTMAX*10);
|
||||
testkey_t* key = newkey(num);
|
||||
testkey_type* key = newkey(num);
|
||||
struct lruhash_entry* en = slabhash_lookup(table, myhash(num), key, 0);
|
||||
testdata_t* data = en? (testdata_t*)en->data : NULL;
|
||||
testdata_type* data = en? (testdata_type*)en->data : NULL;
|
||||
if(en) {
|
||||
unit_assert(en->key);
|
||||
unit_assert(en->data);
|
||||
@@ -243,7 +243,7 @@ static void
|
||||
test_long_table(struct slabhash* table)
|
||||
{
|
||||
/* assuming it all fits in the hashtable, this check will work */
|
||||
testdata_t* ref[HASHTESTMAX * 100];
|
||||
testdata_type* ref[HASHTESTMAX * 100];
|
||||
size_t i;
|
||||
memset(ref, 0, sizeof(ref));
|
||||
/* test assumption */
|
||||
@@ -301,7 +301,7 @@ struct slab_test_thr {
|
||||
/** thread num, first entry. */
|
||||
int num;
|
||||
/** id */
|
||||
ub_thread_t id;
|
||||
ub_thread_type id;
|
||||
/** hash table */
|
||||
struct slabhash* table;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user