[PATCH v2 0/3] use static_assertion for build errors
Morten Brørup
mb at smartsharesystems.com
Mon Nov 13 19:28:20 CET 2023
> From: Ferruh Yigit [mailto:ferruh.yigit at amd.com]
> Sent: Monday, 13 November 2023 19.14
>
> On 11/13/2023 5:06 PM, Stephen Hemminger wrote:
> > This series fixes a couple places where expressions that could not
> > be evaluated as constant early in compiler passes were used. And then
> > converts RTE_BUILD_BUG_ON() with static_assert.
> >
>
> Acked-by: Ferruh Yigit <ferruh.yigit at amd.com>
>
>
> I am getting more build errors [1], [2].
>
[...]
> [2] `CC=clang meson --buildtype=debugoptimized build`
>
> ../lib/mempool/rte_mempool.c:749:2: error: static_assert expression is
> not an integral constant expression
>
> RTE_BUILD_BUG_ON(CALC_CACHE_FLUSHTHRESH(RTE_MEMPOOL_CACHE_MAX_SIZE) >
>
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../lib/eal/include/rte_common.h:499:51: note: expanded from macro
> 'RTE_BUILD_BUG_ON'
> #define RTE_BUILD_BUG_ON(condition) static_assert(!(condition),
> #condition)
> ^~~~~~~~~~~~
> 1 error generated.
Perhaps you can fix it in rte_mempool.c... the CACHE_FLUSHTHRESH_MULTIPLIER constant seems to be only used for the CALC_CACHE_FLUSHTHRESH() macro, so fix it like this:
-#define CACHE_FLUSHTHRESH_MULTIPLIER 1.5
-#define CALC_CACHE_FLUSHTHRESH(c) \
- ((typeof(c))((c) * CACHE_FLUSHTHRESH_MULTIPLIER))
+/* Cache flush threshold multiplier is 1.5 = 3/2. */
+#define CALC_CACHE_FLUSHTHRESH(c) (c * 3 / 2)
More information about the dev
mailing list