提交 e6c58299 编写于 作者: E Emilio G. Cota 提交者: Richard Henderson

qht: constify qht_lookup

seqlock_read_begin takes a const param since c04649ee
("seqlock: constify seqlock_read_begin", 2018-08-23), so
we can constify the entire lookup.
Signed-off-by: NEmilio G. Cota <cota@braap.org>
Signed-off-by: NRichard Henderson <richard.henderson@linaro.org>
上级 9650ad3e
...@@ -104,7 +104,7 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash, void **existing); ...@@ -104,7 +104,7 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash, void **existing);
* Returns the corresponding pointer when a match is found. * Returns the corresponding pointer when a match is found.
* Returns NULL otherwise. * Returns NULL otherwise.
*/ */
void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t hash,
qht_lookup_func_t func); qht_lookup_func_t func);
/** /**
...@@ -115,7 +115,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, ...@@ -115,7 +115,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash,
* *
* Calls qht_lookup_custom() using @ht's default comparison function. * Calls qht_lookup_custom() using @ht's default comparison function.
*/ */
void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash); void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash);
/** /**
* qht_remove - remove a pointer from the hash table * qht_remove - remove a pointer from the hash table
......
...@@ -236,7 +236,7 @@ static inline void qht_head_init(struct qht_bucket *b) ...@@ -236,7 +236,7 @@ static inline void qht_head_init(struct qht_bucket *b)
} }
static inline static inline
struct qht_bucket *qht_map_to_bucket(struct qht_map *map, uint32_t hash) struct qht_bucket *qht_map_to_bucket(const struct qht_map *map, uint32_t hash)
{ {
return &map->buckets[hash & (map->n_buckets - 1)]; return &map->buckets[hash & (map->n_buckets - 1)];
} }
...@@ -482,10 +482,10 @@ bool qht_reset_size(struct qht *ht, size_t n_elems) ...@@ -482,10 +482,10 @@ bool qht_reset_size(struct qht *ht, size_t n_elems)
} }
static inline static inline
void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func, void *qht_do_lookup(const struct qht_bucket *head, qht_lookup_func_t func,
const void *userp, uint32_t hash) const void *userp, uint32_t hash)
{ {
struct qht_bucket *b = head; const struct qht_bucket *b = head;
int i; int i;
do { do {
...@@ -509,7 +509,7 @@ void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func, ...@@ -509,7 +509,7 @@ void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func,
} }
static __attribute__((noinline)) static __attribute__((noinline))
void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func, void *qht_lookup__slowpath(const struct qht_bucket *b, qht_lookup_func_t func,
const void *userp, uint32_t hash) const void *userp, uint32_t hash)
{ {
unsigned int version; unsigned int version;
...@@ -522,11 +522,11 @@ void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func, ...@@ -522,11 +522,11 @@ void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func,
return ret; return ret;
} }
void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t hash,
qht_lookup_func_t func) qht_lookup_func_t func)
{ {
struct qht_bucket *b; const struct qht_bucket *b;
struct qht_map *map; const struct qht_map *map;
unsigned int version; unsigned int version;
void *ret; void *ret;
...@@ -545,7 +545,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, ...@@ -545,7 +545,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash,
return qht_lookup__slowpath(b, func, userp, hash); return qht_lookup__slowpath(b, func, userp, hash);
} }
void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash) void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash)
{ {
return qht_lookup_custom(ht, userp, hash, ht->cmp); return qht_lookup_custom(ht, userp, hash, ht->cmp);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册