> From: Bruce Richardson [mailto:bruce.richard...@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: roret...@linux.microsoft.com
> 
> Signed-off-by: Bruce Richardson <bruce.richard...@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 <m...@smartsharesystems.com>

Reply via email to