Skip to contentSkip to conversation

hash: cast away atomic qualification

PATCH Superseded Tyler Retzlaff 2 participants 5 messages Apr 16, 2024 – May 26, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hash: cast away atomic qualification

rte_free accepts only non-cva qualified arguments so cast away RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when calling rte_free.

---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/hash/rte_cuckoo_hash.c +2 -2
index 9cf9464..b31a3d9 100644
@@ -481,7 +481,7 @@ struct rte_hash *
 	rte_free(buckets);
 	rte_free(buckets_ext);
 	rte_free(k);
-	rte_free(tbl_chng_cnt);
+	rte_free((void *)(uintptr_t)tbl_chng_cnt);
 	rte_free(ext_bkt_to_free);
 	return NULL;
 }
@@ -526,7 +526,7 @@ struct rte_hash *
 	rte_free(h->key_store);
 	rte_free(h->buckets);
 	rte_free(h->buckets_ext);
-	rte_free(h->tbl_chng_cnt);
+	rte_free((void *)(uintptr_t)h->tbl_chng_cnt);
 	rte_free(h->ext_bkt_to_free);
 	rte_free(h->hash_rcu_cfg);
 	rte_free(h);
Signature · 1 line
1.8.3.1
#1 lore raw

16/04/2024 18:06, Tyler Retzlaff:

Quoted 5 lines

rte_free accepts only non-cva qualified arguments so cast away RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when calling rte_free.

Please add an explanation about the case where it does not compile.

#2 lore raw

PATCH v2 1/1 hash: cast away atomic qualification

In reply to Tyler Retzlaff

rte_free accepts only non-cva qualified arguments so cast away RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when calling rte_free.

Without this change using enable_stdatomic=true with LLVM or MSVC will result in a warning being emitted for discarding the atomic qualification.

v2:
* update commit message to indicate the conditions under which a warning will be issued without this patch.

Tyler Retzlaff (1):
hash: cast away atomic qualification

 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v2 1/1 hash: cast away atomic qualification

rte_free accepts only non-cva qualified arguments so cast away RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when calling rte_free.

Without this change using enable_stdatomic=true with LLVM or MSVC will result in a warning being emitted for discarding the atomic qualification.

---
 lib/hash/rte_cuckoo_hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/hash/rte_cuckoo_hash.c +2 -2
index 9cf9464..b31a3d9 100644
@@ -481,7 +481,7 @@ struct rte_hash *
 	rte_free(buckets);
 	rte_free(buckets_ext);
 	rte_free(k);
-	rte_free(tbl_chng_cnt);
+	rte_free((void *)(uintptr_t)tbl_chng_cnt);
 	rte_free(ext_bkt_to_free);
 	return NULL;
 }
@@ -526,7 +526,7 @@ struct rte_hash *
 	rte_free(h->key_store);
 	rte_free(h->buckets);
 	rte_free(h->buckets_ext);
-	rte_free(h->tbl_chng_cnt);
+	rte_free((void *)(uintptr_t)h->tbl_chng_cnt);
 	rte_free(h->ext_bkt_to_free);
 	rte_free(h->hash_rcu_cfg);
 	rte_free(h);
Signature · 1 line
1.8.3.1
#4 lore raw

22/05/2024 18:33, Tyler Retzlaff:

Quoted 9 lines

rte_free accepts only non-cva qualified arguments so cast away RTE_ATOMIC qualification for tbl_chng_cnt and h->tbl_chng_cnt when calling rte_free.

Without this change using enable_stdatomic=true with LLVM or MSVC will result in a warning being emitted for discarding the atomic qualification.

Applied, thanks.