[PATCH] eal/x86: fix build on systems with WAITPKG support
Morten Brørup
mb at smartsharesystems.com
Fri Aug 25 18:07:48 CEST 2023
> From: Bruce Richardson [mailto:bruce.richardson at intel.com]
> Sent: Friday, 25 August 2023 17.29
>
> When doing a build for a system with WAITPKG support and a modern
> compiler, we get build errors for the "_umonitor" intrinsic, due to the
> casting away of the "volatile" on the parameter.
>
> ../lib/eal/x86/rte_power_intrinsics.c: In function 'rte_power_monitor':
> ../lib/eal/x86/rte_power_intrinsics.c:113:22: error: passing argument 1
> of '_umonitor' discards 'volatile' qualifier from pointer target type
> [-Werror=discarded-qualifiers]
> 113 | _umonitor(pmc->addr);
> | ~~~^~~~~~
>
> We can avoid this issue by using RTE_PTR_ADD(..., 0) to cast the pointer
> through "uintptr_t" and thereby remove the volatile without warning.
> We also ensure comments are correct for each leg of the
> ifdef..else..endif block.
>
> Fixes: 60943c04f3bc ("eal/x86: use intrinsics for power management")
> Cc: roretzla at linux.microsoft.com
>
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
> ---
[...]
> - _umonitor(pmc->addr);
> + /* use RTE_PTR_ADD to cast away "volatile" when using the
> intrinsic */
Yes. Having a comment here is good, so people don't wonder why the magic has been added.
> + _umonitor(RTE_PTR_ADD(pmc->addr, 0));
I think that (void *)(uintptr_t)p is more readable than RTE_PTR_ADD(p, 0), but it's a matter of taste.
Regardless,
Acked-by: Morten Brørup <mb at smartsharesystems.com>
More information about the dev
mailing list