[v2] eal/arm: replace RTE_BUILD_BUG on non-constant
Checks
Commit Message
The ARM implementation of rte_pause uses RTE_BUILD_BUG_ON to check
memorder, which is not constant. This causes compile errors when it is
enabled with RTE_ARM_USE_WFE. eg.
../lib/eal/arm/include/rte_pause_64.h: In function ‘rte_wait_until_equal_16’:
../lib/eal/include/rte_common.h:530:56: error: expression in static assertion is not constant
530 | #define RTE_BUILD_BUG_ON(condition) do { static_assert(!(condition), #condition); } while (0)
| ^~~~~~~~~~~~
../lib/eal/arm/include/rte_pause_64.h:156:9: note: in expansion of macro ‘RTE_BUILD_BUG_ON’
156 | RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
| ^~~~~~~~~~~~~~~~
Fix the compile errors by replacing the check with an assert, like in
the generic implementation (lib/eal/include/generic/rte_pause.h).
Fixes: 875f350924b8 ("eal: add a new helper for wait until scheme")
Signed-off-by: Daniel Gregory <daniel.gregory@bytedance.com>
---
Cc: feifei.wang2@arm.com
---
lib/eal/arm/include/rte_pause_64.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Comments
Apologies, mis-sent this before attaching a changelog:
v2:
* replaced RTE_ASSERT with assert
* added Fixes: tag
On Fri, 3 May 2024 19:27:30 +0100
Daniel Gregory <daniel.gregory@bytedance.com> wrote:
> The ARM implementation of rte_pause uses RTE_BUILD_BUG_ON to check
> memorder, which is not constant. This causes compile errors when it is
> enabled with RTE_ARM_USE_WFE. eg.
>
> ../lib/eal/arm/include/rte_pause_64.h: In function ‘rte_wait_until_equal_16’:
> ../lib/eal/include/rte_common.h:530:56: error: expression in static assertion is not constant
> 530 | #define RTE_BUILD_BUG_ON(condition) do { static_assert(!(condition), #condition); } while (0)
> | ^~~~~~~~~~~~
> ../lib/eal/arm/include/rte_pause_64.h:156:9: note: in expansion of macro ‘RTE_BUILD_BUG_ON’
> 156 | RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
> | ^~~~~~~~~~~~~~~~
>
> Fix the compile errors by replacing the check with an assert, like in
> the generic implementation (lib/eal/include/generic/rte_pause.h).
No, don't hide the problem.
What code is calling these. Looks like a real bug. Could be behind layers of wrappers.
+ Arm team to the loop.
Removed invalid email address.
From: Daniel Gregory <daniel.gregory@bytedance.com>
Date: Saturday, May 4, 2024 at 2:27 AM
To: Ruifeng Wang <Ruifeng.Wang@arm.com>
Cc: dev@dpdk.org <dev@dpdk.org>, Punit Agrawal <punit.agrawal@bytedance.com>, Liang Ma <liangma@bytedance.com>, Daniel Gregory <daniel.gregory@bytedance.com>, Feifei Wang <Feifei.Wang2@arm.com>
Subject: [PATCH v2] eal/arm: replace RTE_BUILD_BUG on non-constant
The ARM implementation of rte_pause uses RTE_BUILD_BUG_ON to check
memorder, which is not constant. This causes compile errors when it is
enabled with RTE_ARM_USE_WFE. eg.
../lib/eal/arm/include/rte_pause_64.h: In function ‘rte_wait_until_equal_16’:
../lib/eal/include/rte_common.h:530:56: error: expression in static assertion is not constant
530 | #define RTE_BUILD_BUG_ON(condition) do { static_assert(!(condition), #condition); } while (0)
| ^~~~~~~~~~~~
../lib/eal/arm/include/rte_pause_64.h:156:9: note: in expansion of macro ‘RTE_BUILD_BUG_ON’
156 | RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
| ^~~~~~~~~~~~~~~~
Fix the compile errors by replacing the check with an assert, like in
the generic implementation (lib/eal/include/generic/rte_pause.h).
Fixes: 875f350924b8 ("eal: add a new helper for wait until scheme")
Signed-off-by: Daniel Gregory <daniel.gregory@bytedance.com>
---
Cc: feifei.wang2@arm.com
---
lib/eal/arm/include/rte_pause_64.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
> ../lib/eal/arm/include/rte_pause_64.h: In function ‘rte_wait_until_equal_16’:
> ../lib/eal/include/rte_common.h:530:56: error: expression in static assertion
> is not constant
> 530 | #define RTE_BUILD_BUG_ON(condition) do {
> static_assert(!(condition), #condition); } while (0)
> | ^~~~~~~~~~~~
> ../lib/eal/arm/include/rte_pause_64.h:156:9: note: in expansion of macro
> ‘RTE_BUILD_BUG_ON’
> 156 | RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
> | ^~~~~~~~~~~~~~~~
>
> Fix the compile errors by replacing the check with an assert, like in the generic
> implementation (lib/eal/include/generic/rte_pause.h).
>
> Fixes: 875f350924b8 ("eal: add a new helper for wait until scheme")
>
> Signed-off-by: Daniel Gregory <daniel.gregory@bytedance.com>
Acked-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
@@ -10,6 +10,8 @@
extern "C" {
#endif
+#include <assert.h>
+
#include <rte_common.h>
#ifdef RTE_ARM_USE_WFE
@@ -153,7 +155,7 @@ rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
{
uint16_t value;
- RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
+ assert(memorder != rte_memory_order_acquire &&
memorder != rte_memory_order_relaxed);
__RTE_ARM_LOAD_EXC_16(addr, value, memorder)
@@ -172,7 +174,7 @@ rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected,
{
uint32_t value;
- RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
+ assert(memorder != rte_memory_order_acquire &&
memorder != rte_memory_order_relaxed);
__RTE_ARM_LOAD_EXC_32(addr, value, memorder)
@@ -191,7 +193,7 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
{
uint64_t value;
- RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
+ assert(memorder != rte_memory_order_acquire &&
memorder != rte_memory_order_relaxed);
__RTE_ARM_LOAD_EXC_64(addr, value, memorder)