summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.c38
-rw-r--r--src/gallium/auxiliary/util/u_hash_table.h6
-rw-r--r--src/gallium/state_trackers/nine/nine_ff.c18
-rw-r--r--src/gallium/state_trackers/nine/nine_pdata.h12
-rw-r--r--src/gallium/winsys/svga/drm/vmw_screen.c6
5 files changed, 40 insertions, 40 deletions
diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c
index e58c7823be2..0db5ddbee5e 100644
--- a/src/gallium/auxiliary/util/u_hash_table.c
+++ b/src/gallium/auxiliary/util/u_hash_table.c
@@ -57,10 +57,10 @@ struct util_hash_table
struct cso_hash cso;
/** Hash function */
- unsigned (*hash)(void *key);
+ uint32_t (*hash)(const void *key);
/** Compare two keys */
- int (*compare)(void *key1, void *key2);
+ bool (*equal)(const void *key1, const void *key2);
/* TODO: key, value destructors? */
};
@@ -81,8 +81,8 @@ util_hash_table_item(struct cso_hash_iter iter)
struct util_hash_table *
-util_hash_table_create(unsigned (*hash)(void *key),
- int (*compare)(void *key1, void *key2))
+util_hash_table_create(uint32_t (*hash)(const void *key),
+ bool (*equal)(const void *key1, const void *key2))
{
struct util_hash_table *ht;
@@ -93,34 +93,34 @@ util_hash_table_create(unsigned (*hash)(void *key),
cso_hash_init(&ht->cso);
ht->hash = hash;
- ht->compare = compare;
+ ht->equal = equal;
return ht;
}
-static unsigned
-pointer_hash(void *key)
+static uint32_t
+pointer_hash(const void *key)
{
return _mesa_hash_pointer(key);
}
-static int
-pointer_compare(void *a, void *b)
+static bool
+pointer_equal(const void *a, const void *b)
{
- return a != b;
+ return a == b;
}
struct util_hash_table *
util_hash_table_create_ptr_keys(void)
{
- return util_hash_table_create(pointer_hash, pointer_compare);
+ return util_hash_table_create(pointer_hash, pointer_equal);
}
-static unsigned hash_fd(void *key)
+static uint32_t hash_fd(const void *key)
{
#if DETECT_OS_UNIX
int fd = pointer_to_intptr(key);
@@ -135,7 +135,7 @@ static unsigned hash_fd(void *key)
}
-static int compare_fd(void *key1, void *key2)
+static bool equal_fd(const void *key1, const void *key2)
{
#if DETECT_OS_UNIX
int fd1 = pointer_to_intptr(key1);
@@ -145,9 +145,9 @@ static int compare_fd(void *key1, void *key2)
fstat(fd1, &stat1);
fstat(fd2, &stat2);
- return stat1.st_dev != stat2.st_dev ||
- stat1.st_ino != stat2.st_ino ||
- stat1.st_rdev != stat2.st_rdev;
+ return stat1.st_dev == stat2.st_dev &&
+ stat1.st_ino == stat2.st_ino &&
+ stat1.st_rdev == stat2.st_rdev;
#else
return 0;
#endif
@@ -157,7 +157,7 @@ static int compare_fd(void *key1, void *key2)
struct util_hash_table *
util_hash_table_create_fd_keys(void)
{
- return util_hash_table_create(hash_fd, compare_fd);
+ return util_hash_table_create(hash_fd, equal_fd);
}
@@ -172,7 +172,7 @@ util_hash_table_find_iter(struct util_hash_table *ht,
iter = cso_hash_find(&ht->cso, key_hash);
while (!cso_hash_iter_is_null(iter)) {
item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
- if (!ht->compare(item->key, key))
+ if (ht->equal(item->key, key))
break;
iter = cso_hash_iter_next(iter);
}
@@ -192,7 +192,7 @@ util_hash_table_find_item(struct util_hash_table *ht,
iter = cso_hash_find(&ht->cso, key_hash);
while (!cso_hash_iter_is_null(iter)) {
item = (struct util_hash_table_item *)cso_hash_iter_data(iter);
- if (!ht->compare(item->key, key))
+ if (ht->equal(item->key, key))
return item;
iter = cso_hash_iter_next(iter);
}
diff --git a/src/gallium/auxiliary/util/u_hash_table.h b/src/gallium/auxiliary/util/u_hash_table.h
index 7db87c4367b..3d751f423aa 100644
--- a/src/gallium/auxiliary/util/u_hash_table.h
+++ b/src/gallium/auxiliary/util/u_hash_table.h
@@ -53,11 +53,11 @@ struct util_hash_table;
* Create an hash table.
*
* @param hash hash function
- * @param compare should return 0 for two equal keys.
+ * @param equal should return true for two equal keys.
*/
struct util_hash_table *
-util_hash_table_create(unsigned (*hash)(void *key),
- int (*compare)(void *key1, void *key2));
+util_hash_table_create(uint32_t (*hash)(const void *key),
+ bool (*equal)(const void *key1, const void *key2));
/**
* Create a hash table where the keys are generic pointers.
diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index 5e756b36707..8973dcbbc28 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -124,7 +124,7 @@ struct nine_ff_ps_key
};
};
-static unsigned nine_ff_vs_key_hash(void *key)
+static uint32_t nine_ff_vs_key_hash(const void *key)
{
struct nine_ff_vs_key *vs = key;
unsigned i;
@@ -133,14 +133,14 @@ static unsigned nine_ff_vs_key_hash(void *key)
hash ^= vs->value32[i];
return hash;
}
-static int nine_ff_vs_key_comp(void *key1, void *key2)
+static bool nine_ff_vs_key_comp(const void *key1, const void *key2)
{
struct nine_ff_vs_key *a = (struct nine_ff_vs_key *)key1;
struct nine_ff_vs_key *b = (struct nine_ff_vs_key *)key2;
- return memcmp(a->value64, b->value64, sizeof(a->value64));
+ return memcmp(a->value64, b->value64, sizeof(a->value64)) == 0;
}
-static unsigned nine_ff_ps_key_hash(void *key)
+static uint32_t nine_ff_ps_key_hash(const void *key)
{
struct nine_ff_ps_key *ps = key;
unsigned i;
@@ -149,20 +149,20 @@ static unsigned nine_ff_ps_key_hash(void *key)
hash ^= ps->value32[i];
return hash;
}
-static int nine_ff_ps_key_comp(void *key1, void *key2)
+static bool nine_ff_ps_key_comp(const void *key1, const void *key2)
{
struct nine_ff_ps_key *a = (struct nine_ff_ps_key *)key1;
struct nine_ff_ps_key *b = (struct nine_ff_ps_key *)key2;
- return memcmp(a->value64, b->value64, sizeof(a->value64));
+ return memcmp(a->value64, b->value64, sizeof(a->value64)) == 0;
}
-static unsigned nine_ff_fvf_key_hash(void *key)
+static uint32_t nine_ff_fvf_key_hash(const void *key)
{
return *(DWORD *)key;
}
-static int nine_ff_fvf_key_comp(void *key1, void *key2)
+static bool nine_ff_fvf_key_comp(const void *key1, const void *key2)
{
- return *(DWORD *)key1 != *(DWORD *)key2;
+ return *(DWORD *)key1 == *(DWORD *)key2;
}
static void nine_ff_prune_vs(struct NineDevice9 *);
diff --git a/src/gallium/state_trackers/nine/nine_pdata.h b/src/gallium/state_trackers/nine/nine_pdata.h
index 92e50c8a72c..8c73cd619ba 100644
--- a/src/gallium/state_trackers/nine/nine_pdata.h
+++ b/src/gallium/state_trackers/nine/nine_pdata.h
@@ -9,15 +9,15 @@ struct pheader
DWORD size;
};
-static int
-ht_guid_compare( void *a,
- void *b )
+static bool
+ht_guid_compare( const void *a,
+ const void *b )
{
- return GUID_equal(a, b) ? 0 : 1;
+ return GUID_equal(a, b);
}
-static unsigned
-ht_guid_hash( void *key )
+static uint32_t
+ht_guid_hash( const void *key )
{
unsigned i, hash = 0;
const unsigned char *str = key;
diff --git a/src/gallium/winsys/svga/drm/vmw_screen.c b/src/gallium/winsys/svga/drm/vmw_screen.c
index e3440bfd957..5f68a894673 100644
--- a/src/gallium/winsys/svga/drm/vmw_screen.c
+++ b/src/gallium/winsys/svga/drm/vmw_screen.c
@@ -43,13 +43,13 @@
static struct util_hash_table *dev_hash = NULL;
-static int vmw_dev_compare(void *key1, void *key2)
+static bool vmw_dev_compare(const void *key1, const void *key2)
{
return (major(*(dev_t *)key1) == major(*(dev_t *)key2) &&
- minor(*(dev_t *)key1) == minor(*(dev_t *)key2)) ? 0 : 1;
+ minor(*(dev_t *)key1) == minor(*(dev_t *)key2));
}
-static unsigned vmw_dev_hash(void *key)
+static uint32_t vmw_dev_hash(const void *key)
{
return (major(*(dev_t *) key) << 16) | minor(*(dev_t *) key);
}