Re: [PATCH V9 08/17] cpufreq: Use enum for cpufreq flags that use BIT()
From: Miguel Ojeda
Date: Fri Apr 11 2025 - 13:08:25 EST
On Fri, Apr 11, 2025 at 6:07 PM Yury Norov <yury.norov@xxxxxxxxx> wrote:
>
> The BIT() is as simple as '1 << nr'. How that it's so complex for that
> tool to realize that '1 << 2' is the constant?
It is a C macro which requires evaluating a C expression as the C
compiler would.
A solution (a workaround, really) in `bindgen` is coming, that
essentially forces `libclang` to evaluate it for us, but even if it
works perfectly fine already, it will require upgrading the minimum
version and so on, so it will take time.
For the moment, either we do something like this (a similar approach
was used for some `enum`s in Binder) or the values can be replicated
on the Rust side (ideally with a test somewhere to ensure they are in
sync). The latter may be best if the values have not changed much over
time, i.e. if there is low maintenance required.
I hope that helps.
Cheers,
Miguel