lkml.org 
[lkml]   [2024]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [patch V6a 01/19] x86/cpu: Provide cpuid_read() et al.
    Date
    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.

    \
     
     \ /
      Last update: 2024-05-27 15:05    [W:2.459 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site