From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 654EBA0471 for ; Mon, 17 Jun 2019 09:41:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 153BC1BE04; Mon, 17 Jun 2019 09:41:51 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 72EEC1BE08 for ; Mon, 17 Jun 2019 09:41:49 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B86D628; Mon, 17 Jun 2019 00:41:48 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (unknown [10.169.107.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4F3233F246; Mon, 17 Jun 2019 00:41:47 -0700 (PDT) From: Phil Yang To: dev@dpdk.org Cc: nd@arm.com, gage.eads@intel.com, honnappa.nagarahalli@arm.com, gavin.hu@arm.com, phil.yang@arm.com Date: Mon, 17 Jun 2019 15:41:30 +0800 Message-Id: <1560757290-22238-1-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560531283-5229-1-git-send-email-phil.yang@arm.com> References: <1560531283-5229-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH v2] eal/stack: fix 'pointer-sign' warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" clang raise 'pointer-sign' warnings in __atomic_compare_exchange when passing 'uint64_t *' to parameter of type 'int64_t *' converts between pointers to integer types with different sign. Fixes: 7e6e609939a8 ("stack: add C11 atomic implementation") Suggested-by: Gage Eads Signed-off-by: Phil Yang Reviewed-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu --- lib/librte_stack/rte_stack.h | 2 +- lib/librte_stack/rte_stack_lf_c11.h | 8 ++++---- lib/librte_stack/rte_stack_lf_generic.h | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/librte_stack/rte_stack.h b/lib/librte_stack/rte_stack.h index fe048f0..93c360c 100644 --- a/lib/librte_stack/rte_stack.h +++ b/lib/librte_stack/rte_stack.h @@ -47,7 +47,7 @@ struct rte_stack_lf_list { /** List head */ struct rte_stack_lf_head head __rte_aligned(16); /** List len */ - rte_atomic64_t len; + uint64_t len; }; /* Structure containing two lock-free LIFO lists: the stack itself and a list diff --git a/lib/librte_stack/rte_stack_lf_c11.h b/lib/librte_stack/rte_stack_lf_c11.h index a316e9a..3d677ae 100644 --- a/lib/librte_stack/rte_stack_lf_c11.h +++ b/lib/librte_stack/rte_stack_lf_c11.h @@ -26,7 +26,7 @@ __rte_stack_lf_count(struct rte_stack *s) * elements. If the mempool is near-empty to the point that this is a * concern, the user should consider increasing the mempool size. */ - return (unsigned int)__atomic_load_n(&s->stack_lf.used.len.cnt, + return (unsigned int)__atomic_load_n(&s->stack_lf.used.len, __ATOMIC_RELAXED); } @@ -78,7 +78,7 @@ __rte_stack_lf_push_elems(struct rte_stack_lf_list *list, /* Ensure the stack modifications are not reordered with respect * to the LIFO len update. */ - __atomic_add_fetch(&list->len.cnt, num, __ATOMIC_RELEASE); + __atomic_add_fetch(&list->len, num, __ATOMIC_RELEASE); #endif } @@ -101,7 +101,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list, int success; /* Reserve num elements, if available */ - len = __atomic_load_n(&list->len.cnt, __ATOMIC_ACQUIRE); + len = __atomic_load_n(&list->len, __ATOMIC_ACQUIRE); while (1) { /* Does the list contain enough elements? */ @@ -109,7 +109,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list, return NULL; /* len is updated on failure */ - if (__atomic_compare_exchange_n(&list->len.cnt, + if (__atomic_compare_exchange_n(&list->len, &len, len - num, 0, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) diff --git a/lib/librte_stack/rte_stack_lf_generic.h b/lib/librte_stack/rte_stack_lf_generic.h index 1191406..3182151 100644 --- a/lib/librte_stack/rte_stack_lf_generic.h +++ b/lib/librte_stack/rte_stack_lf_generic.h @@ -26,7 +26,8 @@ __rte_stack_lf_count(struct rte_stack *s) * elements. If the mempool is near-empty to the point that this is a * concern, the user should consider increasing the mempool size. */ - return (unsigned int)rte_atomic64_read(&s->stack_lf.used.len); + return (unsigned int)rte_atomic64_read((rte_atomic64_t *) + &s->stack_lf.used.len); } static __rte_always_inline void @@ -73,7 +74,7 @@ __rte_stack_lf_push_elems(struct rte_stack_lf_list *list, __ATOMIC_RELAXED); } while (success == 0); - rte_atomic64_add(&list->len, num); + rte_atomic64_add((rte_atomic64_t *)&list->len, num); #endif } @@ -96,7 +97,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list, /* Reserve num elements, if available */ while (1) { - uint64_t len = rte_atomic64_read(&list->len); + uint64_t len = rte_atomic64_read((rte_atomic64_t *)&list->len); /* Does the list contain enough elements? */ if (unlikely(len < num)) -- 2.7.4