On 1/9/21 3:46 PM, Roman Bolshakov wrote: > +static int xgetbv(uint32_t cpuid_ecx, uint32_t idx, uint64_t *xcr) > { > - uint32_t eax, edx; > + uint32_t xcrl, xcrh; > > - __asm__ volatile ("xgetbv" > - : "=a" (eax), "=d" (edx) > - : "c" (xcr)); > + if (cpuid_ecx && CPUID_EXT_OSXSAVE) { > + /* The xgetbv instruction is not available to older versions of > + * the assembler, so we encode the instruction manually. > + */ > + asm(".byte 0x0f, 0x01, 0xd0" : "=a" (xcrl), "=d" (xcrh) : "c" (idx)); > > - return (((uint64_t)edx) << 32) | eax; > + *xcr = (((uint64_t)xcrh) << 32) | xcrl; > + return 0; > + } > + > + return 1; > }
Not to bikeshed too much, but this looks like it should return bool, and true on success, not the other way around. r~