[PATCH] eal/arm: replace RTE_BUILD_BUG on non-constant
Stephen Hemminger
stephen at networkplumber.org
Thu May 2 18:20:45 CEST 2024
On Thu, 2 May 2024 15:21:16 +0100
Daniel Gregory <daniel.gregory at 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 &&
> | ^~~~~~~~~~~~~~~~
>
> This has been the case since the switch to C11 assert (537caad2). Fix
> the compile errors by replacing the check with an RTE_ASSERT.
>
> Signed-off-by: Daniel Gregory <daniel.gregory at bytedance.com>
The memory order passed to those routines must be constant.
Why not:
diff --git a/lib/eal/arm/include/rte_pause_64.h b/lib/eal/arm/include/rte_pause_64.h
index 5cb8b59056..81987de771 100644
--- a/lib/eal/arm/include/rte_pause_64.h
+++ b/lib/eal/arm/include/rte_pause_64.h
@@ -172,6 +172,8 @@ rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected,
{
uint32_t value;
+ static_assert(__builtin_constant_p(memorder), "memory order is not a constant");
+
RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
memorder != rte_memory_order_relaxed);
@@ -191,6 +193,8 @@ rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
{
uint64_t value;
+ static_assert(__builtin_constant_p(memorder), "memory order is not a constant");
+
RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire &&
memorder != rte_memory_order_relaxed);
More information about the dev
mailing list