Messages in this thread | | | From | Thomas Gleixner <> | Subject | Re: [patch V6a 01/19] x86/cpu: Provide cpuid_read() et al. | Date | Thu, 15 Feb 2024 16:07:05 +0100 |
| |
On Thu, Feb 15 2024 at 10:49, Andy Shevchenko wrote:
> On Wed, Feb 14, 2024 at 10:29 PM Thomas Gleixner <tglx@linutronixde> wrote: >> >> Provide a few helper functions to read CPUID leafs or individual registers >> into a data structure without requiring unions. > > ... > >> +#define cpuid_subleaf(leaf, subleaf, regs) { \ >> + BUILD_BUG_ON(sizeof(*(regs)) != 16); \ >> + __cpuid_read(leaf, subleaf, (u32 *)(regs)); \ >> +} >> + >> +#define cpuid_leaf(leaf, regs) { \ >> + BUILD_BUG_ON(sizeof(*(regs)) != 16); \ >> + __cpuid_read(leaf, 0, (u32 *)(regs)); \ >> +} > > ... > >> +#define cpuid_subleaf_reg(leaf, subleaf, regidx, reg) { \ >> + BUILD_BUG_ON(sizeof(*(reg)) != 4); \ >> + __cpuid_read_reg(leaf, subleaf, regidx, (u32 *)(reg)); \ >> +} >> + >> +#define cpuid_leaf_reg(leaf, regidx, reg) { \ >> + BUILD_BUG_ON(sizeof(*(reg)) != 4); \ >> + __cpuid_read_reg(leaf, 0, regidx, (u32 *)(reg)); \ >> +} > > I'm wondering if we can use static_assert() instead of BUILD_BUG_ON() > in the above macros.
Probably.
| |